@@ -11,36 +11,36 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class SmartFormUserElement extends XoopsFormSelect |
| 13 | 13 | { |
| 14 | - public $multiple = false; |
|
| 14 | + public $multiple = false; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * SmartFormUserElement constructor. |
|
| 18 | - * @param string $object |
|
| 19 | - * @param string $key |
|
| 20 | - */ |
|
| 21 | - public function __construct($object, $key) |
|
| 22 | - { |
|
| 23 | - $var = $object->vars[$key]; |
|
| 24 | - $size = isset($var['size']) ? $var['size'] : ($this->multiple ? 5 : 1); |
|
| 16 | + /** |
|
| 17 | + * SmartFormUserElement constructor. |
|
| 18 | + * @param string $object |
|
| 19 | + * @param string $key |
|
| 20 | + */ |
|
| 21 | + public function __construct($object, $key) |
|
| 22 | + { |
|
| 23 | + $var = $object->vars[$key]; |
|
| 24 | + $size = isset($var['size']) ? $var['size'] : ($this->multiple ? 5 : 1); |
|
| 25 | 25 | |
| 26 | - parent::__construct($var['form_caption'], $key, $object->getVar($key, 'e'), $size, $this->multiple); |
|
| 26 | + parent::__construct($var['form_caption'], $key, $object->getVar($key, 'e'), $size, $this->multiple); |
|
| 27 | 27 | |
| 28 | - // Adding the options inside this SelectBox |
|
| 29 | - // If the custom method is not from a module, than it's from the core |
|
| 30 | - $control = $object->getControl($key); |
|
| 28 | + // Adding the options inside this SelectBox |
|
| 29 | + // If the custom method is not from a module, than it's from the core |
|
| 30 | + $control = $object->getControl($key); |
|
| 31 | 31 | |
| 32 | - global $xoopsDB; |
|
| 33 | - $ret = array(); |
|
| 34 | - $limit = $start = 0; |
|
| 35 | - $sql = 'SELECT uid, uname FROM ' . $xoopsDB->prefix('users'); |
|
| 36 | - $sql .= ' ORDER BY uname ASC'; |
|
| 32 | + global $xoopsDB; |
|
| 33 | + $ret = array(); |
|
| 34 | + $limit = $start = 0; |
|
| 35 | + $sql = 'SELECT uid, uname FROM ' . $xoopsDB->prefix('users'); |
|
| 36 | + $sql .= ' ORDER BY uname ASC'; |
|
| 37 | 37 | |
| 38 | - $result = $xoopsDB->query($sql); |
|
| 39 | - if ($result) { |
|
| 40 | - while ($myrow = $xoopsDB->fetchArray($result)) { |
|
| 41 | - $uArray[$myrow['uid']] = $myrow['uname']; |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - $this->addOptionArray($uArray); |
|
| 45 | - } |
|
| 38 | + $result = $xoopsDB->query($sql); |
|
| 39 | + if ($result) { |
|
| 40 | + while ($myrow = $xoopsDB->fetchArray($result)) { |
|
| 41 | + $uArray[$myrow['uid']] = $myrow['uname']; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + $this->addOptionArray($uArray); |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | global $xoopsDB; |
| 33 | 33 | $ret = array(); |
| 34 | 34 | $limit = $start = 0; |
| 35 | - $sql = 'SELECT uid, uname FROM ' . $xoopsDB->prefix('users'); |
|
| 35 | + $sql = 'SELECT uid, uname FROM '.$xoopsDB->prefix('users'); |
|
| 36 | 36 | $sql .= ' ORDER BY uname ASC'; |
| 37 | 37 | |
| 38 | 38 | $result = $xoopsDB->query($sql); |
@@ -11,25 +11,25 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class SmartFormUploadElement extends XoopsFormFile |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * @param $object |
|
| 16 | - * @param $key |
|
| 17 | - */ |
|
| 18 | - public function SmartFormFileElement($object, $key) |
|
| 19 | - { |
|
| 20 | - parent::__construct(_CO_SOBJECT_UPLOAD, $key, isset($object->vars[$key]['form_maxfilesize']) ? $object->vars[$key]['form_maxfilesize'] : 0); |
|
| 21 | - $this->setExtra(' size=50'); |
|
| 22 | - } |
|
| 14 | + /** |
|
| 15 | + * @param $object |
|
| 16 | + * @param $key |
|
| 17 | + */ |
|
| 18 | + public function SmartFormFileElement($object, $key) |
|
| 19 | + { |
|
| 20 | + parent::__construct(_CO_SOBJECT_UPLOAD, $key, isset($object->vars[$key]['form_maxfilesize']) ? $object->vars[$key]['form_maxfilesize'] : 0); |
|
| 21 | + $this->setExtra(' size=50'); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * prepare HTML for output |
|
| 26 | - * |
|
| 27 | - * @return string HTML |
|
| 28 | - */ |
|
| 29 | - public function render() |
|
| 30 | - { |
|
| 31 | - return "<input type='hidden' name='MAX_FILE_SIZE' value='" . $this->getMaxFileSize() . "'> |
|
| 24 | + /** |
|
| 25 | + * prepare HTML for output |
|
| 26 | + * |
|
| 27 | + * @return string HTML |
|
| 28 | + */ |
|
| 29 | + public function render() |
|
| 30 | + { |
|
| 31 | + return "<input type='hidden' name='MAX_FILE_SIZE' value='" . $this->getMaxFileSize() . "'> |
|
| 32 | 32 | <input type='file' name='" . $this->getName() . "' id='" . $this->getName() . "'" . $this->getExtra() . "> |
| 33 | 33 | <input type='hidden' name='smart_upload_file[]' id='smart_upload_file[]' value='" . $this->getName() . "'>"; |
| 34 | - } |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -28,8 +28,8 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | public function render() |
| 30 | 30 | { |
| 31 | - return "<input type='hidden' name='MAX_FILE_SIZE' value='" . $this->getMaxFileSize() . "'> |
|
| 32 | - <input type='file' name='" . $this->getName() . "' id='" . $this->getName() . "'" . $this->getExtra() . "> |
|
| 33 | - <input type='hidden' name='smart_upload_file[]' id='smart_upload_file[]' value='" . $this->getName() . "'>"; |
|
| 31 | + return "<input type='hidden' name='MAX_FILE_SIZE' value='".$this->getMaxFileSize()."'> |
|
| 32 | + <input type='file' name='" . $this->getName()."' id='".$this->getName()."'".$this->getExtra()."> |
|
| 33 | + <input type='hidden' name='smart_upload_file[]' id='smart_upload_file[]' value='" . $this->getName()."'>"; |
|
| 34 | 34 | } |
| 35 | 35 | } |
@@ -5,38 +5,38 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class SmartFormFileElement extends XoopsFormFile |
| 7 | 7 | { |
| 8 | - public $object; |
|
| 9 | - public $key; |
|
| 8 | + public $object; |
|
| 9 | + public $key; |
|
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * SmartFormFileElement constructor. |
|
| 13 | - * @param string $object |
|
| 14 | - * @param string $key |
|
| 15 | - */ |
|
| 16 | - public function __construct($object, $key) |
|
| 17 | - { |
|
| 18 | - $this->object = $object; |
|
| 19 | - $this->key = $key; |
|
| 20 | - parent::__construct($object->vars[$key]['form_caption'], $key, isset($object->vars[$key]['form_maxfilesize']) ? $object->vars[$key]['form_maxfilesize'] : 0); |
|
| 21 | - $this->setExtra(' size=50'); |
|
| 22 | - } |
|
| 11 | + /** |
|
| 12 | + * SmartFormFileElement constructor. |
|
| 13 | + * @param string $object |
|
| 14 | + * @param string $key |
|
| 15 | + */ |
|
| 16 | + public function __construct($object, $key) |
|
| 17 | + { |
|
| 18 | + $this->object = $object; |
|
| 19 | + $this->key = $key; |
|
| 20 | + parent::__construct($object->vars[$key]['form_caption'], $key, isset($object->vars[$key]['form_maxfilesize']) ? $object->vars[$key]['form_maxfilesize'] : 0); |
|
| 21 | + $this->setExtra(' size=50'); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * prepare HTML for output |
|
| 26 | - * |
|
| 27 | - * @return string HTML |
|
| 28 | - */ |
|
| 29 | - public function render() |
|
| 30 | - { |
|
| 31 | - $ret = ''; |
|
| 32 | - if ($this->object->getVar($this->key) !== '') { |
|
| 33 | - $ret .= '<div>' . _CO_SOBJECT_CURRENT_FILE . $this->object->getVar($this->key) . '</div>'; |
|
| 34 | - } |
|
| 24 | + /** |
|
| 25 | + * prepare HTML for output |
|
| 26 | + * |
|
| 27 | + * @return string HTML |
|
| 28 | + */ |
|
| 29 | + public function render() |
|
| 30 | + { |
|
| 31 | + $ret = ''; |
|
| 32 | + if ($this->object->getVar($this->key) !== '') { |
|
| 33 | + $ret .= '<div>' . _CO_SOBJECT_CURRENT_FILE . $this->object->getVar($this->key) . '</div>'; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - $ret .= "<div><input type='hidden' name='MAX_FILE_SIZE' value='" . $this->getMaxFileSize() . "'> |
|
| 36 | + $ret .= "<div><input type='hidden' name='MAX_FILE_SIZE' value='" . $this->getMaxFileSize() . "'> |
|
| 37 | 37 | <input type='file' name='" . $this->getName() . "' id='" . $this->getName() . "'" . $this->getExtra() . "> |
| 38 | 38 | <input type='hidden' name='smart_upload_file[]' id='smart_upload_file[]' value='" . $this->getName() . "'></div>"; |
| 39 | 39 | |
| 40 | - return $ret; |
|
| 41 | - } |
|
| 40 | + return $ret; |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -30,12 +30,12 @@ |
||
| 30 | 30 | { |
| 31 | 31 | $ret = ''; |
| 32 | 32 | if ($this->object->getVar($this->key) !== '') { |
| 33 | - $ret .= '<div>' . _CO_SOBJECT_CURRENT_FILE . $this->object->getVar($this->key) . '</div>'; |
|
| 33 | + $ret .= '<div>'._CO_SOBJECT_CURRENT_FILE.$this->object->getVar($this->key).'</div>'; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $ret .= "<div><input type='hidden' name='MAX_FILE_SIZE' value='" . $this->getMaxFileSize() . "'> |
|
| 37 | - <input type='file' name='" . $this->getName() . "' id='" . $this->getName() . "'" . $this->getExtra() . "> |
|
| 38 | - <input type='hidden' name='smart_upload_file[]' id='smart_upload_file[]' value='" . $this->getName() . "'></div>"; |
|
| 36 | + $ret .= "<div><input type='hidden' name='MAX_FILE_SIZE' value='".$this->getMaxFileSize()."'> |
|
| 37 | + <input type='file' name='" . $this->getName()."' id='".$this->getName()."'".$this->getExtra()."> |
|
| 38 | + <input type='hidden' name='smart_upload_file[]' id='smart_upload_file[]' value='" . $this->getName()."'></div>"; |
|
| 39 | 39 | |
| 40 | 40 | return $ret; |
| 41 | 41 | } |
@@ -11,59 +11,59 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class SmartFormSelectElement extends XoopsFormSelect |
| 13 | 13 | { |
| 14 | - public $multiple = false; |
|
| 14 | + public $multiple = false; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * SmartFormSelectElement constructor. |
|
| 18 | - * @param string $object |
|
| 19 | - * @param string $key |
|
| 20 | - */ |
|
| 21 | - public function __construct($object, $key) |
|
| 22 | - { |
|
| 23 | - $var = $object->vars[$key]; |
|
| 24 | - $size = isset($var['size']) ? $var['size'] : ($this->multiple ? 5 : 1); |
|
| 16 | + /** |
|
| 17 | + * SmartFormSelectElement constructor. |
|
| 18 | + * @param string $object |
|
| 19 | + * @param string $key |
|
| 20 | + */ |
|
| 21 | + public function __construct($object, $key) |
|
| 22 | + { |
|
| 23 | + $var = $object->vars[$key]; |
|
| 24 | + $size = isset($var['size']) ? $var['size'] : ($this->multiple ? 5 : 1); |
|
| 25 | 25 | |
| 26 | - // Adding the options inside this SelectBox |
|
| 27 | - // If the custom method is not from a module, than it's from the core |
|
| 28 | - $control = $object->getControl($key); |
|
| 26 | + // Adding the options inside this SelectBox |
|
| 27 | + // If the custom method is not from a module, than it's from the core |
|
| 28 | + $control = $object->getControl($key); |
|
| 29 | 29 | |
| 30 | - $value = isset($control['value']) ? $control['value'] : $object->getVar($key, 'e'); |
|
| 30 | + $value = isset($control['value']) ? $control['value'] : $object->getVar($key, 'e'); |
|
| 31 | 31 | |
| 32 | - parent::__construct($var['form_caption'], $key, $value, $size, $this->multiple); |
|
| 32 | + parent::__construct($var['form_caption'], $key, $value, $size, $this->multiple); |
|
| 33 | 33 | |
| 34 | - if (isset($control['options'])) { |
|
| 35 | - $this->addOptionArray($control['options']); |
|
| 36 | - } else { |
|
| 37 | - // let's find if the method we need to call comes from an already defined object |
|
| 38 | - if (isset($control['object'])) { |
|
| 39 | - if (method_exists($control['object'], $control['method'])) { |
|
| 40 | - if ($option_array = $control['object']->{$control['method']}()) { |
|
| 41 | - // Adding the options array to the XoopsFormSelect |
|
| 42 | - $this->addOptionArray($option_array); |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - } else { |
|
| 46 | - // finding the itemHandler; if none, let's take the itemHandler of the $object |
|
| 47 | - if (isset($control['itemHandler'])) { |
|
| 48 | - if (!$control['module']) { |
|
| 49 | - // Creating the specified core object handler |
|
| 50 | - $controlHandler = xoops_getHandler($control['itemHandler']); |
|
| 51 | - } else { |
|
| 52 | - $controlHandler = xoops_getModuleHandler($control['itemHandler'], $control['module']); |
|
| 53 | - } |
|
| 54 | - } else { |
|
| 55 | - $controlHandler = $object->handler; |
|
| 56 | - } |
|
| 34 | + if (isset($control['options'])) { |
|
| 35 | + $this->addOptionArray($control['options']); |
|
| 36 | + } else { |
|
| 37 | + // let's find if the method we need to call comes from an already defined object |
|
| 38 | + if (isset($control['object'])) { |
|
| 39 | + if (method_exists($control['object'], $control['method'])) { |
|
| 40 | + if ($option_array = $control['object']->{$control['method']}()) { |
|
| 41 | + // Adding the options array to the XoopsFormSelect |
|
| 42 | + $this->addOptionArray($option_array); |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + } else { |
|
| 46 | + // finding the itemHandler; if none, let's take the itemHandler of the $object |
|
| 47 | + if (isset($control['itemHandler'])) { |
|
| 48 | + if (!$control['module']) { |
|
| 49 | + // Creating the specified core object handler |
|
| 50 | + $controlHandler = xoops_getHandler($control['itemHandler']); |
|
| 51 | + } else { |
|
| 52 | + $controlHandler = xoops_getModuleHandler($control['itemHandler'], $control['module']); |
|
| 53 | + } |
|
| 54 | + } else { |
|
| 55 | + $controlHandler = $object->handler; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - // Checking if the specified method exists |
|
| 59 | - if (method_exists($controlHandler, $control['method'])) { |
|
| 60 | - // TODO: How could I pass the parameters in the following call ... |
|
| 61 | - if ($option_array = $controlHandler->{$control['method']}()) { |
|
| 62 | - // Adding the options array to the XoopsFormSelect |
|
| 63 | - $this->addOptionArray($option_array); |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - } |
|
| 58 | + // Checking if the specified method exists |
|
| 59 | + if (method_exists($controlHandler, $control['method'])) { |
|
| 60 | + // TODO: How could I pass the parameters in the following call ... |
|
| 61 | + if ($option_array = $controlHandler->{$control['method']}()) { |
|
| 62 | + // Adding the options array to the XoopsFormSelect |
|
| 63 | + $this->addOptionArray($option_array); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -11,39 +11,39 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class SmartFormImageElement extends XoopsFormElementTray |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * SmartFormImageElement constructor. |
|
| 16 | - * @param string $object |
|
| 17 | - * @param string $key |
|
| 18 | - */ |
|
| 19 | - public function __construct($object, $key) |
|
| 20 | - { |
|
| 21 | - $var = $object->vars[$key]; |
|
| 22 | - $object_imageurl = $object->getImageDir(); |
|
| 23 | - parent::__construct($var['form_caption'], ' '); |
|
| 14 | + /** |
|
| 15 | + * SmartFormImageElement constructor. |
|
| 16 | + * @param string $object |
|
| 17 | + * @param string $key |
|
| 18 | + */ |
|
| 19 | + public function __construct($object, $key) |
|
| 20 | + { |
|
| 21 | + $var = $object->vars[$key]; |
|
| 22 | + $object_imageurl = $object->getImageDir(); |
|
| 23 | + parent::__construct($var['form_caption'], ' '); |
|
| 24 | 24 | |
| 25 | - $objectArray['image'] = str_replace('{XOOPS_URL}', XOOPS_URL, $objectArray['image']); |
|
| 25 | + $objectArray['image'] = str_replace('{XOOPS_URL}', XOOPS_URL, $objectArray['image']); |
|
| 26 | 26 | |
| 27 | - if ($object->getVar($key) !== '' |
|
| 28 | - && (0 === strpos($object->getVar($key), 'http') |
|
| 29 | - || 0 === strpos($object->getVar($key), '{XOOPS_URL}'))) { |
|
| 30 | - $this->addElement(new XoopsFormLabel('', "<img src='" . str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar($key)) . "' alt=''><br><br>")); |
|
| 31 | - } elseif ($object->getVar($key) !== '') { |
|
| 32 | - $this->addElement(new XoopsFormLabel('', "<img src='" . $object_imageurl . $object->getVar($key) . "' alt=''><br><br>")); |
|
| 33 | - } |
|
| 27 | + if ($object->getVar($key) !== '' |
|
| 28 | + && (0 === strpos($object->getVar($key), 'http') |
|
| 29 | + || 0 === strpos($object->getVar($key), '{XOOPS_URL}'))) { |
|
| 30 | + $this->addElement(new XoopsFormLabel('', "<img src='" . str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar($key)) . "' alt=''><br><br>")); |
|
| 31 | + } elseif ($object->getVar($key) !== '') { |
|
| 32 | + $this->addElement(new XoopsFormLabel('', "<img src='" . $object_imageurl . $object->getVar($key) . "' alt=''><br><br>")); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformfileuploadelement.php'; |
|
| 36 | - $this->addElement(new SmartFormFileUploadElement($object, $key)); |
|
| 35 | + require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformfileuploadelement.php'; |
|
| 36 | + $this->addElement(new SmartFormFileUploadElement($object, $key)); |
|
| 37 | 37 | |
| 38 | - $this->addElement(new XoopsFormLabel('<div style="height: 10px; padding-top: 8px; font-size: 80%;">' . _CO_SOBJECT_URL_FILE_DSC . '</div>', '')); |
|
| 39 | - require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformtextelement.php'; |
|
| 40 | - require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php'; |
|
| 38 | + $this->addElement(new XoopsFormLabel('<div style="height: 10px; padding-top: 8px; font-size: 80%;">' . _CO_SOBJECT_URL_FILE_DSC . '</div>', '')); |
|
| 39 | + require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformtextelement.php'; |
|
| 40 | + require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php'; |
|
| 41 | 41 | |
| 42 | - $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URL_FILE)); |
|
| 43 | - $this->addElement(new SmartFormTextElement($object, 'url_' . $key)); |
|
| 44 | - $this->addElement(new XoopsFormLabel('', '<br><br>')); |
|
| 45 | - $delete_check = new SmartFormCheckElement('', 'delete_' . $key); |
|
| 46 | - $delete_check->addOption(1, '<span style="color:red;">' . _CO_SOBJECT_DELETE . '</span>'); |
|
| 47 | - $this->addElement($delete_check); |
|
| 48 | - } |
|
| 42 | + $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URL_FILE)); |
|
| 43 | + $this->addElement(new SmartFormTextElement($object, 'url_' . $key)); |
|
| 44 | + $this->addElement(new XoopsFormLabel('', '<br><br>')); |
|
| 45 | + $delete_check = new SmartFormCheckElement('', 'delete_' . $key); |
|
| 46 | + $delete_check->addOption(1, '<span style="color:red;">' . _CO_SOBJECT_DELETE . '</span>'); |
|
| 47 | + $this->addElement($delete_check); |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -27,23 +27,23 @@ |
||
| 27 | 27 | if ($object->getVar($key) !== '' |
| 28 | 28 | && (0 === strpos($object->getVar($key), 'http') |
| 29 | 29 | || 0 === strpos($object->getVar($key), '{XOOPS_URL}'))) { |
| 30 | - $this->addElement(new XoopsFormLabel('', "<img src='" . str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar($key)) . "' alt=''><br><br>")); |
|
| 30 | + $this->addElement(new XoopsFormLabel('', "<img src='".str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar($key))."' alt=''><br><br>")); |
|
| 31 | 31 | } elseif ($object->getVar($key) !== '') { |
| 32 | - $this->addElement(new XoopsFormLabel('', "<img src='" . $object_imageurl . $object->getVar($key) . "' alt=''><br><br>")); |
|
| 32 | + $this->addElement(new XoopsFormLabel('', "<img src='".$object_imageurl.$object->getVar($key)."' alt=''><br><br>")); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformfileuploadelement.php'; |
|
| 35 | + require_once SMARTOBJECT_ROOT_PATH.'class/form/elements/smartformfileuploadelement.php'; |
|
| 36 | 36 | $this->addElement(new SmartFormFileUploadElement($object, $key)); |
| 37 | 37 | |
| 38 | - $this->addElement(new XoopsFormLabel('<div style="height: 10px; padding-top: 8px; font-size: 80%;">' . _CO_SOBJECT_URL_FILE_DSC . '</div>', '')); |
|
| 39 | - require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformtextelement.php'; |
|
| 40 | - require_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php'; |
|
| 38 | + $this->addElement(new XoopsFormLabel('<div style="height: 10px; padding-top: 8px; font-size: 80%;">'._CO_SOBJECT_URL_FILE_DSC.'</div>', '')); |
|
| 39 | + require_once SMARTOBJECT_ROOT_PATH.'class/form/elements/smartformtextelement.php'; |
|
| 40 | + require_once SMARTOBJECT_ROOT_PATH.'class/form/elements/smartformcheckelement.php'; |
|
| 41 | 41 | |
| 42 | - $this->addElement(new XoopsFormLabel('', '<br>' . _CO_SOBJECT_URL_FILE)); |
|
| 43 | - $this->addElement(new SmartFormTextElement($object, 'url_' . $key)); |
|
| 42 | + $this->addElement(new XoopsFormLabel('', '<br>'._CO_SOBJECT_URL_FILE)); |
|
| 43 | + $this->addElement(new SmartFormTextElement($object, 'url_'.$key)); |
|
| 44 | 44 | $this->addElement(new XoopsFormLabel('', '<br><br>')); |
| 45 | - $delete_check = new SmartFormCheckElement('', 'delete_' . $key); |
|
| 46 | - $delete_check->addOption(1, '<span style="color:red;">' . _CO_SOBJECT_DELETE . '</span>'); |
|
| 45 | + $delete_check = new SmartFormCheckElement('', 'delete_'.$key); |
|
| 46 | + $delete_check->addOption(1, '<span style="color:red;">'._CO_SOBJECT_DELETE.'</span>'); |
|
| 47 | 47 | $this->addElement($delete_check); |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -7,41 +7,41 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | class SmartFormCheckElement extends XoopsFormCheckBox |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * |
|
| 12 | - * /** |
|
| 13 | - * prepare HTML for output |
|
| 14 | - * |
|
| 15 | - * @return string |
|
| 16 | - */ |
|
| 17 | - public function render() |
|
| 18 | - { |
|
| 19 | - $ret = ''; |
|
| 20 | - if (count($this->getOptions()) > 1 && substr($this->getName(), -2, 2) !== '[]') { |
|
| 21 | - $newname = $this->getName() . '[]'; |
|
| 22 | - $this->setName($newname); |
|
| 23 | - } |
|
| 24 | - foreach ($this->getOptions() as $value => $name) { |
|
| 25 | - $ret .= "<input type='checkbox' name='" . $this->getName() . "' value='" . $value . "'"; |
|
| 26 | - if (count($this->getValue()) > 0 && in_array($value, $this->getValue())) { |
|
| 27 | - $ret .= ' checked'; |
|
| 28 | - } |
|
| 29 | - $ret .= $this->getExtra() . '>' . $name . '<br>'; |
|
| 30 | - } |
|
| 10 | + /** |
|
| 11 | + * |
|
| 12 | + * /** |
|
| 13 | + * prepare HTML for output |
|
| 14 | + * |
|
| 15 | + * @return string |
|
| 16 | + */ |
|
| 17 | + public function render() |
|
| 18 | + { |
|
| 19 | + $ret = ''; |
|
| 20 | + if (count($this->getOptions()) > 1 && substr($this->getName(), -2, 2) !== '[]') { |
|
| 21 | + $newname = $this->getName() . '[]'; |
|
| 22 | + $this->setName($newname); |
|
| 23 | + } |
|
| 24 | + foreach ($this->getOptions() as $value => $name) { |
|
| 25 | + $ret .= "<input type='checkbox' name='" . $this->getName() . "' value='" . $value . "'"; |
|
| 26 | + if (count($this->getValue()) > 0 && in_array($value, $this->getValue())) { |
|
| 27 | + $ret .= ' checked'; |
|
| 28 | + } |
|
| 29 | + $ret .= $this->getExtra() . '>' . $name . '<br>'; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - return $ret; |
|
| 33 | - } |
|
| 32 | + return $ret; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @return string |
|
| 37 | - */ |
|
| 38 | - public function renderValidationJS() |
|
| 39 | - { |
|
| 40 | - $js .= 'var hasSelections = false;'; |
|
| 41 | - //sometimes, there is an implicit '[]', sometimes not |
|
| 42 | - $eltname = $this->getName(); |
|
| 43 | - if (strpos($eltname, '[') === false) { |
|
| 44 | - $js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) { |
|
| 35 | + /** |
|
| 36 | + * @return string |
|
| 37 | + */ |
|
| 38 | + public function renderValidationJS() |
|
| 39 | + { |
|
| 40 | + $js .= 'var hasSelections = false;'; |
|
| 41 | + //sometimes, there is an implicit '[]', sometimes not |
|
| 42 | + $eltname = $this->getName(); |
|
| 43 | + if (strpos($eltname, '[') === false) { |
|
| 44 | + $js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) { |
|
| 45 | 45 | if (myform['{$eltname}[]'][i].checked) { |
| 46 | 46 | hasSelections = true; |
| 47 | 47 | } |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | if (hasSelections === false) { |
| 51 | 51 | window.alert(\"{$eltmsg}\"); myform['{$eltname}[]'][0].focus(); return false; }\n"; |
| 52 | - } else { |
|
| 53 | - $js .= "for (var i = 0; i < myform['" . $eltname . "'].length; i++) { |
|
| 52 | + } else { |
|
| 53 | + $js .= "for (var i = 0; i < myform['" . $eltname . "'].length; i++) { |
|
| 54 | 54 | if (myform['{$eltname}'][i].checked) { |
| 55 | 55 | hasSelections = true; |
| 56 | 56 | } |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | if (hasSelections === false) { |
| 60 | 60 | window.alert(\"{$eltmsg}\"); myform['{$eltname}'][0].focus(); return false; }\n"; |
| 61 | - } |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return $js; |
|
| 64 | - } |
|
| 63 | + return $js; |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -18,15 +18,15 @@ discard block |
||
| 18 | 18 | { |
| 19 | 19 | $ret = ''; |
| 20 | 20 | if (count($this->getOptions()) > 1 && substr($this->getName(), -2, 2) !== '[]') { |
| 21 | - $newname = $this->getName() . '[]'; |
|
| 21 | + $newname = $this->getName().'[]'; |
|
| 22 | 22 | $this->setName($newname); |
| 23 | 23 | } |
| 24 | 24 | foreach ($this->getOptions() as $value => $name) { |
| 25 | - $ret .= "<input type='checkbox' name='" . $this->getName() . "' value='" . $value . "'"; |
|
| 25 | + $ret .= "<input type='checkbox' name='".$this->getName()."' value='".$value."'"; |
|
| 26 | 26 | if (count($this->getValue()) > 0 && in_array($value, $this->getValue())) { |
| 27 | 27 | $ret .= ' checked'; |
| 28 | 28 | } |
| 29 | - $ret .= $this->getExtra() . '>' . $name . '<br>'; |
|
| 29 | + $ret .= $this->getExtra().'>'.$name.'<br>'; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | return $ret; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | if (hasSelections === false) { |
| 51 | 51 | window.alert(\"{$eltmsg}\"); myform['{$eltname}[]'][0].focus(); return false; }\n"; |
| 52 | 52 | } else { |
| 53 | - $js .= "for (var i = 0; i < myform['" . $eltname . "'].length; i++) { |
|
| 53 | + $js .= "for (var i = 0; i < myform['".$eltname."'].length; i++) { |
|
| 54 | 54 | if (myform['{$eltname}'][i].checked) { |
| 55 | 55 | hasSelections = true; |
| 56 | 56 | } |
@@ -11,59 +11,59 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class SmartFormParentCategoryElement extends XoopsFormSelect |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * SmartFormParentcategoryElement constructor. |
|
| 16 | - * @param string $object |
|
| 17 | - * @param string $key |
|
| 18 | - */ |
|
| 19 | - public function __construct($object, $key) |
|
| 20 | - { |
|
| 21 | - $addNoParent = isset($object->controls[$key]['addNoParent']) ? $object->controls[$key]['addNoParent'] : true; |
|
| 22 | - $criteria = new CriteriaCompo(); |
|
| 23 | - $criteria->setSort('weight, name'); |
|
| 24 | - $categoryHandler = xoops_getModuleHandler('category', $object->handler->_moduleName); |
|
| 25 | - $categories = $categoryHandler->getObjects($criteria); |
|
| 14 | + /** |
|
| 15 | + * SmartFormParentcategoryElement constructor. |
|
| 16 | + * @param string $object |
|
| 17 | + * @param string $key |
|
| 18 | + */ |
|
| 19 | + public function __construct($object, $key) |
|
| 20 | + { |
|
| 21 | + $addNoParent = isset($object->controls[$key]['addNoParent']) ? $object->controls[$key]['addNoParent'] : true; |
|
| 22 | + $criteria = new CriteriaCompo(); |
|
| 23 | + $criteria->setSort('weight, name'); |
|
| 24 | + $categoryHandler = xoops_getModuleHandler('category', $object->handler->_moduleName); |
|
| 25 | + $categories = $categoryHandler->getObjects($criteria); |
|
| 26 | 26 | |
| 27 | - require_once XOOPS_ROOT_PATH . '/class/tree.php'; |
|
| 28 | - $mytree = new XoopsObjectTree($categories, 'categoryid', 'parentid'); |
|
| 29 | - parent::__construct($object->vars[$key]['form_caption'], $key, $object->getVar($key, 'e')); |
|
| 27 | + require_once XOOPS_ROOT_PATH . '/class/tree.php'; |
|
| 28 | + $mytree = new XoopsObjectTree($categories, 'categoryid', 'parentid'); |
|
| 29 | + parent::__construct($object->vars[$key]['form_caption'], $key, $object->getVar($key, 'e')); |
|
| 30 | 30 | |
| 31 | - $ret = array(); |
|
| 32 | - $options = $this->getOptionArray($mytree, 'name', 0, '', $ret); |
|
| 33 | - if ($addNoParent) { |
|
| 34 | - $newOptions = array('0' => '----'); |
|
| 35 | - foreach ($options as $k => $v) { |
|
| 36 | - $newOptions[$k] = $v; |
|
| 37 | - } |
|
| 38 | - $options = $newOptions; |
|
| 39 | - } |
|
| 40 | - $this->addOptionArray($options); |
|
| 41 | - } |
|
| 31 | + $ret = array(); |
|
| 32 | + $options = $this->getOptionArray($mytree, 'name', 0, '', $ret); |
|
| 33 | + if ($addNoParent) { |
|
| 34 | + $newOptions = array('0' => '----'); |
|
| 35 | + foreach ($options as $k => $v) { |
|
| 36 | + $newOptions[$k] = $v; |
|
| 37 | + } |
|
| 38 | + $options = $newOptions; |
|
| 39 | + } |
|
| 40 | + $this->addOptionArray($options); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Get options for a category select with hierarchy (recursive) |
|
| 45 | - * |
|
| 46 | - * @param XoopsObjectTree $tree |
|
| 47 | - * @param string $fieldName |
|
| 48 | - * @param int $key |
|
| 49 | - * @param string $prefix_curr |
|
| 50 | - * @param array $ret |
|
| 51 | - * |
|
| 52 | - * @return array |
|
| 53 | - */ |
|
| 54 | - public function getOptionArray($tree, $fieldName, $key, $prefix_curr = '', &$ret) |
|
| 55 | - { |
|
| 56 | - if ($key > 0) { |
|
| 57 | - $value = $tree->tree[$key]['obj']->getVar($tree->_myId); |
|
| 58 | - $ret[$key] = $prefix_curr . $tree->tree[$key]['obj']->getVar($fieldName); |
|
| 59 | - $prefix_curr .= '-'; |
|
| 60 | - } |
|
| 61 | - if (isset($tree->tree[$key]['child']) && !empty($tree->tree[$key]['child'])) { |
|
| 62 | - foreach ($tree->tree[$key]['child'] as $childkey) { |
|
| 63 | - $this->getOptionArray($tree, $fieldName, $childkey, $prefix_curr, $ret); |
|
| 64 | - } |
|
| 65 | - } |
|
| 43 | + /** |
|
| 44 | + * Get options for a category select with hierarchy (recursive) |
|
| 45 | + * |
|
| 46 | + * @param XoopsObjectTree $tree |
|
| 47 | + * @param string $fieldName |
|
| 48 | + * @param int $key |
|
| 49 | + * @param string $prefix_curr |
|
| 50 | + * @param array $ret |
|
| 51 | + * |
|
| 52 | + * @return array |
|
| 53 | + */ |
|
| 54 | + public function getOptionArray($tree, $fieldName, $key, $prefix_curr = '', &$ret) |
|
| 55 | + { |
|
| 56 | + if ($key > 0) { |
|
| 57 | + $value = $tree->tree[$key]['obj']->getVar($tree->_myId); |
|
| 58 | + $ret[$key] = $prefix_curr . $tree->tree[$key]['obj']->getVar($fieldName); |
|
| 59 | + $prefix_curr .= '-'; |
|
| 60 | + } |
|
| 61 | + if (isset($tree->tree[$key]['child']) && !empty($tree->tree[$key]['child'])) { |
|
| 62 | + foreach ($tree->tree[$key]['child'] as $childkey) { |
|
| 63 | + $this->getOptionArray($tree, $fieldName, $childkey, $prefix_curr, $ret); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - return $ret; |
|
| 68 | - } |
|
| 67 | + return $ret; |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $categoryHandler = xoops_getModuleHandler('category', $object->handler->_moduleName); |
| 25 | 25 | $categories = $categoryHandler->getObjects($criteria); |
| 26 | 26 | |
| 27 | - require_once XOOPS_ROOT_PATH . '/class/tree.php'; |
|
| 27 | + require_once XOOPS_ROOT_PATH.'/class/tree.php'; |
|
| 28 | 28 | $mytree = new XoopsObjectTree($categories, 'categoryid', 'parentid'); |
| 29 | 29 | parent::__construct($object->vars[$key]['form_caption'], $key, $object->getVar($key, 'e')); |
| 30 | 30 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | if ($key > 0) { |
| 57 | 57 | $value = $tree->tree[$key]['obj']->getVar($tree->_myId); |
| 58 | - $ret[$key] = $prefix_curr . $tree->tree[$key]['obj']->getVar($fieldName); |
|
| 58 | + $ret[$key] = $prefix_curr.$tree->tree[$key]['obj']->getVar($fieldName); |
|
| 59 | 59 | $prefix_curr .= '-'; |
| 60 | 60 | } |
| 61 | 61 | if (isset($tree->tree[$key]['child']) && !empty($tree->tree[$key]['child'])) { |
@@ -24,20 +24,20 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | class SmartFormHidden extends XoopsFormHidden |
| 26 | 26 | { |
| 27 | - /** |
|
| 28 | - * @return string |
|
| 29 | - */ |
|
| 30 | - public function render() |
|
| 31 | - { |
|
| 32 | - if (is_array($this->getValue())) { |
|
| 33 | - $ret = ''; |
|
| 34 | - foreach ($this->getValue() as $value) { |
|
| 35 | - $ret .= "<input type='hidden' name='" . $this->getName() . "[]' id='" . $this->getName() . "' value='" . $value . "'>\n"; |
|
| 36 | - } |
|
| 37 | - } else { |
|
| 38 | - $ret = "<input type='hidden' name='" . $this->getName() . "' id='" . $this->getName() . "' value='" . $this->getValue() . "'>"; |
|
| 39 | - } |
|
| 27 | + /** |
|
| 28 | + * @return string |
|
| 29 | + */ |
|
| 30 | + public function render() |
|
| 31 | + { |
|
| 32 | + if (is_array($this->getValue())) { |
|
| 33 | + $ret = ''; |
|
| 34 | + foreach ($this->getValue() as $value) { |
|
| 35 | + $ret .= "<input type='hidden' name='" . $this->getName() . "[]' id='" . $this->getName() . "' value='" . $value . "'>\n"; |
|
| 36 | + } |
|
| 37 | + } else { |
|
| 38 | + $ret = "<input type='hidden' name='" . $this->getName() . "' id='" . $this->getName() . "' value='" . $this->getValue() . "'>"; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - return $ret; |
|
| 42 | - } |
|
| 41 | + return $ret; |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -32,10 +32,10 @@ |
||
| 32 | 32 | if (is_array($this->getValue())) { |
| 33 | 33 | $ret = ''; |
| 34 | 34 | foreach ($this->getValue() as $value) { |
| 35 | - $ret .= "<input type='hidden' name='" . $this->getName() . "[]' id='" . $this->getName() . "' value='" . $value . "'>\n"; |
|
| 35 | + $ret .= "<input type='hidden' name='".$this->getName()."[]' id='".$this->getName()."' value='".$value."'>\n"; |
|
| 36 | 36 | } |
| 37 | 37 | } else { |
| 38 | - $ret = "<input type='hidden' name='" . $this->getName() . "' id='" . $this->getName() . "' value='" . $this->getValue() . "'>"; |
|
| 38 | + $ret = "<input type='hidden' name='".$this->getName()."' id='".$this->getName()."' value='".$this->getValue()."'>"; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return $ret; |
@@ -11,54 +11,54 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class SmartFormRadioElement extends XoopsFormRadio |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * SmartFormRadioElement constructor. |
|
| 16 | - * @param string $object |
|
| 17 | - * @param string $key |
|
| 18 | - */ |
|
| 19 | - public function __construct($object, $key) |
|
| 20 | - { |
|
| 21 | - $var = $object->vars[$key]; |
|
| 14 | + /** |
|
| 15 | + * SmartFormRadioElement constructor. |
|
| 16 | + * @param string $object |
|
| 17 | + * @param string $key |
|
| 18 | + */ |
|
| 19 | + public function __construct($object, $key) |
|
| 20 | + { |
|
| 21 | + $var = $object->vars[$key]; |
|
| 22 | 22 | |
| 23 | - parent::__construct($var['form_caption'], $key, $object->getVar($key, 'e')); |
|
| 23 | + parent::__construct($var['form_caption'], $key, $object->getVar($key, 'e')); |
|
| 24 | 24 | |
| 25 | - // Adding the options inside this SelectBox |
|
| 26 | - // If the custom method is not from a module, than it's from the core |
|
| 27 | - $control = $object->getControl($key); |
|
| 25 | + // Adding the options inside this SelectBox |
|
| 26 | + // If the custom method is not from a module, than it's from the core |
|
| 27 | + $control = $object->getControl($key); |
|
| 28 | 28 | |
| 29 | - if (isset($control['options'])) { |
|
| 30 | - $this->addOptionArray($control['options']); |
|
| 31 | - } else { |
|
| 32 | - // let's find if the method we need to call comes from an already defined object |
|
| 33 | - if (isset($control['object'])) { |
|
| 34 | - if (method_exists($control['object'], $control['method'])) { |
|
| 35 | - if ($option_array = $control['object']->{$control['method']}()) { |
|
| 36 | - // Adding the options array to the XoopsFormSelect |
|
| 37 | - $this->addOptionArray($option_array); |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - } else { |
|
| 41 | - // finding the itemHandler; if none, let's take the itemHandler of the $object |
|
| 42 | - if (isset($control['itemHandler'])) { |
|
| 43 | - if (!$control['module']) { |
|
| 44 | - // Creating the specified core object handler |
|
| 45 | - $controlHandler = xoops_getHandler($control['itemHandler']); |
|
| 46 | - } else { |
|
| 47 | - $controlHandler = xoops_getModuleHandler($control['itemHandler'], $control['module']); |
|
| 48 | - } |
|
| 49 | - } else { |
|
| 50 | - $controlHandler = $object->handler; |
|
| 51 | - } |
|
| 29 | + if (isset($control['options'])) { |
|
| 30 | + $this->addOptionArray($control['options']); |
|
| 31 | + } else { |
|
| 32 | + // let's find if the method we need to call comes from an already defined object |
|
| 33 | + if (isset($control['object'])) { |
|
| 34 | + if (method_exists($control['object'], $control['method'])) { |
|
| 35 | + if ($option_array = $control['object']->{$control['method']}()) { |
|
| 36 | + // Adding the options array to the XoopsFormSelect |
|
| 37 | + $this->addOptionArray($option_array); |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + } else { |
|
| 41 | + // finding the itemHandler; if none, let's take the itemHandler of the $object |
|
| 42 | + if (isset($control['itemHandler'])) { |
|
| 43 | + if (!$control['module']) { |
|
| 44 | + // Creating the specified core object handler |
|
| 45 | + $controlHandler = xoops_getHandler($control['itemHandler']); |
|
| 46 | + } else { |
|
| 47 | + $controlHandler = xoops_getModuleHandler($control['itemHandler'], $control['module']); |
|
| 48 | + } |
|
| 49 | + } else { |
|
| 50 | + $controlHandler = $object->handler; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - // Checking if the specified method exists |
|
| 54 | - if (method_exists($controlHandler, $control['method'])) { |
|
| 55 | - // TODO: How could I pass the parameters in the following call ... |
|
| 56 | - if ($option_array = $controlHandler->{$control['method']}()) { |
|
| 57 | - // Adding the options array to the XoopsFormSelect |
|
| 58 | - $this->addOptionArray($option_array); |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - } |
|
| 53 | + // Checking if the specified method exists |
|
| 54 | + if (method_exists($controlHandler, $control['method'])) { |
|
| 55 | + // TODO: How could I pass the parameters in the following call ... |
|
| 56 | + if ($option_array = $controlHandler->{$control['method']}()) { |
|
| 57 | + // Adding the options array to the XoopsFormSelect |
|
| 58 | + $this->addOptionArray($option_array); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | } |