Passed
Pull Request — master (#2)
by Michael
07:08 queued 02:34
created

songlist_songs_get_form()   F

Complexity

Conditions 69
Paths > 20000

Size

Total Lines 157
Code Lines 121

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 69
eloc 121
nc 65536
nop 2
dl 0
loc 157
rs 0
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
	xoops_loadLanguage('user');
4
	
5
	/**
6
	 * Get {@link XoopsThemeForm} for adding/editing fields
7
	 *
8
	 * @param object $field {@link ProfileField} object to get edit form for
9
	 * @param mixed $action URL to submit to - or false for $_SERVER['PHP_SELF']
10
	 *
11
	 * @return object
12
	 */
13
	function songlist_getFieldForm(&$field, $action = false)
14
	{
15
		if ( $action === false ) {
16
			$action = $_SERVER['PHP_SELF'];
17
		}
18
		
19
		xoops_loadLanguage('forms', 'songlist');
20
		
21
		$title = $field->isNew() ? sprintf(_FRM_SONGLIST_FIELDS_ADD, _FRM_SONGLIST_FIELDS_FIELD) : sprintf(_FRM_SONGLIST_FIELDS_EDIT, _FRM_SONGLIST_FIELDS_FIELD);
22
	
23
		xoops_load('XoopsFormLoader');
24
	
25
		$form = new XoopsThemeForm($title, 'form', $action, 'post', true);
26
	
27
		$form->addElement(new XoopsFormText(_FRM_SONGLIST_FIELDS_TITLE, 'field_title', 35, 255, $field->getVar('field_title', 'e')));
28
		$form->addElement(new XoopsFormTextArea(_FRM_SONGLIST_FIELDS_DESCRIPTION, 'field_description', $field->getVar('field_description', 'e')));
29
	
30
		if (!$field->isNew()) {
31
			$fieldcid = $field->getVar('cids');
32
		} else {
33
			$fieldcid = array(1=>0);
34
		}
35
		$category_handler = xoops_getmodulehandler('category', 'songlist');
36
		$cat_select = new XoopsFormSelect(_FRM_SONGLIST_FIELDS_CATEGORY, 'cids', $fieldcid, 7, true);
37
		$cat_select->addOption(0, _FRM_SONGLIST_FIELDS_DEFAULT);
38
		foreach($category_handler->getObjects(NULL, true) as $cid => $category)
0 ignored issues
show
Bug introduced by
The method getObjects() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsRankHandler or XoUserHandler. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
		foreach($category_handler->/** @scrutinizer ignore-call */ getObjects(NULL, true) as $cid => $category)
Loading history...
39
			$cat_select->addOption($cid, $category->getVar('name'));
40
		$form->addElement($cat_select);
41
		$form->addElement(new XoopsFormText(_FRM_SONGLIST_FIELDS_WEIGHT, 'field_weight', 10, 10, $field->getVar('field_weight', 'e')));
42
		if ($field->getVar('field_config') || $field->isNew()) {
43
			if (!$field->isNew()) {
44
				$form->addElement(new XoopsFormLabel(_FRM_SONGLIST_FIELDS_NAME, $field->getVar('field_name')));
45
				$form->addElement(new XoopsFormHidden('id', $field->getVar('field_id')));
46
			} else {
47
				$form->addElement(new XoopsFormText(_FRM_SONGLIST_FIELDS_NAME, 'field_name', 35, 255, $field->getVar('field_name', 'e')));
48
			}
49
	
50
			//autotext and theme left out of this one as fields of that type should never be changed (valid assumption, I think)
51
			$fieldtypes = array(
52
				'checkbox' => _FRM_SONGLIST_FIELDS_CHECKBOX,
53
				'date' => _FRM_SONGLIST_FIELDS_DATE,
54
				'datetime' => _FRM_SONGLIST_FIELDS_DATETIME,
55
				'longdate' => _FRM_SONGLIST_FIELDS_LONGDATE,
56
				'group' => _FRM_SONGLIST_FIELDS_GROUP,
57
				'group_multi' => _FRM_SONGLIST_FIELDS_GROUPMULTI,
58
				'language' => _FRM_SONGLIST_FIELDS_LANGUAGE,
59
				'radio' => _FRM_SONGLIST_FIELDS_RADIO,
60
				'select' => _FRM_SONGLIST_FIELDS_SELECT,
61
				'select_multi' => _FRM_SONGLIST_FIELDS_SELECTMULTI,
62
				'textarea' => _FRM_SONGLIST_FIELDS_TEXTAREA,
63
				'dhtml' => _FRM_SONGLIST_FIELDS_DHTMLTEXTAREA,
64
				'textbox' => _FRM_SONGLIST_FIELDS_TEXTBOX,
65
				'timezone' => _FRM_SONGLIST_FIELDS_TIMEZONE,
66
				'yesno' => _FRM_SONGLIST_FIELDS_YESNO);
67
	
68
			$element_select = new XoopsFormSelect(_FRM_SONGLIST_FIELDS_TYPE, 'field_type', $field->getVar('field_type', 'e'));
69
			$element_select->addOptionArray($fieldtypes);
70
	
71
			$form->addElement($element_select);
72
	
73
			switch ($field->getVar('field_type')) {
74
				case "textbox":
75
					$valuetypes = array(
76
						XOBJ_DTYPE_ARRAY            => _FRM_SONGLIST_FIELDS_ARRAY,
77
						XOBJ_DTYPE_EMAIL            => _FRM_SONGLIST_FIELDS_EMAIL,
78
						XOBJ_DTYPE_INT              => _FRM_SONGLIST_FIELDS_INT,
79
						XOBJ_DTYPE_FLOAT            => _FRM_SONGLIST_FIELDS_FLOAT,
80
						XOBJ_DTYPE_DECIMAL          => _FRM_SONGLIST_FIELDS_DECIMAL,
81
						XOBJ_DTYPE_TXTAREA          => _FRM_SONGLIST_FIELDS_TXTAREA,
82
						XOBJ_DTYPE_TXTBOX           => _FRM_SONGLIST_FIELDS_TXTBOX,
83
						XOBJ_DTYPE_URL              => _FRM_SONGLIST_FIELDS_URL,
84
						XOBJ_DTYPE_OTHER    		=> _FRM_SONGLIST_FIELDS_OTHER);
85
	
86
					$type_select = new XoopsFormSelect(_FRM_SONGLIST_FIELDS_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
87
					$type_select->addOptionArray($valuetypes);
88
					$form->addElement($type_select);
89
					break;
90
	
91
				case "select":
92
				case "radio":
93
					$valuetypes = array(
94
						XOBJ_DTYPE_ARRAY            => _FRM_SONGLIST_FIELDS_ARRAY,
95
						XOBJ_DTYPE_EMAIL            => _FRM_SONGLIST_FIELDS_EMAIL,
96
						XOBJ_DTYPE_INT              => _FRM_SONGLIST_FIELDS_INT,
97
						XOBJ_DTYPE_FLOAT            => _FRM_SONGLIST_FIELDS_FLOAT,
98
						XOBJ_DTYPE_DECIMAL          => _FRM_SONGLIST_FIELDS_DECIMAL,
99
						XOBJ_DTYPE_TXTAREA          => _FRM_SONGLIST_FIELDS_TXTAREA,
100
						XOBJ_DTYPE_TXTBOX           => _FRM_SONGLIST_FIELDS_TXTBOX,
101
						XOBJ_DTYPE_URL              => _FRM_SONGLIST_FIELDS_URL,
102
						XOBJ_DTYPE_OTHER            => _FRM_SONGLIST_FIELDS_OTHER);
103
	
104
					$type_select = new XoopsFormSelect(_FRM_SONGLIST_FIELDS_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
105
					$type_select->addOptionArray($valuetypes);
106
					$form->addElement($type_select);
107
					break;
108
			}
109
	
110
			//$form->addElement(new XoopsFormRadioYN(_FRM_SONGLIST_FIELDS_NOTNULL, 'field_notnull', $field->getVar('field_notnull', 'e') ));
111
	
112
			if ($field->getVar('field_type') == "select" || $field->getVar('field_type') == "select_multi" || $field->getVar('field_type') == "radio" || $field->getVar('field_type') == "checkbox") {
113
				$options = $field->getVar('field_options');
114
				if (count($options) > 0) {
115
					$remove_options = new XoopsFormCheckBox(_FRM_SONGLIST_FIELDS_REMOVEOPTIONS, 'removeOptions');
116
					$remove_options->columns = 3;
117
					asort($options);
118
					foreach (array_keys($options) as $key) {
119
						$options[$key] .= "[{$key}]";
120
					}
121
					$remove_options->addOptionArray($options);
122
					$form->addElement($remove_options);
123
				}
124
	
125
				$option_text = "<table  cellspacing='1'><tr><td width='20%'>" . _FRM_SONGLIST_FIELDS_KEY . "</td><td>" . _FRM_SONGLIST_FIELDS_VALUE . "</td></tr>";
126
				for ($i = 0; $i < 3; $i++) {
127
					$option_text .= "<tr><td><input type='text' name='addOption[{$i}][key]' id='addOption[{$i}][key]' size='15' /></td><td><input type='text' name='addOption[{$i}][value]' id='addOption[{$i}][value]' size='35' /></td></tr>";
128
					$option_text .= "<tr height='3px'><td colspan='2'> </td></tr>";
129
				}
130
				$option_text .= "</table>";
131
				$form->addElement(new XoopsFormLabel(_FRM_SONGLIST_FIELDS_ADDOPTION, $option_text) );
132
			}
133
		}
134
	
135
		if ($field->getVar('field_edit')) {
136
			switch ($field->getVar('field_type')) {
137
				case "textbox":
138
				case "textarea":
139
				case "dhtml":
140
					$form->addElement(new XoopsFormText(_FRM_SONGLIST_FIELDS_MAXLENGTH, 'field_maxlength', 35, 35, $field->getVar('field_maxlength', 'e')));
141
					$form->addElement(new XoopsFormTextArea(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
142
					break;
143
	
144
				case "checkbox":
145
				case "select_multi":
146
					$def_value = $field->getVar('field_default', 'e') != null ? unserialize($field->getVar('field_default', 'n')) : null;
147
					$element = new XoopsFormSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $def_value, 8, true);
148
					$options = $field->getVar('field_options');
149
					asort($options);
150
					// If options do not include an empty element, then add a blank option to prevent any default selection
151
					if (!in_array('', array_keys($options))) {
152
						$element->addOption('', _NONE);
153
					}
154
					$element->addOptionArray($options);
155
					$form->addElement($element);
156
					break;
157
	
158
				case "select":
159
				case "radio":
160
					$def_value = $field->getVar('field_default', 'e') != null ? $field->getVar('field_default') : null;
161
					$element = new XoopsFormSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $def_value);
162
					$options = $field->getVar('field_options');
163
					asort($options);
164
					// If options do not include an empty element, then add a blank option to prevent any default selection
165
					if (!in_array('', array_keys($options))) {
166
						$element->addOption('', _NONE);
167
					}
168
					$element->addOptionArray($options);
169
					$form->addElement($element);
170
					break;
171
	
172
				case "date":
173
					$form->addElement(new XoopsFormTextDateSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', 15, $field->getVar('field_default', 'e')));
174
					break;
175
	
176
				case "longdate":
177
					$form->addElement(new XoopsFormTextDateSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', 15, strtotime($field->getVar('field_default', 'e'))));
178
					break;
179
	
180
				case "datetime":
181
					$form->addElement(new XoopsFormDateTime(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', 15, $field->getVar('field_default', 'e')));
182
					break;
183
	
184
				case "yesno":
185
					$form->addElement(new XoopsFormRadioYN(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
186
					break;
187
	
188
				case "timezone":
189
					$form->addElement(new XoopsFormSelectTimezone(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
190
					break;
191
	
192
				case "language":
193
					$form->addElement(new XoopsFormSelectLang(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
194
					break;
195
	
196
				case "group":
197
					$form->addElement(new XoopsFormSelectGroup(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', true, $field->getVar('field_default', 'e')));
198
					break;
199
	
200
				case "group_multi":
201
					$form->addElement(new XoopsFormSelectGroup(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', true, $field->getVar('field_default', 'e'), 5, true));
202
					break;
203
	
204
				case "theme":
205
					$form->addElement(new XoopsFormSelectTheme(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
206
					break;
207
	
208
				case "autotext":
209
					$form->addElement(new XoopsFormTextArea(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
210
					break;
211
			}
212
		}
213
	
214
		$groupperm_handler = xoops_gethandler('groupperm');
215
		$searchable_types = array(
216
			'textbox',
217
			'select',
218
			'radio',
219
			'yesno',
220
			'date',
221
			'datetime',
222
			'timezone',
223
			'language');
224
		if (in_array($field->getVar('field_type'), $searchable_types)) {
225
			$search_groups = $groupperm_handler->getGroupIds('songlist_search', $field->getVar('field_id'), $GLOBALS['songlistModule']->getVar('mid'));
0 ignored issues
show
Bug introduced by
The method getGroupIds() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

225
			/** @scrutinizer ignore-call */ 
226
   $search_groups = $groupperm_handler->getGroupIds('songlist_search', $field->getVar('field_id'), $GLOBALS['songlistModule']->getVar('mid'));
Loading history...
226
			$form->addElement(new XoopsFormSelectGroup(_FRM_SONGLIST_FIELDS_PROF_SEARCH, 'songlist_search', true, $search_groups, 5, true) );
227
		}
228
		if ($field->getVar('field_edit') || $field->isNew()) {
229
			if (!$field->isNew()) {
230
				//Load groups
231
				$editable_groups = $groupperm_handler->getGroupIds('songlist_edit', $field->getVar('field_id'), $GLOBALS['songlistModule']->getVar('mid'));
232
			} else {
233
				$editable_groups = array();
234
			}
235
			$form->addElement(new XoopsFormSelectGroup(_FRM_SONGLIST_FIELDS_PROF_EDITABLE, 'songlist_edit', false, $editable_groups, 5, true));
236
			$form->addElement($steps_select);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $steps_select seems to be never defined.
Loading history...
237
		}
238
		$form->addElement(new XoopsFormHidden('op', 'save') );
239
		$form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
240
	
241
		return $form;
242
	}
243
	
244
	
245
	/**
246
	* Get {@link XoopsThemeForm} for editing a user
247
	*
248
	* @param object $user {@link XoopsUser} to edit
249
	*
250
	* @return object
251
	*/
252
	function songlist_getUserSearchForm($action = false)
253
	{
254
		
255
		xoops_loadLanguage('forms', 'songlist');
256
		
257
		if ($action === false) {
258
			$action = $_SERVER['PHP_SELF'];
259
		}
260
		if (empty($GLOBALS['xoopsConfigUser'])) {
261
			$config_handler = xoops_gethandler('config');
262
			$GLOBALS['xoopsConfigUser'] = $config_handler->getConfigsByCat(XOOPS_CONF_USER);
0 ignored issues
show
Bug introduced by
The method getConfigsByCat() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

262
			/** @scrutinizer ignore-call */ 
263
   $GLOBALS['xoopsConfigUser'] = $config_handler->getConfigsByCat(XOOPS_CONF_USER);
Loading history...
263
		}
264
	
265
		$title = _FRM_SONGLIST_FIELDS_SEARCH;
266
	
267
		$form = new XoopsThemeForm($title, 'search', $action, 'post', true);
268
	
269
		$songlist_handler = xoops_getmodulehandler('profile', 'objects');
270
		// Get fields
271
		$fields = $songlist_handler->loadFields();
0 ignored issues
show
Bug introduced by
The method loadFields() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

271
		/** @scrutinizer ignore-call */ 
272
  $fields = $songlist_handler->loadFields();
Loading history...
272
	
273
		$gperm_handler = xoops_gethandler('groupperm');
0 ignored issues
show
Unused Code introduced by
The assignment to $gperm_handler is dead and can be removed.
Loading history...
274
		$config_handler = xoops_gethandler('config');
0 ignored issues
show
Unused Code introduced by
The assignment to $config_handler is dead and can be removed.
Loading history...
275
		$groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
276
		$module_handler = xoops_gethandler('module');
277
		$xoModule = $module_handler->getByDirname('objects');
0 ignored issues
show
Bug introduced by
The method getByDirname() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

277
		/** @scrutinizer ignore-call */ 
278
  $xoModule = $module_handler->getByDirname('objects');
Loading history...
278
		$modid = $xoModule->getVar('mid');
279
	
280
		// Get ids of fields that can be edited
281
		$gperm_handler = xoops_gethandler('groupperm');
282
	
283
		$editable_fields = $gperm_handler->getItemIds('songlist_search', $groups, $modid );
0 ignored issues
show
Bug introduced by
The method getItemIds() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

283
		/** @scrutinizer ignore-call */ 
284
  $editable_fields = $gperm_handler->getItemIds('songlist_search', $groups, $modid );
Loading history...
284
	
285
		$cat_handler = xoops_getmodulehandler('category');
286
	
287
		$selcat = new XoopsFormSelectForum('Forum', 'cid', (!empty($_REQUEST['cid']))?intval($_REQUEST['cid']):0, 1, false, false, false, true );
0 ignored issues
show
Bug introduced by
The type XoopsFormSelectForum was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
288
		$selcat->setExtra(' onChange="window.location=\''.XOOPS_URL.'/modules/objects/search.php?op=search&fct=form&cid=\'+document.search.cid.options[document.search.cid.selectedIndex].value"');
289
	
290
		$form->addElement($selcat, true);
291
	
292
		$categories = array();
293
	
294
		$criteria = new CriteriaCompo(new Criteria('cid', (!empty($_REQUEST['cid']))?intval($_REQUEST['cid']):'0'), "OR");
295
		$all_categories = $cat_handler->getObjects($criteria, true, false);
296
		$count_fields = count($fields);
297
	
298
		foreach (array_keys($fields) as $i ) {
299
			if ( in_array($fields[$i]->getVar('field_id'), $editable_fields)  ) {
300
				// Set default value for user fields if available
301
				$fieldinfo['element'] = $fields[$i]->getSearchElement();
302
				$fieldinfo['required'] = false;
303
	
304
				foreach($fields[$i]->getVar('cids') as $catidid => $cid) {
305
					if (in_array($cid, array_keys($all_categories))) {
306
						$key = $all_categories[$cid]['cat_weight'] * $count_fields + $cid;
307
						$elements[$key][] = $fieldinfo;
308
						$weights[$key][] = $fields[$i]->getVar('field_weight');
309
						$categories[$key] = $all_categories[$cid];
310
					} elseif (in_array(0, $fields[$i]->getVar('cids'))) {
311
						$key = $all_categories[$cid]['cat_weight'] * $count_fields + $cid;
312
						$elements[$key][] = $fieldinfo;
313
						$weights[$key][] = $fields[$i]->getVar('field_weight');
314
						$categories[$key] = $all_categories[$cid];
315
					}
316
				}
317
			}
318
		}
319
	
320
		ksort($elements);
321
		foreach (array_keys($elements) as $k) {
322
			array_multisort($weights[$k], SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]);
0 ignored issues
show
Bug introduced by
SORT_ASC cannot be passed to array_multisort() as the parameter $rest expects a reference. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

322
			array_multisort($weights[$k], /** @scrutinizer ignore-type */ SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]);
Loading history...
Bug introduced by
array_keys($elements[$k]) cannot be passed to array_multisort() as the parameter $rest expects a reference. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

322
			array_multisort($weights[$k], SORT_ASC, /** @scrutinizer ignore-type */ array_keys($elements[$k]), SORT_ASC, $elements[$k]);
Loading history...
Comprehensibility Best Practice introduced by
The variable $weights does not seem to be defined for all execution paths leading up to this point.
Loading history...
323
			$title = isset($categories[$k]) ? $categories[$k]['cat_title'] : _OBJS_MF_DEFAULT;
0 ignored issues
show
Bug introduced by
The constant _OBJS_MF_DEFAULT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
324
			$desc = isset($categories[$k]) ? $categories[$k]['cat_description'] : "";
325
			$form->addElement(new XoopsFormLabel("<h3>{$title}</h3>", $desc), false);
326
			foreach (array_keys($elements[$k]) as $i) {
327
				$form->addElement($elements[$k][$i]['element'], $elements[$k][$i]['required']);
328
			}
329
		}
330
	
331
		$form->addElement(new XoopsFormHidden('fct', 'objects' ));
332
		$form->addElement(new XoopsFormHidden('op', 'search' ));
333
		$form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
334
		return $form;
335
	}
336
	
337
	function songlist_import_get_form($as_array = false) {
338
		
339
		xoops_loadLanguage('forms', 'songlist');
340
		
341
		$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_IMPORT, 'import', $_SERVER['PHP_SELF'], 'post');
342
		$sform->setExtra( "enctype='multipart/form-data'" ) ;
343
		
344
		$ele['op'] = new XoopsFormHidden('op', 'import');
0 ignored issues
show
Comprehensibility Best Practice introduced by
$ele was never initialized. Although not strictly required by PHP, it is generally a good practice to add $ele = array(); before regardless.
Loading history...
345
		$ele['fct'] = new XoopsFormHidden('fct', 'upload');
346
		$ele['xmlfile'] = new XoopsFormFile(($as_array==false?_FRM_SONGLIST_FORM_IMPORT_UPLOAD_XML:''), 'xmlfile', (1024*1024*1024*32));
347
		$ele['xmlfile']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_IMPORT_UPLOAD_XML_DESC:''));
348
		$ele['file'] = new XoopsFormSelect(($as_array==false?_FRM_SONGLIST_FORM_IMPORT_EXISTING_XML:''), 'file');
349
		$ele['file']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_IMPORT_EXISTING_XML_DESC:''));
350
		$ele['file']->addOption('', '*********');
351
		xoops_load('XoopsLists');
352
		foreach(XoopsLists::getFileListAsArray($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $file) {
353
			if (substr($file, strlen($file)-3, 3)=='xml') {
354
				$ele['file']->addOption($file, $file);
355
			}
356
		}
357
		$ele['submit'] = new XoopsFormButton('', 'submit', _SUBMIT, 'submit');
358
		
359
		$required = array();
360
		
361
		foreach($ele as $id => $obj)			
362
			if (in_array($id, $required))
363
				$sform->addElement($ele[$id], true);			
364
			else
365
				$sform->addElement($ele[$id], false);
366
		
367
		return $sform->render();
368
		
369
	}
370
	
371
	function songlist_importb_get_form($file, $as_array = false) {
372
		
373
		xoops_loadLanguage('forms', 'songlist');
374
		
375
		$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_ELEMENTS, 'elements', $_SERVER['PHP_SELF'], 'post');
376
		
377
		$filesize = filesize($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'].$file));
378
		$mb = floor($filesize / 1024 / 1024);
379
		if ($mb>32) {
380
			set_ini('memory_limit', ($mb+128).'M');	
0 ignored issues
show
Bug introduced by
The function set_ini was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

380
			/** @scrutinizer ignore-call */ 
381
   set_ini('memory_limit', ($mb+128).'M');	
Loading history...
381
		}
382
		set_time_limit(3600);
383
								
384
		$i=0;
385
		foreach (file($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'].$_SESSION['xmlfile'])) as $data) {
386
			$i++;
387
			if ($i<20) {
388
				$line .= htmlspecialchars($data) . ($i<19?"\n":'');
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $line seems to be never defined.
Loading history...
389
			}
390
		}
391
		
392
		$ele['op'] = new XoopsFormHidden('op', 'import');
0 ignored issues
show
Comprehensibility Best Practice introduced by
$ele was never initialized. Although not strictly required by PHP, it is generally a good practice to add $ele = array(); before regardless.
Loading history...
393
		$ele['fct'] = new XoopsFormHidden('fct', 'import');
394
		$ele['example'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_EXAMPLE:''), '<pre>'.$line.'</pre>');
395
		$ele['example']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_EXAMPLE_DESC:''));
396
		$ele['collection'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_COLLECTION:''), 'collection', 32, 128, 'collection');
397
		$ele['collection']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_COLLECTION_DESC:''));
398
		$ele['record'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_RECORD:''), 'record', 32, 128, 'record');
399
		$ele['record']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_RECORD_DESC:''));
400
		$ele['genre'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_GENRES:''), 'genre', 32, 128, 'genre');
401
		$ele['genre']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_GENRES_DESC:''));
402
		$ele['voice'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_VOICE:''), 'voice', 32, 128, 'voice');
403
		$ele['voice']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_VOICE_DESC:''));		
404
		$ele['category'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_CATEGORY:''), 'category', 32, 128, 'category');
405
		$ele['category']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_CATEGORY_DESC:''));
