From f6f19aafc7e13e1aab87a982a5bf668f998a697d Mon Sep 17 00:00:00 2001 From: Julio Cesar Laura Date: Thu, 12 Dec 2013 13:49:43 -0400 Subject: [PATCH] BUG 13637 and 13640 SOLVED - Many incorrect operations to determine the scrollbar use for the frid in large forms - Fix the incorrect operations, now the scrollbar and the form width is displayed correctly --- gulliver/system/class.xmlform.php | 106 ++++++++++++++---------------- 1 file changed, 49 insertions(+), 57 deletions(-) diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index 10fa7c75b..12eb1af77 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -3970,63 +3970,7 @@ class XmlForm_Field_Grid extends XmlForm_Field public function render ($values, $owner = null) { - $arrayKeys = array_keys( $this->fields ); - $emptyRow = array (); - $fieldsSize = 0; - foreach ($arrayKeys as $key) { - if (isset( $this->fields[$key]->defaultValue )) { - $emptyValue = $this->fields[$key]->defaultValue; - /** - * if (isset($this->fields[$key]->dependentFields)){ - * if ($this->fields[$key]->dependentFields != ''){ - * $emptyValue = ''; - * } - * } - */ - } else { - $emptyValue = ''; - } - if (isset( $this->fields[$key]->size )) { - $size = $this->fields[$key]->size; - } - if (! isset( $size )) { - $size = 15; - } - $fieldsSize += $size; - $emptyRow[$key] = array ($emptyValue - ); - } - - if (isset( $owner->adjustgridswidth ) && $owner->adjustgridswidth == '1') { - // 400w -> 34s to Firefox - // 400w -> 43s to Chrome - $baseWidth = 400; - $minusWidth = 30; - if (eregi( 'chrome', $_SERVER['HTTP_USER_AGENT'] )) { - $baseSize = 43; - } else { - if (strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false) { - $minusWidth = 20; - } - $baseSize = 34; - } - - $baseWidth = 400; - $formWidth = (int) $owner->width; - $maxSize = (($formWidth * $baseSize) / $baseWidth); - - if ($fieldsSize > $maxSize) { - $this->scrollStyle = 'height:100%; overflow-x: scroll; width:'; - $this->scrollStyle .= $formWidth - $minusWidth . ';'; - } - } else { - if ($fieldsSize > 100) { - $owner->width = '100%'; - } - - } - // else - // $owner->width = $fieldsSize . 'em'; + $emptyRow = $this->setScrollStyle( $owner ); return $this->renderGrid( $emptyRow, $owner ); } @@ -4180,6 +4124,53 @@ class XmlForm_Field_Grid extends XmlForm_Field return $flipped; } + + public function setScrollStyle($owner) { + $arrayKeys = array_keys( $this->fields ); + $emptyRow = array (); + $fieldsSize = 0; + foreach ($arrayKeys as $key) { + if (isset( $this->fields[$key]->defaultValue )) { + $emptyValue = $this->fields[$key]->defaultValue; + } else { + $emptyValue = ''; + } + if (isset( $this->fields[$key]->size )) { + $size = $this->fields[$key]->size; + } + if (! isset( $size )) { + $size = 15; + } + $fieldsSize += $size; + $emptyRow[$key] = array ($emptyValue); + } + + if (isset( $owner->adjustgridswidth ) && $owner->adjustgridswidth == '1') { + // 400w -> 34s to Firefox + // 400w -> 43s to Chrome + $baseWidth = 400; + $minusWidth = 30; + if (eregi( 'chrome', $_SERVER['HTTP_USER_AGENT'] )) { + $baseSize = 43; + } else { + if (strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false) { + $minusWidth = 20; + } + $baseSize = 34; + } + + $baseWidth = 400; + $formWidth = (int) $owner->width; + $maxSize = (($formWidth * $baseSize) / $baseWidth); + + if ($fieldsSize > $maxSize) { + $this->scrollStyle = 'height:100%; overflow-x: scroll; width:'; + $this->scrollStyle .= $formWidth - $minusWidth . ';'; + } + } + + return $emptyRow; + } } /** @@ -5745,6 +5736,7 @@ class xmlformTemplate extends Smarty } } } + $form->fields[$k]->setScrollStyle( $form ); $result["form"][$k] = $form->fields[$k]->renderGrid( $value, $form, $therow ); } else { switch ($field->type) {