Completed
Push — master ( 2d4977...3189d6 )
by Michael
10:50
created
class/form/elements/smartformselect_multielement.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
class/form/elements/smartformautocompleteelement.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
11 11
  */
12 12
 class SmartFormAutocompleteElement extends SmartAutocompleteElement
13 13
 {
14
-    /**
15
-     * SmartFormAutocompleteElement constructor.
16
-     * @param string $object
17
-     * @param string $key
18
-     */
19
-    public function __construct($object, $key)
20
-    {
21
-        $var            = $object->vars[$key];
22
-        $control        = $object->controls[$key];
23
-        $form_maxlength = isset($control['maxlength']) ? $control['maxlength'] : (isset($var['maxlength']) ? $var['maxlength'] : 255);
14
+	/**
15
+	 * SmartFormAutocompleteElement constructor.
16
+	 * @param string $object
17
+	 * @param string $key
18
+	 */
19
+	public function __construct($object, $key)
20
+	{
21
+		$var            = $object->vars[$key];
22
+		$control        = $object->controls[$key];
23
+		$form_maxlength = isset($control['maxlength']) ? $control['maxlength'] : (isset($var['maxlength']) ? $var['maxlength'] : 255);
24 24
 
25
-        $form_size = isset($control['size']) ? $control['size'] : 50;
26
-        parent::__construct($var['form_caption'], $key, $form_size, $form_maxlength, $object->getVar($key, 'e'));
27
-    }
25
+		$form_size = isset($control['size']) ? $control['size'] : 50;
26
+		parent::__construct($var['form_caption'], $key, $form_size, $form_maxlength, $object->getVar($key, 'e'));
27
+	}
28 28
 }
Please login to merge, or discard this patch.
class/form/elements/smartformyesnoelement.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@
 block discarded – undo
11 11
  */
12 12
 class SmartFormYesnoElement extends XoopsFormRadioYN
13 13
 {
14
-    /**
15
-     * SmartFormYesnoElement constructor.
16
-     * @param string $object
17
-     * @param string $key
18
-     */
19
-    public function __construct($object, $key)
20
-    {
21
-        parent::__construct($object->vars[$key]['form_caption'], $key, $object->getVar($key, 'e'));
22
-    }
14
+	/**
15
+	 * SmartFormYesnoElement constructor.
16
+	 * @param string $object
17
+	 * @param string $key
18
+	 */
19
+	public function __construct($object, $key)
20
+	{
21
+		parent::__construct($object->vars[$key]['form_caption'], $key, $object->getVar($key, 'e'));
22
+	}
23 23
 }
Please login to merge, or discard this patch.
class/form/elements/smartautocompleteelement.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -11,38 +11,38 @@
 block discarded – undo
11 11
  */
12 12
 class SmartAutocompleteElement extends XoopsFormText
13 13
 {
14
-    public $_include_file;
14
+	public $_include_file;
15 15
 
16
-    /**
17
-     * SmartAutocompleteElement constructor.
18
-     * @param string $caption
19
-     * @param string $name
20
-     * @param int    $include_file
21
-     * @param int    $size
22
-     * @param string $maxlength
23
-     * @param string $value
24
-     */
25
-    public function __construct($caption, $name, $include_file, $size, $maxlength, $value = '')
26
-    {
27
-        $this->_include_file = $include_file;
28
-        parent::__construct($caption, $name, $size, $maxlength, $value);
29
-    }
16
+	/**
17
+	 * SmartAutocompleteElement constructor.
18
+	 * @param string $caption
19
+	 * @param string $name
20
+	 * @param int    $include_file
21
+	 * @param int    $size
22
+	 * @param string $maxlength
23
+	 * @param string $value
24
+	 */
25
+	public function __construct($caption, $name, $include_file, $size, $maxlength, $value = '')
26
+	{
27
+		$this->_include_file = $include_file;
28
+		parent::__construct($caption, $name, $size, $maxlength, $value);
29
+	}
30 30
 
31
-    /**
32
-     * Prepare HTML for output
33
-     *
34
-     * @return string HTML
35
-     */
36
-    public function render()
37
-    {
38
-        $ret = "<input type='text' name='" . $this->getName() . "' id='" . $this->getName() . "' size='" . $this->getSize() . "' maxlength='" . $this->getMaxlength() . "' value='" . $this->getValue() . "'" . $this->getExtra() . ' />';
31
+	/**
32
+	 * Prepare HTML for output
33
+	 *
34
+	 * @return string HTML
35
+	 */
36
+	public function render()
37
+	{
38
+		$ret = "<input type='text' name='" . $this->getName() . "' id='" . $this->getName() . "' size='" . $this->getSize() . "' maxlength='" . $this->getMaxlength() . "' value='" . $this->getValue() . "'" . $this->getExtra() . ' />';
39 39
 
40
-        $ret .= '   <div class="smartobject_autocomplete_hint" id="smartobject_autocomplete_hint' . $this->getName() . '"></div>
40
+		$ret .= '   <div class="smartobject_autocomplete_hint" id="smartobject_autocomplete_hint' . $this->getName() . '"></div>
41 41
 
42 42
     <script type="text/javascript">
43 43
         new Ajax.Autocompleter("' . $this->getName() . '","smartobject_autocomplete_hint' . $this->getName() . '","' . $this->_include_file . '?key=' . $this->getName() . '");
44 44
     </script>';
45 45
 
46
-        return $ret;
47
-    }
46
+		return $ret;
47
+	}
48 48
 }
