X-Git-Url: https://git.llucax.com/mecon/meconlib.git/blobdiff_plain/843a300214cc71a3eccd15ef316604bdd0a0d7ff..b371ffddb6dbdf292f496845e4b27d83bd70fa3f:/lib/MECON/HTML/QuickForm/caritas.php diff --git a/lib/MECON/HTML/QuickForm/caritas.php b/lib/MECON/HTML/QuickForm/caritas.php index 9979b21..9308aba 100644 --- a/lib/MECON/HTML/QuickForm/caritas.php +++ b/lib/MECON/HTML/QuickForm/caritas.php @@ -22,15 +22,14 @@ require_once('HTML/QuickForm/element.php'); require_once('HTML/QuickForm/radio.php'); require_once('MECON/defaults.php'); -require_once('HTML/Image.php'); +require_once 'MECON/HTML/Image.php'; /** * Class to dynamically create HTML Select elements from a date * * @author Bertrand Mansion * @access public */ -class HTML_QuickForm_caritas extends HTML_QuickForm_element -{ +class MECON_HTML_QuickForm_caritas extends HTML_QuickForm_element { // {{{ properties /** @@ -39,15 +38,15 @@ class HTML_QuickForm_caritas extends HTML_QuickForm_element * @access private */ var $radios = array(); - + /** * Default values of the SELECTs * @var array * @access private */ - var $_selectedCarita = null; - - var $_numRows = 5; + var $_selected = null; + + var $_cols = 5; /** @@ -57,7 +56,7 @@ class HTML_QuickForm_caritas extends HTML_QuickForm_element */ var $_flagFrozen = false; -// +X2C Operation 533 + // +X2C Operation 533 /** * Lista archivos devolviendo un array apropiado para un SELECT. * @@ -92,9 +91,8 @@ class HTML_QuickForm_caritas extends HTML_QuickForm_element * @access public * @return void */ - - function HTML_QuickForm_caritas($elementName=null, $elementLabel=null, $options=array(), $attributes=null) - { + + function MECON_HTML_QuickForm_caritas($elementName=null, $elementLabel=null, $options=array(), $attributes=null) { HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->_type = 'caritas'; @@ -116,47 +114,90 @@ class HTML_QuickForm_caritas extends HTML_QuickForm_element * @access private * @return void */ - function _setDefaults($options) - { - /* if (isset($options['format'])) { - $this->setFormat($options['format']); - } - if (isset($options['language'])) { - $this->setLanguage($options['language']); - } - if (isset($options['minYear'])) { - $this->setMinYear($options['minYear']); + function _setDefaults($options) { + if (isset($options['cols'])) { + $this->setCols($options['cols']); } - if (isset($options['maxYear'])) { - $this->setMaxYear($options['maxYear']); - } - */ + /* if (isset($options['language'])) { + $this->setLanguage($options['language']); + } + if (isset($options['minYear'])) { + $this->setMinYear($options['minYear']); + } + if (isset($options['maxYear'])) { + $this->setMaxYear($options['maxYear']); + } + */ } // end func _setDefaults // }}} // {{{ setName() + /** + * Sets the number of cols (columns) + * @param string $name Input field name attribute + * @access public + * @return void + */ + function setCols($cols) { + $this->_cols = $cols; + } //end func setCols + /** * Sets the input field name * @param string $name Input field name attribute * @access public * @return void */ - function setName($name) - { + function setName($name) { $this->name = $name; } //end func setName // }}} // {{{ getName() + /** + * Sets the element value + * @access public + * @return string + */ + function setValue($value) { + $this->_selected = $value; + } //end func getName + + /** + * Sets the element value + * @access public + * @return string + */ + function setSelected($value) { + $this->_selected = $value; + } //end func getName + + /** + * Returns the element value + * @access public + * @return string + */ + function getValue() { + return $this->_selected; + } //end func getName + + /** + * Returns the element value + * @access public + * @return string + */ + function getSelected() { + return $this->_selected; + } //end func getName + /** * Returns the element name * @access public * @return string */ - function getName() - { + function getName() { return $this->name; } //end func getName @@ -168,15 +209,13 @@ class HTML_QuickForm_caritas extends HTML_QuickForm_element * @access public * @return void */ - function _createRadios() - { + function _createRadios() { $this->caritas= array(); $elementName = $this->name; $dir = MECON_DIR_FS_IMG.'/caritas'; $cant=5; $i=1; - foreach ($this->listarArchivos($dir,'','.gif') as $nombre) - { + foreach ($this->listarArchivos($dir,'','.gif') as $nombre) { $this->radios[$nombre] = &new HTML_QuickForm_radio($elementName, '', '', $nombre, $this->getAttributes()); } } // end func _createSelects @@ -184,21 +223,6 @@ class HTML_QuickForm_caritas extends HTML_QuickForm_element // }}} // {{{ _createNumericOptionList() - // {{{ setSelectedCarita() - - /** - * Sets the selected carita - * @param mixed an associative array corresponding to the format you chose - * for your date or an unix epoch timestamp - * @access public - * @return void - */ - function setSelectedCarita($value) - { - $this->_selectedCarita = $value; - } // end func setSelectedDate - - // }}} // {{{ toHtml() /** @@ -206,14 +230,13 @@ class HTML_QuickForm_caritas extends HTML_QuickForm_element * @access public * @return string * @throws - */ - function toHtml() - { + */ + function toHtml() { $this->_createRadios(); $strHtml = ''; $i = 1; foreach ($this->radios as $nombre => $element) { - if (@$this->_selectedCarita == $nombre) { + if (@$this->_selected == $nombre) { $element->setChecked(true); } if ($this->_flagFrozen) { @@ -229,9 +252,9 @@ class HTML_QuickForm_caritas extends HTML_QuickForm_element $strHtml .= $element->toHtml(); } } - $imagen =& new HTML_Image(MECON_DIR_IMG."/caritas/$nombre"); + $imagen =& new MECON_HTML_Image(MECON_DIR_IMG."/caritas/$nombre"); $strHtml .= ' ' . $imagen->toHtml() . '     '; - if (!($i++ % $this->_numRows)) + if (!($i++ % $this->_cols)) $strHtml .= '
'; } return $strHtml; @@ -251,28 +274,27 @@ class HTML_QuickForm_caritas extends HTML_QuickForm_element * @return void * @throws */ - function onQuickFormEvent($event, $arg, &$caller) - { + function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { - case 'updateValue': + case 'updateValue': // constant values override both default and submitted ones // default values are overriden by submitted $value = $this->_findValue($caller->_constantValues); + if (null === $value) { + $value = $this->_findValue($caller->_submitValues); if (null === $value) { - $value = $this->_findValue($caller->_submitValues); - if (null === $value) { - $value = $this->_findValue($caller->_defaultValues); - } + $value = $this->_findValue($caller->_defaultValues); } - if (null !== $value) { - $this->setSelectedCarita($value); - } - break; - case 'setGroupValue': - $this->setSelectedCarita($arg); - break; - default: - parent::onQuickFormEvent($event, $arg, $caller); + } + if (null !== $value) { + $this->setSelected($value); + } + break; + case 'setGroupValue': + $this->setSelected($arg); + break; + default: + parent::onQuickFormEvent($event, $arg, $caller); } return true; } // end func onQuickFormEvent