406
		$ele['artist'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_ARTIST:''), 'artist', 32, 128, 'artist');
407
		$ele['artist']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_ARTIST_DESC:''));
408
		$ele['album'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_ALBUM:''), 'album', 32, 128, 'album');
409
		$ele['album']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_ALBUM_DESC:''));
410
		$ele['songid'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_SONGID:''), 'songid', 32, 128, 'songid');
411
		$ele['songid']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_SONGID_DESC:''));
412
		$ele['traxid'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_TRAXID:''), 'traxid', 32, 128, 'trackno');
413
		$ele['traxid']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_TRAXID_DESC:''));
414
		$ele['title'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_TITLE:''), 'title', 32, 128, 'title');
415
		$ele['title']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_TITLE_DESC:''));
416
		$ele['lyrics'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_LYRICS:''), 'lyrics', 32, 128, 'lyric');
417
		$ele['lyrics']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_LYRICS_DESC:''));
418
		$ele['tags'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_TAGS:''), 'tags', 32, 128, 'tags');
419
		$ele['tags']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_TAGS_DESC:''));
420
		$ele['mp3'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_MP3:''), 'mp3', 32, 128, 'mp3');
421
		$ele['mp3']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ELEMENT_MP3_DESC:''));
422
		$extras_handler = xoops_getmodulehandler('extras', 'songlist');