Please login to merge, or discard this patch.
class/form/smartobjectform.php 1 patch
Indentation   +782 added lines, -782 removed lines patch added patch discarded remove patch
@@ -30,776 +30,776 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class SmartObjectForm extends XoopsThemeForm
32 32
 {
33
-    public $targetObject           = null;
34
-    public $form_fields            = null;
35
-    public $_cancel_js_action      = false;
36
-    public $_custom_button         = false;
37
-    public $_captcha               = false;
38
-    public $_form_name             = false;
39
-    public $_form_caption          = false;
40
-    public $_submit_button_caption = false;
41
-
42
-    /**
43
-     * SmartobjectForm constructor.
44
-     * @param string $target
45
-     * @param string $form_name
46
-     * @param string $form_caption
47
-     * @param string $form_action
48
-     * @param null   $form_fields
49
-     * @param bool   $submit_button_caption
50
-     * @param bool   $cancel_js_action
51
-     * @param bool   $captcha
52
-     */
53
-    public function __construct(&$target, $form_name, $form_caption, $form_action, $form_fields = null, $submit_button_caption = false, $cancel_js_action = false, $captcha = false)
54
-    {
55
-        $this->targetObject           =& $target;
56
-        $this->form_fields            = $form_fields;
57
-        $this->_cancel_js_action      = $cancel_js_action;
58
-        $this->_captcha               = $captcha;
59
-        $this->_form_name             = $form_name;
60
-        $this->_form_caption          = $form_caption;
61
-        $this->_submit_button_caption = $submit_button_caption;
62
-
63
-        if (!isset($form_action)) {
64
-            $form_action = xoops_getenv('PHP_SELF');
65
-        }
66
-
67
-        $this->XoopsForm($form_caption, $form_name, $form_action);
68
-        $this->setExtra('enctype="multipart/form-data"');
69
-
70
-        $this->createElements();
71
-
72
-        if ($captcha) {
73
-            $this->addCaptcha();
74
-        }
75
-
76
-        $this->createPermissionControls();
77
-
78
-        $this->createButtons($form_name, $form_caption, $submit_button_caption);
79
-    }
80
-
81
-    public function addCaptcha()
82
-    {
83
-        include_once(SMARTOBJECT_ROOT_PATH . 'include/captcha/formcaptcha.php');
84
-        $this->addElement(new XoopsFormCaptcha(), true);
85
-    }
86
-
87
-    /**
88
-     * @param      $name
89
-     * @param      $caption
90
-     * @param bool $onclick
91
-     */
92
-    public function addCustomButton($name, $caption, $onclick = false)
93
-    {
94
-        $custom_button_array    = array(
95
-            'name'    => $name,
96
-            'caption' => $caption,
97
-            'onclick' => $onclick
98
-        );
99
-        $this->_custom_button[] = $custom_button_array;
100
-    }
101
-
102
-    /**
103
-     * Add an element to the form
104
-     *
105
-     * @param object      &$formElement reference to a {@link XoopsFormElement}
106
-     * @param bool        $key
107
-     * @param bool        $var
108
-     * @param bool|string $required     is this a "required" element?
109
-     */
110
-    public function addElement(&$formElement, $key = false, $var = false, $required = 'notset')
111
-    {
112
-        if ($key) {
113
-            if ($this->targetObject->vars[$key]['readonly']) {
114
-                $formElement->setExtra('disabled="disabled"');
115
-                $formElement->setName($key . '-readonly');
116
-                // Since this element is disable, we still want to pass it's value in the form
117
-                $hidden = new XoopsFormHidden($key, $this->targetObject->vars[$key]['value']);
118
-                $this->addElement($hidden);
119
-            }
120
-            $formElement->setDescription($var['form_dsc']);
121
-            if (isset($this->targetObject->controls[$key]['onSelect'])) {
122
-                $hidden = new XoopsFormHidden('changedField', false);
123
-                $this->addElement($hidden);
124
-                $otherExtra      = isset($var['form_extra']) ? $var['form_extra'] : '';
125
-                $onchangedString = "this.form.elements.changedField.value='$key'; this.form.elements.op.value='changedField'; submit()";
126
-                $formElement->setExtra('onchange="' . $onchangedString . '"' . ' ' . $otherExtra);
127
-            } else {
128
-                if (isset($var['form_extra'])) {
129
-                    $formElement->setExtra($var['form_extra']);
130
-                }
131
-            }
132
-            $controls = $this->targetObject->controls;
133
-            if (isset($controls[$key]['js'])) {
134
-                $formElement->customValidationCode[] = $controls[$key]['js'];
135
-            }
136
-            parent::addElement($formElement, $required === 'notset' ? $var['required'] : $required);
137
-        } else {
138
-            parent::addElement($formElement, $required === 'notset' ? false : true);
139
-        }
140
-        unset($formElement);
141
-    }
142
-
143
-    public function createElements()
144
-    {
145
-        $controls = $this->targetObject->controls;
146
-        $vars     = $this->targetObject->vars;
147
-        foreach ($vars as $key => $var) {
148
-
149
-            // If $displayOnForm is false OR this is the primary key, it doesn't
150
-            // need to be displayed, then we only create an hidden field
151
-            if ($key == $this->targetObject->handler->keyName || !$var['displayOnForm']) {
152
-                $elementToAdd = new XoopsFormHidden($key, $var['value']);
153
-                $this->addElement($elementToAdd, $key, $var, false);
154
-                unset($elementToAdd);
155
-                // If not, the we need to create the proper form control for this fields
156
-            } else {
157
-                // If this field has a specific control, we will use it
158
-
159
-                if ($key === 'parentid') {
160
-                    /**
161
-                     * Why this ?
162
-                     */
163
-                }
164
-                if (isset($controls[$key])) {
165
-                    /* If the control has name, it's because it's an object already present in the script
33
+	public $targetObject           = null;
34
+	public $form_fields            = null;
35
+	public $_cancel_js_action      = false;
36
+	public $_custom_button         = false;
37
+	public $_captcha               = false;
38
+	public $_form_name             = false;
39
+	public $_form_caption          = false;
40
+	public $_submit_button_caption = false;
41
+
42
+	/**
43
+	 * SmartobjectForm constructor.
44
+	 * @param string $target
45
+	 * @param string $form_name
46
+	 * @param string $form_caption
47
+	 * @param string $form_action
48
+	 * @param null   $form_fields
49
+	 * @param bool   $submit_button_caption
50
+	 * @param bool   $cancel_js_action
51
+	 * @param bool   $captcha
52
+	 */
53
+	public function __construct(&$target, $form_name, $form_caption, $form_action, $form_fields = null, $submit_button_caption = false, $cancel_js_action = false, $captcha = false)
54
+	{
55
+		$this->targetObject           =& $target;
56
+		$this->form_fields            = $form_fields;
57
+		$this->_cancel_js_action      = $cancel_js_action;
58
+		$this->_captcha               = $captcha;
59
+		$this->_form_name             = $form_name;
60
+		$this->_form_caption          = $form_caption;
61
+		$this->_submit_button_caption = $submit_button_caption;
62
+
63
+		if (!isset($form_action)) {
64
+			$form_action = xoops_getenv('PHP_SELF');
65
+		}
66
+
67
+		$this->XoopsForm($form_caption, $form_name, $form_action);
68
+		$this->setExtra('enctype="multipart/form-data"');
69
+
70
+		$this->createElements();
71
+
72
+		if ($captcha) {
73
+			$this->addCaptcha();
74
+		}
75
+
76
+		$this->createPermissionControls();
77
+
78
+		$this->createButtons($form_name, $form_caption, $submit_button_caption);
79
+	}
80
+
81
+	public function addCaptcha()
82
+	{
83
+		include_once(SMARTOBJECT_ROOT_PATH . 'include/captcha/formcaptcha.php');
84
+		$this->addElement(new XoopsFormCaptcha(), true);
85
+	}
86
+
87
+	/**
88
+	 * @param      $name
89
+	 * @param      $caption
90
+	 * @param bool $onclick
91
+	 */
92
+	public function addCustomButton($name, $caption, $onclick = false)
93
+	{
94
+		$custom_button_array    = array(
95
+			'name'    => $name,
96
+			'caption' => $caption,
97
+			'onclick' => $onclick
98
+		);
99
+		$this->_custom_button[] = $custom_button_array;
100
+	}
101
+
102
+	/**
103
+	 * Add an element to the form
104
+	 *
105
+	 * @param object      &$formElement reference to a {@link XoopsFormElement}
106
+	 * @param bool        $key
107
+	 * @param bool        $var
108
+	 * @param bool|string $required     is this a "required" element?
109
+	 */
110
+	public function addElement(&$formElement, $key = false, $var = false, $required = 'notset')
111
+	{
112
+		if ($key) {
113
+			if ($this->targetObject->vars[$key]['readonly']) {
114
+				$formElement->setExtra('disabled="disabled"');
115
+				$formElement->setName($key . '-readonly');
116
+				// Since this element is disable, we still want to pass it's value in the form
117
+				$hidden = new XoopsFormHidden($key, $this->targetObject->vars[$key]['value']);
118
+				$this->addElement($hidden);
119
+			}
120
+			$formElement->setDescription($var['form_dsc']);
121
+			if (isset($this->targetObject->controls[$key]['onSelect'])) {
122
+				$hidden = new XoopsFormHidden('changedField', false);
123
+				$this->addElement($hidden);
124
+				$otherExtra      = isset($var['form_extra']) ? $var['form_extra'] : '';
125
+				$onchangedString = "this.form.elements.changedField.value='$key'; this.form.elements.op.value='changedField'; submit()";
126
+				$formElement->setExtra('onchange="' . $onchangedString . '"' . ' ' . $otherExtra);
127
+			} else {
128
+				if (isset($var['form_extra'])) {
129
+					$formElement->setExtra($var['form_extra']);
130
+				}
131
+			}
132
+			$controls = $this->targetObject->controls;
133
+			if (isset($controls[$key]['js'])) {
134
+				$formElement->customValidationCode[] = $controls[$key]['js'];
135
+			}
136
+			parent::addElement($formElement, $required === 'notset' ? $var['required'] : $required);
137
+		} else {
138
+			parent::addElement($formElement, $required === 'notset' ? false : true);
139
+		}
140
+		unset($formElement);
141
+	}
142
+
143
+	public function createElements()
144
+	{
145
+		$controls = $this->targetObject->controls;
146
+		$vars     = $this->targetObject->vars;
147
+		foreach ($vars as $key => $var) {
148
+
149
+			// If $displayOnForm is false OR this is the primary key, it doesn't
150
+			// need to be displayed, then we only create an hidden field
151
+			if ($key == $this->targetObject->handler->keyName || !$var['displayOnForm']) {
152
+				$elementToAdd = new XoopsFormHidden($key, $var['value']);
153
+				$this->addElement($elementToAdd, $key, $var, false);
154
+				unset($elementToAdd);
155
+				// If not, the we need to create the proper form control for this fields
156
+			} else {
157
+				// If this field has a specific control, we will use it
158
+
159
+				if ($key === 'parentid') {
160
+					/**
161
+					 * Why this ?
162
+					 */
163
+				}
164
+				if (isset($controls[$key])) {
165
+					/* If the control has name, it's because it's an object already present in the script
166 166
                      * for example, "user"
167 167
                      * If the field does not have a name, than we will use a "select" (ie XoopsFormSelect)
168 168
                      */
169
-                    if (!isset($controls[$key]['name']) || !$controls[$key]['name']) {
170
-                        $controls[$key]['name'] = 'select';
171
-                    }
172
-
173
-                    $form_select = $this->getControl($controls[$key]['name'], $key);
174
-
175
-                    // Adding on the form, the control for this field
176
-                    $this->addElement($form_select, $key, $var);
177
-                    unset($form_select);
178
-
179
-                    // If this field don't have a specific control, we will use the standard one, depending on its data type
180
-                } else {
181
-                    switch ($var['data_type']) {
182
-
183
-                        case XOBJ_DTYPE_TXTBOX:
184
-
185
-                            $form_text = $this->getControl('text', $key);
186
-                            $this->addElement($form_text, $key, $var);
187
-                            unset($form_text);
188
-                            break;
189
-
190
-                        case XOBJ_DTYPE_INT:
191
-                            $this->targetObject->setControl($key, array(
192
-                                'name' => 'text',
193
-                                'size' => '5'
194
-                            ));
195
-                            $form_text = $this->getControl('text', $key);
196
-                            $this->addElement($form_text, $key, $var);
197
-                            unset($form_text);
198
-                            break;
199
-
200
-                        case XOBJ_DTYPE_FLOAT:
201
-                            $this->targetObject->setControl($key, array(
202
-                                'name' => 'text',
203
-                                'size' => '5'
204
-                            ));
205
-                            $form_text = $this->getControl('text', $key);
206
-                            $this->addElement($form_text, $key, $var);
207
-                            unset($form_text);
208
-                            break;
209
-
210
-                        case XOBJ_DTYPE_LTIME:
211
-                            $form_date_time = $this->getControl('date_time', $key);
212
-                            $this->addElement($form_date_time, $key, $var);
213
-                            unset($form_date_time);
214
-                            break;
215
-
216
-                        case XOBJ_DTYPE_STIME:
217
-                            $form_date_time = $this->getControl('date', $key);
218
-                            $this->addElement($form_date_time, $key, $var);
219
-                            unset($form_date_time);
220
-                            break;
221
-
222
-                        case XOBJ_DTYPE_TIME_ONLY:
223
-                            $form_time = $this->getControl('time', $key);
224
-                            $this->addElement($form_time, $key, $var);
225
-                            unset($form_time);
226
-                            break;
227
-
228
-                        case XOBJ_DTYPE_CURRENCY:
229
-                            $this->targetObject->setControl($key, array(
230
-                                'name' => 'text',
231
-                                'size' => '15'
232
-                            ));
233
-                            $form_currency = $this->getControl('text', $key);
234
-                            $this->addElement($form_currency, $key, $var);
235
-                            unset($form_currency);
236
-                            break;
237
-
238
-                        case XOBJ_DTYPE_URLLINK:
239
-                            $form_urllink = $this->getControl('urllink', $key);
240
-                            $this->addElement($form_urllink, $key, $var);
241
-                            unset($form_urllink);
242
-                            break;
243
-
244
-                        case XOBJ_DTYPE_FILE:
245
-                            $form_file = $this->getControl('richfile', $key);
246
-                            $this->addElement($form_file, $key, $var);
247
-                            unset($form_file);
248
-                            break;
249
-
250
-                        case XOBJ_DTYPE_TXTAREA:
251
-
252
-                            $form_text_area = $this->getTextArea($key, $var);
253
-                            $this->addElement($form_text_area, $key, $var);
254
-                            unset($form_text_area);
255
-                            break;
256
-
257
-                        case XOBJ_DTYPE_ARRAY:
258
-                            // TODO: To come...
259
-                            break;
260
-                        case XOBJ_DTYPE_SOURCE:
261
-                            // TODO: To come...
262
-                            break;
263
-                        case XOBJ_DTYPE_FORM_SECTION:
264
-                            $section_control = new SmartFormSection($key, $var['value']);
265
-                            $this->addElement($section_control, $key, $var);
266
-                            unset($section_control);
267
-                            break;
268
-                        case XOBJ_DTYPE_FORM_SECTION_CLOSE:
269
-                            $section_control = new SmartFormSectionClose($key, $var['value']);
270
-                            $this->addElement($section_control, $key, $var);
271
-                            unset($section_control);
272
-                            break;
273
-                    }
274
-                }
275
-            }
276
-        }
277
-        // Add an hidden field to store the URL of the page before this form
278
-        $this->addElement(new XoopsFormHidden('smart_page_before_form', smart_get_page_before_form()));
279
-    }
280
-
281
-    public function createPermissionControls()
282
-    {
283
-        $smartModuleConfig = $this->targetObject->handler->getModuleConfig();
284
-
285
-        $permissions = $this->targetObject->handler->getPermissions();
286
-
287
-        if ($permissions) {
288
-            $memberHandler = xoops_getHandler('member');
289
-            $group_list     = $memberHandler->getGroupList();
290
-            asort($group_list);
291
-            foreach ($permissions as $permission) {
292
-                if ($this->targetObject->isNew()) {
293
-                    if (isset($smartModuleConfig['def_perm_' . $permission['perm_name']])) {
294
-                        $groups_value = $smartModuleConfig['def_perm_' . $permission['perm_name']];
295
-                    }
296
-                } else {
297
-                    $groups_value = $this->targetObject->getGroupPerm($permission['perm_name']);
298
-                }
299
-                $groups_select = new XoopsFormSelect($permission['caption'], $permission['perm_name'], $groups_value, 4, true);
300
-                $groups_select->setDescription($permission['description']);
301
-                $groups_select->addOptionArray($group_list);
302
-                $this->addElement($groups_select);
303
-                unset($groups_select);
304
-            }
305
-        }
306
-    }
307
-
308
-    /**
309
-     * @param      $form_name
310
-     * @param      $form_caption
311
-     * @param bool $submit_button_caption
312
-     */
313
-    public function createButtons($form_name, $form_caption, $submit_button_caption = false)
314
-    {
315
-        $button_tray = new XoopsFormElementTray('', '');
316
-        $button_tray->addElement(new XoopsFormHidden('op', $form_name));
317
-        if (!$submit_button_caption) {
318
-            if ($this->targetObject->isNew()) {
319
-                $butt_create = new XoopsFormButton('', 'create_button', _CO_SOBJECT_CREATE, 'submit');
320
-            } else {
321
-                $butt_create = new XoopsFormButton('', 'modify_button', _CO_SOBJECT_MODIFY, 'submit');
322
-            }
323
-        } else {
324
-            $butt_create = new XoopsFormButton('', 'modify_button', $submit_button_caption, 'submit');
325
-        }
326
-        $butt_create->setExtra('onclick="this.form.elements.op.value=\'' . $form_name . '\'"');
327
-        $button_tray->addElement($butt_create);
328
-
329
-        //creating custom buttons
330
-        if ($this->_custom_button) {
331
-            foreach ($this->_custom_button as $custom_button) {
332
-                $butt_custom = new XoopsFormButton('', $custom_button['name'], $custom_button['caption'], 'submit');
333
-                if ($custom_button['onclick']) {
334
-                    $butt_custom->setExtra('onclick="' . $custom_button['onclick'] . '"');
335
-                }
336
-                $button_tray->addElement($butt_custom);
337
-                unset($butt_custom);
338
-            }
339
-        }
340
-
341
-        // creating the "cancel" button
342
-        $butt_cancel = new XoopsFormButton('', 'cancel_button', _CO_SOBJECT_CANCEL, 'button');
343
-        if ($this->_cancel_js_action) {
344
-            $butt_cancel->setExtra('onclick="' . $this->_cancel_js_action . '"');
345
-        } else {
346
-            $butt_cancel->setExtra('onclick="history.go(-1)"');
347
-        }
348
-        $button_tray->addElement($butt_cancel);
349
-
350
-        $this->addElement($button_tray);
351
-    }
352
-
353
-    /**
354
-     * @param $controlName
355
-     * @param $key
356
-     * @return XoopsFormLabel
357
-     */
358
-    public function getControl($controlName, $key)
359
-    {
360
-        switch ($controlName) {
361
-            case 'check':
362
-                include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php');
363
-                $control    = $this->targetObject->getControl($key);
364
-                $controlObj = new SmartFormCheckElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
365
-                $controlObj->addOptionArray($control['options']);
366
-
367
-                return $controlObj;
368
-                break;
369
-
370
-            case 'color':
371
-                $control    = $this->targetObject->getControl($key);
372
-                $controlObj = new XoopsFormColorPicker($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
373
-
374
-                return $controlObj;
375
-                break;
376
-
377
-            case 'radio':
378
-                $control = $this->targetObject->getControl($key);
379
-
380
-                $controlObj = new XoopsFormRadio($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
381
-                $controlObj->addOptionArray($control['options']);
382
-
383
-                return $controlObj;
384
-                break;
385
-
386
-            case 'label':
387
-                return new XoopsFormLabel($this->targetObject->vars[$key]['form_caption'], $this->targetObject->getVar($key));
388
-                break;
389
-
390
-            case 'textarea':
391
-                return $this->getTextArea($key);
392
-
393
-            case 'theme':
394
-                return $this->getThemeSelect($key, $this->targetObject->vars[$key]);
395
-
396
-            case 'theme_multi':
397
-                return $this->getThemeSelect($key, $this->targetObject->vars[$key], true);
398
-                break;
399
-
400
-            case 'timezone':
401
-                return new XoopsFormSelectTimezone($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
402
-                break;
403
-
404
-            case 'group':
405
-                return new XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false);
406
-                break;
407
-
408
-            case 'group_multi':
409
-                return new XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true);
410
-                break;
411
-
412
-            /*case 'user':
169
+					if (!isset($controls[$key]['name']) || !$controls[$key]['name']) {
170
+						$controls[$key]['name'] = 'select';
171
+					}
172
+
173
+					$form_select = $this->getControl($controls[$key]['name'], $key);
174
+
175
+					// Adding on the form, the control for this field
176
+					$this->addElement($form_select, $key, $var);
177
+					unset($form_select);
178
+
179
+					// If this field don't have a specific control, we will use the standard one, depending on its data type
180
+				} else {
181
+					switch ($var['data_type']) {
182
+
183
+						case XOBJ_DTYPE_TXTBOX:
184
+
185
+							$form_text = $this->getControl('text', $key);
186
+							$this->addElement($form_text, $key, $var);
187
+							unset($form_text);
188
+							break;
189
+
190
+						case XOBJ_DTYPE_INT:
191
+							$this->targetObject->setControl($key, array(
192
+								'name' => 'text',
193
+								'size' => '5'
194
+							));
195
+							$form_text = $this->getControl('text', $key);
196
+							$this->addElement($form_text, $key, $var);
197
+							unset($form_text);
198
+							break;
199
+
200
+						case XOBJ_DTYPE_FLOAT:
201
+							$this->targetObject->setControl($key, array(
202
+								'name' => 'text',
203
+								'size' => '5'
204
+							));
205
+							$form_text = $this->getControl('text', $key);
206
+							$this->addElement($form_text, $key, $var);
207
+							unset($form_text);
208
+							break;
209
+
210
+						case XOBJ_DTYPE_LTIME:
211
+							$form_date_time = $this->getControl('date_time', $key);
212
+							$this->addElement($form_date_time, $key, $var);
213
+							unset($form_date_time);
214
+							break;
215
+
216
+						case XOBJ_DTYPE_STIME:
217
+							$form_date_time = $this->getControl('date', $key);
218
+							$this->addElement($form_date_time, $key, $var);
219
+							unset($form_date_time);
220
+							break;
221
+
222
+						case XOBJ_DTYPE_TIME_ONLY:
223
+							$form_time = $this->getControl('time', $key);
224
+							$this->addElement($form_time, $key, $var);
225
+							unset($form_time);
226
+							break;
227
+
228
+						case XOBJ_DTYPE_CURRENCY:
229
+							$this->targetObject->setControl($key, array(
230
+								'name' => 'text',
231
+								'size' => '15'
232
+							));
233
+							$form_currency = $this->getControl('text', $key);
234
+							$this->addElement($form_currency, $key, $var);
235
+							unset($form_currency);
236
+							break;
237
+
238
+						case XOBJ_DTYPE_URLLINK:
239
+							$form_urllink = $this->getControl('urllink', $key);
240
+							$this->addElement($form_urllink, $key, $var);
241
+							unset($form_urllink);
242
+							break;
243
+
244
+						case XOBJ_DTYPE_FILE:
245
+							$form_file = $this->getControl('richfile', $key);
246
+							$this->addElement($form_file, $key, $var);
247
+							unset($form_file);
248
+							break;
249
+
250
+						case XOBJ_DTYPE_TXTAREA:
251
+
252
+							$form_text_area = $this->getTextArea($key, $var);
253
+							$this->addElement($form_text_area, $key, $var);
254
+							unset($form_text_area);
255
+							break;
256
+
257
+						case XOBJ_DTYPE_ARRAY:
258
+							// TODO: To come...
259
+							break;
260
+						case XOBJ_DTYPE_SOURCE:
261
+							// TODO: To come...
262
+							break;
263
+						case XOBJ_DTYPE_FORM_SECTION:
264
+							$section_control = new SmartFormSection($key, $var['value']);
265
+							$this->addElement($section_control, $key, $var);
266
+							unset($section_control);
267
+							break;
268
+						case XOBJ_DTYPE_FORM_SECTION_CLOSE:
269
+							$section_control = new SmartFormSectionClose($key, $var['value']);
270
+							$this->addElement($section_control, $key, $var);
271
+							unset($section_control);
272
+							break;
273
+					}
274
+				}
275
+			}
276
+		}
277
+		// Add an hidden field to store the URL of the page before this form
278
+		$this->addElement(new XoopsFormHidden('smart_page_before_form', smart_get_page_before_form()));
279
+	}
280
+
281
+	public function createPermissionControls()
282
+	{
283
+		$smartModuleConfig = $this->targetObject->handler->getModuleConfig();
284
+
285
+		$permissions = $this->targetObject->handler->getPermissions();
286
+
287
+		if ($permissions) {
288
+			$memberHandler = xoops_getHandler('member');
289
+			$group_list     = $memberHandler->getGroupList();
290
+			asort($group_list);
291
+			foreach ($permissions as $permission) {
292
+				if ($this->targetObject->isNew()) {
293
+					if (isset($smartModuleConfig['def_perm_' . $permission['perm_name']])) {
294
+						$groups_value = $smartModuleConfig['def_perm_' . $permission['perm_name']];
295
+					}
296
+				} else {
297
+					$groups_value = $this->targetObject->getGroupPerm($permission['perm_name']);
298
+				}
299
+				$groups_select = new XoopsFormSelect($permission['caption'], $permission['perm_name'], $groups_value, 4, true);
300
+				$groups_select->setDescription($permission['description']);
301
+				$groups_select->addOptionArray($group_list);
302
+				$this->addElement($groups_select);
303
+				unset($groups_select);
304
+			}
305
+		}
306
+	}
307
+
308
+	/**
309
+	 * @param      $form_name
310
+	 * @param      $form_caption
311
+	 * @param bool $submit_button_caption
312
+	 */
313
+	public function createButtons($form_name, $form_caption, $submit_button_caption = false)
314
+	{
315
+		$button_tray = new XoopsFormElementTray('', '');
316
+		$button_tray->addElement(new XoopsFormHidden('op', $form_name));
317
+		if (!$submit_button_caption) {
318
+			if ($this->targetObject->isNew()) {
319
+				$butt_create = new XoopsFormButton('', 'create_button', _CO_SOBJECT_CREATE, 'submit');
320
+			} else {
321
+				$butt_create = new XoopsFormButton('', 'modify_button', _CO_SOBJECT_MODIFY, 'submit');
322
+			}
323
+		} else {
324
+			$butt_create = new XoopsFormButton('', 'modify_button', $submit_button_caption, 'submit');
325
+		}
326
+		$butt_create->setExtra('onclick="this.form.elements.op.value=\'' . $form_name . '\'"');
327
+		$button_tray->addElement($butt_create);
328
+
329
+		//creating custom buttons
330
+		if ($this->_custom_button) {
331
+			foreach ($this->_custom_button as $custom_button) {
332
+				$butt_custom = new XoopsFormButton('', $custom_button['name'], $custom_button['caption'], 'submit');
333
+				if ($custom_button['onclick']) {
334
+					$butt_custom->setExtra('onclick="' . $custom_button['onclick'] . '"');
335
+				}
336
+				$button_tray->addElement($butt_custom);
337
+				unset($butt_custom);
338
+			}
339
+		}
340
+
341
+		// creating the "cancel" button
342
+		$butt_cancel = new XoopsFormButton('', 'cancel_button', _CO_SOBJECT_CANCEL, 'button');
343
+		if ($this->_cancel_js_action) {
344
+			$butt_cancel->setExtra('onclick="' . $this->_cancel_js_action . '"');
345
+		} else {
346
+			$butt_cancel->setExtra('onclick="history.go(-1)"');
347
+		}
348
+		$button_tray->addElement($butt_cancel);
349
+
350
+		$this->addElement($button_tray);
351
+	}
352
+
353
+	/**
354
+	 * @param $controlName
355
+	 * @param $key
356
+	 * @return XoopsFormLabel
357
+	 */
358
+	public function getControl($controlName, $key)
359
+	{
360
+		switch ($controlName) {
361
+			case 'check':
362
+				include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformcheckelement.php');
363
+				$control    = $this->targetObject->getControl($key);
364
+				$controlObj = new SmartFormCheckElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
365
+				$controlObj->addOptionArray($control['options']);
366
+
367
+				return $controlObj;
368
+				break;
369
+
370
+			case 'color':
371
+				$control    = $this->targetObject->getControl($key);
372
+				$controlObj = new XoopsFormColorPicker($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
373
+
374
+				return $controlObj;
375
+				break;
376
+
377
+			case 'radio':
378
+				$control = $this->targetObject->getControl($key);
379
+
380
+				$controlObj = new XoopsFormRadio($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
381
+				$controlObj->addOptionArray($control['options']);
382
+
383
+				return $controlObj;
384
+				break;
385
+
386
+			case 'label':
387
+				return new XoopsFormLabel($this->targetObject->vars[$key]['form_caption'], $this->targetObject->getVar($key));
388
+				break;
389
+
390
+			case 'textarea':
391
+				return $this->getTextArea($key);
392
+
393
+			case 'theme':
394
+				return $this->getThemeSelect($key, $this->targetObject->vars[$key]);
395
+
396
+			case 'theme_multi':
397
+				return $this->getThemeSelect($key, $this->targetObject->vars[$key], true);
398
+				break;
399
+
400
+			case 'timezone':
401
+				return new XoopsFormSelectTimezone($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
402
+				break;
403
+
404
+			case 'group':
405
+				return new XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false);
406
+				break;
407
+
408
+			case 'group_multi':
409
+				return new XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true);
410
+				break;
411
+
412
+			/*case 'user':
413 413
              return new XoopsFormSelectUser($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false);
414 414
              break;*/
415 415
 
416
-            case 'user_multi':
417
-                return new XoopsFormSelectUser($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true);
418
-                break;
419
-
420
-            case 'password':
421
-                return new XoopsFormPassword($this->targetObject->vars[$key]['form_caption'], $key, 50, 255, $this->targetObject->getVar($key, 'e'));
422
-                break;
423
-
424
-            case 'country':
425
-                return new XoopsFormSelectCountry($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key, 'e'));
426
-                break;
427
-
428
-            case 'urllink':
429
-                include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformurllinkelement.php');
430
-
431
-                return new SmartFormUrlLinkElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getUrlLinkObj($key));
432
-                break;
433
-
434
-            case 'richfile':
435
-                include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformrichfileelement.php');
436
-
437
-                return new SmartFormRichFileElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getFileObj($key));
438
-                break;
439
-            case 'section':
440
-                include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformsection.php');
441
-
442
-                return new SmartFormSection($key, $this->targetObject->vars[$key]['form_caption']);
443
-                break;
444
-
445
-            default:
446
-                $classname = 'SmartForm' . ucfirst($controlName) . 'Element';
447
-                if (!class_exists($classname)) {
448
-                    if (file_exists(SMARTOBJECT_ROOT_PATH . 'class/form/elements/' . strtolower($classname) . '.php')) {
449
-                        include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/' . strtolower($classname) . '.php');
450
-                    } else {
451
-                        // perhaps this is a control created by the module
452
-                        $moduleName             = $this->targetObject->handler->_moduleName;
453
-                        $moduleFormElementsPath = $this->targetObject->handler->_modulePath . 'class/form/elements/';
454
-                        $classname              = ucfirst($moduleName) . ucfirst($controlName) . 'Element';
455
-                        $classFileName          = strtolower($classname) . '.php';
456
-
457
-                        if (file_exists($moduleFormElementsPath . $classFileName)) {
458
-                            include_once($moduleFormElementsPath . $classFileName);
459
-                        } else {
460
-                            trigger_error($classname . ' Not found', E_USER_WARNING);
461
-
462
-                            return new XoopsFormLabel(); //Empty object
463
-                        }
464
-                    }
465
-                }
466
-
467
-                return new $classname($this->targetObject, $key);
468
-                break;
469
-        }
470
-    }
471
-
472
-    /**
473
-     * @param $key
474
-     * @return XoopsFormDhtmlTextArea|XoopsFormEditor|XoopsFormFckeditor|XoopsFormTextArea|XoopsFormTinyTextArea
475
-     */
476
-    public function getTextArea($key)
477
-    {
478
-        $var = $this->targetObject->vars[$key];
479
-
480
-        // if no control has been created, let's create a default one
481
-        if (!isset($this->targetObject->controls[$key])) {
482
-            $control = array(
483
-                'name'        => 'textarea',
484
-                'itemHandler' => false,
485
-                'method'      => false,
486
-                'module'      => false,
487
-                'form_editor' => 'default'
488
-            );
489
-        } else {
490
-            $control = $this->targetObject->controls[$key];
491
-        }
492
-        $xoops22 = smart_isXoops22();
493
-
494
-        $form_editor = isset($control['form_editor']) ? $control['form_editor'] : 'textarea';
495
-        /**
496
-         * If the editor is 'default', retreive the default editor of this module
497
-         */
498
-        if ($form_editor === 'default') {
499
-            global $xoopsModuleConfig;
500
-            $form_editor = isset($xoopsModuleConfig['default_editor']) ? $xoopsModuleConfig['default_editor'] : 'textarea';
501
-        }
502
-
503
-        $caption = $var['form_caption'];
504
-        $name    = $key;
505
-
506
-        $value = $this->targetObject->getVar($key);
507
-
508
-        $value = $this->targetObject->getValueFor($key, true);
509
-
510
-        $editor_configs          = array();
511
-        $editor_configs['name']  = $name;
512
-        $editor_configs['value'] = $value;
513
-        if ($form_editor !== 'textarea') {
514
-            $editor_configs['rows'] = 35;
515
-            $editor_configs['cols'] = 60;
516
-        }
517
-
518
-        if (isset($control['rows'])) {
519
-            $editor_configs['rows'] = $control['rows'];
520
-        }
521
-        if (isset($control['cols'])) {
522
-            $editor_configs['cols'] = $control['cols'];
523
-        }
524
-
525
-        $editor_configs['width']  = '100%';
526
-        $editor_configs['height'] = '400px';
527
-
528
-        $dhtml            = true;
529
-        $xoopseditorclass = XOOPS_ROOT_PATH . '/class/xoopsform/formeditor.php';
530
-
531
-        if (file_exists($xoopseditorclass)) {
532
-            include_once($xoopseditorclass);
533
-            $editor = new XoopsFormEditor($caption, $form_editor, $editor_configs, $nohtml = false, $onfailure = 'textarea');
534
-        } else {
535
-            switch ($form_editor) {
536
-
537
-                case 'tiny':
538
-                    if (!$xoops22) {
539
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php')) {
540
-                            include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php');
541
-                            $editor = new XoopsFormTinyTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
542
-                        } else {
543
-                            if ($dhtml) {
544
-                                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
545
-                            } else {
546
-                                $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
547
-                            }
548
-                        }
549
-                    } else {
550
-                        $editor = new XoopsFormEditor($caption, 'tinyeditor', $editor_configs);
551
-                    }
552
-                    break;
553
-
554
-                case 'dhtmltextarea':
555
-                case 'dhtmltext':
556
-                    $editor = new XoopsFormDhtmlTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), 20, 60);
557
-                    if ($var['form_dsc']) {
558
-                        $editor->setDescription($var['form_dsc']);
559
-                    }
560
-                    break;
561
-
562
-                case 'fckeditor':
563
-                    if (!$xoops22) {
564
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php')) {
565
-                            include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php');
566
-                            $editor = new XoopsFormFckeditor(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
567
-                        } else {
568
-                            if ($dhtml) {
569
-                                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
570
-                            } else {
571
-                                $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
572
-                            }
573
-                        }
574
-                    } else {
575
-                        $editor = new XoopsFormEditor($caption, 'fckeditor', $editor_configs);
576
-                    }
577
-                    break;
578
-
579
-                case 'inbetween':
580
-                    if (!$xoops22) {
581
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/inbetween/forminbetweentextarea.php')) {
582
-                            include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/inbetween/forminbetweentextarea.php');
583
-                            $editor = new XoopsFormInbetweenTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
584
-                        } else {
585
-                            if ($dhtml) {
586
-                                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
587
-                            } else {
588
-                                $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
589
-                            }
590
-                        }
591
-                    } else {
592
-                        $editor = new XoopsFormEditor($caption, 'inbetween', $editor_configs);
593
-                    }
594
-                    break;
595
-
596
-                case 'koivi':
597
-                    if (!$xoops22) {
598
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php')) {
599
-                            include_once(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php');
600
-                            $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '400px');
601
-                        } else {
602
-                            if ($dhtml) {
603
-                                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
604
-                            } else {
605
-                                $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
606
-                            }
607
-                        }
608
-                    } else {
609
-                        $editor = new XoopsFormEditor($caption, 'koivi', $editor_configs);
610
-                    }
611
-                    break;
612
-
613
-                case 'spaw':
614
-                    if (!$xoops22) {
615
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php')) {
616
-                            include_once(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php');
617
-                            $editor = new XoopsFormSpaw($caption, $name, $value);
618
-                        }
619
-                    } else {
620
-                        $editor = new XoopsFormEditor($caption, 'spaw', $editor_configs);
621
-                    }
622
-                    break;
623
-
624
-                case 'htmlarea':
625
-                    if (!$xoops22) {
626
-                        if (is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php')) {
627
-                            include_once(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php');
628
-                            $editor = new XoopsFormHtmlarea($caption, $name, $value);
629
-                        }
630
-                    } else {
631
-                        $editor = new XoopsFormEditor($caption, 'htmlarea', $editor_configs);
632
-                    }
633
-                    break;
634
-
635
-                default:
636
-                case 'textarea':
637
-                    $form_rows = isset($control['rows']) ? $control['rows'] : 5;
638
-                    $form_cols = isset($control['cols']) ? $control['cols'] : 60;
639
-
640
-                    $editor = new XoopsFormTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), $form_rows, $form_cols);
641
-                    if ($var['form_dsc']) {
642
-                        $editor->setDescription($var['form_dsc']);
643
-                    }
644
-                    break;
645
-
646
-            }
647
-        }
648
-
649
-        return $editor;
650
-    }
651
-
652
-    /**
653
-     * @param       $key
654
-     * @param       $var
655
-     * @param  bool $multiple
656
-     * @return XoopsFormSelect
657
-     */
658
-    public function getThemeSelect($key, $var, $multiple = false)
659
-    {
660
-        $size         = $multiple ? 5 : 1;
661
-        $theme_select = new XoopsFormSelect($var['form_caption'], $key, $this->targetObject->getVar($key), $size, $multiple);
662
-
663
-        $handle  = opendir(XOOPS_THEME_PATH . '/');
664
-        $dirlist = array();
665
-        while (false !== ($file = readdir($handle))) {
666
-            if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file) !== 'cvs') {
667
-                $dirlist[$file] = $file;
668
-            }
669
-        }
670
-        closedir($handle);
671
-        if (!empty($dirlist)) {
672
-            asort($dirlist);
673
-            $theme_select->addOptionArray($dirlist);
674
-        }
675
-
676
-        return $theme_select;
677
-    }
678
-
679
-    /**
680
-     * @param $keyname
681
-     * @return bool
682
-     */
683
-    public function &getElementById($keyname)
684
-    {
685
-        foreach ($this->_elements as $eleObj) {
686
-            if ($eleObj->getName() == $keyname) {
687
-                $ret =& $eleObj;
688
-                break;
689
-            }
690
-        }
691
-
692
-        return isset($ret) ? $ret : false;
693
-    }
694
-
695
-    /**
696
-     * create HTML to output the form as a theme-enabled table with validation.
697
-     *
698
-     * @return string
699
-     */
700
-    public function render()
701
-    {
702
-        $required = $this->getRequired();
703
-        $ret      = "
416
+			case 'user_multi':
417
+				return new XoopsFormSelectUser($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true);
418
+				break;
419
+
420
+			case 'password':
421
+				return new XoopsFormPassword($this->targetObject->vars[$key]['form_caption'], $key, 50, 255, $this->targetObject->getVar($key, 'e'));
422
+				break;
423
+
424
+			case 'country':
425
+				return new XoopsFormSelectCountry($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key, 'e'));
426
+				break;
427
+
428
+			case 'urllink':
429
+				include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformurllinkelement.php');
430
+
431
+				return new SmartFormUrlLinkElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getUrlLinkObj($key));
432
+				break;
433
+
434
+			case 'richfile':
435
+				include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformrichfileelement.php');
436
+
437
+				return new SmartFormRichFileElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getFileObj($key));
438
+				break;
439
+			case 'section':
440
+				include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/smartformsection.php');
441
+
442
+				return new SmartFormSection($key, $this->targetObject->vars[$key]['form_caption']);
443
+				break;
444
+
445
+			default:
446
+				$classname = 'SmartForm' . ucfirst($controlName) . 'Element';
447
+				if (!class_exists($classname)) {
448
+					if (file_exists(SMARTOBJECT_ROOT_PATH . 'class/form/elements/' . strtolower($classname) . '.php')) {
449
+						include_once(SMARTOBJECT_ROOT_PATH . 'class/form/elements/' . strtolower($classname) . '.php');
450
+					} else {
451
+						// perhaps this is a control created by the module
452
+						$moduleName             = $this->targetObject->handler->_moduleName;
453
+						$moduleFormElementsPath = $this->targetObject->handler->_modulePath . 'class/form/elements/';
454
+						$classname              = ucfirst($moduleName) . ucfirst($controlName) . 'Element';
455
+						$classFileName          = strtolower($classname) . '.php';
456
+
457
+						if (file_exists($moduleFormElementsPath . $classFileName)) {
458
+							include_once($moduleFormElementsPath . $classFileName);
459
+						} else {
460
+							trigger_error($classname . ' Not found', E_USER_WARNING);
461
+
462
+							return new XoopsFormLabel(); //Empty object
463
+						}
464
+					}
465
+				}
466
+
467
+				return new $classname($this->targetObject, $key);
468
+				break;
469
+		}
470
+	}
471
+
472
+	/**
473
+	 * @param $key
474
+	 * @return XoopsFormDhtmlTextArea|XoopsFormEditor|XoopsFormFckeditor|XoopsFormTextArea|XoopsFormTinyTextArea
475
+	 */
476
+	public function getTextArea($key)
477
+	{
478
+		$var = $this->targetObject->vars[$key];
479
+
480
+		// if no control has been created, let's create a default one
481
+		if (!isset($this->targetObject->controls[$key])) {
482
+			$control = array(
483
+				'name'        => 'textarea',
484
+				'itemHandler' => false,
485
+				'method'      => false,
486
+				'module'      => false,
487
+				'form_editor' => 'default'
488
+			);
489
+		} else {
490
+			$control = $this->targetObject->controls[$key];
491
+		}
492
+		$xoops22 = smart_isXoops22();
493
+
494
+		$form_editor = isset($control['form_editor']) ? $control['form_editor'] : 'textarea';
495
+		/**
496
+		 * If the editor is 'default', retreive the default editor of this module
497
+		 */
498
+		if ($form_editor === 'default') {
499
+			global $xoopsModuleConfig;
500
+			$form_editor = isset($xoopsModuleConfig['default_editor']) ? $xoopsModuleConfig['default_editor'] : 'textarea';
501
+		}
502
+
503
+		$caption = $var['form_caption'];
504
+		$name    = $key;
505
+
506
+		$value = $this->targetObject->getVar($key);
507
+
508
+		$value = $this->targetObject->getValueFor($key, true);
509
+
510
+		$editor_configs          = array();
511
+		$editor_configs['name']  = $name;
512
+		$editor_configs['value'] = $value;
513
+		if ($form_editor !== 'textarea') {
514
+			$editor_configs['rows'] = 35;
515
+			$editor_configs['cols'] = 60;
516
+		}
517
+
518
+		if (isset($control['rows'])) {
519
+			$editor_configs['rows'] = $control['rows'];
520
+		}
521
+		if (isset($control['cols'])) {
522
+			$editor_configs['cols'] = $control['cols'];
523
+		}
524
+
525
+		$editor_configs['width']  = '100%';
526
+		$editor_configs['height'] = '400px';
527
+
528
+		$dhtml            = true;
529
+		$xoopseditorclass = XOOPS_ROOT_PATH . '/class/xoopsform/formeditor.php';
530
+
531
+		if (file_exists($xoopseditorclass)) {
532
+			include_once($xoopseditorclass);
533
+			$editor = new XoopsFormEditor($caption, $form_editor, $editor_configs, $nohtml = false, $onfailure = 'textarea');
534
+		} else {
535
+			switch ($form_editor) {
536
+
537
+				case 'tiny':
538
+					if (!$xoops22) {
539
+						if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php')) {
540
+							include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinytextarea.php');
541
+							$editor = new XoopsFormTinyTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
542
+						} else {
543
+							if ($dhtml) {
544
+								$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
545
+							} else {
546
+								$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
547
+							}
548
+						}
549
+					} else {
550
+						$editor = new XoopsFormEditor($caption, 'tinyeditor', $editor_configs);
551
+					}
552
+					break;
553
+
554
+				case 'dhtmltextarea':
555
+				case 'dhtmltext':
556
+					$editor = new XoopsFormDhtmlTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), 20, 60);
557
+					if ($var['form_dsc']) {
558
+						$editor->setDescription($var['form_dsc']);
559
+					}
560
+					break;
561
+
562
+				case 'fckeditor':
563
+					if (!$xoops22) {
564
+						if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php')) {
565
+							include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php');
566
+							$editor = new XoopsFormFckeditor(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
567
+						} else {
568
+							if ($dhtml) {
569
+								$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
570
+							} else {
571
+								$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
572
+							}
573
+						}
574
+					} else {
575
+						$editor = new XoopsFormEditor($caption, 'fckeditor', $editor_configs);
576
+					}
577
+					break;
578
+
579
+				case 'inbetween':
580
+					if (!$xoops22) {
581
+						if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/inbetween/forminbetweentextarea.php')) {
582
+							include_once(XOOPS_ROOT_PATH . '/class/xoopseditor/inbetween/forminbetweentextarea.php');
583
+							$editor = new XoopsFormInbetweenTextArea(array('caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '300px'), true);
584
+						} else {
585
+							if ($dhtml) {
586
+								$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
587
+							} else {
588
+								$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
589
+							}
590
+						}
591
+					} else {
592
+						$editor = new XoopsFormEditor($caption, 'inbetween', $editor_configs);
593
+					}
594
+					break;
595
+
596
+				case 'koivi':
597
+					if (!$xoops22) {
598
+						if (is_readable(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php')) {
599
+							include_once(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php');
600
+							$editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '400px');
601
+						} else {
602
+							if ($dhtml) {
603
+								$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
604
+							} else {
605
+								$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
606
+							}
607
+						}
608
+					} else {
609
+						$editor = new XoopsFormEditor($caption, 'koivi', $editor_configs);
610
+					}
611
+					break;
612
+
613
+				case 'spaw':
614
+					if (!$xoops22) {
615
+						if (is_readable(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php')) {
616
+							include_once(XOOPS_ROOT_PATH . '/class/spaw/formspaw.php');
617
+							$editor = new XoopsFormSpaw($caption, $name, $value);
618
+						}
619
+					} else {
620
+						$editor = new XoopsFormEditor($caption, 'spaw', $editor_configs);
621
+					}
622
+					break;
623
+
624
+				case 'htmlarea':
625
+					if (!$xoops22) {
626
+						if (is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php')) {
627
+							include_once(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php');
628
+							$editor = new XoopsFormHtmlarea($caption, $name, $value);
629
+						}
630
+					} else {
631
+						$editor = new XoopsFormEditor($caption, 'htmlarea', $editor_configs);
632
+					}
633
+					break;
634
+
635
+				default:
636
+				case 'textarea':
637
+					$form_rows = isset($control['rows']) ? $control['rows'] : 5;
638
+					$form_cols = isset($control['cols']) ? $control['cols'] : 60;
639
+
640
+					$editor = new XoopsFormTextArea($var['form_caption'], $key, $this->targetObject->getVar($key, 'e'), $form_rows, $form_cols);
641
+					if ($var['form_dsc']) {
642
+						$editor->setDescription($var['form_dsc']);
643
+					}
644
+					break;
645
+
646
+			}
647
+		}
648
+
649
+		return $editor;
650
+	}
651
+
652
+	/**
653
+	 * @param       $key
654
+	 * @param       $var
655
+	 * @param  bool $multiple
656
+	 * @return XoopsFormSelect
657
+	 */
658
+	public function getThemeSelect($key, $var, $multiple = false)
659
+	{
660
+		$size         = $multiple ? 5 : 1;
661
+		$theme_select = new XoopsFormSelect($var['form_caption'], $key, $this->targetObject->getVar($key), $size, $multiple);
662
+
663
+		$handle  = opendir(XOOPS_THEME_PATH . '/');
664
+		$dirlist = array();
665
+		while (false !== ($file = readdir($handle))) {
666
+			if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}$/", $file) && strtolower($file) !== 'cvs') {
667
+				$dirlist[$file] = $file;
668
+			}
669
+		}
670
+		closedir($handle);
671
+		if (!empty($dirlist)) {
672
+			asort($dirlist);
673
+			$theme_select->addOptionArray($dirlist);
674
+		}
675
+
676
+		return $theme_select;
677
+	}
678
+
679
+	/**
680
+	 * @param $keyname
681
+	 * @return bool
682
+	 */
683
+	public function &getElementById($keyname)
684
+	{
685
+		foreach ($this->_elements as $eleObj) {
686
+			if ($eleObj->getName() == $keyname) {
687
+				$ret =& $eleObj;
688
+				break;
689
+			}
690
+		}
691
+
692
+		return isset($ret) ? $ret : false;
693
+	}
694
+
695
+	/**
696
+	 * create HTML to output the form as a theme-enabled table with validation.
697
+	 *
698
+	 * @return string
699
+	 */
700
+	public function render()
701
+	{
702
+		$required = $this->getRequired();
703
+		$ret      = "
704 704
             <form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "' onsubmit='return xoopsFormValidate_" . $this->getName() . "(this);'" . $this->getExtra() . ">
705 705
             <table width='100%' class='outer' cellspacing='1'>
706 706
             <tr><th colspan='2'>" . $this->getTitle() . '</th></tr>
707 707
         ';
708
-        $hidden   = '';
709
-        $class    = 'even';
710
-        foreach ($this->getElements() as $ele) {
711
-            if (!is_object($ele)) {
712
-                $ret .= $ele;
713
-            } elseif (!$ele->isHidden()) {
714
-                //$class = ( $class == 'even' ) ? 'odd': 'even';
715
-                $ret .= "<tr id='" . $ele->getName() . "' valign='top' align='left'><td class='head'>" . $ele->getCaption();
716
-                if ($ele->getDescription() != '') {
717
-                    $ret .= '<br /><br /><span style="font-weight: normal;">' . $ele->getDescription() . '</span>';
718
-                }
719
-                $ret .= "</td><td class='$class'>" . $ele->render() . "</td></tr>\n";
720
-            } else {
721
-                $hidden .= $ele->render();
722
-            }
723
-        }
724
-        $ret .= "</table>\n$hidden\n</form>\n";
725
-        $ret .= $this->renderValidationJS(true);
726
-
727
-        return $ret;
728
-    }
729
-
730
-    /**
731
-     * assign to smarty form template instead of displaying directly
732
-     *
733
-     * @param object &$tpl reference to a {@link Smarty} object
734
-     * @param bool   $smartyName
735
-     * @see     Smarty
736
-     */
737
-    public function assign(&$tpl, $smartyName = false)
738
-    {
739
-        $i        = 0;
740
-        $elements = array();
741
-        foreach ($this->getElements() as $ele) {
742
-            $n                             = ($ele->getName() != '') ? $ele->getName() : $i;
743
-            $elements[$n]['name']          = $ele->getName();
744
-            $elements[$n]['caption']       = $ele->getCaption();
745
-            $elements[$n]['body']          = $ele->render();
746
-            $elements[$n]['hidden']        = $ele->isHidden();
747
-            $elements[$n]['section']       = strtolower(get_class($ele)) == strtolower('SmartFormSection');
748
-            $elements[$n]['section_close'] = get_class($ele) === 'SmartFormSectionClose';
749
-            $elements[$n]['hide']          = isset($this->targetObject->vars[$n]['hide']) ? $this->targetObject->vars[$n]['hide'] : false;
750
-            if ($ele->getDescription() != '') {
751
-                $elements[$n]['description'] = $ele->getDescription();
752
-            }
753
-            ++$i;
754
-        }
755
-        $js = $this->renderValidationJS();
756
-        if (!$smartyName) {
757
-            $smartyName = $this->getName();
758
-        }
759
-
760
-        $tpl->assign($smartyName, array(
761
-            'title'      => $this->getTitle(),
762
-            'name'       => $this->getName(),
763
-            'action'     => $this->getAction(),
764
-            'method'     => $this->getMethod(),
765
-            'extra'      => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '(this);"' . $this->getExtra(),
766
-            'javascript' => $js,
767
-            'elements'   => $elements
768
-        ));
769
-    }
770
-
771
-    /**
772
-     * @param  bool $withtags
773
-     * @return string
774
-     */
775
-    public function renderValidationJS($withtags = true)
776
-    {
777
-        $js = '';
778
-        if ($withtags) {
779
-            $js .= "\n<!-- Start Form Validation JavaScript //-->\n<script type='text/javascript'>\n<!--//\n";
780
-        }
781
-        $myts     = MyTextSanitizer::getInstance();
782
-        $formname = $this->getName();
783
-        $js .= "function xoopsFormValidate_{$formname}(myform) {";
784
-        // First, output code to check required elements
785
-        $elements =& $this->getRequired();
786
-        foreach ($elements as $elt) {
787
-            $eltname    = $elt->getName();
788
-            $eltcaption = trim($elt->getCaption());
789
-            $eltmsg     = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption);
790
-            $eltmsg     = str_replace('"', '\"', stripslashes($eltmsg));
791
-            if (strtolower(get_class($elt)) === 'xoopsformradio') {
792
-                $js .= 'var myOption = -1;';
793
-                $js .= "for (i=myform.{$eltname}.length-1; i > -1; i--) {
708
+		$hidden   = '';
709
+		$class    = 'even';
710
+		foreach ($this->getElements() as $ele) {
711
+			if (!is_object($ele)) {
712
+				$ret .= $ele;
713
+			} elseif (!$ele->isHidden()) {
714
+				//$class = ( $class == 'even' ) ? 'odd': 'even';
715
+				$ret .= "<tr id='" . $ele->getName() . "' valign='top' align='left'><td class='head'>" . $ele->getCaption();
716
+				if ($ele->getDescription() != '') {
717
+					$ret .= '<br /><br /><span style="font-weight: normal;">' . $ele->getDescription() . '</span>';
718
+				}
719
+				$ret .= "</td><td class='$class'>" . $ele->render() . "</td></tr>\n";
720
+			} else {
721
+				$hidden .= $ele->render();
722
+			}
723
+		}
724
+		$ret .= "</table>\n$hidden\n</form>\n";
725
+		$ret .= $this->renderValidationJS(true);
726
+
727
+		return $ret;
728
+	}
729
+
730
+	/**
731
+	 * assign to smarty form template instead of displaying directly
732
+	 *
733
+	 * @param object &$tpl reference to a {@link Smarty} object
734
+	 * @param bool   $smartyName
735
+	 * @see     Smarty
736
+	 */
737
+	public function assign(&$tpl, $smartyName = false)
738
+	{
739
+		$i        = 0;
740
+		$elements = array();
741
+		foreach ($this->getElements() as $ele) {
742
+			$n                             = ($ele->getName() != '') ? $ele->getName() : $i;
743
+			$elements[$n]['name']          = $ele->getName();
744
+			$elements[$n]['caption']       = $ele->getCaption();
745
+			$elements[$n]['body']          = $ele->render();
746
+			$elements[$n]['hidden']        = $ele->isHidden();
747
+			$elements[$n]['section']       = strtolower(get_class($ele)) == strtolower('SmartFormSection');
748
+			$elements[$n]['section_close'] = get_class($ele) === 'SmartFormSectionClose';
749
+			$elements[$n]['hide']          = isset($this->targetObject->vars[$n]['hide']) ? $this->targetObject->vars[$n]['hide'] : false;
750
+			if ($ele->getDescription() != '') {
751
+				$elements[$n]['description'] = $ele->getDescription();
752
+			}
753
+			++$i;
754
+		}
755
+		$js = $this->renderValidationJS();
756
+		if (!$smartyName) {
757
+			$smartyName = $this->getName();
758
+		}
759
+
760
+		$tpl->assign($smartyName, array(
761
+			'title'      => $this->getTitle(),
762
+			'name'       => $this->getName(),
763
+			'action'     => $this->getAction(),
764
+			'method'     => $this->getMethod(),
765
+			'extra'      => 'onsubmit="return xoopsFormValidate_' . $this->getName() . '(this);"' . $this->getExtra(),
766
+			'javascript' => $js,
767
+			'elements'   => $elements
768
+		));
769
+	}
770
+
771
+	/**
772
+	 * @param  bool $withtags
773
+	 * @return string
774
+	 */
775
+	public function renderValidationJS($withtags = true)
776
+	{
777
+		$js = '';
778
+		if ($withtags) {
779
+			$js .= "\n<!-- Start Form Validation JavaScript //-->\n<script type='text/javascript'>\n<!--//\n";
780
+		}
781
+		$myts     = MyTextSanitizer::getInstance();
782
+		$formname = $this->getName();
783
+		$js .= "function xoopsFormValidate_{$formname}(myform) {";
784
+		// First, output code to check required elements
785
+		$elements =& $this->getRequired();
786
+		foreach ($elements as $elt) {
787
+			$eltname    = $elt->getName();
788
+			$eltcaption = trim($elt->getCaption());
789
+			$eltmsg     = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption);
790
+			$eltmsg     = str_replace('"', '\"', stripslashes($eltmsg));
791
+			if (strtolower(get_class($elt)) === 'xoopsformradio') {
792
+				$js .= 'var myOption = -1;';
793
+				$js .= "for (i=myform.{$eltname}.length-1; i > -1; i--) {
794 794
                     if (myform.{$eltname}[i].checked) {
795 795
                         myOption = i; i = -1;
796 796
                     }
797 797
                 }
798 798
                 if (myOption == -1) {
799 799
                     window.alert(\"{$eltmsg}\"); myform.{$eltname}[0].focus(); return false; }\n";
800
-            } elseif (strtolower(get_class($elt)) === 'smartformselect_multielement') {
801
-                $js .= 'var hasSelections = false;';
802
-                $js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) {
800
+			} elseif (strtolower(get_class($elt)) === 'smartformselect_multielement') {
801
+				$js .= 'var hasSelections = false;';
802
+				$js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) {
803 803
                     if (myform['{$eltname}[]'].options[i].selected) {
804 804
                         hasSelections = true;
805 805
                     }
@@ -807,11 +807,11 @@  discard block
 block discarded – undo
807 807
                 }
808 808
                 if (hasSelections == false) {
809 809
                     window.alert(\"{$eltmsg}\"); myform['{$eltname}[]'].options[0].focus(); return false; }\n";
810
-            } elseif (strtolower(get_class($elt)) === 'xoopsformcheckbox' || strtolower(get_class($elt)) === 'smartformcheckelement') {
811
-                $js .= 'var hasSelections = false;';
812
-                //sometimes, there is an implicit '[]', sometimes not
813
-                if (strpos($eltname, '[') === false) {
814
-                    $js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) {
810
+			} elseif (strtolower(get_class($elt)) === 'xoopsformcheckbox' || strtolower(get_class($elt)) === 'smartformcheckelement') {
811
+				$js .= 'var hasSelections = false;';
812
+				//sometimes, there is an implicit '[]', sometimes not
813
+				if (strpos($eltname, '[') === false) {
814
+					$js .= "for (var i = 0; i < myform['{$eltname}[]'].length; i++) {
815 815
                         if (myform['{$eltname}[]'][i].checked) {
816 816
                             hasSelections = true;
817 817
                         }
@@ -819,8 +819,8 @@  discard block
 block discarded – undo
819 819
                     }
820 820
                     if (hasSelections == false) {
821 821
                         window.alert(\"{$eltmsg}\"); myform['{$eltname}[]'][0].focus(); return false; }\n";
822
-                } else {
823
-                    $js .= "for (var i = 0; i < myform['{$eltname}'].length; i++) {
822
+				} else {
823
+					$js .= "for (var i = 0; i < myform['{$eltname}'].length; i++) {
824 824
                         if (myform['{$eltname}'][i].checked) {
825 825
                             hasSelections = true;
826 826
                         }
@@ -828,25 +828,25 @@  discard block
 block discarded – undo
828 828
                     }
829 829
                     if (hasSelections == false) {
830 830
                         window.alert(\"{$eltmsg}\"); myform['{$eltname}'][0].focus(); return false; }\n";
831
-                }
832
-            } else {
833
-                $js .= "if ( myform.{$eltname}.value == \"\" ) " . "{ window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }\n";
834
-            }
835
-        }
836
-        // Now, handle custom validation code
837
-        $elements =& $this->getElements(true);
838
-        foreach ($elements as $elt) {
839
-            if (method_exists($elt, 'renderValidationJS') && strtolower(get_class($elt)) !== 'xoopsformcheckbox') {
840
-                if ($eltjs = $elt->renderValidationJS()) {
841
-                    $js .= $eltjs . "\n";
842
-                }
843
-            }
844
-        }
845
-        $js .= "return true;\n}\n";
846
-        if ($withtags) {
847
-            $js .= "//--></script>\n<!-- 'End Form Validation JavaScript' //-->\n";
848
-        }
849
-
850
-        return $js;
851
-    }
831
+				}
832
+			} else {
833
+				$js .= "if ( myform.{$eltname}.value == \"\" ) " . "{ window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }\n";
834
+			}
835
+		}
836
+		// Now, handle custom validation code
837
+		$elements =& $this->getElements(true);
838
+		foreach ($elements as $elt) {
839
+			if (method_exists($elt, 'renderValidationJS') && strtolower(get_class($elt)) !== 'xoopsformcheckbox') {
840
+				if ($eltjs = $elt->renderValidationJS()) {
841
+					$js .= $eltjs . "\n";
842
+				}
843
+			}
844
+		}
845
+		$js .= "return true;\n}\n";
846
+		if ($withtags) {
847
+			$js .= "//--></script>\n<!-- 'End Form Validation JavaScript' //-->\n";
848
+		}
849
+
850
+		return $js;
851
+	}
852 852
 }
