diff --git a/main/inc/lib/pear/HTML/Common.php b/main/inc/lib/pear/HTML/Common.php old mode 100755 new mode 100644 index 6b671bf9de..74f068a0f5 --- a/main/inc/lib/pear/HTML/Common.php +++ b/main/inc/lib/pear/HTML/Common.php @@ -1,46 +1,46 @@ - * @copyright 2001-2009 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id: Common.php,v 1.15 2009/04/03 15:26:22 avb Exp $ - * @link http://pear.php.net/package/HTML_Common/ + * @copyright 2001-2009 The PHP Group + * @license http://www.php.net/license/3_01.txt PHP License 3.01 + * @version CVS: $Id: Common.php,v 1.15 2009/04/03 15:26:22 avb Exp $ + * @link http://pear.php.net/package/HTML_Common/ */ -/** - * Base class for all HTML classes - * - * @category HTML - * @package HTML_Common - * @author Adam Daniel - * @version Release: 1.2.5 +/** + * Base class for all HTML classes + * + * @category HTML + * @package HTML_Common + * @author Adam Daniel + * @version Release: 1.2.5 * @abstract */ -class HTML_Common -{ +class HTML_Common +{ /** - * Associative array of attributes + * Associative array of attributes * @var array * @access private */ var $_attributes = array(); /** - * Tab offset of the tag + * Tab offset of the tag * @var int * @access private */ @@ -139,7 +139,7 @@ class HTML_Common $strAttr = ''; if (is_array($attributes)) { - $charset = HTML_Common::charset(); + $charset = HTML_Common::charset(); foreach ($attributes as $key => $value) { // Modified by Ivan Tcholakov, 16-MAR-2010 //$strAttr .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, $charset) . '"'; @@ -154,7 +154,7 @@ class HTML_Common * Returns a valid atrributes array from either a string or array * @param mixed $attributes Either a typical HTML attribute string or an associative array * @access private - * @return array + * @return array */ function _parseAttributes($attributes) { @@ -182,9 +182,9 @@ class HTML_Common $arrAttr[strtolower(trim($name))] = strtolower(trim($name)); } else { if (substr($value, 0, 1) == "\"" || substr($value, 0, 1) == "'") { - $arrAttr[strtolower(trim($name))] = substr($value, 1, -1); - } else { - $arrAttr[strtolower(trim($name))] = trim($value); + $arrAttr[strtolower(trim($name))] = substr($value, 1, -1); + } else { + $arrAttr[strtolower(trim($name))] = trim($value); } } } @@ -200,7 +200,7 @@ class HTML_Common * @param array $attributes Array of attribute * @since 1.0 * @access private - * @return bool + * @return bool */ function _getAttrKey($attr, $attributes) { @@ -233,7 +233,7 @@ class HTML_Common * @param string $attr Attribute name * @param array $attributes Attribute array * @since 1.4 - * @access private + * @access private * @return void */ function _removeAttr($attr, &$attributes) @@ -250,7 +250,7 @@ class HTML_Common * @param string $attr Attribute name * @since 1.5 * @access public - * @return string|null returns null if an attribute does not exist + * @return string|null returns null if an attribute does not exist */ function getAttribute($attr) { @@ -262,22 +262,22 @@ class HTML_Common } //end func getAttribute /** - * Sets the value of the attribute - * - * @param string Attribute name - * @param string Attribute value (will be set to $name if omitted) - * @access public - */ - function setAttribute($name, $value = null) - { - $name = strtolower($name); - if (is_null($value)) { - $value = $name; - } - $this->_attributes[$name] = $value; - } // end func setAttribute - - /** + * Sets the value of the attribute + * + * @param string Attribute name + * @param string Attribute value (will be set to $name if omitted) + * @access public + */ + function setAttribute($name, $value = null) + { + $name = strtolower($name); + if (is_null($value)) { + $value = $name; + } + $this->_attributes[$name] = $value; + } // end func setAttribute + + /** * Sets the HTML attributes * @param mixed $attributes Either a typical HTML attribute string or an associative array * @access public @@ -344,7 +344,7 @@ class HTML_Common case 'unix': $this->_lineEnd = "\12"; break; - case 'mac': + case 'mac': $this->_lineEnd = "\15"; break; default: @@ -435,40 +435,40 @@ class HTML_Common print $this->toHtml(); } // end func display - /** - * Sets the charset to use by htmlspecialchars() function - * - * Since this parameter is expected to be global, the function is designed - * to be called statically: - * - * HTML_Common::charset('utf-8'); - * - * or - * - * $charset = HTML_Common::charset(); - * - * - * @param string New charset to use. Omit if just getting the - * current value. Consult the htmlspecialchars() docs - * for a list of supported character sets. - * @return string Current charset - * @access public - * @static - */ - function charset($newCharset = null) - { - // Modified by Ivan Tcholakov, 16-MAR-2010 - //static $charset = 'ISO-8859-1'; - static $charset; - if (!isset($charset)) { - $charset = api_get_system_encoding(); - } - // - - if (!is_null($newCharset)) { - $charset = $newCharset; - } - return $charset; - } // end func charset + /** + * Sets the charset to use by htmlspecialchars() function + * + * Since this parameter is expected to be global, the function is designed + * to be called statically: + * + * HTML_Common::charset('utf-8'); + * + * or + * + * $charset = HTML_Common::charset(); + * + * + * @param string New charset to use. Omit if just getting the + * current value. Consult the htmlspecialchars() docs + * for a list of supported character sets. + * @return string Current charset + * @access public + * @static + */ + function charset($newCharset = null) + { + // Modified by Ivan Tcholakov, 16-MAR-2010 + //static $charset = 'ISO-8859-1'; + static $charset; + if (!isset($charset)) { + $charset = api_get_system_encoding(); + } + // + + if (!is_null($newCharset)) { + $charset = $newCharset; + } + return $charset; + } // end func charset } // end class HTML_Common -?> +?> \ No newline at end of file diff --git a/main/inc/lib/pear/HTML/QuickForm.php b/main/inc/lib/pear/HTML/QuickForm.php index 686a162fc0..abf55be795 100644 --- a/main/inc/lib/pear/HTML/QuickForm.php +++ b/main/inc/lib/pear/HTML/QuickForm.php @@ -290,9 +290,11 @@ class HTML_QuickForm extends HTML_Common * @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field * @access public */ - function HTML_QuickForm($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit = false) + public function __construct($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit = false) { HTML_Common::HTML_Common($attributes); + + $method = (strtoupper($method) == 'GET') ? 'get' : 'post'; // Modified by Chamilo team, 16-MAR-2010 //$action = ($action == '') ? $_SERVER['PHP_SELF'] : $action; @@ -338,7 +340,7 @@ class HTML_QuickForm extends HTML_Common default: $this->_maxFileSize = $matches['1']; } - } + } } // end constructor // }}} @@ -1693,8 +1695,7 @@ class HTML_QuickForm extends HTML_Common * @access public * @return void */ - function accept(&$renderer) - { + function accept(&$renderer) { $renderer->startForm($this); foreach (array_keys($this->_elements) as $key) { $element =& $this->_elements[$key]; @@ -1716,15 +1717,13 @@ class HTML_QuickForm extends HTML_Common * @since 3.0 * @return object a default renderer object */ - function &defaultRenderer() - { + function &defaultRenderer() { if (!isset($GLOBALS['_HTML_QuickForm_default_renderer'])) { - include_once('HTML/QuickForm/Renderer/Default.php'); + include_once 'HTML/QuickForm/Renderer/Default.php'; // Modified by Ivan Tcholakov, 16-MAR-2010. Suppressing a deprecation warning on PHP 5.3 //$GLOBALS['_HTML_QuickForm_default_renderer'] =& new HTML_QuickForm_Renderer_Default(); $GLOBALS['_HTML_QuickForm_default_renderer'] = new HTML_QuickForm_Renderer_Default(); - // - } + } return $GLOBALS['_HTML_QuickForm_default_renderer']; } // end func defaultRenderer @@ -1741,12 +1740,12 @@ class HTML_QuickForm extends HTML_Common * @since 1.0 * @access public */ - function toHtml ($in_data = null) - { + function toHtml ($in_data = null) { + if (!is_null($in_data)) { $this->addElement('html', $in_data); } - $renderer =& $this->defaultRenderer(); + $renderer =& $this->defaultRenderer(); $this->accept($renderer); return $renderer->toHtml(); } // end func toHtml @@ -2081,7 +2080,6 @@ class HTML_QuickForm_Error extends PEAR_Error { $this->PEAR_Error("Invalid error code: $code", QUICKFORM_ERROR, $mode, $level, $debuginfo); } } - // }}} } // end class HTML_QuickForm_Error ?> \ No newline at end of file diff --git a/main/inc/lib/pear/HTML/QuickForm/Renderer/Default.php b/main/inc/lib/pear/HTML/QuickForm/Renderer/Default.php index c19a8453ca..3a011e2cb4 100644 --- a/main/inc/lib/pear/HTML/QuickForm/Renderer/Default.php +++ b/main/inc/lib/pear/HTML/QuickForm/Renderer/Default.php @@ -154,7 +154,7 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer */ function HTML_QuickForm_Renderer_Default() { - $this->HTML_QuickForm_Renderer(); + parent::__construct(); } // end constructor /** @@ -197,8 +197,9 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer if (!empty($form->_required) && !$form->_freezeAll) { $this->_html .= str_replace('{requiredNote}', $form->getRequiredNote(), $this->_requiredNoteTemplate); } - // add form attributes and content - $html = str_replace('{attributes}', $form->getAttributes(true), $this->_formTemplate); + // add form attributes and content + $html = str_replace('{attributes}', $form->getAttributes(true), $this->_formTemplate); + if (strpos($this->_formTemplate, '{hidden}')) { $html = str_replace('{hidden}', $this->_hiddenHtml, $html); } else { @@ -247,6 +248,7 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer } else { $nameLabel = $label; } + if (isset($this->_templates[$name])) { $html = str_replace('{label}', $nameLabel, $this->_templates[$name]); } else { @@ -291,12 +293,10 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer * @access public * @return void */ - function renderElement(&$element, $required, $error) - { + function renderElement(&$element, $required, $error) { if (!$this->_inGroup) { - $html = $this->_prepareTemplate($element->getName(), $element->getLabel(), $required, $error); + $html = $this->_prepareTemplate($element->getName(), $element->getLabel(), $required, $error); $this->_html .= str_replace('{element}', $element->toHtml(), $html); - } elseif (!empty($this->_groupElementTemplate)) { $html = str_replace('{label}', $element->getLabel(), $this->_groupElementTemplate); if ($required) { @@ -452,9 +452,8 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer * @access public * @return void */ - function setFormTemplate($html) - { - $this->_formTemplate = $html; + function setFormTemplate($html) { + $this->_formTemplate = $html; } // end func setFormTemplate /** @@ -483,5 +482,4 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer $this->setRequiredNoteTemplate(''); $this->_templates = array(); } // end func clearAllTemplates -} // end class HTML_QuickForm_Renderer_Default -?> +} // end class HTML_QuickForm_Renderer_Default \ No newline at end of file diff --git a/main/inc/lib/pear/HTML/QuickForm/element.php b/main/inc/lib/pear/HTML/QuickForm/element.php index 38d24c4234..e6f14f4581 100644 --- a/main/inc/lib/pear/HTML/QuickForm/element.php +++ b/main/inc/lib/pear/HTML/QuickForm/element.php @@ -1,43 +1,43 @@ - * @author Bertrand Mansion - * @author Alexey Borzov - * @copyright 2001-2009 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id: element.php,v 1.37 2009/04/04 21:34:02 avb Exp $ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for all HTML classes - */ -require_once 'HTML/Common.php'; +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Base class for form elements * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @author Alexey Borzov - * @version Release: 3.2.11 - * @since 1.0 + * PHP versions 4 and 5 + * + * LICENSE: This source file is subject to version 3.01 of the PHP license + * that is available through the world-wide-web at the following URI: + * http://www.php.net/license/3_01.txt If you did not receive a copy of + * the PHP License and are unable to obtain it through the web, please + * send a note to license@php.net so we can mail you a copy immediately. + * + * @category HTML + * @package HTML_QuickForm + * @author Adam Daniel + * @author Bertrand Mansion + * @author Alexey Borzov + * @copyright 2001-2009 The PHP Group + * @license http://www.php.net/license/3_01.txt PHP License 3.01 + * @version CVS: $Id: element.php,v 1.37 2009/04/04 21:34:02 avb Exp $ + * @link http://pear.php.net/package/HTML_QuickForm + */ + +/** + * Base class for all HTML classes + */ +require_once 'HTML/Common.php'; + +/** + * Base class for form elements + * + * @category HTML + * @package HTML_QuickForm + * @author Adam Daniel + * @author Bertrand Mansion + * @author Alexey Borzov + * @version Release: 3.2.11 + * @since 1.0 * @abstract */ class HTML_QuickForm_element extends HTML_Common @@ -112,7 +112,7 @@ class HTML_QuickForm_element extends HTML_Common */ function apiVersion() { - return 3.2; + return 3.2; } // end func apiVersion // }}} @@ -368,7 +368,7 @@ class HTML_QuickForm_element extends HTML_Common * * @param string $event Name of event * @param mixed $arg event arguments - * @param object &$caller calling object + * @param object &$caller calling object * @since 1.0 * @access public * @return void @@ -411,9 +411,9 @@ class HTML_QuickForm_element extends HTML_Common /** * Accepts a renderer * - * @param HTML_QuickForm_Renderer renderer object - * @param bool Whether an element is required - * @param string An error message associated with an element + * @param HTML_QuickForm_Renderer renderer object + * @param bool Whether an element is required + * @param string An error message associated with an element * @access public * @return void */