423
		$fields = $extras_handler->getFields(NULL);
0 ignored issues
show
Bug introduced by
The method getFields() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

423
		/** @scrutinizer ignore-call */ 
424
  $fields = $extras_handler->getFields(NULL);
Loading history...
424
		foreach($fields as $field) {
425
			$ele[$field->getVar('field_name')] = new XoopsFormText(($as_array==false?$field->getVar('field_title'):''), $field->getVar('field_name'), 32, 128, $field->getVar('field_name'));
426
			$ele[$field->getVar('field_name')]->setDescription(($as_array==false?$field->getVar('field_description'):''));
427
		}
428
		$ele['limiting'] = new XoopsFormRadioYN(($as_array==false?_FRM_SONGLIST_FORM_IMPORT_LIMITING:''), 'limiting', true);
0 ignored issues
show
Bug introduced by
true of type true is incompatible with the type string expected by parameter $value of XoopsFormRadioYN::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

428
		$ele['limiting'] = new XoopsFormRadioYN(($as_array==false?_FRM_SONGLIST_FORM_IMPORT_LIMITING:''), 'limiting', /** @scrutinizer ignore-type */ true);
Loading history...
429
		$ele['limiting']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_IMPORT_LIMITING_DESC:''));
430
		$ele['records'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_IMPORT_RECORDS:''), 'records', 10, 10, '250');
431
		$ele['records']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_IMPORT_RECORDS_DESC:''));
432
		$ele['wait'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_IMPORT_WAIT:''), 'wait', 10, 10, '40');
433
		$ele['wait']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_IMPORT_WAIT_DESC:''));
434
		
435
		$ele['submit'] = new XoopsFormButton('', 'submit', _SUBMIT, 'submit');
436
		
437
		$required = array();
438
		
439
		foreach($ele as $id => $obj)			
440
			if (in_array($id, $required))
441
				$sform->addElement($ele[$id], true);			
442
			else
443
				$sform->addElement($ele[$id], false);
444
		
445
		return $sform->render();
446
		
447
	}
448
449
	function songlist_genre_get_form($object, $as_array=false) {
450
		
451
		if (!is_object($object)) {
452
			$handler = xoops_getmodulehandler('genre', 'songlist');
453
			$object = $handler->create(); 
454
		}
455
		
456
		xoops_loadLanguage('forms', 'songlist');
457
		$ele = array();
458
		
459
		if ($object->isNew()) {
460
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_GENRE, 'genre', $_SERVER['PHP_SELF'], 'post');
461
			$ele['mode'] = new XoopsFormHidden('mode', 'new');
462
		} else {
463
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_GENRE, 'genre', $_SERVER['PHP_SELF'], 'post');
464
			$ele['mode'] = new XoopsFormHidden('mode', 'edit');
465
		}
466
		
467
		$sform->setExtra( "enctype='multipart/form-data'" ) ;
468
		
469
		$id = $object->getVar('gid');
470
		if (empty($id)) $id = '0';
471
		
472
		$ele['op'] = new XoopsFormHidden('op', 'genre');
473
		$ele['fct'] = new XoopsFormHidden('fct', 'save');
474
		if ($as_array==false)
475
			$ele['id'] = new XoopsFormHidden('id', $id);
476
		else 
477
			$ele['id'] = new XoopsFormHidden('id['.$id.']', $id);
478
		$ele['sort'] = new XoopsFormHidden('sort', isset($_REQUEST['sort'])?$_REQUEST['sort']:'created');
479
		$ele['order'] = new XoopsFormHidden('order', isset($_REQUEST['order'])?$_REQUEST['order']:'DESC');
480
		$ele['start'] = new XoopsFormHidden('start', isset($_REQUEST['start'])?intval($_REQUEST['start']):0);
481
		$ele['limit'] = new XoopsFormHidden('limit', isset($_REQUEST['limit'])?intval($_REQUEST['limit']):0);
