From 299731a69d9662a02986653867d9acdc80c969a4 Mon Sep 17 00:00:00 2001 From: Hector Cortez Date: Wed, 9 Mar 2011 14:56:01 +0000 Subject: [PATCH] Adjustment to establish mode the Grids Tables, and elements --- gulliver/system/class.xmlform.php | 131 ++++++++++++++++++------------ 1 file changed, 81 insertions(+), 50 deletions(-) diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index f4198e87b..61f18603e 100644 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -66,6 +66,9 @@ class XmlForm_Field { var $pmconnection = ''; var $pmfield = ''; + // For mode cases Grid + var $modeGrid = ''; + var $modeForGrid = ''; /** * Function XmlForm_Field * @author David S. Callizaya S. @@ -83,7 +86,6 @@ class XmlForm_Field { foreach ( $myAttributes as $k => $v ) $myAttributes [$k] = strtoupper ( $k ); //$data: Includes labels and options. - $data = &$xmlNode->findNode ( $lang ); if(!isset($data->value)){ //It seems that in the actual language there are no value for the current field, so get the value in English $data = &$xmlNode->findNode ( "en" ); @@ -122,6 +124,7 @@ class XmlForm_Field { $ownerMode = isset ( $owner->mode ) ? $owner->mode : 'edit'; if ($this->mode === '') $this->mode = $ownerMode !== '' ? $ownerMode : 'edit'; + $this->modeForGrid = $this->mode ; } /** @@ -779,19 +782,20 @@ class XmlForm_Field_SimpleText extends XmlForm_Field } else { $isRequired = '0'; } - $result = array (); $r = 1; + if( ! isset($owner->modeGrid)) $owner->modeGrid = ''; // Note added by Gustavo Cruz // also the fields rendered in a grid needs now have an attribute required set to 0 or 1 // that it means not required or required respectively. + $this->mode = $this->modeForGrid; foreach ( $values as $v ) { - if ($this->mode === 'edit') { + if ($this->mode === 'edit' && $owner->modeGrid != 'view') { if ($this->readOnly) $result [] = ''; else $result [] = ''; - } elseif ($this->mode === 'view') { + } elseif ($this->mode === 'view' || $owner->modeGrid === 'view') { $result [] = '' . htmlentities ( $v, ENT_COMPAT, 'utf-8' ); } else { $result [] = $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ); @@ -828,6 +832,8 @@ class XmlForm_Field_Text extends XmlForm_Field_SimpleText var $function = ''; var $replaceTags = 0; var $hint; + + /** * Function render * @author David S. Callizaya S. @@ -888,6 +894,7 @@ class XmlForm_Field_Text extends XmlForm_Field_SimpleText { $result = $aux = array (); $r = 1; + if( ! isset($owner->modeGrid)) $owner->modeGrid = ''; // Note added by Gustavo Cruz // set the variable isRequired if the needs to be validated if ($this->required){ @@ -898,6 +905,7 @@ class XmlForm_Field_Text extends XmlForm_Field_SimpleText // Note added by Gustavo Cruz // also the fields rendered in a grid needs now have an attribute required set to 0 or 1 // that it means not required or required respectively. + $this->mode = $this->modeForGrid; foreach ( $values as $v ) { $this->executeSQL ( $owner, $r ); $firstElement = key ( $this->sqlOption ); @@ -908,12 +916,12 @@ class XmlForm_Field_Text extends XmlForm_Field_SimpleText } $aux [$r] = $v; $v =($v!='')?$v:$this->defaultValue; - if ($this->mode === 'edit') { + if ($this->mode === 'edit' && $owner->modeGrid != 'view') { if ($this->readOnly) $result [] = ''; else $result [] = ''; - } elseif ($this->mode === 'view') { + } elseif ($this->mode === 'view' || $owner->modeGrid === 'view') { $result [] = '' . htmlentities ( $v, ENT_COMPAT, 'utf-8' ); } else { $result [] = $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ); @@ -1336,17 +1344,18 @@ class XmlForm_Field_Textarea extends XmlForm_Field { // Note added by Gustavo Cruz // also the fields rendered in a grid needs now have an attribute required set to 0 or 1 // that it means not required or required respectively. - $result = array (); $r = 1; + if( ! isset($owner->modeGrid)) $owner->modeGrid = ''; + $this->mode = $this->modeForGrid; foreach ( $values as $v ) { - if ($this->mode === 'edit') { + if ($this->mode === 'edit' && $owner->modeGrid != 'view') { if ($this->readOnly) $result [] = ''; else $result [] = ''; - } elseif ($this->mode === 'view') { + } elseif ($this->mode === 'view' || $owner->modeGrid === 'view') { if (stristr ( $_SERVER ['HTTP_USER_AGENT'], 'iPhone' )) { //$result[] = '
'.$this->htmlentities( $v , ENT_COMPAT, 'utf-8').'
'; @@ -1395,7 +1404,6 @@ class XmlForm_Field_Currency extends XmlForm_Field_SimpleText { */ function render( $value = NULL, $owner = NULL) { $onkeypress = G::replaceDataField ( $this->onkeypress, $owner->values ); - if ($this->mode === 'edit') { if ($this->readOnly) return 'htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>'; @@ -1771,8 +1779,9 @@ class XmlForm_Field_YesNo extends XmlForm_Field function renderGrid($values = array(), $owner) { $result = array (); $r = 1; + $this->mode = $this->modeForGrid; foreach ( $values as $v ) { - $html = ($this->mode == 'view' ? ($v === '0' ? 'NO' : 'YES') : '') . 'mode == 'view' || $owner->modeGrid == 'view')? ' style="display:none;"' : '') . '>'; $html .= '