Please login to merge, or discard this patch.
class/customtag.php 1 patch
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -36,154 +36,154 @@  discard block
 block discarded – undo
36 36
  */
37 37
 class SmartobjectCustomtag extends SmartObject
38 38
 {
39
-    public $content = false;
40
-
41
-    /**
42
-     * SmartobjectCustomtag constructor.
43
-     */
44
-    public function __construct()
45
-    {
46
-        $this->quickInitVar('customtagid', XOBJ_DTYPE_INT, true);
47
-        $this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_NAME, _CO_SOBJECT_CUSTOMTAG_NAME_DSC);
48
-        $this->quickInitVar('description', XOBJ_DTYPE_TXTAREA, false, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION_DSC);
49
-        $this->quickInitVar('content', XOBJ_DTYPE_TXTAREA, true, _CO_SOBJECT_CUSTOMTAG_CONTENT, _CO_SOBJECT_CUSTOMTAG_CONTENT_DSC);
50
-        $this->quickInitVar('language', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_LANGUAGE, _CO_SOBJECT_CUSTOMTAG_LANGUAGE_DSC);
51
-
52
-        $this->initNonPersistableVar('dohtml', XOBJ_DTYPE_INT, 'class', 'dohtml', '', true);
53
-        $this->initNonPersistableVar('doimage', XOBJ_DTYPE_INT, 'class', 'doimage', '', true);
54
-        $this->initNonPersistableVar('doxcode', XOBJ_DTYPE_INT, 'class', 'doxcode', '', true);
55
-        $this->initNonPersistableVar('dosmiley', XOBJ_DTYPE_INT, 'class', 'dosmiley', '', true);
56
-
57
-        $this->setControl('content', array(
58
-            'name'        => 'textarea',
59
-            'form_editor' => 'textarea',
60
-            'form_rows'   => 25
61
-        ));
62
-        $this->setControl('language', array(
63
-            'name' => 'language',
64
-            'all'  => true
65
-        ));
66
-    }
67
-
68
-    /**
69
-     * @param  string $key
70
-     * @param  string $format
71
-     * @return mixed
72
-     */
73
-    public function getVar($key, $format = 's')
74
-    {
75
-        if ($format === 's' && in_array($key, array())) {
76
-            //            return call_user_func(array($this, $key));
77
-            return $this->{$key}();
78
-        }
79
-
80
-        return parent::getVar($key, $format);
81
-    }
82
-
83
-    /**
84
-     * @return bool|mixed
85
-     */
86
-    public function render()
87
-    {
88
-        if (!$this->content) {
89
-            $ret           = $this->getVar('content');
90
-            $this->content = $ret;
91
-        }
92
-
93
-        return $this->content;
94
-    }
95
-
96
-    /**
97
-     * @return bool|mixed|string
98
-     */
99
-    public function renderWithPhp()
100
-    {
101
-        if (!$this->content) {
102
-            $ret           = $this->getVar('content');
103
-            $this->content = $ret;
104
-        } else {
105
-            $ret = $this->content;
106
-        }
107
-
108
-        // check for PHP if we are not on admin side
109
-        if (!defined('XOOPS_CPFUNC_LOADED') && !(strpos($ret, '[php]') === false)) {
110
-            $ret = str_replace('[php]', '', $ret);
111
-            // we have PHP code, let's evaluate
112
-            eval($ret);
113
-
114
-            return '';
115
-        }
116
-
117
-        return $this->content;
118
-    }
119
-
120
-    /**
121
-     * @return string
122
-     */
123
-    public function getXoopsCode()
124
-    {
125
-        $ret = '[customtag]' . $this->getVar('tag', 'n') . '[/customtag]';
126
-
127
-        return $ret;
128
-    }
129
-
130
-    /**
131
-     * @return string
132
-     */
133
-    public function getCloneLink()
134
-    {
135
-        $ret = '<a href="' . SMARTOBJECT_URL . 'admin/customtag.php?op=clone&customtagid=' . $this->id() . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" style="vertical-align: middle;" alt="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '" title="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '" /></a>';
136
-
137
-        return $ret;
138
-    }
139
-
140
-    /**
141
-     * @param $var
142
-     * @return bool
143
-     */
144
-    public function emptyString($var)
145
-    {
146
-        return (strlen($var) > 0);
147
-    }
148
-
149
-    /**
150
-     * @return mixed|string
151
-     */
152
-    public function generateTag()
153
-    {
154
-        $title = rawurlencode(strtolower($this->getVar('description', 'e')));
155
-        $title = xoops_substr($title, 0, 10, '');
156
-        // Transformation des ponctuations
157
-        //                 Tab     Space      !        "        #        %        &        '        (        )        ,        /       :        ;        <        =        >        ?        @        [        \        ]        ^        {        |        }        ~       .
158
-        $pattern = array('/%09/', '/%20/', '/%21/', '/%22/', '/%23/', '/%25/', '/%26/', '/%27/', '/%28/', '/%29/', '/%2C/', '/%2F/', '/%3A/', '/%3B/', '/%3C/', '/%3D/', '/%3E/', '/%3F/', '/%40/', '/%5B/', '/%5C/', '/%5D/', '/%5E/', '/%7B/', '/%7C/', '/%7D/', '/%7E/', "/\./");
159
-        $rep_pat = array('-', '-', '-', '-', '-', '-100', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-at-', '-', '-', '-', '-', '-', '-', '-', '-', '-');
160
-        $title   = preg_replace($pattern, $rep_pat, $title);
161
-
162
-        // Transformation des caract�res accentu�s
163
-        //                  °        è        é        ê        ë        ç        à        â        ä        î        ï        ù        ü        û        ô        ö
164
-        $pattern = array('/%B0/', '/%E8/', '/%E9/', '/%EA/', '/%EB/', '/%E7/', '/%E0/', '/%E2/', '/%E4/', '/%EE/', '/%EF/', '/%F9/', '/%FC/', '/%FB/', '/%F4/', '/%F6/');
165
-        $rep_pat = array('-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o');
166
-        $title   = preg_replace($pattern, $rep_pat, $title);
167
-
168
-        $tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau
169
-        $tableau = array_filter($tableau, array($this, 'emptyString')); // Supprime les chaines vides du tableau
170
-        $title   = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret
171
-
172
-        $title = $title . time();
173
-        $title = md5($title);
174
-
175
-        return $title;
176
-    }
177
-
178
-    /**
179
-     * @return mixed
180
-     */
181
-    public function getCustomtagName()
182
-    {
183
-        $ret = $this->getVar('name');
184
-
185
-        return $ret;
186
-    }
39
+	public $content = false;
40
+
41
+	/**
42
+	 * SmartobjectCustomtag constructor.
43
+	 */
44
+	public function __construct()
45
+	{
46
+		$this->quickInitVar('customtagid', XOBJ_DTYPE_INT, true);
47
+		$this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_NAME, _CO_SOBJECT_CUSTOMTAG_NAME_DSC);
48
+		$this->quickInitVar('description', XOBJ_DTYPE_TXTAREA, false, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION_DSC);
49
+		$this->quickInitVar('content', XOBJ_DTYPE_TXTAREA, true, _CO_SOBJECT_CUSTOMTAG_CONTENT, _CO_SOBJECT_CUSTOMTAG_CONTENT_DSC);
50
+		$this->quickInitVar('language', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_LANGUAGE, _CO_SOBJECT_CUSTOMTAG_LANGUAGE_DSC);
51
+
52
+		$this->initNonPersistableVar('dohtml', XOBJ_DTYPE_INT, 'class', 'dohtml', '', true);
53
+		$this->initNonPersistableVar('doimage', XOBJ_DTYPE_INT, 'class', 'doimage', '', true);
54
+		$this->initNonPersistableVar('doxcode', XOBJ_DTYPE_INT, 'class', 'doxcode', '', true);
55
+		$this->initNonPersistableVar('dosmiley', XOBJ_DTYPE_INT, 'class', 'dosmiley', '', true);
56
+
57
+		$this->setControl('content', array(
58
+			'name'        => 'textarea',
59
+			'form_editor' => 'textarea',
60
+			'form_rows'   => 25
61
+		));
62
+		$this->setControl('language', array(
63
+			'name' => 'language',
64
+			'all'  => true
65
+		));
66
+	}
67
+
68
+	/**
69
+	 * @param  string $key
70
+	 * @param  string $format
71
+	 * @return mixed
72
+	 */
73
+	public function getVar($key, $format = 's')
74
+	{
75
+		if ($format === 's' && in_array($key, array())) {
76
+			//            return call_user_func(array($this, $key));
77
+			return $this->{$key}();
78
+		}
79
+
80
+		return parent::getVar($key, $format);
81
+	}
82
+
83
+	/**
84
+	 * @return bool|mixed
85
+	 */
86
+	public function render()
87
+	{
88
+		if (!$this->content) {
89
+			$ret           = $this->getVar('content');
90
+			$this->content = $ret;
91
+		}
92
+
93
+		return $this->content;
94
+	}
95
+
96
+	/**
97
+	 * @return bool|mixed|string
98
+	 */
99
+	public function renderWithPhp()
100
+	{
101
+		if (!$this->content) {
102
+			$ret           = $this->getVar('content');
103
+			$this->content = $ret;
104
+		} else {
105
+			$ret = $this->content;
106
+		}
107
+
108
+		// check for PHP if we are not on admin side
109
+		if (!defined('XOOPS_CPFUNC_LOADED') && !(strpos($ret, '[php]') === false)) {
110
+			$ret = str_replace('[php]', '', $ret);
111
+			// we have PHP code, let's evaluate
112
+			eval($ret);
113
+
114
+			return '';
115
+		}
116
+
117
+		return $this->content;
118
+	}
119
+
120
+	/**
121
+	 * @return string
122
+	 */
123
+	public function getXoopsCode()
124
+	{
125
+		$ret = '[customtag]' . $this->getVar('tag', 'n') . '[/customtag]';
126
+
127
+		return $ret;
128
+	}
129
+
130
+	/**
131
+	 * @return string
132
+	 */
133
+	public function getCloneLink()
134
+	{
135
+		$ret = '<a href="' . SMARTOBJECT_URL . 'admin/customtag.php?op=clone&customtagid=' . $this->id() . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" style="vertical-align: middle;" alt="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '" title="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '" /></a>';
136
+
137
+		return $ret;
138
+	}
139
+
140
+	/**
141
+	 * @param $var
142
+	 * @return bool
143
+	 */
144
+	public function emptyString($var)
145
+	{
146
+		return (strlen($var) > 0);
147
+	}
148
+
149
+	/**
150
+	 * @return mixed|string
151
+	 */
152
+	public function generateTag()
153
+	{
154
+		$title = rawurlencode(strtolower($this->getVar('description', 'e')));
155
+		$title = xoops_substr($title, 0, 10, '');
156
+		// Transformation des ponctuations
157
+		//                 Tab     Space      !        "        #        %        &        '        (        )        ,        /       :        ;        <        =        >        ?        @        [        \        ]        ^        {        |        }        ~       .
158
+		$pattern = array('/%09/', '/%20/', '/%21/', '/%22/', '/%23/', '/%25/', '/%26/', '/%27/', '/%28/', '/%29/', '/%2C/', '/%2F/', '/%3A/', '/%3B/', '/%3C/', '/%3D/', '/%3E/', '/%3F/', '/%40/', '/%5B/', '/%5C/', '/%5D/', '/%5E/', '/%7B/', '/%7C/', '/%7D/', '/%7E/', "/\./");
159
+		$rep_pat = array('-', '-', '-', '-', '-', '-100', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-at-', '-', '-', '-', '-', '-', '-', '-', '-', '-');
160
+		$title   = preg_replace($pattern, $rep_pat, $title);
161
+
162
+		// Transformation des caract�res accentu�s
163
+		//                  °        è        é        ê        ë        ç        à        â        ä        î        ï        ù        ü        û        ô        ö
164
+		$pattern = array('/%B0/', '/%E8/', '/%E9/', '/%EA/', '/%EB/', '/%E7/', '/%E0/', '/%E2/', '/%E4/', '/%EE/', '/%EF/', '/%F9/', '/%FC/', '/%FB/', '/%F4/', '/%F6/');
165
+		$rep_pat = array('-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o');
166
+		$title   = preg_replace($pattern, $rep_pat, $title);
167
+
168
+		$tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau
169
+		$tableau = array_filter($tableau, array($this, 'emptyString')); // Supprime les chaines vides du tableau
170
+		$title   = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret
171
+
172
+		$title = $title . time();
173
+		$title = md5($title);
174
+
175
+		return $title;
176
+	}
177
+
178
+	/**
179
+	 * @return mixed
180
+	 */
181
+	public function getCustomtagName()
182
+	{
183
+		$ret = $this->getVar('name');
184
+
185
+		return $ret;
186
+	}
187 187
 }