482
		$ele['filter'] = new XoopsFormHidden('filter', isset($_REQUEST['filter'])?$_REQUEST['filter']:'1,1');
483
484
		$ele['name'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_GENRE_NAME:''), $id.'[name]', ($as_array==false?55:21),128, $object->getVar('name'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('name') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

484
		$ele['name'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_GENRE_NAME:''), $id.'[name]', ($as_array==false?55:21),128, /** @scrutinizer ignore-type */ $object->getVar('name'));
Loading history...
485
		$ele['name']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_GENRE_NAME_DESC:''));
486
		$ele['albums'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_GENRE_ALBUMS:''), $object->getVar('albums'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('albums') can also be of type array and array; however, parameter $value of XoopsFormLabel::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

486
		$ele['albums'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_GENRE_ALBUMS:''), /** @scrutinizer ignore-type */ $object->getVar('albums'));
Loading history...
487
		$ele['artists'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_GENRE_ARTISTS:''), $object->getVar('artists'));
488
		$ele['songs'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_GENRE_SONGS:''), $object->getVar('songs'));
489
		$ele['hits'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_GENRE_HITS:''), $object->getVar('hits'));
490
		$ele['rank'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_GENRE_RANK:''), number_format(($object->getVar('rank')>0&&$object->getVar('votes')>0?$object->getVar('rank')/$object->getVar('votes'):0),2). ' of 10');
491
		if ($object->getVar('created')>0) {
492
			$ele['created'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_GENRE_CREATED:''), date(_DATESTRING, $object->getVar('created')));
493
		}
494
		if ($object->getVar('updated')>0) {
495
			$ele['updated'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_GENRE_UPDATED:''), date(_DATESTRING, $object->getVar('updated')));
496
		}
497
498
		if ($as_array==true)
499
			return $ele;
500
		
501
		$ele['submit'] = new XoopsFormButton('', 'submit', _SUBMIT, 'submit');
502
		
503
		$required = array('name');
504
		
505
		foreach($ele as $id => $obj)			
506
			if (in_array($id, $required))
507
				$sform->addElement($ele[$id], true);			
508
			else
509
				$sform->addElement($ele[$id], false);
510
		
511
		return $sform->render();
512
		
513
	}
514
515
	function songlist_voice_get_form($object, $as_array=false) {
516
		
517
		if (!is_object($object)) {
518
			$handler = xoops_getmodulehandler('voice', 'songlist');
519
			$object = $handler->create(); 
520
		}
521
		
522
		xoops_loadLanguage('forms', 'songlist');
523
		$ele = array();
524
		
525
		if ($object->isNew()) {
526
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_VOICE, 'voice', $_SERVER['PHP_SELF'], 'post');
527
			$ele['mode'] = new XoopsFormHidden('mode', 'new');
528
		} else {
529
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_VOICE, 'voice', $_SERVER['PHP_SELF'], 'post');
530
			$ele['mode'] = new XoopsFormHidden('mode', 'edit');
531
		}
532
		
533
		$sform->setExtra( "enctype='multipart/form-data'" ) ;
534
		
535
		$id = $object->getVar('vcid');
536
		if (empty($id)) $id = '0';
537
		
538
		$ele['op'] = new XoopsFormHidden('op', 'voice');
539
		$ele['fct'] = new XoopsFormHidden('fct', 'save');
540
		if ($as_array==false)
541
			$ele['id'] = new XoopsFormHidden('id', $id);
542
		else 
543
			$ele['id'] = new XoopsFormHidden('id['.$id.']', $id);
544
		$ele['sort'] = new XoopsFormHidden('sort', isset($_REQUEST['sort'])?$_REQUEST['sort']:'created');
545
		$ele['order'] = new XoopsFormHidden('order', isset($_REQUEST['order'])?$_REQUEST['order']:'DESC');
546
		$ele['start'] = new XoopsFormHidden('start', isset($_REQUEST['start'])?intval($_REQUEST['start']):0);
547
		$ele['limit'] = new XoopsFormHidden('limit', isset($_REQUEST['limit'])?intval($_REQUEST['limit']):0);
548
		$ele['filter'] = new XoopsFormHidden('filter', isset($_REQUEST['filter'])?$_REQUEST['filter']:'1,1');
549
550
		$ele['name'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_VOICE_NAME:''), $id.'[name]', ($as_array==false?55:21),128, $object->getVar('name'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('name') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

550
		$ele['name'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_VOICE_NAME:''), $id.'[name]', ($as_array==false?55:21),128, /** @scrutinizer ignore-type */ $object->getVar('name'));
Loading history...
551
		$ele['name']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_VOICE_NAME_DESC:''));
552
		$ele['albums'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOICE_ALBUMS:''), $object->getVar('albums'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('albums') can also be of type array and array; however, parameter $value of XoopsFormLabel::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

552
		$ele['albums'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOICE_ALBUMS:''), /** @scrutinizer ignore-type */ $object->getVar('albums'));
Loading history...
553
		$ele['artists'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOICE_ARTISTS:''), $object->getVar('artists'));
554
		$ele['songs'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOICE_SONGS:''), $object->getVar('songs'));
555
		$ele['hits'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOICE_HITS:''), $object->getVar('hits'));
556
		$ele['rank'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOICE_RANK:''), number_format(($object->getVar('rank')>0&&$object->getVar('votes')>0?$object->getVar('rank')/$object->getVar('votes'):0),2). ' of 10');
557
		if ($object->getVar('created')>0) {
558
			$ele['created'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOICE_CREATED:''), date(_DATESTRING, $object->getVar('created')));
559
		}
560
		if ($object->getVar('updated')>0) {
561
			$ele['updated'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOICE_UPDATED:''), date(_DATESTRING, $object->getVar('updated')));
562
		}
563
564
		if ($as_array==true)
565
			return $ele;
566
		
567
		$ele['submit'] = new XoopsFormButton('', 'submit', _SUBMIT, 'submit');
568
		
569
		$required = array('name');
570
		
571
		foreach($ele as $id => $obj)			
572
			if (in_array($id, $required))
573
				$sform->addElement($ele[$id], true);			
574
			else
575
				$sform->addElement($ele[$id], false);
576
		
577
		return $sform->render();
578
		
579
	}
580
581
582
	function songlist_albums_get_form($object, $as_array=false) {
583
		
584
		if (!is_object($object)) {
585
			$handler = xoops_getmodulehandler('albums', 'songlist');
586
			$object = $handler->create(); 
587
		}
588
		
589
		xoops_loadLanguage('forms', 'songlist');
590
		$ele = array();
591
		
592
		if ($object->isNew()) {
593
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_ALBUMS, 'albums', $_SERVER['PHP_SELF'], 'post');
594
			$ele['mode'] = new XoopsFormHidden('mode', 'new');
595
		} else {
596
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_ALBUMS, 'albums', $_SERVER['PHP_SELF'], 'post');
597
			$ele['mode'] = new XoopsFormHidden('mode', 'edit');
598
		}
599
		
600
		$sform->setExtra( "enctype='multipart/form-data'" ) ;
601
		
602
		$id = $object->getVar('abid');
603
		if (empty($id)) $id = '0';
604
		
605
		$ele['op'] = new XoopsFormHidden('op', 'albums');
606
		$ele['fct'] = new XoopsFormHidden('fct', 'save');
607
		if ($as_array==false)
608
			$ele['id'] = new XoopsFormHidden('id', $id);
609
		else 
610
			$ele['id'] = new XoopsFormHidden('id['.$id.']', $id);
611
		$ele['sort'] = new XoopsFormHidden('sort', isset($_REQUEST['sort'])?$_REQUEST['sort']:'created');
612
		$ele['order'] = new XoopsFormHidden('order', isset($_REQUEST['order'])?$_REQUEST['order']:'DESC');
613
		$ele['start'] = new XoopsFormHidden('start', isset($_REQUEST['start'])?intval($_REQUEST['start']):0);
614
		$ele['limit'] = new XoopsFormHidden('limit', isset($_REQUEST['limit'])?intval($_REQUEST['limit']):0);
615
		$ele['filter'] = new XoopsFormHidden('filter', isset($_REQUEST['filter'])?$_REQUEST['filter']:'1,1');
616
617
		$ele['cid'] = new SonglistFormSelectCategory(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_CATEGORY:''), $id.'[cid]', $object->getVar('cid'), 1, false, false, false);
0 ignored issues
show
Unused Code introduced by
The call to SonglistFormSelectCategory::__construct() has too many arguments starting with $as_array == false ? _FR...RM_ALBUMS_CATEGORY : ''. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

617
		$ele['cid'] = /** @scrutinizer ignore-call */ new SonglistFormSelectCategory(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_CATEGORY:''), $id.'[cid]', $object->getVar('cid'), 1, false, false, false);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
618
		$ele['cid']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_CATEGORY_DESC:''));
619
		$ele['title'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_TITLE:''), $id.'[title]', ($as_array==false?55:21),128, $object->getVar('title'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('title') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

619
		$ele['title'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_TITLE:''), $id.'[title]', ($as_array==false?55:21),128, /** @scrutinizer ignore-type */ $object->getVar('title'));
Loading history...
620
		$ele['title']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_TITLE_DESC:''));
621
		$ele['image'] = new XoopsFormFile(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_UPLOAD_POSTER:''), 'image', $GLOBALS['songlistModuleConfig']['filesize_upload']);
622
		$ele['image']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_UPLOAD_POSTER_DESC:''));
623
		if (strlen($object->getVar('image'))>0&&file_exists($GLOBALS['xoops']->path($object->getVar('path').$object->getVar('image')))) {
624
			$ele['image_preview'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_POSTER:''), '<img src="'.$object->getImage('image').'" width="340px" />' );
0 ignored issues
show
Bug introduced by
The method getImage() does not exist on XoopsObject. It seems like you code against a sub-type of XoopsObject such as SonglistAlbums or XoopsModules\Songlist\Category or XoopsModules\Songlist\Albums or SonglistCategory. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

624
			$ele['image_preview'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_POSTER:''), '<img src="'.$object->/** @scrutinizer ignore-call */ getImage('image').'" width="340px" />' );
