cvs: pear /HTML_QuickForm_Livesearch livesearch_select.php

From: Date: Fri, 23 Jun 2006 09:50:29 +0000
Subject: cvs: pear /HTML_QuickForm_Livesearch livesearch_select.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-40873@lists.php.net to get a copy of this message
thesee Fri Jun 23 09:50:29 2006 UTC Modified files: /pear/HTML_QuickForm_Livesearch livesearch_select.php Log: solved bug with frozen from, added getFroenhtml function and getvalue function http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm_Livesearch/livesearch_select.php?r1=1.8&r2=1.9&diff_format=u Index: pear/HTML_QuickForm_Livesearch/livesearch_select.php diff -u pear/HTML_QuickForm_Livesearch/livesearch_select.php:1.8 pear/HTML_QuickForm_Livesearch/livesearch_select.php:1.9 --- pear/HTML_QuickForm_Livesearch/livesearch_select.php:1.8 Thu May 25 09:24:41 2006 +++ pear/HTML_QuickForm_Livesearch/livesearch_select.php Fri Jun 23 09:50:28 2006 @@ -13,7 +13,7 @@ // +----------------------------------------------------------------------+ // | Author: Giuseppe Dessì <thesee@fastwebnet.it> | // +----------------------------------------------------------------------+ -// $Id: livesearch_select.php,v 1.8 2006/05/25 09:24:41 thesee Exp $ +// $Id: livesearch_select.php,v 1.9 2006/06/23 09:50:28 thesee Exp $ /** * Class to dynamically create an HTML input text element that @@ -39,6 +39,14 @@ var $_options = array(); /** + * Original name of element + * + * @var string + * @access private + */ + var $realName = ''; + + /** * The values passed by the hidden element * * @var array @@ -107,7 +115,24 @@ ); } } - + /** + * Gets the element's value + * + * @param mixed Element's value + * @access public + */ + function getValue($internal = NULL) + { + if ($this->_flagFrozen) { + if ($internal) { + return $this->_value; + } else { + return $this->_hidden_value; + } + } else { + return $this->_hidden_value; + } + } /** * Sets the options for the LiveSearch_Select input text element * @@ -121,9 +146,29 @@ } // end func setOptions // }}} - // {{{ toHtml() + // {{{ getFrozenHtml() /** + * Returns the value of field without HTML tags + * + * @since 1.0 + * @access public + * @return string + */ + function getFrozenHtml() + { + $value = $this->getValue(true); + $id = $this->getAttribute('id'); + return ('' != $value ? htmlspecialchars($value): '&nbsp;').'<input' . $this->_getAttrString(array( + 'type' => 'hidden', + 'name' => $this->realName, + 'value' => $this->getValue() + ) + (isset($id)? array('id' => $id): array())) . ' />'; + } //end func getFrozenHtml + + // }}} + // {{{ toHtml() + /** * Returns Html for the LiveSearch_Select input text element * * @access public @@ -131,7 +176,7 @@ */ function toHtml() { - $oldName = $this->getName(); + $this->realName = $this->getName(); $liveform = ''; $scriptLoad = ''; $style = 'display: block;'; @@ -140,13 +185,9 @@ $listyle = ' class="listyle" '; $zeroLength = 0; $this->updateAttributes(array( - 'name' => $this->getPrivateName($oldName), + 'name' => $this->getPrivateName($this->realName) ) ); -// if (isset($this->_options['getparameters']) ) -// $getParam = "&".$this->_options['getparameters']."&class=".$this->getName()."ObjLS"; -// else -// $getParam = "&class=".$this->getName()."ObjLS"; if (isset($this->_options['style']) AND $this->_options['style'] != '') { $style = ' style="'.$this->_options['style'].'" '; } @@ -165,7 +206,7 @@ $zeroLength = 0; } $this->updateAttributes(array( - 'onkeyup' => 'javascript:liveSearchKeyPress(this, event, \''.$this->getName().'Result\', \'target_'.$this->_options['elementId'].'\', \''.$this->_options['elementId'].'\', \''.$oldName.'\', '.$zeroLength.');',//'javascript:'.$this->getName().'ObjLS.liveSearchKeyPress(this, event);disable();', + 'onkeyup' => 'javascript:liveSearchKeyPress(this, event, \''.$this->getName().'Result\', \'target_'.$this->_options['elementId'].'\', \''.$this->_options['elementId'].'\', \''.$this->realName.'\', '.$zeroLength.');',//'javascript:'.$this->getName().'ObjLS.liveSearchKeyPress(this, event);disable();', 'onblur' => 'javascript:liveSearchHide(\''.$this->getName().'Result\');', 'id' => $this->_options['elementId'], 'style' => $style, @@ -173,7 +214,7 @@ ) ); if ($this->_flagFrozen) { - $liveform = ''; + return $this->getFrozenHtml(); } else { $liveform .= ' <div'.$divstyle.'id="'.$this->getName().'Result"> @@ -273,7 +314,7 @@ var out = "<?xml version=\'1.0\' encoding=\'utf-8\' ?><ul class=\"outerUl\" >"; for(var i in result) { if (i != \'______array\') { - out += "<li class=\"outerLi\"><a href=\"#\" value=\""+i+"\" text=\""+result[i]+"\" onmouseover=\"liveSearchHover(this);\" onmousedown=\"liveSearchClicked(this.getAttribute(\'value\'), this.getAttribute(\'text\'), \''.$this->_options['elementId'].'\', \''.$oldName.'\');\">"+result[i]+"</a></li>"; + out += "<li class=\"outerLi\"><a href=\"#\" value=\""+i+"\" text=\""+result[i]+"\" onmouseover=\"liveSearchHover(this);\" onmousedown=\"liveSearchClicked(this.getAttribute(\'value\'), this.getAttribute(\'text\'), \''.$this->_options['elementId'].'\', \''.$this->realName.'\');\">"+result[i]+"</a></li>"; } } out += "</ul>"; @@ -296,7 +337,7 @@ define('HTML_QUICKFORM_JS_INIT_EXISTS', true); } $scriptLoad .= ' -<input type="hidden" name="'.$oldName.'" id="'.$oldName.'" value="'.$this->_hidden_value.'">'."\n"; +<input type="hidden" name="'.$this->realName.'" id="'.$this->realName.'" value="'.$this->_hidden_value.'">'."\n"; }

« previous php.pear.cvs (#40873) next »