188 188
 
189 189
 /**
@@ -191,48 +191,48 @@  discard block
 block discarded – undo
191 191
  */
192 192
 class SmartobjectCustomtagHandler extends SmartPersistableObjectHandler
193 193
 {
194
-    public $objects = false;
195
-
196
-    /**
197
-     * SmartobjectCustomtagHandler constructor.
198
-     * @param object|XoopsDatabase $db
199
-     */
200
-    public function __construct($db)
201
-    {
202
-        parent::__construct($db, 'customtag', 'customtagid', 'name', 'description', 'smartobject');
203
-        $this->addPermission('view', _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW, _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW_DSC);
204
-    }
205
-
206
-    /**
207
-     * @return array|bool
208
-     */
209
-    public function getCustomtagsByName()
210
-    {
211
-        if (!$this->objects) {
212
-            global $xoopsConfig;
213
-
214
-            $ret = array();
215
-
216
-            $criteria = new CriteriaCompo();
217
-
218
-            $criteria_language = new CriteriaCompo();
219
-            $criteria_language->add(new Criteria('language', $xoopsConfig['language']));
220
-            $criteria_language->add(new Criteria('language', 'all'), 'OR');
221
-            $criteria->add($criteria_language);
222
-
223
-            $smartobjectPermissionsHandler = new SmartObjectPermissionHandler($this);
224
-            $granted_ids                     = $smartobjectPermissionsHandler->getGrantedItems('view');
225
-
226
-            if ($granted_ids && count($granted_ids) > 0) {
227
-                $criteria->add(new Criteria('customtagid', '(' . implode(', ', $granted_ids) . ')', 'IN'));
228
-                $customtagsObj = $this->getObjects($criteria, true);
229
-                foreach ($customtagsObj as $customtagObj) {
230
-                    $ret[$customtagObj->getVar('name')] = $customtagObj;
231
-                }
232
-            }
233
-            $this->objects = $ret;
234
-        }
235
-
236
-        return $this->objects;
237
-    }
194
+	public $objects = false;
195
+
196
+	/**
197
+	 * SmartobjectCustomtagHandler constructor.
198
+	 * @param object|XoopsDatabase $db
199
+	 */
200
+	public function __construct($db)
201
+	{
202
+		parent::__construct($db, 'customtag', 'customtagid', 'name', 'description', 'smartobject');
203
+		$this->addPermission('view', _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW, _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW_DSC);
204
+	}
205
+
206
+	/**
207
+	 * @return array|bool
208
+	 */
209
+	public function getCustomtagsByName()
210
+	{
211
+		if (!$this->objects) {
212
+			global $xoopsConfig;
213
+
214
+			$ret = array();
215
+
216
+			$criteria = new CriteriaCompo();
217
+
218
+			$criteria_language = new CriteriaCompo();
219
+			$criteria_language->add(new Criteria('language', $xoopsConfig['language']));
220
+			$criteria_language->add(new Criteria('language', 'all'), 'OR');
221
+			$criteria->add($criteria_language);
222
+
223
+			$smartobjectPermissionsHandler = new SmartObjectPermissionHandler($this);
224
+			$granted_ids                     = $smartobjectPermissionsHandler->getGrantedItems('view');
225
+
226
+			if ($granted_ids && count($granted_ids) > 0) {
227
+				$criteria->add(new Criteria('customtagid', '(' . implode(', ', $granted_ids) . ')', 'IN'));
228
+				$customtagsObj = $this->getObjects($criteria, true);
229
+				foreach ($customtagsObj as $customtagObj) {
230
+					$ret[$customtagObj->getVar('name')] = $customtagObj;
231
+				}
232
+			}
233
+			$this->objects = $ret;
234
+		}
235
+
236
+		return $this->objects;
237
+	}
238 238
 }