Loading history...
625
			$ele['image_preview']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_POSTER_DESC:''));
626
		}
627
		$ele['artists'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_ARTISTS:''), $object->getVar('artists'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('artists') can also be of type array and array; however, parameter $value of XoopsFormLabel::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

627
		$ele['artists'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_ARTISTS:''), /** @scrutinizer ignore-type */ $object->getVar('artists'));
Loading history...
628
		$ele['songs'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_SONGS:''), $object->getVar('songs'));
629
		$ele['hits'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_HITS:''), $object->getVar('hits'));
630
		$ele['rank'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_RANK:''), number_format(($object->getVar('rank')>0&&$object->getVar('votes')>0?$object->getVar('rank')/$object->getVar('votes'):0),2). ' of 10');
631
		if ($object->getVar('created')>0) {
632
			$ele['created'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_CREATED:''), date(_DATESTRING, $object->getVar('created')));
633
		}
634
		if ($object->getVar('updated')>0) {
635
			$ele['updated'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ALBUMS_UPDATED:''), date(_DATESTRING, $object->getVar('updated')));
636
		}
637
638
		if ($as_array==true)
639
			return $ele;
640
		
641
		$ele['submit'] = new XoopsFormButton('', 'submit', _SUBMIT, 'submit');
642
		
643
		$required = array('name', 'id', 'source');
644
		
645
		foreach($ele as $id => $obj)			
646
			if (in_array($id, $required))
647
				$sform->addElement($ele[$id], true);			
648
			else
649
				$sform->addElement($ele[$id], false);
650
		
651
		return $sform->render();
652
		
653
	}
654
655
	function songlist_artists_get_form($object, $as_array=false) {
656
		
657
		if (!is_object($object)) {
658
			$handler = xoops_getmodulehandler('artists', 'songlist');
659
			$object = $handler->create(); 
660
		}
661
		
662
		xoops_loadLanguage('forms', 'songlist');
663
		$ele = array();
664
		
665
		if ($object->isNew()) {
666
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_ARTISTS, 'artists', $_SERVER['PHP_SELF'], 'post');
667
			$ele['mode'] = new XoopsFormHidden('mode', 'new');
668
		} else {
669
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_ARTISTS, 'artists', $_SERVER['PHP_SELF'], 'post');
670
			$ele['mode'] = new XoopsFormHidden('mode', 'edit');
671
		}
672
		
673
		$id = $object->getVar('aid');
674
		if (empty($id)) $id = '0';
675
		
676
		$ele['op'] = new XoopsFormHidden('op', 'artists');
677
		$ele['fct'] = new XoopsFormHidden('fct', 'save');
678
		if ($as_array==false)
679
			$ele['id'] = new XoopsFormHidden('id', $id);
680
		else 
681
			$ele['id'] = new XoopsFormHidden('id['.$id.']', $id);
682
		$ele['sort'] = new XoopsFormHidden('sort', isset($_REQUEST['sort'])?$_REQUEST['sort']:'created');
683
		$ele['order'] = new XoopsFormHidden('order', isset($_REQUEST['order'])?$_REQUEST['order']:'DESC');
684
		$ele['start'] = new XoopsFormHidden('start', isset($_REQUEST['start'])?intval($_REQUEST['start']):0);
685
		$ele['limit'] = new XoopsFormHidden('limit', isset($_REQUEST['limit'])?intval($_REQUEST['limit']):0);
686
		$ele['filter'] = new XoopsFormHidden('filter', isset($_REQUEST['filter'])?$_REQUEST['filter']:'1,1');
687
688
		$ele['cids'] = new SonglistFormSelectCategory(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_CATEGORY:''), $id.'[cids]', $object->getVar('cids'), 7, true, false, false);
0 ignored issues
show
Unused Code introduced by
The call to SonglistFormSelectCategory::__construct() has too many arguments starting with $as_array == false ? _FR...M_ARTISTS_CATEGORY : ''. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

688
		$ele['cids'] = /** @scrutinizer ignore-call */ new SonglistFormSelectCategory(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_CATEGORY:''), $id.'[cids]', $object->getVar('cids'), 7, true, false, false);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
689
		$ele['cids']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_CATEGORY_DESC:''));
690
		//$ele['singer'] = new SonglistFormSelectSinger(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_SINGER:''), $id.'[singer]', $object->getVar('singer'), 1, false, false, false);
691
		//$ele['singer']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_SINGER_DESC:''));
692
		$ele['name'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_NAME:''), $id.'[name]', ($as_array==false?55:21),128, $object->getVar('name'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('name') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

692
		$ele['name'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_NAME:''), $id.'[name]', ($as_array==false?55:21),128, /** @scrutinizer ignore-type */ $object->getVar('name'));
Loading history...
693
		$ele['name']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_NAME_DESC:''));
694
		$ele['albums'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_ALBUMS:''), $object->getVar('albums'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('albums') can also be of type array and array; however, parameter $value of XoopsFormLabel::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

694
		$ele['albums'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_ALBUMS:''), /** @scrutinizer ignore-type */ $object->getVar('albums'));
Loading history...
695
		$ele['songs'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_SONGS:''), $object->getVar('songs'));
696
		$ele['hits'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_HITS:''), $object->getVar('hits'));
697
		$ele['rank'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_RANK:''), number_format(($object->getVar('rank')>0&&$object->getVar('votes')>0?$object->getVar('rank')/$object->getVar('votes'):0),2). ' of 10');
698
		if ($object->getVar('created')>0) {
699
			$ele['created'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_CREATED:''), date(_DATESTRING, $object->getVar('created')));
700
		}
701
		if ($object->getVar('updated')>0) {
702
			$ele['updated'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_UPDATED:''), date(_DATESTRING, $object->getVar('updated')));
703
		}
704
				
705
		if ($as_array==true)
706
			return $ele;
707
		
708
		$ele['submit'] = new XoopsFormButton('', 'submit', _SUBMIT, 'submit');
709
		
710
		$required = array('name', 'mimetype', 'support');
711
		
712
		foreach($ele as $id => $obj)			
713
			if (in_array($id, $required))
714
				$sform->addElement($ele[$id], true);			
715
			else
716
				$sform->addElement($ele[$id], false);
717
		
718
		return $sform->render();
719
		
720
	}
721
722
	function songlist_category_get_form($object, $as_array=false) {
723
		
724
		if (!is_object($object)) {
725
			$handler = xoops_getmodulehandler('category', 'songlist');
726
			$object = $handler->create(); 
727
		}
728
		
729
		xoops_loadLanguage('forms', 'songlist');
730
		$ele = array();
731
		
732
		if ($object->isNew()) {
733
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_CATEGORY, 'category', $_SERVER['PHP_SELF'], 'post');
734
			$ele['mode'] = new XoopsFormHidden('mode', 'new');
735
		} else {
736
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_CATEGORY, 'category', $_SERVER['PHP_SELF'], 'post');
737
			$ele['mode'] = new XoopsFormHidden('mode', 'edit');
738
		}
739
		
740
		$sform->setExtra( "enctype='multipart/form-data'" ) ;
741
		
742
		$id = $object->getVar('cid');
743
		if (empty($id)) $id = '0';
744
		
745
		$ele['op'] = new XoopsFormHidden('op', 'category');
746
		$ele['fct'] = new XoopsFormHidden('fct', 'save');
747
		if ($as_array==false)
748
			$ele['id'] = new XoopsFormHidden('id', $id);
749
		else 
750
			$ele['id'] = new XoopsFormHidden('id['.$id.']', $id);
751
		$ele['sort'] = new XoopsFormHidden('sort', isset($_REQUEST['sort'])?$_REQUEST['sort']:'created');
752
		$ele['order'] = new XoopsFormHidden('order', isset($_REQUEST['order'])?$_REQUEST['order']:'DESC');
753
		$ele['start'] = new XoopsFormHidden('start', isset($_REQUEST['start'])?intval($_REQUEST['start']):0);
754
		$ele['limit'] = new XoopsFormHidden('limit', isset($_REQUEST['limit'])?intval($_REQUEST['limit']):0);
755
		$ele['filter'] = new XoopsFormHidden('filter', isset($_REQUEST['filter'])?$_REQUEST['filter']:'1,1');
756
757
		$ele['pid'] = new SonglistFormSelectCategory(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_PARENT:''), $id.'[pid]', $object->getVar('pid'), 1, false, $object->getVar('cid'));
0 ignored issues
show
Unused Code introduced by
The call to SonglistFormSelectCategory::__construct() has too many arguments starting with $as_array == false ? _FR...RM_CATEGORY_PARENT : ''. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

757
		$ele['pid'] = /** @scrutinizer ignore-call */ new SonglistFormSelectCategory(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_PARENT:''), $id.'[pid]', $object->getVar('pid'), 1, false, $object->getVar('cid'));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
758
		$ele['pid']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_PARENT_DESC:''));
759
		$ele['name'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_NAME:''), $id.'[name]', ($as_array==false?55:21),128, $object->getVar('name'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('name') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

759
		$ele['name'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_NAME:''), $id.'[name]', ($as_array==false?55:21),128, /** @scrutinizer ignore-type */ $object->getVar('name'));
Loading history...
760
		$ele['name']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_NAME_DESC:''));
761
		$description_configs = array();
762
		$description_configs['name'] = $id.'[description]';
763
		$description_configs['value'] = $object->getVar('description');
764
		$description_configs['rows'] = 35;
765
		$description_configs['cols'] = 60;
766
		$description_configs['width'] = "100%";
767
		$description_configs['height'] = "400px";
768
		$ele['description'] = new XoopsFormEditor(_FRM_SONGLIST_FORM_CATEGORY_DESCRIPTION, $GLOBALS['songlistModuleConfig']['editor'], $description_configs);
769
		$ele['description']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_DESCRIPTION_DESC:''));
770
		$ele['image'] = new XoopsFormFile(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_UPLOAD_POSTER:''), 'image', $GLOBALS['songlistModuleConfig']['filesize_upload']);
