From: <tr...@us...> - 2011-10-22 14:22:44
|
Revision: 7922 http://xoops.svn.sourceforge.net/xoops/?rev=7922&view=rev Author: trabis Date: 2011-10-22 14:22:35 +0000 (Sat, 22 Oct 2011) Log Message: ----------- refactoring class/xoopsforms Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopseditor/xoopseditor.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/form.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formbutton.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formbuttontray.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcaptcha.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcheckbox.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcolorpicker.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formdatetime.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formdhtmltextarea.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formeditor.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formelement.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formelementtray.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formfile.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formhidden.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formhiddentoken.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formlabel.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formpassword.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formradio.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formradioyn.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formselect.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formselectcheckgroup.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formselectcountry.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formselecteditor.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formselectgroup.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formselectlang.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formselectmatchoption.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formselecttheme.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formselecttimezone.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formselectuser.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formtext.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formtextarea.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formtextdateselect.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/grouppermform.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/simpleform.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/tableform.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/themeform.php XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/admin/preferences/main.php Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopseditor/xoopseditor.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopseditor/xoopseditor.php 2011-10-21 20:15:00 UTC (rev 7921) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopseditor/xoopseditor.php 2011-10-22 14:22:35 UTC (rev 7922) @@ -159,7 +159,7 @@ * @param bool $noHtml * @param string $OnFailure a pre-validated editor that will be used if the required editor is failed to create * @param bool $noHtml dohtml disabled - * @return null + * @return null|XoopsEditor */ public function get($name = '', $options = null, $noHtml = false, $OnFailure = '') { @@ -235,7 +235,7 @@ * * @param string $name * @param mixed $options - * @return + * @return XoopsEditor|null */ private function _loadEditor($name, $options = null) { Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/form.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/form.php 2011-10-21 20:15:00 UTC (rev 7921) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/form.php 2011-10-22 14:22:35 UTC (rev 7922) @@ -11,100 +11,75 @@ * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel - * @subpackage form + * @package class + * @subpackage xoopsform * @since 2.0.0 * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ * @author Taiwen Jiang <ph...@us...> * @version $Id$ */ + defined('XOOPS_ROOT_PATH') or die('Restricted access'); -/** - * Abstract base class for forms - * - * @author Kazumi Ono <on...@xo...> - * @author Taiwen Jiang <ph...@us...> - * @package kernel - * @subpackage form - * @access public - */ -class XoopsForm +abstract class XoopsForm implements XoopsFormContainer { /** - * *#@+ - * - * @access private - */ - /** * "action" attribute for the html form * * @var string */ - var $_action; + private $_action; /** * "method" attribute for the form. * * @var string */ - var $_method; + private $_method; /** * "name" attribute of the form * * @var string */ - var $_name; + private $_name; /** * title for the form * * @var string */ - var $_title; + private $_title; /** * summary for the form (WGAC2 Requirement) * * @var string */ - var $_summary = ''; + private $_summary = ''; /** * array of {@link XoopsFormElement} objects * * @var array */ - var $_elements = array(); + private $_elements = array(); /** * extra information for the <form> tag * * @var array */ - var $_extra = array(); + private $_extra = array(); /** * required elements * * @var array */ - var $_required = array(); + private $_required = array(); - /** - * additional seralised object checksum (ERM Analysis - Requirement) - * @deprecated - * @access private - */ - var $_objid = 'da39a3ee5e6b4b0d3255bfef95601890afd80709'; - - /** - * *#@- - */ - - /** * constructor * * @param string $title title of the form @@ -112,108 +87,38 @@ * @param string $action "action" attribute for the <form> tag * @param string $method "method" attribute for the <form> tag * @param bool $addtoken whether to add a security token to the form + * @param string $summary */ - function XoopsForm($title, $name, $action, $method = 'post', $addtoken = false, $summary = '') + public function __construct($title, $name, $action, $method = 'post', $addtoken = false, $summary = '') { $this->_title = $title; $this->_name = $name; $this->_action = $action; $this->_method = $method; - $this->_summary = $summary; + $this->_summary = $summary; if ($addtoken != false) { $this->addElement(new XoopsFormHiddenToken()); } } - /** - * *#@+ - * retrieves object serialisation/identification id (sha1 used) - * - * each object has serialisation<br /> - * - legal requirement of enterprise relational management (ERM) - * - * @deprecated - * @access public - */ - function getObjectID($object, $hashinfo = 'sha1') - { - if (!is_object($object)) - $object = $this; - - switch($hashinfo) { - case "md5": - - @$var['name'] = md5(get_class($object)); - - foreach(get_object_vars($object) as $key => $value) - if ($key != '_objid') - @$var['value'] = $this->getArrayID($value, $key, $var['value'], $hashinfo); - - foreach(get_class_methods($object) as $key => $value) - @$var['func'] = $this->getArrayID($value, $key, $var['func'], $hashinfo); - - @$this->_objid = md5($var['name'].":".$var['func'].":".$var['value']); - return $this->_objid; - break; - - default: - - @$var['name'] = sha1(get_class($object)); - - foreach(get_object_vars($object) as $key => $value) - if ($key != '_objid') - @$var['value'] = $this->getArrayID($value, $key, $var['value'], $hashinfo); - - foreach(get_class_methods($object) as $key => $value) - @$var['func'] = $this->getArrayID($value, $key, $var['func'], $hashinfo); - - @$this->_objid = sha1($var['name'].":".$var['func'].":".$var['value']); - return $this->_objid; - - } - } - - function getArrayID($value, $key, $ret, $hashinfo = 'sha1') { - switch($hashinfo) { - case "md5": - if (is_array($value)) { - foreach ($value as $keyb => $valueb) - @$ret = md5($ret.":".$this->getArrayID($valueb, $keyb, $ret, $hashinfo)); - } else { - @$ret = md5($ret.":".$key.":".$value); - } - return $ret; - break; - default: - if (is_array($value)) { - foreach ($value as $keyb => $valueb) - @$ret = sha1($ret.":".$this->getArrayID($valueb, $keyb, $ret, $hashinfo)); - } else { - @$ret = sha1($ret.":".$key.":".$value); - } - return $ret; - break; - } - } - - /** + /** * return the summary of the form * * @param bool $encode To sanitizer the text? * @return string */ - function getSummary($encode = false) + public function getSummary($encode = false) { return $encode ? htmlspecialchars($this->_summary, ENT_QUOTES) : $this->_summary; } - /** + /** * return the title of the form * * @param bool $encode To sanitizer the text? * @return string */ - function getTitle($encode = false) + public function getTitle($encode = false) { return $encode ? htmlspecialchars($this->_title, ENT_QUOTES) : $this->_title; } @@ -226,7 +131,7 @@ * @param bool $encode To sanitizer the text? * @return string */ - function getName($encode = true) + public function getName($encode = true) { return $encode ? htmlspecialchars($this->_name, ENT_QUOTES) : $this->_name; } @@ -237,7 +142,7 @@ * @param bool $encode To sanitizer the text? * @return string */ - function getAction($encode = true) + public function getAction($encode = true) { // Convert & to & for backward compatibility return $encode ? htmlspecialchars(str_replace('&', '&', $this->_action), ENT_QUOTES) : $this->_action; @@ -248,7 +153,7 @@ * * @return string */ - function getMethod() + public function getMethod() { return (strtolower($this->_method) == 'get') ? 'get' : 'post'; } @@ -256,56 +161,54 @@ /** * Add an element to the form * - * @param object $ &$formElement reference to a {@link XoopsFormElement} + * @param XoopsFormElement $formElement * @param bool $required is this a "required" element? + * @return void */ - function addElement(&$formElement, $required = false) + public function addElement(XoopsFormElement &$formElement, $required = false) { - if (is_string($formElement)) { - $this->_elements[] = $formElement; - } elseif (is_subclass_of($formElement, 'xoopsformelement')) { - $this->_elements[] = $formElement; - if (! $formElement->isContainer()) { - if ($required) { - $formElement->_required = true; - $this->_required[] = $formElement; - } - } else { - $required_elements = $formElement->getRequired(); - $count = count($required_elements); - for($i = 0; $i < $count; $i ++) { - $this->_required[] = $required_elements[$i]; - } + /* @var XoopsFormElement $formElement */ + $this->_elements[] = $formElement; + if ($formElement instanceof XoopsFormContainer) { + /* @var $formElement XoopsFormContainer */ + $required_elements = $formElement->getRequired(); + $count = count($required_elements); + for ($i = 0; $i < $count; $i++) { + $this->_required[] = $required_elements[$i]; } + } else { + if ($required && !$formElement instanceof XoopsFormRaw) { + $formElement->setRequired(); + $this->_required[] = $formElement; + } } } /** * get an array of forms elements * - * @param bool $ get elements recursively? + * @param bool $recurse get elements recursively? * @return array array of {@link XoopsFormElement}s */ - function getElements($recurse = false) + public function getElements($recurse = false) { - if (! $recurse) { + if (!$recurse) { return $this->_elements; } else { $ret = array(); - $count = count($this->_elements); - for($i = 0; $i < $count; $i ++) { - if (is_object($this->_elements[$i])) { - if (! $this->_elements[$i]->isContainer()) { - $ret[] = $this->_elements[$i]; - } else { - $elements = $this->_elements[$i]->getElements(true); - $count2 = count($elements); - for($j = 0; $j < $count2; $j ++) { - $ret[] = $elements[$j]; - } - unset($elements); + foreach ($this->_elements as $ele) { + if ($ele instanceof XoopsFormContainer) { + /* @var $ele XoopsFormContainer */ + $elements = $ele->getElements(true); + foreach ($elements as $ele2) { + $ret[] = $ele2; } + unset($elements); + unset($ele2); + } else { + $ret[] = $ele; } + unset($ele); } return $ret; } @@ -316,13 +219,14 @@ * * @return array array of form element names */ - function getElementNames() + public function getElementNames() { $ret = array(); $elements = $this->getElements(true); - $count = count($elements); - for($i = 0; $i < $count; $i ++) { - $ret[] = $elements[$i]->getName(); + foreach ($elements as $ele) { + /* @var $ele XoopsFormElement */ + $ret[] = $ele->getName(); + unset($ele); } return $ret; } @@ -331,33 +235,32 @@ * get a reference to a {@link XoopsFormElement} object by its "name" * * @param string $name "name" attribute assigned to a {@link XoopsFormElement} - * @return object reference to a {@link XoopsFormElement}, false if not found + * + * @return null|XoopsFormElement */ - function getElementByName($name) + public function getElementByName($name) { $elements = $this->getElements(true); - $count = count($elements); - for($i = 0; $i < $count; $i ++) { - if ($name == $elements[$i]->getName(false)) { - return $elements[$i]; + foreach ($elements as $ele) { + /* @var XoopsFormElement $ele */ + if ($name == $ele->getName(false)) { + return $ele; } } - $elt = null; - return $elt; + $ele = null; + return $ele; } - /** + /** * Sets the "value" attribute of a form element * * @param string $name the "name" attribute of a form element * @param string $value the "value" attribute of a form element */ - function setElementValue($name, $value) + public function setElementValue($name, $value) { $ele = $this->getElementByName($name); - if (is_object($ele) && method_exists($ele, 'setValue')) { - $ele->setValue($value); - } + $ele->setValue($value); } /** @@ -365,16 +268,16 @@ * * @param array $values array of name/value pairs to be assigned to form elements */ - function setElementValues($values) + public function setElementValues($values) { - if (is_array($values) && ! empty($values)) { + if (is_array($values) && !empty($values)) { // will not use getElementByName() for performance.. $elements = $this->getElements(true); - $count = count($elements); - for($i = 0; $i < $count; $i ++) { - $name = $elements[$i]->getName(false); - if ($name && isset($values[$name]) && method_exists($elements[$i], 'setValue')) { - $elements[$i]->setValue($values[$name]); + foreach ($elements as $ele) { + /* @var $ele XoopsFormElement */ + $name = $ele->getName(false); + if ($name && isset($values[$name])) { + $ele->setValue($values[$name]); } } } @@ -385,15 +288,12 @@ * * @param string $name the "name" attribute of a form element * @param bool $encode To sanitizer the text? - * @return string the "value" attribute assigned to a form element, null if not set + * @return string|null the "value" attribute assigned to a form element, null if not set */ - function getElementValue($name, $encode = false) + public function getElementValue($name, $encode = false) { $ele = $this->getElementByName($name); - if (is_object($ele) && method_exists($ele, 'getValue')) { - return $ele->getValue($encode); - } - return; + return $ele->getValue($encode); } /** @@ -402,16 +302,16 @@ * @param bool $encode To sanitizer the text? * @return array array of name/value pairs assigned to form elements */ - function getElementValues($encode = false) + public function getElementValues($encode = false) { // will not use getElementByName() for performance.. $elements = $this->getElements(true); - $count = count($elements); $values = array(); - for($i = 0; $i < $count; $i ++) { - $name = $elements[$i]->getName(false); - if ($name && method_exists($elements[$i], 'getValue')) { - $values[$name] = $elements[$i]->getValue($encode); + foreach ($elements as $ele) { + /* @var XoopsFormElement $ele */ + $name = $ele->getName(false); + if ($name) { + $values[$name] = $ele->getValue($encode); } } return $values; @@ -422,22 +322,23 @@ * * @param string $extra extra attributes for the <form> tag */ - function setExtra($extra) + public function setExtra($extra) { - if (! empty($extra)) { + if (!empty($extra)) { $this->_extra[] = $extra; } } - /** + /** * set the summary tag for the <form> tag * - * @param string $extra extra attributes for the <form> tag + * @param $summary + * @return void */ - function setSummary($summary) + public function setSummary($summary) { - if (! empty($summary)) { - $this->summary = strip_tags($summary); + if (!empty($summary)) { + $this->_summary = strip_tags($summary); } } @@ -446,7 +347,7 @@ * * @return string */ - function getExtra() + public function getExtra() { $extra = empty($this->_extra) ? '' : ' ' . implode(' ', $this->_extra); return $extra; @@ -455,9 +356,10 @@ /** * make an element "required" * - * @param object $ &$formElement reference to a {@link XoopsFormElement} + * @param XoopsFormElement $formElement + * @return void */ - function setRequired(&$formElement) + public function setRequired(XoopsFormElement &$formElement) { $this->_required[] = $formElement; } @@ -467,38 +369,24 @@ * * @return array array of {@link XoopsFormElement}s */ - function getRequired() + public function getRequired() { return $this->_required; } /** - * insert a break in the form - * - * This method is abstract. It must be overwritten in the child classes. - * - * @param string $extra extra information for the break - * @abstract - */ - function insertBreak($extra = null) - { - } - - /** * returns renderered form * * This method is abstract. It must be overwritten in the child classes. * * @abstract */ - function render() - { - } + abstract function render(); /** * displays rendered form */ - function display() + public function display() { echo $this->render(); } @@ -524,8 +412,10 @@ * </code> * * @param boolean $withtags Include the < javascript > tags in the returned string + * + * @return string */ - function renderValidationJS($withtags = true) + public function renderValidationJS($withtags = true) { $js = ''; if ($withtags) { @@ -534,10 +424,9 @@ $formname = $this->getName(); $js .= "function xoopsFormValidate_{$formname}() { var myform = window.document.{$formname}; "; $elements = $this->getElements(true); - foreach($elements as $elt) { - if (method_exists($elt, 'renderValidationJS')) { - $js .= $elt->renderValidationJS(); - } + foreach ($elements as $ele) { + /* @var XoopsFormElement $ele */ + $js .= $ele->renderValidationJS(); } $js .= "return true;\n}\n"; if ($withtags) { @@ -549,22 +438,19 @@ /** * assign to smarty form template instead of displaying directly * - * @param object $ &$tpl reference to a {@link Smarty} object - * @see Smarty + * @param XoopsTpl $tpl + * @return void */ - function assign(&$tpl) + public function assign(XoopsTpl &$tpl) { - $i = - 1; + $i = -1; $elements = array(); if (count($this->getRequired()) > 0) { - $this->_elements[] = "<tr class='foot'><td colspan='2'>* = " . _REQUIRED . "</td></tr>"; + $this->_elements[] = new XoopsFormRaw("<tr class='foot'><td colspan='2'>* = " . _REQUIRED . "</td></tr>"); } - foreach($this->getElements() as $ele) { - ++ $i; - if (is_string($ele)) { - $elements[$i]['body'] = $ele; - continue; - } + foreach ($this->getElements() as $ele) { + ++$i; + /* @var XoopsFormElement $ele */ $ele_name = $ele->getName(); $ele_description = $ele->getDescription(); $n = $ele_name ? $ele_name : $i; @@ -579,13 +465,11 @@ } $js = $this->renderValidationJS(); $tpl->assign($this->getName(), array( - 'title' => $this->getTitle() , - 'name' => $this->getName() , - 'action' => $this->getAction() , - 'method' => $this->getMethod() , - 'extra' => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '();"' . $this->getExtra() , - 'javascript' => $js , - 'elements' => $elements)); + 'title' => $this->getTitle(), 'name' => $this->getName(), 'action' => $this->getAction(), + 'method' => $this->getMethod(), + 'extra' => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '();"' . $this->getExtra(), + 'javascript' => $js, 'elements' => $elements + )); } } Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formbutton.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formbutton.php 2011-10-21 20:15:00 UTC (rev 7921) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formbutton.php 2011-10-22 14:22:35 UTC (rev 7922) @@ -11,104 +11,59 @@ * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel - * @subpackage form + * @package class + * @subpackage xoopsform * @since 2.0.0 * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ * @version $Id$ */ + defined('XOOPS_ROOT_PATH') or die("XOOPS root path not defined"); -/** - * - * - * @package kernel - * @subpackage form - * - * @author Kazumi Ono <on...@xo...> - * @copyright copyright (c) 2000-2003 XOOPS.org - */ -/** - * A button - * - * @author Kazumi Ono <on...@xo...> - * @copyright copyright (c) 2000-2003 XOOPS.org - * - * @package kernel - * @subpackage form - */ class XoopsFormButton extends XoopsFormElement { - /** - * Value - * @var string - * @access private - */ - var $_value; - - /** + /** * Type of the button. This could be either "button", "submit", or "reset" - * @var string - * @access private - */ - var $_type; + * @var string + */ + protected $_type; - /** - * Constructor + /** + * Constructor * - * @param string $caption Caption - * @param string $name - * @param string $value - * @param string $type Type of the button. Potential values: "button", "submit", or "reset" - */ - function XoopsFormButton($caption, $name, $value = "", $type = "button") - { - $this->setCaption($caption); - $this->setName($name); - $this->_type = $type; - $this->setValue($value); - } + * @param string $caption Caption + * @param string $name + * @param string $value + * @param string $type Type of the button. Potential values: "button", "submit", or "reset" + */ + public function __construct($caption, $name, $value = "", $type = "button") + { + $this->setCaption($caption); + $this->setName($name); + $this->_type = $type; + $this->setValue($value); + } - /** - * Get the initial value - * - * @param bool $encode To sanitizer the text? - * @return string - */ - function getValue($encode = false) - { - return $encode ? htmlspecialchars($this->_value, ENT_QUOTES) : $this->_value; - } + /** + * Get the type + * + * @return string + */ + public function getType() + { + return in_array(strtolower($this->_type), array("button", "submit", "reset")) ? $this->_type : "button"; + } - /** - * Set the initial value - * - * @return string - */ - function setValue($value) - { - $this->_value = $value; - } - - /** - * Get the type - * - * @return string - */ - function getType() - { - return in_array( strtolower($this->_type), array("button", "submit", "reset") ) ? $this->_type : "button"; - } - - /** - * prepare HTML for output - * - * @return string - */ - function render() - { - return "<input type='" . $this->getType() . "' class='formButton' name='" . $this->getName() . "' id='" . $this->getName() . "' value='" . $this->getValue() . "' title='" . $this->getValue() . "'" . $this->getExtra() . " />"; - } + /** + * prepare HTML for output + * + * @return string + */ + public function render() + { + return "<input type='" . $this->getType() . "' class='formButton' name='" . $this->getName() . "' id='" . $this->getName() . "' value='" . $this->getValue() . "' title='" . $this->getValue() . "'" . $this->getExtra() . " />"; + } } + ?> \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formbuttontray.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formbuttontray.php 2011-10-21 20:15:00 UTC (rev 7921) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formbuttontray.php 2011-10-22 14:22:35 UTC (rev 7922) @@ -1,105 +1,77 @@ <?php /** - * XOOPS Form Class Elements + * XOOPS Form element of button tray * - * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel - * @subpackage form + * @package class + * @subpackage xoopsform * @since 2.4.0 * @author John Neill <cat...@xo...> * @version $Id: formbuttontray.php 0000 14/04/2009 16:16:22 John Neill $ - * */ + defined('XOOPS_ROOT_PATH') or die('Restricted access'); -/** - * XoopsFormButtonTray - * - * @author John Neill <cat...@xo...> - * @package kernel - * @subpackage form - * @access public - */ -class XoopsFormButtonTray extends XoopsFormElement { - /** - * Value - * - * @var string - * @access private - */ - var $_value; +class XoopsFormButtonTray extends XoopsFormElement +{ - /** - * Type of the button. This could be either "button", "submit", or "reset" - * - * @var string - * @access private - */ - var $_type; + /** + * Type of the button. This could be either "button", "submit", or "reset" + * + * @var string + */ + private $_type; - /** - * XoopsFormButtonTray::XoopsFormButtonTray() - * - * @param mixed $name - * @param string $value - * @param string $type - * @param string $onclick - */ - function XoopsFormButtonTray( $name, $value = '', $type = '', $onclick = '', $showDelete = false ) { - $this->setName( $name ); - $this->setValue( $value ); - $this->_type = ( !empty( $type ) ) ? $type : 'submit'; - $this->_showDelete = $showDelete; - if ( $onclick ) { - $this->setExtra( $onclick ); - } else { - $this->setExtra( '' ); - } - } + /** + * XoopsFormButtonTray::XoopsFormButtonTray() + * + * @param mixed $name + * @param string $value + * @param string $type + * @param string $onclick + * @param bool $showDelete + */ + function __construct($name, $value = '', $type = '', $onclick = '', $showDelete = false) + { + $this->setName($name); + $this->setValue($value); + $this->_type = (!empty($type)) ? $type : 'submit'; + $this->_showDelete = $showDelete; + if ($onclick) { + $this->setExtra($onclick); + } else { + $this->setExtra(''); + } + } - /** - * XoopsFormButtonTray::getValue() - * - * @return - */ - function getValue() { - return $this->_value; - } + /** + * @return string + */ + public function getType() + { + return $this->_type; + } - /** - * XoopsFormButtonTray::setValue() - * - * @param mixed $value - * @return - */ - function setValue( $value ) { - $this->_value = $value; - } - - /** - * XoopsFormButtonTray::getType() - * - * @return - */ - function getType() { - return $this->_type; - } - - /** - * XoopsFormButtonTray::render() - * - * @return - */ - function render() { - // onclick="this.form.elements.op.value=\'delfile\'; - $ret = ''; - if ( $this->_showDelete ) { - $ret .= '<input type="submit" class="formbutton" name="delete" id="delete" value="' . _DELETE . '" onclick="this.form.elements.op.value=\'delete\'"> '; - } - $ret .= '<input type="button" value="' . _CANCEL . '" onClick="history.go(-1);return true;" /> <input type="reset" class="formbutton" name="reset" id="reset" value="' . _RESET . '" /> <input type="' . $this->getType() . '" class="formbutton" name="' . $this->getName() . '" id="' . $this->getName() . '" value="' . $this->getValue() . '"' . $this->getExtra() . ' />'; - return $ret; - } + /** + * @return string + */ + public function render() + { + $ret = ''; + if ($this->_showDelete) { + $ret .= '<input type="submit" class="formbutton" name="delete" id="delete" value="' . _DELETE . '" onclick="this.form.elements.op.value=\'delete\'"> '; + } + $ret .= '<input type="button" value="' . _CANCEL . '" onClick="history.go(-1);return true;" /> <input type="reset" class="formbutton" name="reset" id="reset" value="' . _RESET . '" /> <input type="' . $this->getType() . '" class="formbutton" name="' . $this->getName() . '" id="' . $this->getName() . '" value="' . $this->getValue() . '"' . $this->getExtra() . ' />'; + return $ret; + } } ?> \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcaptcha.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcaptcha.php 2011-10-21 20:15:00 UTC (rev 7921) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcaptcha.php 2011-10-22 14:22:35 UTC (rev 7922) @@ -11,12 +11,13 @@ * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel - * @subpackage form + * @package class + * @subpackage xoopsform * @since 2.3.0 * @author Taiwen Jiang <ph...@us...> * @version $Id$ */ + defined('XOOPS_ROOT_PATH') or die('Restricted access'); /** @@ -36,24 +37,21 @@ * </code> */ -/** - * Xoops Form Captcha - * - * @author Taiwen Jiang <ph...@us...> - * @package kernel - * @subpackage form - */ class XoopsFormCaptcha extends XoopsFormElement { - var $captchaHandler; + /** + * @var XoopsCaptcha + */ + public $captchaHandler; /** * * @param string $caption Caption of the form element, default value is defined in captcha/language/ * @param string $name Name for the input box * @param boolean $skipmember Skip CAPTCHA check for members + * @param array $configs */ - function XoopsFormCaptcha($caption = '', $name = 'xoopscaptcha', $skipmember = true, $configs = array()) + public function __construct($caption = '', $name = 'xoopscaptcha', $skipmember = true, $configs = array()) { $this->captchaHandler = XoopsCaptcha::getInstance(); $configs['name'] = $name; @@ -68,19 +66,17 @@ } } - function setConfig($name, $val) + public function setConfig($name, $val) { return $this->captchaHandler->setConfig($name, $val); } - function render() + public function render() { - // if (!$this->isHidden()) { return $this->captchaHandler->render(); - // } } - function renderValidationJS() + public function renderValidationJS() { return $this->captchaHandler->renderValidationJS(); } Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcheckbox.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcheckbox.php 2011-10-21 20:15:00 UTC (rev 7921) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcheckbox.php 2011-10-22 14:22:35 UTC (rev 7922) @@ -1,6 +1,6 @@ <?php /** - * XOOPS form checkbox compo + * XOOPS form element of checkbox compo * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code @@ -11,13 +11,15 @@ * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel + * @package class + * @subpackage xoopsform * @since 2.0 * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ * @author Skalpa Keo <sk...@xo...> * @author Taiwen Jiang <ph...@us...> * @version $Id$ */ + defined('XOOPS_ROOT_PATH') or die('Restricted access'); class XoopsFormCheckBox extends XoopsFormElement @@ -26,33 +28,29 @@ * Availlable options * * @var array - * @access private */ - var $_options = array(); + private $_options = array(); /** * pre-selected values in array * * @var array - * @access private */ - var $_value = array(); + protected $_value = array(); /** * HTML to seperate the elements * * @var string - * @access private */ - var $_delimeter; + private $_delimeter; /** * Column number for rendering * * @var int - * @access public */ - var $columns; + public $columns; /** * Constructor @@ -60,8 +58,9 @@ * @param string $caption * @param string $name * @param mixed $value Either one value as a string or an array of them. + * @param string $delimeter */ - function XoopsFormCheckBox($caption, $name, $value = null, $delimeter = ' ') + public function __construct($caption, $name, $value = null, $delimeter = ' ') { $this->setCaption($caption); $this->setName($name); @@ -69,51 +68,15 @@ $this->setValue($value); } $this->_delimeter = $delimeter; - $this->setFormType('checkbox'); } /** - * Get the "value" - * - * @param bool $encode To sanitizer the text? - * @return array - */ - function getValue($encode = false) - { - if (! $encode) { - return $this->_value; - } - $value = array(); - foreach($this->_value as $val) { - $value[] = $val ? htmlspecialchars($val, ENT_QUOTES) : $val; - } - return $value; - } - - /** - * Set the "value" - * - * @param array $ - */ - function setValue($value) - { - $this->_value = array(); - if (is_array($value)) { - foreach($value as $v) { - $this->_value[] = $v; - } - } else { - $this->_value[] = $value; - } - } - - /** * Add an option * * @param string $value * @param string $name */ - function addOption($value, $name = '') + public function addOption($value, $name = '') { if ($name != '') { $this->_options[$value] = $name; @@ -127,10 +90,10 @@ * * @param array $options Associative array of value->name pairs */ - function addOptionArray($options) + public function addOptionArray($options) { if (is_array($options)) { - foreach($options as $k => $v) { + foreach ($options as $k => $v) { $this->addOption($k, $v); } } @@ -139,17 +102,18 @@ /** * Get an array with all the options * - * @param int $encode To sanitizer the text? potential values: 0 - skip; 1 - only for value; 2 - for both value and name + * @param bool $encode To sanitizer the text? potential values: 0 - skip; 1 - only for value; 2 - for both value and name * @return array Associative array of value->name pairs */ - function getOptions($encode = false) + public function getOptions($encode = false) { - if (! $encode) { + if (!$encode) { return $this->_options; } $value = array(); - foreach($this->_options as $val => $name) { - $value[$encode ? htmlspecialchars($val, ENT_QUOTES) : $val] = ($encode > 1) ? htmlspecialchars($name, ENT_QUOTES) : $name; + foreach ($this->_options as $val => $name) { + $value[$encode ? htmlspecialchars($val, ENT_QUOTES) : $val] = ($encode > 1) + ? htmlspecialchars($name, ENT_QUOTES) : $name; } return $value; } @@ -160,7 +124,7 @@ * @param bool $encode To sanitizer the text? * @return string The delimiter */ - function getDelimeter($encode = false) + public function getDelimeter($encode = false) { return $encode ? htmlspecialchars(str_replace(' ', ' ', $this->_delimeter)) : $this->_delimeter; } @@ -170,29 +134,29 @@ * * @return string */ - function render() + public function render() { $ele_name = $this->getName(); - $ele_title = $this->getTitle(); + $ele_title = $this->getTitle(); $ele_id = $ele_name; $ele_value = $this->getValue(); $ele_options = $this->getOptions(); $ele_extra = $this->getExtra(); $ele_delimeter = empty($this->columns) ? $this->getDelimeter() : ''; - if (count($ele_options) > 1 && substr($ele_name, - 2, 2) != '[]') { + if (count($ele_options) > 1 && substr($ele_name, -2, 2) != '[]') { $ele_name = $ele_name . '[]'; $this->setName($ele_name); } $ret = ''; - if (! empty($this->columns)) { + if (!empty($this->columns)) { $ret .= '<table><tr>'; } $i = 0; $id_ele = 0; - foreach($ele_options as $value => $name) { - $id_ele ++; - if (! empty($this->columns)) { + foreach ($ele_options as $value => $name) { + $id_ele++; + if (!empty($this->columns)) { if ($i % $this->columns == 0) { $ret .= '<tr>'; } @@ -203,15 +167,15 @@ if (count($ele_value) > 0 && in_array($value, $ele_value)) { $ret .= ' checked="checked"'; } - $ret .= $ele_extra . ' />'."<label name='xolb_{$ele_name}' for='{$ele_id}{$id_ele}'>" . $name . "</label>" . $ele_delimeter ; - if (! empty($this->columns)) { + $ret .= $ele_extra . ' />' . "<label name='xolb_{$ele_name}' for='{$ele_id}{$id_ele}'>" . $name . "</label>" . $ele_delimeter; + if (!empty($this->columns)) { $ret .= '</td>'; - if (++ $i % $this->columns == 0) { + if (++$i % $this->columns == 0) { $ret .= '</tr>'; } } } - if (! empty($this->columns)) { + if (!empty($this->columns)) { if ($span = $i % $this->columns) { $ret .= '<td colspan="' . ($this->columns - $span) . '"></td></tr>'; } @@ -224,11 +188,13 @@ * Render custom javascript validation code * * @seealso XoopsForm::renderValidationJS + * + * @return string */ - function renderValidationJS() + public function renderValidationJS() { // render custom validation code if any - if (! empty($this->customValidationCode)) { + if (!empty($this->customValidationCode)) { return implode(NWLINE, $this->customValidationCode); // generate validation code if required } elseif ($this->isRequired()) { Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcolorpicker.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcolorpicker.php 2011-10-21 20:15:00 UTC (rev 7921) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formcolorpicker.php 2011-10-22 14:22:35 UTC (rev 7922) @@ -1,9 +1,9 @@ <?php /** - * XoopsFormColorPicker component class file - * + * XOOPS form element of colorpicker + * * You may not change or alter any portion of this comment or credits - * of supporting developers from this source code or any supporting source code + * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -11,44 +11,32 @@ * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel - * @subpackage form + * @package class + * @subpackage xoopsform * @since 2.0.0 * @author Zoullou <web...@zo...> + * @author John Neill <cat...@xo...> * @version $Id$ */ + defined('XOOPS_ROOT_PATH') or die('Restricted access'); -/** - * Color Selection Field - * - * @author Zoullou <web...@zo...> - * @author John Neill <cat...@xo...> - * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ - * @version $Id$ - * @package Kernel - * @access public - */ class XoopsFormColorPicker extends XoopsFormText { /** - * XoopsFormColorPicker::XoopsFormColorPicker() - * * @param mixed $caption * @param mixed $name * @param string $value */ - function XoopsFormColorPicker($caption, $name, $value = '#FFFFFF') + public function XoopsFormColorPicker($caption, $name, $value = '#FFFFFF') { - $this->XoopsFormText($caption, $name, 9, 7, $value); + parent::__construct($caption, $name, 9, 7, $value); } - + /** - * XoopsFormColorPicker::render() - * - * @return + * @return string */ - function render() + public function render() { if (isset($GLOBALS['xoTheme'])) { $GLOBALS['xoTheme']->addScript('include/color-picker.js'); @@ -56,20 +44,20 @@ echo '<script type="text/javascript" src="' . XOOPS_URL . '/include/color-picker.js"></script>'; } $this->setExtra(' style="background-color:' . $this->getValue() . ';"'); - return parent::render() . "<input type='reset' value=' ... ' onclick=\"return TCP.popup('" . XOOPS_URL . "/include/',document.getElementById('" . $this->getName() . "'));\">" ; + return parent::render() . "<input type='reset' value=' ... ' onclick=\"return TCP.popup('" . XOOPS_URL . "/include/',document.getElementById('" . $this->getName() . "'));\">" ; } - + /** * Returns custom validation Javascript * * @return string Element validation Javascript */ - function renderValidationJS() + public function renderValidationJS() { $eltname = $this->getName(); $eltcaption = $this->getCaption(); $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption); - + return "if ( !(new RegExp(\"^#[0-9a-fA-F]{6}\",\"i\").test(myform.{$eltname}.value)) ) { window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }"; } } Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formdatetime.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formdatetime.php 2011-10-21 20:15:00 UTC (rev 7921) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formdatetime.php 2011-10-22 14:22:35 UTC (rev 7922) @@ -9,44 +9,36 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel - * @subpackage form + * @package class + * @subpackage xoopsform * @since 2.0.0 * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ * @version $Id$ */ + defined('XOOPS_ROOT_PATH') or die('Restricted access'); -/** - * Date and time selection field - * - * @author Kazumi Ono <on...@xo...> - * @package kernel - * @subpackage form - * @access public - */ + class XoopsFormDateTime extends XoopsFormElementTray { /** - * XoopsFormDateTime::XoopsFormDateTime() - * * @param mixed $caption * @param mixed $name * @param integer $size * @param integer $value * @param mixed $showtime */ - function XoopsFormDateTime($caption, $name, $size = 15, $value = 0, $showtime = true) + public function __construct($caption, $name, $size = 15, $value = 0, $showtime = true) { - $this->XoopsFormElementTray($caption, ' '); + parent::__construct($caption, ' '); $value = intval($value); $value = ($value > 0) ? $value : time(); $datetime = getDate($value); $this->addElement(new XoopsFormTextDateSelect('', $name . '[date]', $size, $value, $showtime)); $timearray = array(); - for ($i = 0; $i < 24; $i ++) { + for ($i = 0; $i < 24; $i++) { for ($j = 0; $j < 60; $j = $j + 10) { $key = ($i * 3600) + ($j * 60); $timearray[$key] = ($j != 0) ? $i . ':' . $j : $i . ':0' . $j; Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formdhtmltextarea.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formdhtmltextarea.php 2011-10-21 20:15:00 UTC (rev 7921) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsform/formdhtmltextarea.php 2011-10-22 14:22:35 UTC (rev 7922) @@ -1,6 +1,6 @@ <?php /** - * Formatted textarea form + * XOOPS form element of dhtmltextarea * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code @@ -11,17 +11,17 @@ * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package kernel - * @subpackage form + * @package class + * @subpackage xoopsform * @since 2.0.0 * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ * @author Taiwen Jiang <ph...@us...> * @author Vinod <sma...@gm...> * @version $Id$ */ + defined('XOOPS_ROOT_PATH') or die('Restricted access'); - /** * A textarea with xoopsish formatting and smilie buttons * @@ -34,35 +34,56 @@ * <p>If an extended HTML editor is set, the renderer will be replaced by the specified editor, usually a visual or WYSIWYG editor.</p> * * <ul>Developer and user guide: - * <li><ul>For run-time settings per call - * <li>To use an editor pre-configured by {@link XoopsEditor}, e.g. 'fckeditor': <code>$options['editor'] = 'fckeditor';</code></li> - * <li>To use a custom editor, e.g. 'MyEditor' class located in "/modules/myeditor/myeditor.php": <code>$options['editor'] = array('MyEditor', XOOPS_ROOT_PATH . "/modules/myeditor/myeditor.php");</code></li> - * </ul></li> - * <li><ul>For pre-configured settings, which will force to use a editor if no specific editor is set for call - * <li><ul>Set up custom configs: in XOOPS_VAR_PATH . '/configs/xoopsconfig.php' set a editor as default, e.g. - * <li>a pre-configured editor 'fckeditor': <code>return array('editor' => 'fckeditor');</code></li> - * <li>a custom editor 'MyEditor' class located in "/modules/myeditor/myeditor.php": <code>return array('editor' => array('MyEditor', XOOPS_ROOT_PATH . "/modules/myeditor/myeditor.php");</code></li> - * </ul></li> - * <li>To disable the default editor, in XOOPS_VAR_PATH . '/configs/xoopsconfig.php': <code>return array();</code></li> - * <li>To disable the default editor for a specific call: <code>$options['editor'] = 'dhtmltextarea';</code></li> - * </ul></li> + * <li> + * <ul>For run-time settings per call + * <li>To use an editor pre-configured by {@link XoopsEditor}, e.g. 'fckeditor': <code>$options['editor'] = 'fckeditor';</code></li> + * <li>To use a custom editor, e.g. 'MyEditor' class located in "/modules/myeditor/myeditor.php": <code>$options['editor'] = array('MyEditor', XOOPS_ROOT_PATH . "/modules/myeditor/myeditor.php");</code></li> + * </ul> + * </li> + * <li> + * <ul>For pre-configured settings, which will force to use a editor if no specific editor is set for call + * <li> + * <ul>Set up custom configs: in XOOPS_VAR_PATH . '/configs/xoopsconfig.php' set a editor as default, e.g. + * <li>a pre-configured editor 'fckeditor': <code>return array('editor' => 'fckeditor');</code></li> + * <li>a custom editor 'MyEditor' class located in "/modules/myeditor/myeditor.php": <code>return array('editor' => array('MyEditor', XOOPS_ROOT_PATH . "/modules/myeditor/myeditor.php");</code></li> + * </ul> + * </li> + * <li>To disable the default editor, in XOOPS_VAR_PATH . '/configs/xoopsconfig.php': <code>return array();</code></li> + * <li>To disable the default editor for a specific call: <code>$options['editor'] = 'dhtmltextarea';</code></li> + * </ul> + * </li> * </ul> */ - var $htmlEditor = array(); + public $htmlEditor = array(); /** * Hidden text * * @var string - * @access private */ - var $_hiddenText; + private $_hiddenText; - var $skipPreview = false; - var $doHtml = false; - var $js = ''; + /** + * @var bool + */ + public $skipPreview = false; /** + * @var bool + */ + public $doHtml = false; + + /** + * @var string + */ + public $js = ''; + + /** + * @var array + */ + public $configs = array(); + + /** * Constructor * * @param string $caption Caption @@ -73,32 +94,33 @@ * @param string $hiddentext Identifier for hidden Text * @param array $options Extra options */ - function XoopsFormDhtmlTextArea($caption, $name, $value = "", $rows = 5, $cols = 50, $hiddentext = "xoopsHiddenText", $options = array()) + public function __construct($caption, $name, $value = "", $rows = 5, $cols = 50, $hiddentext = "xoopsHiddenText", $options = + array()) { - global $xoopsConfig; static $inLoop = 0; - $inLoop ++; + $inLoop++; // Second loop, invalid, return directly if ($inLoop > 2) { return; } // Else, initialize - $this->XoopsFormTextArea($caption, $name, $value, $rows, $cols); + parent::__construct($caption, $name, $value, $rows, $cols); $this->_hiddenText = $hiddentext; if ($inLoop > 1) { return; } if (!isset($options['editor'])) { - if (isset($xoopsConfig['editor'])) - $options['editor'] = $xoopsConfig['editor']; + if (isset($GLOBALS['SxoopsConfig']['editor'])) { + $options['editor'] = $GLOBALS['SxoopsConfig']['editor']; + } } - if (! empty($this->htmlEditor) || ! empty($options['editor'])) { + if (!empty($this->htmlEditor) || !empty($options['editor'])) { $options['name'] = $this->getName(); $options['value'] = $this->getValue(); - if (! empty($options['editor'])) { + if (!empty($options['editor'])) { $this->htmlEditor = is_array($options['editor']) ? $options['editor'] : array($options['editor']); } @@ -128,10 +150,10 @@ * * @return string HTML */ - function render() + public function render() { if ($this->htmlEditor && is_object($this->htmlEditor)) { - if (! isset($this->htmlEditor->isEnabled) || $this->htmlEditor->isEnabled) { + if (!isset($this->htmlEditor->isEnabled) || $this->htmlEditor->isEnabled) { return $this->htmlEditor->render(); } } @@ -147,21 +169,23 @@ $ret .= "<input type='button' onclick=\"XoopsCheckLength('" . $this->getName() . "', '" . @$this->configs['maxlength'] . "', '" . _XOOPS_FORM_ALT_LENGTH . "', '" . _XOOPS_FORM_ALT_LENGTH_MAX . "');\" value=' ? ' title='" . _XOOPS_FORM_ALT_CHECKLENGTH . "' />"; $ret .= "<br />\n"; // the textarea box - $ret .= "<textarea id='" . $this->getName() . "' name='" . $this->getName() . "' title='". $this->getTitle() . "' onselect=\"xoopsSavePosition('" . $this->getName() . "');\" onclick=\"xoopsSavePosition('" . $this->getName() . "');\" onkeyup=\"xoopsSavePosition('" . $this->getName() . "');\" cols='" . $this->getCols() . "' rows='" . $this->getRows() . "'" . $this->getExtra() . ">" . $this->getValue() . "</textarea><br />\n"; + $ret .= "<textarea id='" . $this->getName() . "' name='" . $this->getName() . "' title='" . $this->getTitle() . "' onselect=\"xoopsSavePosition('" . $this->getName() . "');\" onclick=\"xoopsSavePosition('" . $this->getName() . "');\" onkeyup=\"xoopsSavePosition('" . $this->getName() . "');\" cols='" . $this->getCols() . "' rows='" . $this->getRows() . "'" . $this->getExtra() . ">" . $this->getValue() . "</textarea><br />\n"; if (empty($this->skipPreview)) { if (empty($GLOBALS['xoTheme'])) { $this->js .= implode("", file(XOOPS_ROOT_PATH . "/class/textsanitizer/image/image.js")); } else { - $GLOBALS['xoTheme']->addScript('/class/textsanitizer/image/image.js', array('type' => 'text/javascript')); + $GLOBALS['xoTheme']->addScript('/class/textsanitizer/image/image.js', + array('type' => 'text/javascript')); } - $button = // "<br />" . -"<input " . " id='" . $this->getName() . "_preview_button'" . " type='button' " . " value='" . _PREVIEW . "' " . " onclick=\"form_instantPreview('" . XOOPS_URL . "', '" . $this->getName() . "','" . XOOPS_URL . "/images', " . intval($this->doHtml) . ", '" . $GLOBALS['xoopsSecurity']->createToken() . "')\"" . " />"; - $ret .= "<br />" . "<div id='" . $this->getName() . "_hidden' style='display: block;'> " . " <fieldset>" . " <legend>" . $button . "</legend>" . " <div id='" . $this->getName() . "_hidden_data'>" . _XOOPS_FORM_PREVIEW_CONTENT . "</div>" . " </fieldset>" . "</div>"; + $button = "<input id='" . $this->getName() . "_preview_button' " . "type='button' " . "value='" . _PREVIEW . "' " . "onclick=\"form_instantPreview('" . XOOPS_URL . "', '" . $this->getName() . "','" . XOOPS_URL . "/images', " . intval($this->doHtml) . ", '" . $GLOBALS['xoopsSecurity']->createToken() . "')\"" . " />"; + $ret .= "<br />" . "<div id='" . $this->getName() . "_hidden' style='display: block;'> " . "<fieldset>"... [truncated message content] |