Please login to merge, or discard this patch.
class/user.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@
 block discarded – undo
30 30
 // ------------------------------------------------------------------------- //
31 31
 // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
32 32
 /**
33
- * Class for users
34
- * @author    Kazumi Ono <[email protected]>
35
- * @copyright copyright (c) 2000-2003 XOOPS.org
36
- * @package   kernel
37
- */
33
+	 * Class for users
34
+	 * @author    Kazumi Ono <[email protected]>
35
+	 * @copyright copyright (c) 2000-2003 XOOPS.org
36
+	 * @package   kernel
37
+	 */
38 38
 class SmartobjectUser extends XoopsUser
39 39
 {
40 40
 }
Please login to merge, or discard this patch.
class/basedurl.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -36,29 +36,29 @@
 block discarded – undo
36 36
  */
37 37
 class SmartobjectBasedUrl extends SmartObject
38 38
 {
39
-    /**
40
-     * SmartobjectBasedUrl constructor.
41
-     */
42
-    public function __construct()
43
-    {
44
-        $this->quickInitVar('caption', XOBJ_DTYPE_TXTBOX, false);
45
-        $this->quickInitVar('description', XOBJ_DTYPE_TXTBOX, false);
46
-        $this->quickInitVar('url', XOBJ_DTYPE_TXTBOX, false);
47
-    }
39
+	/**
40
+	 * SmartobjectBasedUrl constructor.
41
+	 */
42
+	public function __construct()
43
+	{
44
+		$this->quickInitVar('caption', XOBJ_DTYPE_TXTBOX, false);
45
+		$this->quickInitVar('description', XOBJ_DTYPE_TXTBOX, false);
46
+		$this->quickInitVar('url', XOBJ_DTYPE_TXTBOX, false);
47
+	}
48 48
 
49
-    /**
50
-     * @param  string $key
51
-     * @param  string $format
52
-     * @return mixed
53
-     */
54
-    public function getVar($key, $format = 'e')
55
-    {
56
-        if (0 === strpos($key, 'url_')) {
57
-            return parent::getVar('url', $format);
58
-        } elseif (0 === strpos($key, 'caption_')) {
59
-            return parent::getVar('caption', $format);
60
-        } else {
61
-            return parent::getVar($key, $format);
62
-        }
63
-    }
49
+	/**
50
+	 * @param  string $key
51
+	 * @param  string $format
52
+	 * @return mixed
53
+	 */
54
+	public function getVar($key, $format = 'e')
55
+	{
56
+		if (0 === strpos($key, 'url_')) {
57
+			return parent::getVar('url', $format);
58
+		} elseif (0 === strpos($key, 'caption_')) {
59
+			return parent::getVar('caption', $format);
60
+		} else {
61
+			return parent::getVar($key, $format);
62
+		}
63
+	}
64 64
 }