771
		$ele['image']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_UPLOAD_POSTER_DESC:''));
772
		if (strlen($object->getVar('image'))>0&&file_exists($GLOBALS['xoops']->path($object->getVar('path').$object->getVar('image')))) {
773
			$ele['image_preview'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_POSTER:''), '<img src="'.$object->getImage('image').'" width="340px" />' );
774
			$ele['image_preview']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_POSTER_DESC:''));
775
		}
776
		$ele['artists'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_ARTISTS:''), $object->getVar('artists'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('artists') can also be of type array and array; however, parameter $value of XoopsFormLabel::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

776
		$ele['artists'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_ARTISTS:''), /** @scrutinizer ignore-type */ $object->getVar('artists'));
Loading history...
777
		$ele['songs'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_SONGS:''), $object->getVar('songs'));
778
		$ele['hits'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_HITS:''), $object->getVar('hits'));
779
		$ele['rank'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_RANK:''), number_format(($object->getVar('rank')>0&&$object->getVar('votes')>0?$object->getVar('rank')/$object->getVar('votes'):0),2). ' of 10');
780
		if ($object->getVar('created')>0) {
781
			$ele['created'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_CREATED:''), date(_DATESTRING, $object->getVar('created')));
782
		}
783
		if ($object->getVar('updated')>0) {
784
			$ele['updated'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_CATEGORY_UPDATED:''), date(_DATESTRING, $object->getVar('updated')));
785
		}
786
		
787
		if ($as_array==true)
788
			return $ele;
789
		
790
		$ele['submit'] = new XoopsFormButton('', 'submit', _SUBMIT, 'submit');
791
		
792
		$required = array('name', 'id', 'source');
793
		
794
		foreach($ele as $id => $obj)			
795
			if (in_array($id, $required))
796
				$sform->addElement($ele[$id], true);			
797
			else
798
				$sform->addElement($ele[$id], false);
799
		
800
		return $sform->render();
801
		
802
	}
803
804
	function songlist_utf8map_get_form($object, $as_array=false) {
805
		
806
		if (!is_object($object)) {
807
			$handler = xoops_getmodulehandler('utf8map', 'songlist');
808
			$object = $handler->create(); 
809
		}
810
		
811
		xoops_loadLanguage('forms', 'songlist');
812
		$ele = array();
813
		
814
		if ($object->isNew()) {
815
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_UTF8MAP, 'utf8map', $_SERVER['PHP_SELF'], 'post');
816
			$ele['mode'] = new XoopsFormHidden('mode', 'new');
817
		} else {
818
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_UTF8MAP, 'utf8map', $_SERVER['PHP_SELF'], 'post');
819
			$ele['mode'] = new XoopsFormHidden('mode', 'edit');
820
		}
821
		
822
		$sform->setExtra( "enctype='multipart/form-data'" ) ;
823
		
824
		$id = $object->getVar('utfid');
825
		if (empty($id)) $id = '0';
826
		
827
		$ele['op'] = new XoopsFormHidden('op', 'utf8map');
828
		$ele['fct'] = new XoopsFormHidden('fct', 'save');
829
		if ($as_array==false)
830
			$ele['id'] = new XoopsFormHidden('id', $id);
831
		else 
832
			$ele['id'] = new XoopsFormHidden('id['.$id.']', $id);
833
		$ele['sort'] = new XoopsFormHidden('sort', isset($_REQUEST['sort'])?$_REQUEST['sort']:'created');
834
		$ele['order'] = new XoopsFormHidden('order', isset($_REQUEST['order'])?$_REQUEST['order']:'DESC');
835
		$ele['start'] = new XoopsFormHidden('start', isset($_REQUEST['start'])?intval($_REQUEST['start']):0);
836
		$ele['limit'] = new XoopsFormHidden('limit', isset($_REQUEST['limit'])?intval($_REQUEST['limit']):0);
837
		$ele['filter'] = new XoopsFormHidden('filter', isset($_REQUEST['filter'])?$_REQUEST['filter']:'1,1');
838
839
		$ele['from'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_UTF8MAP_FROM:''), $id.'[from]', ($as_array==false?6:4),2, $object->getVar('from'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('from') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

839
		$ele['from'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_UTF8MAP_FROM:''), $id.'[from]', ($as_array==false?6:4),2, /** @scrutinizer ignore-type */ $object->getVar('from'));
Loading history...
840
		$ele['from']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_UTF8MAP_FROM_DESC:''));
841
		$ele['to'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_UTF8MAP_TO:''), $id.'[to]', ($as_array==false?6:4),2, $object->getVar('to'));
842
		$ele['to']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_UTF8MAP_TO_DESC:''));
843
		
844
		if ($object->getVar('created')>0) {
845
			$ele['created'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_UTF8MAP_CREATED:''), date(_DATESTRING, $object->getVar('created')));
846
		}
847
		if ($object->getVar('updated')>0) {
848
			$ele['updated'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_UTF8MAP_UPDATED:''), date(_DATESTRING, $object->getVar('updated')));
849
		}
850
		
851
		if ($as_array==true)
852
			return $ele;
853
		
854
		$ele['submit'] = new XoopsFormButton('', 'submit', _SUBMIT, 'submit');
855
		
856
		$required = array('from', 'to');
857
		
858
		foreach($ele as $id => $obj)			
859
			if (in_array($id, $required))
860
				$sform->addElement($ele[$id], true);			
861
			else
862
				$sform->addElement($ele[$id], false);
863
		
864
		return $sform->render();
865
		
866
	}
867
	
868
	function songlist_requests_get_form($object, $as_array=false) {
869
		
870
		if (!is_object($object)) {
871
			$handler = xoops_getmodulehandler('requests', 'songlist');
872
			$object = $handler->create(); 
873
		}
874
		
875
		xoops_loadLanguage('forms', 'songlist');
876
		$ele = array();
877
		
878
		if ($object->isNew()) {
879
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_REQUESTS, 'requests', $_SERVER['PHP_SELF'], 'post');
880
			$ele['mode'] = new XoopsFormHidden('mode', 'new');
881
		} else {
882
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_REQUESTS, 'requests', $_SERVER['PHP_SELF'], 'post');
883
			$ele['mode'] = new XoopsFormHidden('mode', 'edit');
884
		}
885
		
886
		$sform->setExtra( "enctype='multipart/form-data'" ) ;
887
		
888
		$id = $object->getVar('rid');
889
		if (empty($id)) $id = '0';
890
		
891
		$ele['op'] = new XoopsFormHidden('op', 'requests');
892
		$ele['fct'] = new XoopsFormHidden('fct', 'save');
893
		if ($as_array==false)
894
			$ele['id'] = new XoopsFormHidden('id', $id);
895
		else 
896
			$ele['id'] = new XoopsFormHidden('id['.$id.']', $id);
897
		$ele['sort'] = new XoopsFormHidden('sort', isset($_REQUEST['sort'])?$_REQUEST['sort']:'created');
898
		$ele['order'] = new XoopsFormHidden('order', isset($_REQUEST['order'])?$_REQUEST['order']:'DESC');
899
		$ele['start'] = new XoopsFormHidden('start', isset($_REQUEST['start'])?intval($_REQUEST['start']):0);
900
		$ele['limit'] = new XoopsFormHidden('limit', isset($_REQUEST['limit'])?intval($_REQUEST['limit']):0);
901
		$ele['filter'] = new XoopsFormHidden('filter', isset($_REQUEST['filter'])?$_REQUEST['filter']:'1,1');
902
903
		$ele['artist'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_ARTIST:''), $id.'[artist]', ($as_array==false?55:21),128, $object->getVar('artist'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('artist') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

903
		$ele['artist'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_ARTIST:''), $id.'[artist]', ($as_array==false?55:21),128, /** @scrutinizer ignore-type */ $object->getVar('artist'));
Loading history...
904
		$ele['artist']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_ARTIST_DESC:''));
905
		$ele['album'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_ALBUM:''), $id.'[album]', ($as_array==false?55:21),128, $object->getVar('album'));
906
		$ele['album']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_ALBUM_DESC:''));
907
		$ele['title'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_TITLE:''), $id.'[title]', ($as_array==false?55:21),128, $object->getVar('title'));
908
		$ele['title']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_TITLE_DESC:''));
909
		$ele['lyrics'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_LYRICS:''), $id.'[lyrics]', ($as_array==false?55:21),128, $object->getVar('lyrics'));
910
		$ele['lyrics']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_LYRICS_DESC:''));
911
		
912
		if (is_object($GLOBALS['xoopsUser'])) {
913
			$ele['uid'] = new XoopsFormHidden('uid', $GLOBALS['xoopsUser']->getVar('uid'));
914
			$ele['name'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_NAME:''), $id.'[name]', ($as_array==false?55:21),128, ($object->isNew()?$GLOBALS['xoopsUser']->getVar('name'):$object->getVar('name')));
915
			$ele['name']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_NAME_DESC:''));
916
			$ele['email'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_EMAIL:''), $id.'[email]', ($as_array==false?55:21),128, ($object->isNew()?$GLOBALS['xoopsUser']->getVar('email'):$object->getVar('email')));
917
			$ele['email']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_EMAIL_DESC:''));
918
		} else {
919
			$ele['uid'] = new XoopsFormHidden('uid', 0);
920
			$ele['name'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_NAME:''), $id.'[name]', ($as_array==false?55:21),128, ($object->isNew()?'':$object->getVar('name')));
921
			$ele['name']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_NAME_DESC:''));
922
			$ele['email'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_EMAIL:''), $id.'[email]', ($as_array==false?55:21),128, ($object->isNew()?'':$object->getVar('email')));
923
			$ele['email']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_EMAIL_DESC:''));
924
		}		
925
		if ($object->getVar('created')>0) {
926
			$ele['created'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_CREATED:''), date(_DATESTRING, $object->getVar('created')));
927
		}
928
		if ($object->getVar('updated')>0) {
929
			$ele['updated'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_REQUESTS_UPDATED:''), date(_DATESTRING, $object->getVar('updated')));
