@@ -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='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='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 | } |
@@ -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 | } |
@@ -36,20 +36,20 @@ |
||
36 | 36 | */ |
37 | 37 | class SmartFormHidden extends XoopsFormHidden |
38 | 38 | { |
39 | - /** |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function render() |
|
43 | - { |
|
44 | - if (is_array($this->getValue())) { |
|
45 | - $ret = ''; |
|
46 | - foreach ($this->getValue() as $value) { |
|
47 | - $ret .= "<input type='hidden' name='" . $this->getName() . "[]' id='" . $this->getName() . "' value='" . $value . "' />\n"; |
|
48 | - } |
|
49 | - } else { |
|
50 | - $ret = "<input type='hidden' name='" . $this->getName() . "' id='" . $this->getName() . "' value='" . $this->getValue() . "' />"; |
|
51 | - } |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function render() |
|
43 | + { |
|
44 | + if (is_array($this->getValue())) { |
|
45 | + $ret = ''; |
|
46 | + foreach ($this->getValue() as $value) { |
|
47 | + $ret .= "<input type='hidden' name='" . $this->getName() . "[]' id='" . $this->getName() . "' value='" . $value . "' />\n"; |
|
48 | + } |
|
49 | + } else { |
|
50 | + $ret = "<input type='hidden' name='" . $this->getName() . "' id='" . $this->getName() . "' value='" . $this->getValue() . "' />"; |
|
51 | + } |
|
52 | 52 | |
53 | - return $ret; |
|
54 | - } |
|
53 | + return $ret; |
|
54 | + } |
|
55 | 55 | } |
@@ -11,13 +11,13 @@ |
||
11 | 11 | */ |
12 | 12 | class SmartFormDate_timeElement extends XoopsFormDateTime |
13 | 13 | { |
14 | - /** |
|
15 | - * SmartFormDate_timeElement constructor. |
|
16 | - * @param mixed $object |
|
17 | - * @param mixed $key |
|
18 | - */ |
|
19 | - public function __construct($object, $key) |
|
20 | - { |
|
21 | - parent::__construct($object->vars[$key]['form_caption'], $key, 15, $object->getVar($key, 'e')); |
|
22 | - } |
|
14 | + /** |
|
15 | + * SmartFormDate_timeElement constructor. |
|
16 | + * @param mixed $object |
|
17 | + * @param mixed $key |
|
18 | + */ |
|
19 | + public function __construct($object, $key) |
|
20 | + { |
|
21 | + parent::__construct($object->vars[$key]['form_caption'], $key, 15, $object->getVar($key, 'e')); |
|
22 | + } |
|
23 | 23 | } |
@@ -6,41 +6,41 @@ |
||
6 | 6 | */ |
7 | 7 | class SmartFormSectionClose extends XoopsFormElement |
8 | 8 | { |
9 | - /** |
|
10 | - * Text |
|
11 | - * @var string |
|
12 | - * @access private |
|
13 | - */ |
|
14 | - public $_value; |
|
9 | + /** |
|
10 | + * Text |
|
11 | + * @var string |
|
12 | + * @access private |
|
13 | + */ |
|
14 | + public $_value; |
|
15 | 15 | |
16 | - /** |
|
17 | - * SmartFormSectionClose constructor. |
|
18 | - * @param $sectionname |
|
19 | - * @param bool $value |
|
20 | - */ |
|
21 | - public function __construct($sectionname, $value = false) |
|
22 | - { |
|
23 | - $this->setName($sectionname); |
|
24 | - $this->_value = $value; |
|
25 | - } |
|
16 | + /** |
|
17 | + * SmartFormSectionClose constructor. |
|
18 | + * @param $sectionname |
|
19 | + * @param bool $value |
|
20 | + */ |
|
21 | + public function __construct($sectionname, $value = false) |
|
22 | + { |
|
23 | + $this->setName($sectionname); |
|
24 | + $this->_value = $value; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Get the text |
|
29 | - * |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function getValue() |
|
33 | - { |
|
34 | - return $this->_value; |
|
35 | - } |
|
27 | + /** |
|
28 | + * Get the text |
|
29 | + * |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function getValue() |
|
33 | + { |
|
34 | + return $this->_value; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Prepare HTML for output |
|
39 | - * |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function render() |
|
43 | - { |
|
44 | - return $this->getValue(); |
|
45 | - } |
|
37 | + /** |
|
38 | + * Prepare HTML for output |
|
39 | + * |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function render() |
|
43 | + { |
|
44 | + return $this->getValue(); |
|
45 | + } |
|
46 | 46 | } |
@@ -11,37 +11,37 @@ |
||
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) != '' && (0 === strpos($object->getVar($key), 'http') || 0 === strpos($object->getVar($key), '{XOOPS_URL}'))) { |
|
28 | - $this->addElement(new XoopsFormLabel('', "<img src='" . str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar($key)) . "' alt='' /><br/><br/>")); |
|
29 | - } elseif ($object->getVar($key) != '') { |
|
30 | - $this->addElement(new XoopsFormLabel('', "<img src='" . $object_imageurl . $object->getVar($key) . "' alt='' /><br/><br/>")); |
|
31 | - } |
|
27 | + if ($object->getVar($key) != '' && (0 === strpos($object->getVar($key), 'http') || 0 === strpos($object->getVar($key), '{XOOPS_URL}'))) { |
|
28 | + $this->addElement(new XoopsFormLabel('', "<img src='" . str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar($key)) . "' alt='' /><br/><br/>")); |
|
29 | + } elseif ($object->getVar($key) != '') { |
|
30 | + $this->addElement(new XoopsFormLabel('', "<img src='" . $object_imageurl . $object->getVar($key) . "' alt='' /><br/><br/>")); |
|
31 | + } |
|
32 | 32 | |
33 | - include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformfileuploadelement.php'; |
|
34 | - $this->addElement(new SmartFormFileUploadElement($object, $key)); |
|
33 | + include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformfileuploadelement.php'; |
|
34 | + $this->addElement(new SmartFormFileUploadElement($object, $key)); |
|
35 | 35 | |
36 | - $this->addElement(new XoopsFormLabel('<div style="height: 10px; padding-top: 8px; font-size: 80%;">' . _CO_SOBJECT_URL_FILE_DSC . '</div>', '')); |
|
37 | - include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformtextelement.php'; |
|
38 | - include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php'; |
|
36 | + $this->addElement(new XoopsFormLabel('<div style="height: 10px; padding-top: 8px; font-size: 80%;">' . _CO_SOBJECT_URL_FILE_DSC . '</div>', '')); |
|
37 | + include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformtextelement.php'; |
|
38 | + include_once SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php'; |
|
39 | 39 | |
40 | - $this->addElement(new XoopsFormLabel('', '<br />' . _CO_SOBJECT_URL_FILE)); |
|
41 | - $this->addElement(new SmartFormTextElement($object, 'url_' . $key)); |
|
42 | - $this->addElement(new XoopsFormLabel('', '<br /><br />')); |
|
43 | - $delete_check = new SmartFormCheckElement('', 'delete_' . $key); |
|
44 | - $delete_check->addOption(1, '<span style="color:red;">' . _CO_SOBJECT_DELETE . '</span>'); |
|
45 | - $this->addElement($delete_check); |
|
46 | - } |
|
40 | + $this->addElement(new XoopsFormLabel('', '<br />' . _CO_SOBJECT_URL_FILE)); |
|
41 | + $this->addElement(new SmartFormTextElement($object, 'url_' . $key)); |
|
42 | + $this->addElement(new XoopsFormLabel('', '<br /><br />')); |
|
43 | + $delete_check = new SmartFormCheckElement('', 'delete_' . $key); |
|
44 | + $delete_check->addOption(1, '<span style="color:red;">' . _CO_SOBJECT_DELETE . '</span>'); |
|
45 | + $this->addElement($delete_check); |
|
46 | + } |
|
47 | 47 | } |
@@ -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 | } |
@@ -47,7 +47,7 @@ |
||
47 | 47 | $controlHandler = xoops_getModuleHandler($control['itemHandler'], $control['module']); |
48 | 48 | } |
49 | 49 | } else { |
50 | - $controlHandler =& $object->handler; |
|
50 | + $controlHandler = & $object->handler; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // Checking if the specified method exists |
@@ -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 | - include_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 | + include_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 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $criteria = new CriteriaCompo(); |
23 | 23 | $criteria->setSort('weight, name'); |
24 | 24 | $categoryHandler = xoops_getModuleHandler('category', $object->handler->_moduleName); |
25 | - $categories = $categoryHandler->getObjects($criteria); |
|
25 | + $categories = $categoryHandler->getObjects($criteria); |
|
26 | 26 | |
27 | 27 | include_once(XOOPS_ROOT_PATH . '/class/tree.php'); |
28 | 28 | $mytree = new XoopsObjectTree($categories, 'categoryid', 'parentid'); |
@@ -16,14 +16,14 @@ |
||
16 | 16 | */ |
17 | 17 | class SmartFormSelect_multiElement extends SmartFormSelectElement |
18 | 18 | { |
19 | - /** |
|
20 | - * SmartFormSelect_multiElement constructor. |
|
21 | - * @param string $object |
|
22 | - * @param string $key |
|
23 | - */ |
|
24 | - public function __construct($object, $key) |
|
25 | - { |
|
26 | - $this->multiple = true; |
|
27 | - parent::__construct($object, $key); |
|
28 | - } |
|
19 | + /** |
|
20 | + * SmartFormSelect_multiElement constructor. |
|
21 | + * @param string $object |
|
22 | + * @param string $key |
|
23 | + */ |
|
24 | + public function __construct($object, $key) |
|
25 | + { |
|
26 | + $this->multiple = true; |
|
27 | + parent::__construct($object, $key); |
|
28 | + } |
|
29 | 29 | } |