Please login to merge, or discard this patch.
class/currency.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -37,115 +37,115 @@  discard block
 block discarded – undo
37 37
  */
38 38
 class SmartobjectCurrency extends SmartObject
39 39
 {
40
-    public $_modulePlugin = false;
41
-
42
-    /**
43
-     * SmartobjectCurrency constructor.
44
-     */
45
-    public function __construct()
46
-    {
47
-        $this->quickInitVar('currencyid', XOBJ_DTYPE_INT, true);
48
-        $this->quickInitVar('iso4217', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_ISO4217, _CO_SOBJECT_CURRENCY_ISO4217_DSC);
49
-        $this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_NAME);
50
-        $this->quickInitVar('symbol', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_SYMBOL);
51
-        $this->quickInitVar('rate', XOBJ_DTYPE_FLOAT, true, _CO_SOBJECT_CURRENCY_RATE, '', '1.0');
52
-        $this->quickInitVar('default_currency', XOBJ_DTYPE_INT, false, _CO_SOBJECT_CURRENCY_DEFAULT, '', false);
53
-
54
-        $this->setControl('symbol', array(
55
-            'name'      => 'text',
56
-            'size'      => '15',
57
-            'maxlength' => '15'
58
-        ));
59
-
60
-        $this->setControl('iso4217', array(
61
-            'name'      => 'text',
62
-            'size'      => '5',
63
-            'maxlength' => '5'
64
-        ));
65
-
66
-        $this->setControl('rate', array(
67
-            'name'      => 'text',
68
-            'size'      => '5',
69
-            'maxlength' => '5'
70
-        ));
71
-
72
-        $this->setControl('rate', array(
73
-            'name'      => 'text',
74
-            'size'      => '5',
75
-            'maxlength' => '5'
76
-        ));
77
-
78
-        $this->hideFieldFromForm('default_currency');
79
-    }
80
-
81
-    /**
82
-     * @param  string $key
83
-     * @param  string $format
84
-     * @return mixed
85
-     */
86
-    public function getVar($key, $format = 's')
87
-    {
88
-        if ($format === 's' && in_array($key, array('rate', 'default_currency'))) {
89
-            //            return call_user_func(array($this, $key));
90
-            return $this->{$key}();
91
-        }
92
-
93
-        return parent::getVar($key, $format);
94
-    }
95
-
96
-    /**
97
-     * @return mixed
98
-     */
99
-    public function getCurrencyLink()
100
-    {
101
-        $ret = $this->getVar('name', 'e');
102
-
103
-        return $ret;
104
-    }
105
-
106
-    /**
107
-     * @return mixed
108
-     */
109
-    public function getCode()
110
-    {
111
-        $ret = $this->getVar('iso4217', 'e');
112
-
113
-        return $ret;
114
-    }
115
-
116
-    /**
117
-     * @return float|int|mixed|string
118
-     */
119
-    public function rate()
120
-    {
121
-        return smart_currency($this->getVar('rate', 'e'));
122
-    }
123
-
124
-    /**
125
-     * @return string
126
-     */
127
-    public function defaultCurrency()
128
-    {
129
-        if ($this->getVar('default_currency', 'e') == true) {
130
-            return _YES;
131
-        } else {
132
-            return _NO;
133
-        }
134
-    }
135
-
136
-    /**
137
-     * @return string
138
-     */
139
-    public function getDefaultCurrencyControl()
140
-    {
141
-        $radio_box = '<input name="default_currency" value="' . $this->getVar('currencyid') . '" type="radio"';
142
-        if ($this->getVar('default_currency', 'e')) {
143
-            $radio_box .= 'checked="checked"';
144
-        }
145
-        $radio_box .= '>';
146
-
147
-        return $radio_box;
148
-    }
40
+	public $_modulePlugin = false;
41
+
42
+	/**
43
+	 * SmartobjectCurrency constructor.
44
+	 */
45
+	public function __construct()
46
+	{
47
+		$this->quickInitVar('currencyid', XOBJ_DTYPE_INT, true);
48
+		$this->quickInitVar('iso4217', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_ISO4217, _CO_SOBJECT_CURRENCY_ISO4217_DSC);
49
+		$this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_NAME);
50
+		$this->quickInitVar('symbol', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CURRENCY_SYMBOL);
51
+		$this->quickInitVar('rate', XOBJ_DTYPE_FLOAT, true, _CO_SOBJECT_CURRENCY_RATE, '', '1.0');
52
+		$this->quickInitVar('default_currency', XOBJ_DTYPE_INT, false, _CO_SOBJECT_CURRENCY_DEFAULT, '', false);
53
+
54
+		$this->setControl('symbol', array(
55
+			'name'      => 'text',
56
+			'size'      => '15',
57
+			'maxlength' => '15'
58
+		));
59
+
60
+		$this->setControl('iso4217', array(
61
+			'name'      => 'text',
62
+			'size'      => '5',
63
+			'maxlength' => '5'
64
+		));
65
+
66
+		$this->setControl('rate', array(
67
+			'name'      => 'text',
68
+			'size'      => '5',
69
+			'maxlength' => '5'
70
+		));
71
+
72
+		$this->setControl('rate', array(
73
+			'name'      => 'text',
74
+			'size'      => '5',
75
+			'maxlength' => '5'
76
+		));
77
+
78
+		$this->hideFieldFromForm('default_currency');
79
+	}
80
+
81
+	/**
82
+	 * @param  string $key
83
+	 * @param  string $format
84
+	 * @return mixed
85
+	 */
86
+	public function getVar($key, $format = 's')
87
+	{
88
+		if ($format === 's' && in_array($key, array('rate', 'default_currency'))) {
89
+			//            return call_user_func(array($this, $key));
90
+			return $this->{$key}();
91
+		}
92
+
93
+		return parent::getVar($key, $format);
94
+	}
95
+
96
+	/**
97
+	 * @return mixed
98
+	 */
99
+	public function getCurrencyLink()
100
+	{
101
+		$ret = $this->getVar('name', 'e');
102
+
103
+		return $ret;
104
+	}
105
+
106
+	/**
107
+	 * @return mixed
108
+	 */
109
+	public function getCode()
110
+	{
111
+		$ret = $this->getVar('iso4217', 'e');
112
+
113
+		return $ret;
114
+	}
115
+
116
+	/**
117
+	 * @return float|int|mixed|string
118
+	 */
119
+	public function rate()
120
+	{
121
+		return smart_currency($this->getVar('rate', 'e'));
122
+	}
123
+
124
+	/**
125
+	 * @return string
126
+	 */
127
+	public function defaultCurrency()
128
+	{
129
+		if ($this->getVar('default_currency', 'e') == true) {
130
+			return _YES;
131
+		} else {
132
+			return _NO;
133
+		}
134
+	}
135
+
136
+	/**
137
+	 * @return string
138
+	 */
139
+	public function getDefaultCurrencyControl()
140
+	{
141
+		$radio_box = '<input name="default_currency" value="' . $this->getVar('currencyid') . '" type="radio"';
142
+		if ($this->getVar('default_currency', 'e')) {
143
+			$radio_box .= 'checked="checked"';
144
+		}
145
+		$radio_box .= '>';
146
+
147
+		return $radio_box;
148
+	}
149 149
 }