930
		}
931
		
932
		if ($as_array==true)
933
			return $ele;
934
		
935
		$ele['submit'] = new XoopsFormButton('', 'submit', _SUBMIT, 'submit');
936
		
937
		$required = array('name', 'email');
938
		
939
		foreach($ele as $id => $obj)			
940
			if (in_array($id, $required))
941
				$sform->addElement($ele[$id], true);			
942
			else
943
				$sform->addElement($ele[$id], false);
944
		
945
		return $sform->render();
946
		
947
	}
948
	
949
	
950
	function songlist_songs_get_form($object, $as_array=false) {
951
		
952
		if (!is_object($object)) {
953
			$handler = xoops_getmodulehandler('songs', 'songlist');
954
			$object = $handler->create(); 
955
		}
956
		
957
		xoops_loadLanguage('forms', 'songlist');
958
		$ele = array();
959
		
960
		if ($object->isNew()) {
961
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_SONGS, 'songs', $_SERVER['PHP_SELF'], 'post');
962
			$ele['mode'] = new XoopsFormHidden('mode', 'new');
963
		} else {
964
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_SONGS, 'songs', $_SERVER['PHP_SELF'], 'post');
965
			$ele['mode'] = new XoopsFormHidden('mode', 'edit');
966
		}
967
		
968
		$sform->setExtra( "enctype='multipart/form-data'" ) ;
969
		
970
		$id = $object->getVar('sid');
971
		if (empty($id)) $id = '0';
972
		
973
		$ele['op'] = new XoopsFormHidden('op', 'songs');
974
		$ele['fct'] = new XoopsFormHidden('fct', 'save');
975
		if ($as_array==false)
976
			$ele['id'] = new XoopsFormHidden('id', $id);
977
		else 
978
			$ele['id'] = new XoopsFormHidden('id['.$id.']', $id);
979
		$ele['sort'] = new XoopsFormHidden('sort', isset($_REQUEST['sort'])?$_REQUEST['sort']:'created');
980
		$ele['order'] = new XoopsFormHidden('order', isset($_REQUEST['order'])?$_REQUEST['order']:'DESC');
981
		$ele['start'] = new XoopsFormHidden('start', isset($_REQUEST['start'])?intval($_REQUEST['start']):0);
982
		$ele['limit'] = new XoopsFormHidden('limit', isset($_REQUEST['limit'])?intval($_REQUEST['limit']):0);
983
		$ele['filter'] = new XoopsFormHidden('filter', isset($_REQUEST['filter'])?$_REQUEST['filter']:'1,1');
984
985
		$ele['cid'] = new SonglistFormSelectCategory(($as_array==false?_FRM_SONGLIST_FORM_SONGS_CATEGORY:''), $id.'[cid]', (isset($_REQUEST['cid'])?$_REQUEST['cid']:$object->getVar('cid')), 1, false);
0 ignored issues
show
Unused Code introduced by
The call to SonglistFormSelectCategory::__construct() has too many arguments starting with $as_array == false ? _FR...ORM_SONGS_CATEGORY : ''. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

985
		$ele['cid'] = /** @scrutinizer ignore-call */ new SonglistFormSelectCategory(($as_array==false?_FRM_SONGLIST_FORM_SONGS_CATEGORY:''), $id.'[cid]', (isset($_REQUEST['cid'])?$_REQUEST['cid']:$object->getVar('cid')), 1, false);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
986
		$ele['cid']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_SONGS_CATEGORY_DESC:''));
987
		if ($GLOBALS['songlistModuleConfig']['genre']) {
988
			$ele['gids'] = new SonglistFormSelectGenre(($as_array==false?_FRM_SONGLIST_FORM_SONGS_GENRE:''), $id.'[gids]', (isset($_REQUEST['gids'])?$_REQUEST['gids']:$object->getVar('gids')), 8, true);
0 ignored issues
show
Unused Code introduced by
The call to SonglistFormSelectGenre::__construct() has too many arguments starting with $as_array == false ? _FR...T_FORM_SONGS_GENRE : ''. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

988
			$ele['gids'] = /** @scrutinizer ignore-call */ new SonglistFormSelectGenre(($as_array==false?_FRM_SONGLIST_FORM_SONGS_GENRE:''), $id.'[gids]', (isset($_REQUEST['gids'])?$_REQUEST['gids']:$object->getVar('gids')), 8, true);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
989
			$ele['gids']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_SONGS_GENRE_DESC:''));
990
		}
991
		if ($GLOBALS['songlistModuleConfig']['voice']) {
992
			$ele['vcid'] = new SonglistFormSelectVoice(($as_array==false?_FRM_SONGLIST_FORM_SONGS_VOICE:''), $id.'[vcid]', (isset($_REQUEST['vcid'])?$_REQUEST['vcid']:$object->getVar('vcid')), 1, false);
0 ignored issues
show
Unused Code introduced by
The call to SonglistFormSelectVoice::__construct() has too many arguments starting with $as_array == false ? _FR...T_FORM_SONGS_VOICE : ''. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

992
			$ele['vcid'] = /** @scrutinizer ignore-call */ new SonglistFormSelectVoice(($as_array==false?_FRM_SONGLIST_FORM_SONGS_VOICE:''), $id.'[vcid]', (isset($_REQUEST['vcid'])?$_REQUEST['vcid']:$object->getVar('vcid')), 1, false);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
993
			$ele['vcid']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_SONGS_VOICE_DESC:''));
994
		}		
995
		if ($GLOBALS['songlistModuleConfig']['album']) {
996
			$ele['abid'] = new SonglistFormSelectAlbum(($as_array==false?_FRM_SONGLIST_FORM_SONGS_ALBUM:''), $id.'[abid]', $object->getVar('abid'), 1, false);
0 ignored issues
show
Unused Code introduced by
The call to SonglistFormSelectAlbum::__construct() has too many arguments starting with $as_array == false ? _FR...T_FORM_SONGS_ALBUM : ''. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

996
			$ele['abid'] = /** @scrutinizer ignore-call */ new SonglistFormSelectAlbum(($as_array==false?_FRM_SONGLIST_FORM_SONGS_ALBUM:''), $id.'[abid]', $object->getVar('abid'), 1, false);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
997
			$ele['abid']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_SONGS_ALBUM_DESC:''));
998
		}
999
		$ele['aids'] = new SonglistFormSelectArtist(($as_array==false?_FRM_SONGLIST_FORM_SONGS_ARTISTS:''), $id.'[aids]', $object->getVar('aids'), 7, true);
0 ignored issues
show
Unused Code introduced by
The call to SonglistFormSelectArtist::__construct() has too many arguments starting with $as_array == false ? _FR...FORM_SONGS_ARTISTS : ''. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

999
		$ele['aids'] = /** @scrutinizer ignore-call */ new SonglistFormSelectArtist(($as_array==false?_FRM_SONGLIST_FORM_SONGS_ARTISTS:''), $id.'[aids]', $object->getVar('aids'), 7, true);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
1000
		$ele['aids']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_SONGS_ARTISTS_DESC:''));
1001
		$ele['songid'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_SONGS_SONGID:''), $id.'[songid]', ($as_array==false?25:15),32, $object->getVar('songid'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('songid') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1001
		$ele['songid'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_SONGS_SONGID:''), $id.'[songid]', ($as_array==false?25:15),32, /** @scrutinizer ignore-type */ $object->getVar('songid'));
Loading history...
1002
		$ele['songid']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_SONGS_SONGID_DESC:''));
1003
		$ele['traxid'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_SONGS_TRAXID:''), $id.'[traxid]', ($as_array==false?25:15),32, $object->getVar('traxid'));
1004
		$ele['traxid']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_SONGS_TRAXID_DESC:''));
1005
		$ele['title'] = new XoopsFormText(($as_array==false?_FRM_SONGLIST_FORM_SONGS_TITLE:''), $id.'[title]', ($as_array==false?55:21),128, $object->getVar('title'));
1006
		$ele['title']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_SONGS_TITLE_DESC:''));
1007
		$description_configs = array();
1008
		$description_configs['name'] = $id.'[lyrics]';
1009
		$description_configs['value'] = $object->getVar('lyrics');
1010
		$description_configs['rows'] = 35;
1011
		$description_configs['cols'] = 60;
1012
		$description_configs['width'] = "100%";
1013
		$description_configs['height'] = "400px";
1014
		$ele['lyrics'] = new XoopsFormEditor(_FRM_SONGLIST_FORM_SONGS_LYRICS, $GLOBALS['songlistModuleConfig']['editor'], $description_configs);
1015
		$ele['lyrics']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_SONGS_LYRICS_DESC:''));
1016
		$ele['mp3'] = new XoopsFormFile(($as_array==false?_FRM_SONGLIST_FORM_SONGS_MP3:''), 'mp3'.$id, $GLOBALS['songlistModuleConfig']['mp3_filesize']);
1017
		$ele['mp3']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_SONGS_MP3_DESC:''));
1018
		$category_handler = xoops_getmodulehandler('category', 'songlist');
1019
		$criteria = new CriteriaCompo(new Criteria('cid', (!empty($_REQUEST['cid']))?intval($_REQUEST['cid']):$object->getVar('cid')));