150 150
 
151 151
 /**
@@ -153,22 +153,22 @@  discard block
 block discarded – undo
153 153
  */
154 154
 class SmartObjectCurrencyHandler extends SmartPersistableObjectHandler
155 155
 {
156
-    /**
157
-     * SmartObjectCurrencyHandler constructor.
158
-     * @param object|XoopsDatabase $db
159
-     */
160
-    public function __construct($db)
161
-    {
162
-        parent::__construct($db, 'currency', 'currencyid', 'name', '', 'smartobject');
163
-    }
164
-
165
-    /**
166
-     * @return array
167
-     */
168
-    public function getCurrencies()
169
-    {
170
-        $currenciesObj = $this->getObjects(null, true);
171
-
172
-        return $currenciesObj;
173
-    }
156
+	/**
157
+	 * SmartObjectCurrencyHandler constructor.
158
+	 * @param object|XoopsDatabase $db
159
+	 */
160
+	public function __construct($db)
161
+	{
162
+		parent::__construct($db, 'currency', 'currencyid', 'name', '', 'smartobject');
163
+	}
164
+
165
+	/**
166
+	 * @return array
167
+	 */
168
+	public function getCurrencies()
169
+	{
170
+		$currenciesObj = $this->getObjects(null, true);
171
+
172
+		return $currenciesObj;
173
+	}
174 174
 }
Please login to merge, or discard this patch.