0 ignored issues
show
Bug introduced by
It seems like ! empty($_REQUEST['cid']... $object->getVar('cid') can also be of type array and array; however, parameter $value of Criteria::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1019
		$criteria = new CriteriaCompo(new Criteria('cid', /** @scrutinizer ignore-type */ (!empty($_REQUEST['cid']))?intval($_REQUEST['cid']):$object->getVar('cid')));
Loading history...
1020
		$all_categories = $category_handler->getObjects($criteria, true, false);
1021
1022
		// Dynamic fields
1023
		$extras_handler = xoops_getmodulehandler('extras');
1024
		$gperm_handler = xoops_gethandler('groupperm');
1025
		$module_handler = xoops_gethandler('module');
1026
		$xoModule = $module_handler->getByDirname('songlist');
1027
		$modid = $xoModule->getVar('mid');
1028
		
1029
		if (is_object($GLOBALS['xoopsUser']))
1030
			$groups = $GLOBALS['xoopsUser']->getGroups();
1031
		else
1032
			$groups = array(XOOPS_GROUP_ANONYMOUS=>XOOPS_GROUP_ANONYMOUS);
1033
		
1034
		$count_fields = 0;
1035
		$fields = $extras_handler->loadFields();
1036
		
1037
		$required = array();
1038
		$elements = array();
1039
		$weights = array();
1040
		if ($object->getVar('sid')>0)
1041
			$extra = $extras_handler->get($object->getVar('sid'));
1042
		else
1043
			$extra = $extras_handler->create();
1044
		$allnames = array();
1045
		if (is_array($fields)) {
1046
			foreach (array_keys($fields) as $i) {
1047
				if (($object->getVar('sid')<>0&&$gperm_handler->checkRight('songlist_edit',$fields[$i]->getVar('field_id'),$groups, $modid)) ||
0 ignored issues
show
Bug introduced by
The method checkRight() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1047
				if (($object->getVar('sid')<>0&&$gperm_handler->/** @scrutinizer ignore-call */ checkRight('songlist_edit',$fields[$i]->getVar('field_id'),$groups, $modid)) ||
Loading history...
1048
					($object->getVar('sid')==0&&$gperm_handler->checkRight('songlist_post',$fields[$i]->getVar('field_id'),$groups, $modid))) {
1049
					$fieldinfo['element'] = $fields[$i]->getEditElement($object, $extra);
1050
					$fieldinfo['required'] = $fields[$i]->getVar('field_required');
1051
					foreach($fields[$i]->getVar('cids') as $catidid => $cid) {
1052
						if (!in_array($fields[$i]->getVar('field_name'), $allnames)) {
1053
							$allnames[] = $fields[$i]->getVar('field_name');
1054
							if (in_array($cid, array_keys($all_categories))||$cid==((!empty($_REQUEST['cid']))?intval($_REQUEST['cid']):$object->getVar('cid'))) {
1055
								$key = $all_categories[$cid]['weight'] * $count_fields + $object->getVar('cid');
1056
								$elements[$key][] = $fieldinfo;
1057
								$weights[$key][] = $fields[$i]->getVar('field_weight');
1058
							} elseif (in_array(0, $fields[$i]->getVar('cids'))) {
1059
								$key = $all_categories[$cid]['weight'] * $count_fields + $object->getVar('cid');
1060
								$elements[$key][] = $fieldinfo;
1061
								$weights[$key][] = $fields[$i]->getVar('field_weight');
1062
							}
1063
						}
1064
					}
1065
				}
1066
			}
1067
		}
1068
		if (is_array($elements)) {
0 ignored issues
show
introduced by
The condition is_array($elements) is always true.
Loading history...
1069
			ksort($elements);
1070
			foreach (array_keys($elements) as $k) {
1071
				array_multisort($weights[$k], SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]);
0 ignored issues
show
Bug introduced by
array_keys($elements[$k]) cannot be passed to array_multisort() as the parameter $rest expects a reference. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1071
				array_multisort($weights[$k], SORT_ASC, /** @scrutinizer ignore-type */ array_keys($elements[$k]), SORT_ASC, $elements[$k]);
Loading history...
Bug introduced by
SORT_ASC cannot be passed to array_multisort() as the parameter $rest expects a reference. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1071
				array_multisort($weights[$k], /** @scrutinizer ignore-type */ SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]);
Loading history...
1072
				foreach (array_keys($elements[$k]) as $i) {
1073
					$ele[$k] = $elements[$k][$i]['element'];
1074
					if ($elements[$k][$i]['required']==true) {
1075
						$required[$k] = $elements[$k][$i]['element']->getName();
1076
					}
1077
				}
1078
			}
1079
		}
1080
			
1081
		if (!class_exists('XoopsFormTag')) {
1082
			$ele['tags'] = new XoopsFormHidden('tags', $object->getVar('tags'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('tags') can also be of type array and array; however, parameter $value of XoopsFormHidden::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1082
			$ele['tags'] = new XoopsFormHidden('tags', /** @scrutinizer ignore-type */ $object->getVar('tags'));
Loading history...
1083
		} else {
1084
			$ele['tags'] = new XoopsFormTag('tags', 60, 255, $object->getVar('sid'), $object->getVar('cid'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('sid') can also be of type array and array; however, parameter $value of XoopsFormTag::__construct() does only seem to accept integer|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1084
			$ele['tags'] = new XoopsFormTag('tags', 60, 255, /** @scrutinizer ignore-type */ $object->getVar('sid'), $object->getVar('cid'));
Loading history...
1085
		}
1086
		
1087
		$ele['hits'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_SONGS_HITS:''), $object->getVar('hits'));
0 ignored issues
show
Bug introduced by
It seems like $object->getVar('hits') can also be of type array and array; however, parameter $value of XoopsFormLabel::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1087
		$ele['hits'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_SONGS_HITS:''), /** @scrutinizer ignore-type */ $object->getVar('hits'));
Loading history...
1088
		$ele['rank'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_SONGS_RANK:''), number_format(($object->getVar('rank')>0&&$object->getVar('votes')>0?$object->getVar('rank')/$object->getVar('votes'):0),2). ' of 10');
1089
		if ($object->getVar('created')>0) {
1090
			$ele['created'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_SONGS_CREATED:''), date(_DATESTRING, $object->getVar('created')));
1091
		}
1092
		if ($object->getVar('updated')>0) {
1093
			$ele['updated'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_SONGS_UPDATED:''), date(_DATESTRING, $object->getVar('updated')));
1094
		}
1095
		if ($as_array==true)
1096
			return $ele;
1097
		
1098
		$ele['submit'] = new XoopsFormButton('', 'submit', _SUBMIT, 'submit');
1099
		
1100
		foreach($ele as $id => $obj)			
1101
			if (in_array($id, $required))
1102
				$sform->addElement($ele[$id], true);			
1103
			else
1104
				$sform->addElement($ele[$id], false);
1105
		
1106
		return $sform->render();
1107
		
1108
	}
1109
	
1110
	function songlist_votes_get_form($object, $as_array=false) {
1111
		
1112
		if (!is_object($object)) {
1113
			$handler = xoops_getmodulehandler('votes', 'songlist');
1114
			$object = $handler->create(); 
1115
		}
1116
		
1117
		xoops_loadLanguage('forms', 'songlist');
1118
		$ele = array();
1119
		
1120
		if ($object->isNew()) {
1121
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_CART, 'votes', $_SERVER['PHP_SELF'], 'post');
1122
			$ele['mode'] = new XoopsFormHidden('mode', 'new');
1123
		} else {
1124
			$sform = new XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_CART, 'votes', $_SERVER['PHP_SELF'], 'post');
1125
			$ele['mode'] = new XoopsFormHidden('mode', 'edit');
1126
		}
1127
		
1128
		$sform->setExtra( "enctype='multipart/form-data'" ) ;
1129
		
1130
		$id = $object->getVar('cid');
1131
		if (empty($id)) $id = '0';
1132
		
1133
		$ele['op'] = new XoopsFormHidden('op', 'votes');
1134
		$ele['fct'] = new XoopsFormHidden('fct', 'save');
1135
		if ($as_array==false)
1136
			$ele['id'] = new XoopsFormHidden('id', $id);
1137
		else 
1138
			$ele['id'] = new XoopsFormHidden('id['.$id.']', $id);
1139
		$ele['sort'] = new XoopsFormHidden('sort', isset($_REQUEST['sort'])?$_REQUEST['sort']:'created');
1140
		$ele['order'] = new XoopsFormHidden('order', isset($_REQUEST['order'])?$_REQUEST['order']:'DESC');
1141
		$ele['start'] = new XoopsFormHidden('start', isset($_REQUEST['start'])?intval($_REQUEST['start']):0);
1142
		$ele['limit'] = new XoopsFormHidden('limit', isset($_REQUEST['limit'])?intval($_REQUEST['limit']):0);
1143
		$ele['filter'] = new XoopsFormHidden('filter', isset($_REQUEST['filter'])?$_REQUEST['filter']:'1,1');
1144
1145
		$songs_handler = xoops_getmodulehandler('songs', 'songlist');
1146
		$user_handler = xoops_gethandler('user');
1147
		$song = $songs_handler->get($object->getVar('sid'));
1148
		$user = $user_handler->get($object->getVar('uid'));
1149
		if (is_object($song)) {
1150
			$ele['sid'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOTES_SONG:''), $song->getVar('title'));
0 ignored issues
show
Bug introduced by
It seems like $song->getVar('title') can also be of type array and array; however, parameter $value of XoopsFormLabel::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1150
			$ele['sid'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOTES_SONG:''), /** @scrutinizer ignore-type */ $song->getVar('title'));
Loading history...
1151
		} else {
1152
			$ele['sid'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOTES_SONG:''), $object->getVar('sid'));
1153
		}
1154
		if (is_object($user)) {
1155
			$ele['uid'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOTES_USER:''), $user->getVar('uname'));
1156
		} else {
1157
			$ele['uid'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOTES_USER:''), _GUESTS);
1158
		}
1159
		$ele['ip'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOTES_IP:''), $object->getVar('ip'));
1160
		$ele['netaddy'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOTES_NETADDY:''), $object->getVar('netaddy'));
1161
		$ele['rank'] = new XoopsFormLabel(($as_array==false?_FRM_SONGLIST_FORM_VOTES_RANK:''), $object->getVar('rank'). ' of 10');
1162
		
1163
		if ($as_array==true)
1164
			return $ele;
1165
		
1166
		$ele['submit'] = new XoopsFormButton('', 'submit', _SUBMIT, 'submit');
1167
		
1168
		$required = array();
1169
		
1170
		foreach($ele as $id => $obj)			
1171
			if (in_array($id, $required))
1172
				$sform->addElement($ele[$id], true);			
1173
			else
1174
				$sform->addElement($ele[$id], false);
1175
		
1176
		return $sform->render();
1177
		
1178
	}
1179
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...