Passed
Pull Request — master (#2)
by Michael
07:10 queued 03:28
created
admin/votes.php 2 patches
Indentation   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
 use Xmf\Module\Admin;
4 4
 use Xmf\Request;
5 5
 use XoopsModules\Songlist\{
6
-    Form\FormController,
7
-    Helper,
8
-    Votes,
9
-    VotesHandler,
10
-    Uploader
6
+	Form\FormController,
7
+	Helper,
8
+	Votes,
9
+	VotesHandler,
10
+	Uploader
11 11
 };
12 12
 
13 13
 /** @var Votes $votes */
@@ -27,102 +27,102 @@  discard block
 block discarded – undo
27 27
 $filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1';
28 28
 
29 29
 switch ($op) {
30
-    default:
31
-    case 'votes':
32
-        switch ($fct) {
33
-            default:
34
-            case 'list':
35
-                $adminObject = Admin::getInstance();
36
-                $adminObject->displayNavigation(basename(__FILE__));
37
-
38
-                /** @var VotesHandler $votesHandler */
39
-                $votesHandler = Helper::getInstance()->getHandler('Votes');
40
-
41
-                $criteria        = $votesHandler->getFilterCriteria($GLOBALS['filter']);
42
-                $ttl             = $votesHandler->getCount($criteria);
43
-                $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created';
44
-
45
-                $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']);
46
-                $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav());
47
-
48
-                foreach ($votesHandler->filterFields() as $id => $key) {
49
-                    $GLOBALS['xoopsTpl']->assign(
50
-                        \mb_strtolower(str_replace('-', '_', $key) . '_th'),
51
-                        '<a href="'
52
-                        . $_SERVER['SCRIPT_NAME']
53
-                        . '?start='
54
-                        . $GLOBALS['start']
55
-                        . '&limit='
56
-                        . $GLOBALS['limit']
57
-                        . '&sort='
58
-                        . $key
59
-                        . '&order='
60
-                        . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order'])
61
-                        . '&op='
62
-                        . $GLOBALS['op']
63
-                        . '&filter='
64
-                        . $GLOBALS['filter']
65
-                        . '">'
66
-                        . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key)))
67
-                        . '</a>'
68
-                    );
69
-                    $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $votesHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct']));
70
-                }
71
-
72
-                $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']);
73
-                $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']);
74
-                $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']);
75
-                $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']);
76
-                $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']);
77
-                $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']);
78
-
79
-                $criteria->setStart($GLOBALS['start']);
80
-                $criteria->setLimit($GLOBALS['limit']);
81
-                $criteria->setSort('`' . $GLOBALS['sort'] . '`');
82
-                $criteria->setOrder($GLOBALS['order']);
83
-
84
-                $votess = $votesHandler->getObjects($criteria, true);
85
-                foreach ($votess as $cid => $votes) {
86
-                    if (is_object($votes)) {
87
-                        $GLOBALS['xoopsTpl']->append('categories', $votes->toArray());
88
-                    }
89
-                }
90
-                //$GLOBALS['xoopsTpl']->assign('form', FormController::votes_get_form(false));
91
-                $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']);
92
-                $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_votes_list.tpl');
93
-                break;
94
-            case 'new':
95
-            case 'edit':
96
-                $adminObject = Admin::getInstance();
97
-                $adminObject->displayNavigation(basename(__FILE__));
98
-
99
-                $votesHandler = Helper::getInstance()->getHandler('Votes');
100
-                if (Request::hasVar('id', 'REQUEST')) {
101
-                    $votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST'));
102
-                } else {
103
-                    $votes = $votesHandler->create();
104
-                }
105
-
106
-                $GLOBALS['xoopsTpl']->assign('form', $votes->getForm());
107
-                $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']);
108
-                $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_votes_edit.tpl');
109
-                break;
110
-            case 'save':
111
-                $votesHandler = Helper::getInstance()->getHandler('Votes');
112
-                $id           = 0;
113
-                $id           = Request::getInt('id', 0, 'REQUEST');
114
-                if ($id) {
115
-                    $votes = $votesHandler->get($id);
116
-                } else {
117
-                    $votes = $votesHandler->create();
118
-                }
119
-                $votes->setVars($_POST[$id]);
120
-
121
-                if (!$id = $votesHandler->insert($votes)) {
122
-                    redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE);
123
-                    exit(0);
124
-                }
125
-                if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) {
30
+	default:
31
+	case 'votes':
32
+		switch ($fct) {
33
+			default:
34
+			case 'list':
35
+				$adminObject = Admin::getInstance();
36
+				$adminObject->displayNavigation(basename(__FILE__));
37
+
38
+				/** @var VotesHandler $votesHandler */
39
+				$votesHandler = Helper::getInstance()->getHandler('Votes');
40
+
41
+				$criteria        = $votesHandler->getFilterCriteria($GLOBALS['filter']);
42
+				$ttl             = $votesHandler->getCount($criteria);
43
+				$GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created';
44
+
45
+				$pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']);
46
+				$GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav());
47
+
48
+				foreach ($votesHandler->filterFields() as $id => $key) {
49
+					$GLOBALS['xoopsTpl']->assign(
50
+						\mb_strtolower(str_replace('-', '_', $key) . '_th'),
51
+						'<a href="'
52
+						. $_SERVER['SCRIPT_NAME']
53
+						. '?start='
54
+						. $GLOBALS['start']
55
+						. '&limit='
56
+						. $GLOBALS['limit']
57
+						. '&sort='
58
+						. $key
59
+						. '&order='
60
+						. (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order'])
61
+						. '&op='
62
+						. $GLOBALS['op']
63
+						. '&filter='
64
+						. $GLOBALS['filter']
65
+						. '">'
66
+						. (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key)))
67
+						. '</a>'
68
+					);
69
+					$GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $votesHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct']));
70
+				}
71
+
72
+				$GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']);
73
+				$GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']);
74
+				$GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']);
75
+				$GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']);
76
+				$GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']);
77
+				$GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']);
78
+
79
+				$criteria->setStart($GLOBALS['start']);
80
+				$criteria->setLimit($GLOBALS['limit']);
81
+				$criteria->setSort('`' . $GLOBALS['sort'] . '`');
82
+				$criteria->setOrder($GLOBALS['order']);
83
+
84
+				$votess = $votesHandler->getObjects($criteria, true);
85
+				foreach ($votess as $cid => $votes) {
86
+					if (is_object($votes)) {
87
+						$GLOBALS['xoopsTpl']->append('categories', $votes->toArray());
88
+					}
89
+				}
90
+				//$GLOBALS['xoopsTpl']->assign('form', FormController::votes_get_form(false));
91
+				$GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']);
92
+				$GLOBALS['xoopsTpl']->display('db:songlist_cpanel_votes_list.tpl');
93
+				break;
94
+			case 'new':
95
+			case 'edit':
96
+				$adminObject = Admin::getInstance();
97
+				$adminObject->displayNavigation(basename(__FILE__));
98
+
99
+				$votesHandler = Helper::getInstance()->getHandler('Votes');
100
+				if (Request::hasVar('id', 'REQUEST')) {
101
+					$votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST'));
102
+				} else {
103
+					$votes = $votesHandler->create();
104
+				}
105
+
106
+				$GLOBALS['xoopsTpl']->assign('form', $votes->getForm());
107
+				$GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']);
108
+				$GLOBALS['xoopsTpl']->display('db:songlist_cpanel_votes_edit.tpl');
109
+				break;
110
+			case 'save':
111
+				$votesHandler = Helper::getInstance()->getHandler('Votes');
112
+				$id           = 0;
113
+				$id           = Request::getInt('id', 0, 'REQUEST');
114
+				if ($id) {
115
+					$votes = $votesHandler->get($id);
116
+				} else {
117
+					$votes = $votesHandler->create();
118
+				}
119
+				$votes->setVars($_POST[$id]);
120
+
121
+				if (!$id = $votesHandler->insert($votes)) {
122
+					redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE);
123
+					exit(0);
124
+				}
125
+				if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) {
126 126
 //                    if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) {
127 127
 //                        foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) {
128 128
 //                            foreach (explode('/', $folders) as $folder) {
@@ -135,99 +135,99 @@  discard block
 block discarded – undo
135 135
 //                    }
136 136
 
137 137
 //                    require_once $GLOBALS['xoops']->path('modules/songlist/include/uploader.php');
138
-                    $votes    = $votesHandler->get($id);
139
-                    $uploader = new Uploader(
140
-                        $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']),
141
-                        explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']),
142
-                        $GLOBALS['songlistModuleConfig']['filesize_upload'],
143
-                        0,
144
-                        0,
145
-                        explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions'])
146
-                    );
147
-                    try {
148
-                        $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13));
149
-                    } catch (Exception $e) {
150
-                    }
151
-
152
-                    if ($uploader->fetchMedia('image')) {
153
-                        if (!$uploader->upload()) {
154
-                            $adminObject = Admin::getInstance();
155
-                            $adminObject->displayNavigation(basename(__FILE__));
156
-                            echo $uploader->getErrors();
157
-                            require __DIR__ . '/admin_footer.php';
158
-                            exit(0);
159
-                        }
160
-                        if (mb_strlen($votes->getVar('image'))) {
161
-                            unlink($GLOBALS['xoops']->path($votes->getVar('path')) . $votes->getVar('image'));
162
-                        }
163
-
164
-                        $votes->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']);
165
-                        $votes->setVar('image', $uploader->getSavedFileName());
166
-                        @$votesHandler->insert($votes);
167
-                    } else {
168
-                        $adminObject = Admin::getInstance();
169
-                        $adminObject->displayNavigation(basename(__FILE__));
170
-                        echo $uploader->getErrors();
171
-                        require __DIR__ . '/admin_footer.php';
172
-                        exit(0);
173
-                    }
174
-                }
175
-
176
-                if ('new' === $_REQUEST['state'][$_REQUEST['id']]) {
177
-                    redirect_header(
178
-                        $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
179
-                        10,
180
-                        _AM_SONGLIST_MSG_VOTES_SAVEDOKEY
181
-                    );
182
-                } else {
183
-                    redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY);
184
-                }
185
-                exit(0);
186
-
187
-                break;
188
-            case 'savelist':
189
-                $votesHandler = Helper::getInstance()->getHandler('Votes');
190
-                foreach ($_REQUEST['id'] as $id) {
191
-                    $votes = $votesHandler->get($id);
192
-                    $votes->setVars($_POST[$id]);
193
-                    if (!$votesHandler->insert($votes)) {
194
-                        redirect_header(
195
-                            $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
196
-                            10,
197
-                            _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE
198
-                        );
199
-                        exit(0);
200
-                    }
201
-                }
202
-                redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY);
203
-                exit(0);
204
-                break;
205
-            case 'delete':
206
-                $votesHandler = Helper::getInstance()->getHandler('Votes');
207
-                $id           = 0;
208
-                if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) {
209
-                    $votes = $votesHandler->get($id);
210
-                    if (!$votesHandler->delete($votes)) {
211
-                        redirect_header(
212
-                            $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
213
-                            10,
214
-                            _AM_SONGLIST_MSG_VOTES_FAILEDTODELETE
215
-                        );
216
-                        exit(0);
217
-                    }
218
-                    redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_DELETED);
219
-                    exit(0);
220
-                }
221
-                $votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST'));
222
-                xoops_confirm(
223
-                    ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']],
224
-                    $_SERVER['SCRIPT_NAME'],
225
-                    sprintf(_AM_SONGLIST_MSG_VOTES_DELETE, $votes->getVar('name'))
226
-                );
227
-
228
-                break;
229
-        }
230
-        break;
138
+					$votes    = $votesHandler->get($id);
139
+					$uploader = new Uploader(
140
+						$GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']),
141
+						explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']),
142
+						$GLOBALS['songlistModuleConfig']['filesize_upload'],
143
+						0,
144
+						0,
145
+						explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions'])
146
+					);
147
+					try {
148
+						$uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13));
149
+					} catch (Exception $e) {
150
+					}
151
+
152
+					if ($uploader->fetchMedia('image')) {
153
+						if (!$uploader->upload()) {
154
+							$adminObject = Admin::getInstance();
155
+							$adminObject->displayNavigation(basename(__FILE__));
156
+							echo $uploader->getErrors();
157
+							require __DIR__ . '/admin_footer.php';
158
+							exit(0);
159
+						}
160
+						if (mb_strlen($votes->getVar('image'))) {
161
+							unlink($GLOBALS['xoops']->path($votes->getVar('path')) . $votes->getVar('image'));
162
+						}
163
+
164
+						$votes->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']);
165
+						$votes->setVar('image', $uploader->getSavedFileName());
166
+						@$votesHandler->insert($votes);
167
+					} else {
168
+						$adminObject = Admin::getInstance();
169
+						$adminObject->displayNavigation(basename(__FILE__));
170
+						echo $uploader->getErrors();
171
+						require __DIR__ . '/admin_footer.php';
172
+						exit(0);
173
+					}
174
+				}
175
+
176
+				if ('new' === $_REQUEST['state'][$_REQUEST['id']]) {
177
+					redirect_header(
178
+						$_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
179
+						10,
180
+						_AM_SONGLIST_MSG_VOTES_SAVEDOKEY
181
+					);
182
+				} else {
183
+					redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY);
184
+				}
185
+				exit(0);
186
+
187
+				break;
188
+			case 'savelist':
189
+				$votesHandler = Helper::getInstance()->getHandler('Votes');
190
+				foreach ($_REQUEST['id'] as $id) {
191
+					$votes = $votesHandler->get($id);
192
+					$votes->setVars($_POST[$id]);
193
+					if (!$votesHandler->insert($votes)) {
194
+						redirect_header(
195
+							$_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
196
+							10,
197
+							_AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE
198
+						);
199
+						exit(0);
200
+					}
201
+				}
202
+				redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY);
203
+				exit(0);
204
+				break;
205
+			case 'delete':
206
+				$votesHandler = Helper::getInstance()->getHandler('Votes');
207
+				$id           = 0;
208
+				if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) {
209
+					$votes = $votesHandler->get($id);
210
+					if (!$votesHandler->delete($votes)) {
211
+						redirect_header(
212
+							$_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
213
+							10,
214
+							_AM_SONGLIST_MSG_VOTES_FAILEDTODELETE
215
+						);
216
+						exit(0);
217
+					}
218
+					redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_DELETED);
219
+					exit(0);
220
+				}
221
+				$votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST'));
222
+				xoops_confirm(
223
+					['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']],
224
+					$_SERVER['SCRIPT_NAME'],
225
+					sprintf(_AM_SONGLIST_MSG_VOTES_DELETE, $votes->getVar('name'))
226
+				);
227
+
228
+				break;
229
+		}
230
+		break;
231 231
 }
232 232
 
233 233
 xoops_cp_footer();
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 /** @var Votes $votes */
14 14
 
15
-require __DIR__ . '/header.php';
15
+require __DIR__.'/header.php';
16 16
 
17 17
 xoops_loadLanguage('admin', 'songlist');
18 18
 
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 $limit  = Request::getInt('limit', 30, 'REQUEST');
24 24
 $start  = Request::getInt('start', 0, 'REQUEST');
25 25
 $order  = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC';
26
-$sort   = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created';
27
-$filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1';
26
+$sort   = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created';
27
+$filter = !empty($_REQUEST['filter']) ? ''.$_REQUEST['filter'].'' : '1,1';
28 28
 
29 29
 switch ($op) {
30 30
     default:
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 
41 41
                 $criteria        = $votesHandler->getFilterCriteria($GLOBALS['filter']);
42 42
                 $ttl             = $votesHandler->getCount($criteria);
43
-                $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created';
43
+                $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created';
44 44
 
45
-                $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']);
45
+                $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit='.$GLOBALS['limit'].'&sort='.$GLOBALS['sort'].'&order='.$GLOBALS['order'].'&op='.$GLOBALS['op'].'&fct='.$GLOBALS['fct'].'&filter='.$GLOBALS['filter']);
46 46
                 $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav());
47 47
 
48 48
                 foreach ($votesHandler->filterFields() as $id => $key) {
49 49
                     $GLOBALS['xoopsTpl']->assign(
50
-                        \mb_strtolower(str_replace('-', '_', $key) . '_th'),
50
+                        \mb_strtolower(str_replace('-', '_', $key).'_th'),
51 51
                         '<a href="'
52 52
                         . $_SERVER['SCRIPT_NAME']
53 53
                         . '?start='
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
                         . '&sort='
58 58
                         . $key
59 59
                         . '&order='
60
-                        . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order'])
60
+                        . (($key==$GLOBALS['sort']) ? ('DESC'===$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order'])
61 61
                         . '&op='
62 62
                         . $GLOBALS['op']
63 63
                         . '&filter='
64 64
                         . $GLOBALS['filter']
65 65
                         . '">'
66
-                        . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key)))
66
+                        . (defined('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key)))
67 67
                         . '</a>'
68 68
                     );
69
-                    $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $votesHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct']));
69
+                    $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $votesHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct']));
70 70
                 }
71 71
 
72 72
                 $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
                 $criteria->setStart($GLOBALS['start']);
80 80
                 $criteria->setLimit($GLOBALS['limit']);
81
-                $criteria->setSort('`' . $GLOBALS['sort'] . '`');
81
+                $criteria->setSort('`'.$GLOBALS['sort'].'`');
82 82
                 $criteria->setOrder($GLOBALS['order']);
83 83
 
84 84
                 $votess = $votesHandler->getObjects($criteria, true);
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
                 $votes->setVars($_POST[$id]);
120 120
 
121 121
                 if (!$id = $votesHandler->insert($votes)) {
122
-                    redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE);
122
+                    redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE);
123 123
                     exit(0);
124 124
                 }
125 125
                 if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) {
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                         explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions'])
146 146
                     );
147 147
                     try {
148
-                        $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13));
148
+                        $uploader->setPrefix(mb_substr(md5((string) microtime(true)), random_int(0, 20), 13));
149 149
                     } catch (Exception $e) {
150 150
                     }
151 151
 
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
                             $adminObject = Admin::getInstance();
155 155
                             $adminObject->displayNavigation(basename(__FILE__));
156 156
                             echo $uploader->getErrors();
157
-                            require __DIR__ . '/admin_footer.php';
157
+                            require __DIR__.'/admin_footer.php';
158 158
                             exit(0);
159 159
                         }
160 160
                         if (mb_strlen($votes->getVar('image'))) {
161
-                            unlink($GLOBALS['xoops']->path($votes->getVar('path')) . $votes->getVar('image'));
161
+                            unlink($GLOBALS['xoops']->path($votes->getVar('path')).$votes->getVar('image'));
162 162
                         }
163 163
 
164 164
                         $votes->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']);
@@ -168,19 +168,19 @@  discard block
 block discarded – undo
168 168
                         $adminObject = Admin::getInstance();
169 169
                         $adminObject->displayNavigation(basename(__FILE__));
170 170
                         echo $uploader->getErrors();
171
-                        require __DIR__ . '/admin_footer.php';
171
+                        require __DIR__.'/admin_footer.php';
172 172
                         exit(0);
173 173
                     }
174 174
                 }
175 175
 
176
-                if ('new' === $_REQUEST['state'][$_REQUEST['id']]) {
176
+                if ('new'===$_REQUEST['state'][$_REQUEST['id']]) {
177 177
                     redirect_header(
178
-                        $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
178
+                        $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=edit&id='.$_REQUEST['id'].'&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'],
179 179
                         10,
180 180
                         _AM_SONGLIST_MSG_VOTES_SAVEDOKEY
181 181
                     );
182 182
                 } else {
183
-                    redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY);
183
+                    redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY);
184 184
                 }
185 185
                 exit(0);
186 186
 
@@ -192,14 +192,14 @@  discard block
 block discarded – undo
192 192
                     $votes->setVars($_POST[$id]);
193 193
                     if (!$votesHandler->insert($votes)) {
194 194
                         redirect_header(
195
-                            $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
195
+                            $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'],
196 196
                             10,
197 197
                             _AM_SONGLIST_MSG_VOTES_FAILEDTOSAVE
198 198
                         );
199 199
                         exit(0);
200 200
                     }
201 201
                 }
202
-                redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY);
202
+                redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_SAVEDOKEY);
203 203
                 exit(0);
204 204
                 break;
205 205
             case 'delete':
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
                     $votes = $votesHandler->get($id);
210 210
                     if (!$votesHandler->delete($votes)) {
211 211
                         redirect_header(
212
-                            $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
212
+                            $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'],
213 213
                             10,
214 214
                             _AM_SONGLIST_MSG_VOTES_FAILEDTODELETE
215 215
                         );
216 216
                         exit(0);
217 217
                     }
218
-                    redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_DELETED);
218
+                    redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_VOTES_DELETED);
219 219
                     exit(0);
220 220
                 }
221 221
                 $votes = $votesHandler->get(Request::getInt('id', 0, 'REQUEST'));
Please login to merge, or discard this patch.
admin/requests.php 2 patches
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -3,10 +3,10 @@  discard block
 block discarded – undo
3 3
 use Xmf\Module\Admin;
4 4
 use Xmf\Request;
5 5
 use XoopsModules\Songlist\{
6
-    Form\FormController,
7
-    Helper,
8
-    Requests,
9
-    RequestsHandler,
6
+	Form\FormController,
7
+	Helper,
8
+	Requests,
9
+	RequestsHandler,
10 10
 };
11 11
 
12 12
 /** @var Requests $requests */
@@ -27,156 +27,156 @@  discard block
 block discarded – undo
27 27
 $filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1';
28 28
 
29 29
 switch ($op) {
30
-    default:
31
-    case 'requests':
32
-        switch ($fct) {
33
-            default:
34
-            case 'list':
35
-                $adminObject = Admin::getInstance();
36
-                $adminObject->displayNavigation(basename(__FILE__));
37
-
38
-            /** @var RequestsHandler $requestsHandler */
39
-            $requestsHandler = Helper::getInstance()->getHandler('Requests');
40
-
41
-                $criteria        = $requestsHandler->getFilterCriteria($GLOBALS['filter']);
42
-                $ttl             = $requestsHandler->getCount($criteria);
43
-                $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created';
44
-
45
-                $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']);
46
-                $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav());
47
-
48
-                foreach ($requestsHandler->filterFields() as $id => $key) {
49
-                    $GLOBALS['xoopsTpl']->assign(
50
-                        \mb_strtolower(str_replace('-', '_', $key) . '_th'),
51
-                        '<a href="'
52
-                        . $_SERVER['SCRIPT_NAME']
53
-                        . '?start='
54
-                        . $GLOBALS['start']
55
-                        . '&limit='
56
-                        . $GLOBALS['limit']
57
-                        . '&sort='
58
-                        . $key
59
-                        . '&order='
60
-                        . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order'])
61
-                        . '&op='
62
-                        . $GLOBALS['op']
63
-                        . '&filter='
64
-                        . $GLOBALS['filter']
65
-                        . '">'
66
-                        . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key)))
67
-                        . '</a>'
68
-                    );
69
-                    $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $requestsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct']));
70
-                }
71
-
72
-                $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']);
73
-                $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']);
74
-                $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']);
75
-                $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']);
76
-                $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']);
77
-                $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']);
78
-
79
-                $criteria->setStart($GLOBALS['start']);
80
-                $criteria->setLimit($GLOBALS['limit']);
81
-                $criteria->setSort('`' . $GLOBALS['sort'] . '`');
82
-                $criteria->setOrder($GLOBALS['order']);
83
-
84
-                $requestss = $requestsHandler->getObjects($criteria, true);
85
-                foreach ($requestss as $cid => $requests) {
86
-                    if (is_object($requests)) {
87
-                        $GLOBALS['xoopsTpl']->append('requests', $requests->toArray());
88
-                    }
89
-                }
90
-                $GLOBALS['xoopsTpl']->assign('form', FormController::getFormRequests(false));
91
-                $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']);
92
-                $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_requests_list.tpl');
93
-                break;
94
-            case 'new':
95
-            case 'edit':
96
-                $adminObject = Admin::getInstance();
97
-                $adminObject->displayNavigation(basename(__FILE__));
98
-
99
-                $requestsHandler = Helper::getInstance()->getHandler('Requests');
100
-                if (Request::hasVar('id', 'REQUEST')) {
101
-                    $requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST'));
102
-                } else {
103
-                    $requests = $requestsHandler->create();
104
-                }
105
-
106
-                $GLOBALS['xoopsTpl']->assign('form', $requests->getForm());
107
-                $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']);
108
-                $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_requests_edit.tpl');
109
-                break;
110
-            case 'save':
111
-                $requestsHandler = Helper::getInstance()->getHandler('Requests');
112
-                $id              = 0;
113
-                $id              = Request::getInt('id', 0, 'REQUEST');
114
-                if ($id) {
115
-                    $requests = $requestsHandler->get($id);
116
-                } else {
117
-                    $requests = $requestsHandler->create();
118
-                }
119
-                $requests->setVars($_POST[$id]);
120
-
121
-                if (!$id = $requestsHandler->insert($requests)) {
122
-                    redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE);
123
-                    exit(0);
124
-                }
125
-                if ('new' === $_REQUEST['state'][$_REQUEST['id']]) {
126
-                    redirect_header(
127
-                        $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
128
-                        10,
129
-                        _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY
130
-                    );
131
-                } else {
132
-                    redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY);
133
-                }
134
-                exit(0);
135
-
136
-                break;
137
-            case 'savelist':
138
-                $requestsHandler = Helper::getInstance()->getHandler('Requests');
139
-                foreach ($_REQUEST['id'] as $id) {
140
-                    $requests = $requestsHandler->get($id);
141
-                    $requests->setVars($_POST[$id]);
142
-                    if (!$requestsHandler->insert($requests)) {
143
-                        redirect_header(
144
-                            $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
145
-                            10,
146
-                            _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE
147
-                        );
148
-                        exit(0);
149
-                    }
150
-                }
151
-                redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY);
152
-                exit(0);
153
-                break;
154
-            case 'delete':
155
-                $requestsHandler = Helper::getInstance()->getHandler('Requests');
156
-                $id              = 0;
157
-                if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) {
158
-                    $requests = $requestsHandler->get($id);
159
-                    if (!$requestsHandler->delete($requests)) {
160
-                        redirect_header(
161
-                            $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
162
-                            10,
163
-                            _AM_SONGLIST_MSG_REQUESTS_FAILEDTODELETE
164
-                        );
165
-                        exit(0);
166
-                    }
167
-                    redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_DELETED);
168
-                    exit(0);
169
-                }
170
-                $requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST'));
171
-                xoops_confirm(
172
-                    ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']],
173
-                    $_SERVER['SCRIPT_NAME'],
174
-                    sprintf(_AM_SONGLIST_MSG_REQUESTS_DELETE, $requests->getVar('name'))
175
-                );
176
-
177
-                break;
178
-        }
179
-        break;
30
+	default:
31
+	case 'requests':
32
+		switch ($fct) {
33
+			default:
34
+			case 'list':
35
+				$adminObject = Admin::getInstance();
36
+				$adminObject->displayNavigation(basename(__FILE__));
37
+
38
+			/** @var RequestsHandler $requestsHandler */
39
+			$requestsHandler = Helper::getInstance()->getHandler('Requests');
40
+
41
+				$criteria        = $requestsHandler->getFilterCriteria($GLOBALS['filter']);
42
+				$ttl             = $requestsHandler->getCount($criteria);
43
+				$GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created';
44
+
45
+				$pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']);
46
+				$GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav());
47
+
48
+				foreach ($requestsHandler->filterFields() as $id => $key) {
49
+					$GLOBALS['xoopsTpl']->assign(
50
+						\mb_strtolower(str_replace('-', '_', $key) . '_th'),
51
+						'<a href="'
52
+						. $_SERVER['SCRIPT_NAME']
53
+						. '?start='
54
+						. $GLOBALS['start']
55
+						. '&limit='
56
+						. $GLOBALS['limit']
57
+						. '&sort='
58
+						. $key
59
+						. '&order='
60
+						. (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order'])
61
+						. '&op='
62
+						. $GLOBALS['op']
63
+						. '&filter='
64
+						. $GLOBALS['filter']
65
+						. '">'
66
+						. (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key)))
67
+						. '</a>'
68
+					);
69
+					$GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $requestsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct']));
70
+				}
71
+
72
+				$GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']);
73
+				$GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']);
74
+				$GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']);
75
+				$GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']);
76
+				$GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']);
77
+				$GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']);
78
+
79
+				$criteria->setStart($GLOBALS['start']);
80
+				$criteria->setLimit($GLOBALS['limit']);
81
+				$criteria->setSort('`' . $GLOBALS['sort'] . '`');
82
+				$criteria->setOrder($GLOBALS['order']);
83
+
84
+				$requestss = $requestsHandler->getObjects($criteria, true);
85
+				foreach ($requestss as $cid => $requests) {
86
+					if (is_object($requests)) {
87
+						$GLOBALS['xoopsTpl']->append('requests', $requests->toArray());
88
+					}
89
+				}
90
+				$GLOBALS['xoopsTpl']->assign('form', FormController::getFormRequests(false));
91
+				$GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']);
92
+				$GLOBALS['xoopsTpl']->display('db:songlist_cpanel_requests_list.tpl');
93
+				break;
94
+			case 'new':
95
+			case 'edit':
96
+				$adminObject = Admin::getInstance();
97
+				$adminObject->displayNavigation(basename(__FILE__));
98
+
99
+				$requestsHandler = Helper::getInstance()->getHandler('Requests');
100
+				if (Request::hasVar('id', 'REQUEST')) {
101
+					$requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST'));
102
+				} else {
103
+					$requests = $requestsHandler->create();
104
+				}
105
+
106
+				$GLOBALS['xoopsTpl']->assign('form', $requests->getForm());
107
+				$GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']);
108
+				$GLOBALS['xoopsTpl']->display('db:songlist_cpanel_requests_edit.tpl');
109
+				break;
110
+			case 'save':
111
+				$requestsHandler = Helper::getInstance()->getHandler('Requests');
112
+				$id              = 0;
113
+				$id              = Request::getInt('id', 0, 'REQUEST');
114
+				if ($id) {
115
+					$requests = $requestsHandler->get($id);
116
+				} else {
117
+					$requests = $requestsHandler->create();
118
+				}
119
+				$requests->setVars($_POST[$id]);
120
+
121
+				if (!$id = $requestsHandler->insert($requests)) {
122
+					redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE);
123
+					exit(0);
124
+				}
125
+				if ('new' === $_REQUEST['state'][$_REQUEST['id']]) {
126
+					redirect_header(
127
+						$_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
128
+						10,
129
+						_AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY
130
+					);
131
+				} else {
132
+					redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY);
133
+				}
134
+				exit(0);
135
+
136
+				break;
137
+			case 'savelist':
138
+				$requestsHandler = Helper::getInstance()->getHandler('Requests');
139
+				foreach ($_REQUEST['id'] as $id) {
140
+					$requests = $requestsHandler->get($id);
141
+					$requests->setVars($_POST[$id]);
142
+					if (!$requestsHandler->insert($requests)) {
143
+						redirect_header(
144
+							$_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
145
+							10,
146
+							_AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE
147
+						);
148
+						exit(0);
149
+					}
150
+				}
151
+				redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY);
152
+				exit(0);
153
+				break;
154
+			case 'delete':
155
+				$requestsHandler = Helper::getInstance()->getHandler('Requests');
156
+				$id              = 0;
157
+				if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) {
158
+					$requests = $requestsHandler->get($id);
159
+					if (!$requestsHandler->delete($requests)) {
160
+						redirect_header(
161
+							$_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
162
+							10,
163
+							_AM_SONGLIST_MSG_REQUESTS_FAILEDTODELETE
164
+						);
165
+						exit(0);
166
+					}
167
+					redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_DELETED);
168
+					exit(0);
169
+				}
170
+				$requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST'));
171
+				xoops_confirm(
172
+					['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']],
173
+					$_SERVER['SCRIPT_NAME'],
174
+					sprintf(_AM_SONGLIST_MSG_REQUESTS_DELETE, $requests->getVar('name'))
175
+				);
176
+
177
+				break;
178
+		}
179
+		break;
180 180
 }
181 181
 
182 182
 xoops_cp_footer();
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 /** @var Requests $requests */
13 13
 
14 14
 
15
-require __DIR__ . '/header.php';
15
+require __DIR__.'/header.php';
16 16
 
17 17
 xoops_loadLanguage('admin', 'songlist');
18 18
 
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 $limit  = Request::getInt('limit', 30, 'REQUEST');
24 24
 $start  = Request::getInt('start', 0, 'REQUEST');
25 25
 $order  = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC';
26
-$sort   = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created';
27
-$filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1';
26
+$sort   = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created';
27
+$filter = !empty($_REQUEST['filter']) ? ''.$_REQUEST['filter'].'' : '1,1';
28 28
 
29 29
 switch ($op) {
30 30
     default:
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 
41 41
                 $criteria        = $requestsHandler->getFilterCriteria($GLOBALS['filter']);
42 42
                 $ttl             = $requestsHandler->getCount($criteria);
43
-                $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created';
43
+                $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created';
44 44
 
45
-                $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']);
45
+                $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit='.$GLOBALS['limit'].'&sort='.$GLOBALS['sort'].'&order='.$GLOBALS['order'].'&op='.$GLOBALS['op'].'&fct='.$GLOBALS['fct'].'&filter='.$GLOBALS['filter']);
46 46
                 $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav());
47 47
 
48 48
                 foreach ($requestsHandler->filterFields() as $id => $key) {
49 49
                     $GLOBALS['xoopsTpl']->assign(
50
-                        \mb_strtolower(str_replace('-', '_', $key) . '_th'),
50
+                        \mb_strtolower(str_replace('-', '_', $key).'_th'),
51 51
                         '<a href="'
52 52
                         . $_SERVER['SCRIPT_NAME']
53 53
                         . '?start='
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
                         . '&sort='
58 58
                         . $key
59 59
                         . '&order='
60
-                        . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order'])
60
+                        . (($key==$GLOBALS['sort']) ? ('DESC'===$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order'])
61 61
                         . '&op='
62 62
                         . $GLOBALS['op']
63 63
                         . '&filter='
64 64
                         . $GLOBALS['filter']
65 65
                         . '">'
66
-                        . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key)))
66
+                        . (defined('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_'.\mb_strtoupper(str_replace('-', '_', $key)))
67 67
                         . '</a>'
68 68
                     );
69
-                    $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $requestsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct']));
69
+                    $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $requestsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct']));
70 70
                 }
71 71
 
72 72
                 $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
                 $criteria->setStart($GLOBALS['start']);
80 80
                 $criteria->setLimit($GLOBALS['limit']);
81
-                $criteria->setSort('`' . $GLOBALS['sort'] . '`');
81
+                $criteria->setSort('`'.$GLOBALS['sort'].'`');
82 82
                 $criteria->setOrder($GLOBALS['order']);
83 83
 
84 84
                 $requestss = $requestsHandler->getObjects($criteria, true);
@@ -119,17 +119,17 @@  discard block
 block discarded – undo
119 119
                 $requests->setVars($_POST[$id]);
120 120
 
121 121
                 if (!$id = $requestsHandler->insert($requests)) {
122
-                    redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE);
122
+                    redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE);
123 123
                     exit(0);
124 124
                 }
125
-                if ('new' === $_REQUEST['state'][$_REQUEST['id']]) {
125
+                if ('new'===$_REQUEST['state'][$_REQUEST['id']]) {
126 126
                     redirect_header(
127
-                        $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
127
+                        $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=edit&id='.$_REQUEST['id'].'&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'],
128 128
                         10,
129 129
                         _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY
130 130
                     );
131 131
                 } else {
132
-                    redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY);
132
+                    redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY);
133 133
                 }
134 134
                 exit(0);
135 135
 
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
                     $requests->setVars($_POST[$id]);
142 142
                     if (!$requestsHandler->insert($requests)) {
143 143
                         redirect_header(
144
-                            $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
144
+                            $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'],
145 145
                             10,
146 146
                             _AM_SONGLIST_MSG_REQUESTS_FAILEDTOSAVE
147 147
                         );
148 148
                         exit(0);
149 149
                     }
150 150
                 }
151
-                redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY);
151
+                redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_SAVEDOKEY);
152 152
                 exit(0);
153 153
                 break;
154 154
             case 'delete':
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
                     $requests = $requestsHandler->get($id);
159 159
                     if (!$requestsHandler->delete($requests)) {
160 160
                         redirect_header(
161
-                            $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'],
161
+                            $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'],
162 162
                             10,
163 163
                             _AM_SONGLIST_MSG_REQUESTS_FAILEDTODELETE
164 164
                         );
165 165
                         exit(0);
166 166
                     }
167
-                    redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_DELETED);
167
+                    redirect_header($_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], 10, _AM_SONGLIST_MSG_REQUESTS_DELETED);
168 168
                     exit(0);
169 169
                 }
170 170
                 $requests = $requestsHandler->get(Request::getInt('id', 0, 'REQUEST'));
Please login to merge, or discard this patch.
class/Voice.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -14,96 +14,96 @@
 block discarded – undo
14 14
  */
15 15
 class Voice extends XoopsObject
16 16
 {
17
-    public $vcid;
18
-    public $name;
19
-    public $artists;
20
-    public $albums;
21
-    public $songs;
22
-    public $hits;
23
-    public $rank;
24
-    public $votes;
25
-    public $created;
26
-    public $updated;
17
+	public $vcid;
18
+	public $name;
19
+	public $artists;
20
+	public $albums;
21
+	public $songs;
22
+	public $hits;
23
+	public $rank;
24
+	public $votes;
25
+	public $created;
26
+	public $updated;
27 27
 
28
-    /**
29
-     * Voice constructor.
30
-     * @param null $fid
31
-     */
32
-    public function __construct($fid = null)
33
-    {
34
-        $this->initVar('vcid', \XOBJ_DTYPE_INT, 0, false);
35
-        $this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128);
36
-        $this->initVar('artists', \XOBJ_DTYPE_INT, 0, false);
37
-        $this->initVar('albums', \XOBJ_DTYPE_INT, 0, false);
38
-        $this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
39
-        $this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
40
-        $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
41
-        $this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
42
-        $this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
43
-        $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
44
-    }
28
+	/**
29
+	 * Voice constructor.
30
+	 * @param null $fid
31
+	 */
32
+	public function __construct($fid = null)
33
+	{
34
+		$this->initVar('vcid', \XOBJ_DTYPE_INT, 0, false);
35
+		$this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128);
36
+		$this->initVar('artists', \XOBJ_DTYPE_INT, 0, false);
37
+		$this->initVar('albums', \XOBJ_DTYPE_INT, 0, false);
38
+		$this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
39
+		$this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
40
+		$this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
41
+		$this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
42
+		$this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
43
+		$this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
44
+	}
45 45
 
46
-    /**
47
-     * @param bool $as_array
48
-     * @return array|string
49
-     */
50
-    public function getForm($as_array = false)
51
-    {
52
-        return FormController::getFormVoice($this, $as_array);
53
-    }
46
+	/**
47
+	 * @param bool $as_array
48
+	 * @return array|string
49
+	 */
50
+	public function getForm($as_array = false)
51
+	{
52
+		return FormController::getFormVoice($this, $as_array);
53
+	}
54 54
 
55
-    /**
56
-     * @return array
57
-     */
58
-    public function toArray(): array
59
-    {
60
-        $ret  = parent::toArray();
61
-        $form = $this->getForm(true);
62
-        foreach ($form as $key => $element) {
63
-            $ret['form'][$key] = $element->render();
64
-        }
65
-        foreach (['created', 'updated'] as $key) {
66
-            if ($this->getVar($key) > 0) {
67
-                $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
68
-                $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
69
-            }
70
-        }
71
-        $ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
55
+	/**
56
+	 * @return array
57
+	 */
58
+	public function toArray(): array
59
+	{
60
+		$ret  = parent::toArray();
61
+		$form = $this->getForm(true);
62
+		foreach ($form as $key => $element) {
63
+			$ret['form'][$key] = $element->render();
64
+		}
65
+		foreach (['created', 'updated'] as $key) {
66
+			if ($this->getVar($key) > 0) {
67
+				$ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
68
+				$ret[$key]         = \date(_DATESTRING, $this->getVar($key));
69
+			}
70
+		}
71
+		$ret['rank'] = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
72 72
 
73
-        return $ret;
74
-    }
73
+		return $ret;
74
+	}
75 75
 
76
-    /**
77
-     * @return string
78
-     */
79
-    public function getURL(): string
80
-    {
81
-        global $file, $op, $fct, $id, $value, $gid, $vid, $cid, $start, $limit;
82
-        if ($GLOBALS['songlistModuleConfig']['htaccess']) {
83
-            return XOOPS_URL
84
-                   . '/'
85
-                   . $GLOBALS['songlistModuleConfig']['baseurl']
86
-                   . '/'
87
-                   . $file
88
-                   . '/'
89
-                   . \urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('name')))
90
-                   . '/'
91
-                   . $op
92
-                   . '-'
93
-                   . $fct
94
-                   . '-'
95
-                   . $this->getVar('gid')
96
-                   . '-'
97
-                   . \urlencode($value)
98
-                   . '-'
99
-                   . $gid
100
-                   . '-'
101
-                   . $vid
102
-                   . '-'
103
-                   . $cid
104
-                   . $GLOBALS['songlistModuleConfig']['endofurl'];
105
-        }
76
+	/**
77
+	 * @return string
78
+	 */
79
+	public function getURL(): string
80
+	{
81
+		global $file, $op, $fct, $id, $value, $gid, $vid, $cid, $start, $limit;
82
+		if ($GLOBALS['songlistModuleConfig']['htaccess']) {
83
+			return XOOPS_URL
84
+				   . '/'
85
+				   . $GLOBALS['songlistModuleConfig']['baseurl']
86
+				   . '/'
87
+				   . $file
88
+				   . '/'
89
+				   . \urlencode(\str_replace([' ', \chr(9)], '-', $this->getVar('name')))
90
+				   . '/'
91
+				   . $op
92
+				   . '-'
93
+				   . $fct
94
+				   . '-'
95
+				   . $this->getVar('gid')
96
+				   . '-'
97
+				   . \urlencode($value)
98
+				   . '-'
99
+				   . $gid
100
+				   . '-'
101
+				   . $vid
102
+				   . '-'
103
+				   . $cid
104
+				   . $GLOBALS['songlistModuleConfig']['endofurl'];
105
+		}
106 106
 
107
-        return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=' . $op . '&fct=' . $fct . '&id=' . $this->getVar('gid') . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&vid=' . $vid . '&cid=' . $cid;
108
-    }
107
+		return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=' . $op . '&fct=' . $fct . '&id=' . $this->getVar('gid') . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&vid=' . $vid . '&cid=' . $cid;
108
+	}
109 109
 }
Please login to merge, or discard this patch.
class/Utility.php 1 patch
Indentation   +789 added lines, -789 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@  discard block
 block discarded – undo
4 4
 
5 5
 use Xmf\Request;
6 6
 use XoopsModules\Songlist\Form\{
7
-    SelectAlbumForm,
8
-    SelectCategoryForm,
9
-    SelectGenreForm,
10
-    SelectVoiceForm,
11
-    SelectSongForm
7
+	SelectAlbumForm,
8
+	SelectCategoryForm,
9
+	SelectGenreForm,
10
+	SelectVoiceForm,
11
+	SelectSongForm
12 12
 };
13 13
 
14 14
 /**
@@ -16,788 +16,788 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class Utility extends Common\SysUtility
18 18
 {
19
-    //--------------- Custom module methods -----------------------------
20
-    /**
21
-     * Function responsible for checking if a directory exists, we can also write in and create an index.html file
22
-     *
23
-     * @param string $folder The full path of the directory to check
24
-     */
25
-    public static function createFolder($folder): void
26
-    {
27
-        //        try {
28
-        //            if (!is_dir($folder) && !mkdir($folder) && !is_dir($folder)) {
29
-        //                throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder));
30
-        //            } else {
31
-        //                file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
32
-        //            }
33
-        //        }
34
-        //        catch (\Exception $e) {
35
-        //            echo 'Caught exception: ', $e->getMessage(), "\n", '<br>';
36
-        //        }
37
-        try {
38
-            if (!\is_dir($folder)) {
39
-                if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) {
40
-                    throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder));
41
-                }
42
-                file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
43
-            }
44
-        } catch (\Throwable $e) {
45
-            echo 'Caught exception: ', $e->getMessage(), "\n", '<br>';
46
-        }
47
-    }
48
-
49
-    /**
50
-     * @param string $file
51
-     * @param string $folder
52
-     * @return bool
53
-     */
54
-    public static function copyFile(string $file, string $folder): bool
55
-    {
56
-        return \copy($file, $folder);
57
-        //        try {
58
-        //            if (!is_dir($folder)) {
59
-        //                throw new \RuntimeException(sprintf('Unable to copy file as: %s ', $folder));
60
-        //            } else {
61
-        //                return copy($file, $folder);
62
-        //            }
63
-        //        } catch (\Exception $e) {
64
-        //            echo 'Caught exception: ', $e->getMessage(), "\n", "<br>";
65
-        //        }
66
-        //        return false;
67
-    }
68
-
69
-    /**
70
-     * @param $src
71
-     * @param $dst
72
-     */
73
-    public static function recurseCopy($src, $dst): void
74
-    {
75
-        $dir = \opendir($src);
76
-        //    @mkdir($dst);
77
-        while (false !== ($file = \readdir($dir))) {
78
-            if (('.' !== $file) && ('..' !== $file)) {
79
-                if (\is_dir($src . '/' . $file)) {
80
-                    self::recurseCopy($src . '/' . $file, $dst . '/' . $file);
81
-                } else {
82
-                    \copy($src . '/' . $file, $dst . '/' . $file);
83
-                }
84
-            }
85
-        }
86
-        \closedir($dir);
87
-    }
88
-
89
-    /**
90
-     * Verifies XOOPS version meets minimum requirements for this module
91
-     * @static
92
-     * @param \XoopsModule|null $module
93
-     *
94
-     * @param null|string       $requiredVer
95
-     * @return bool true if meets requirements, false if not
96
-     */
97
-    public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null): bool
98
-    {
99
-        $moduleDirName = \basename(\dirname(__DIR__));
100
-        if (null === $module) {
101
-            $module = \XoopsModule::getByDirname($moduleDirName);
102
-        }
103
-        \xoops_loadLanguage('admin', $moduleDirName);
104
-        \xoops_loadLanguage('common', $moduleDirName);
105
-
106
-        //check for minimum XOOPS version
107
-        $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string
108
-        if (null === $requiredVer) {
109
-            $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
110
-        }
111
-        $success = true;
112
-
113
-        if (\version_compare($currentVer, $requiredVer, '<')) {
114
-            $success = false;
115
-            $module->setErrors(\sprintf(\_AM_SONGLIST_ERROR_BAD_XOOPS, $requiredVer, $currentVer));
116
-        }
117
-
118
-        return $success;
119
-    }
120
-
121
-    /**
122
-     * Verifies PHP version meets minimum requirements for this module
123
-     * @static
124
-     * @param \XoopsModule|bool|null $module
125
-     *
126
-     * @return bool true if meets requirements, false if not
127
-     */
128
-    public static function checkVerPhp(\XoopsModule $module = null): bool
129
-    {
130
-        $moduleDirName      = \basename(\dirname(__DIR__, 2));
131
-        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
132
-        if (null === $module) {
133
-            $module = \XoopsModule::getByDirname($moduleDirName);
134
-        }
135
-        \xoops_loadLanguage('admin', $moduleDirName);
136
-        \xoops_loadLanguage('common', $moduleDirName);
137
-
138
-        // check for minimum PHP version
139
-        $success = true;
140
-
141
-        $verNum = \PHP_VERSION;
142
-        $reqVer = &$module->getInfo('min_php');
143
-
144
-        if (false !== $reqVer && '' !== $reqVer) {
145
-            if (\version_compare($verNum, $reqVer, '<')) {
146
-                $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
147
-                $success = false;
148
-            }
149
-        }
150
-
151
-        return $success;
152
-    }
153
-
154
-    /**
155
-     * compares current module version with the latest GitHub release
156
-     * @static
157
-     *
158
-     * @return string|array info about the latest module version, if newer
159
-     */
160
-    public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array
161
-    {
162
-        $moduleDirName      = \basename(\dirname(__DIR__, 2));
163
-        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
164
-        $update             = '';
165
-        $repository         = 'XoopsModules25x/' . $moduleDirName;
166
-        //        $repository         = 'XoopsModules25x/publisher'; //for testing only
167
-        $ret             = null;
168
-        $infoReleasesUrl = "https://api.github.com/repos/$repository/releases";
169
-        if ('github' === $source) {
170
-            if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) {
171
-                \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl);
172
-                \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true);
173
-                \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized'
174
-                \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]);
175
-                $curlReturn = \curl_exec($curlHandle);
176
-                if (false === $curlReturn) {
177
-                    \trigger_error(\curl_error($curlHandle));
178
-                } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) {
179
-                    \trigger_error('Repository Not Found: ' . $infoReleasesUrl);
180
-                } else {
181
-                    $file              = json_decode($curlReturn, false);
182
-                    $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default);
183
-                    $latestVersion     = $file[0]->tag_name;
184
-                    $prerelease        = $file[0]->prerelease;
185
-                    if ('master' !== $latestVersionLink) {
186
-                        $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion;
187
-                    }
188
-                    //"PHP-standardized" version
189
-                    $latestVersion = \mb_strtolower($latestVersion);
190
-                    if (false !== mb_strpos($latestVersion, 'final')) {
191
-                        $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion));
192
-                        $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion));
193
-                    }
194
-                    $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status'));
195
-                    //"PHP-standardized" version
196
-                    $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion));
197
-                    //                    $moduleVersion = '1.0'; //for testing only
198
-                    //                    $moduleDirName = 'publisher'; //for testing only
199
-                    if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) {
200
-                        $ret   = [];
201
-                        $ret[] = $update;
202
-                        $ret[] = $latestVersionLink;
203
-                    }
204
-                }
205
-                \curl_close($curlHandle);
206
-            }
207
-        }
208
-
209
-        return $ret;
210
-    }
211
-
212
-    //=========================================================
213
-
214
-    /**
215
-     * @return mixed
216
-     */
217
-    public static function getToken()
218
-    {
219
-        $sql    = 'SELECT md5(rand()/rand()*rand()/rand()*rand()*rand()/rand()*rand()) as `salt`';
220
-        $result = $GLOBALS['xoopsDB']->queryF($sql);
221
-        [$salt] = $GLOBALS['xoopsDB']->fetchRow($result);
222
-
223
-        return $salt;
224
-    }
225
-
226
-    /**
227
-     * @param $string
228
-     * @return string
229
-     */
230
-    public static function ucword($string): string
231
-    {
232
-        $ret = [];
233
-        foreach (explode(' ', \mb_strtolower($string)) as $part) {
234
-            $ret[] = ucfirst($part);
235
-        }
236
-
237
-        return implode(' ', $ret);
238
-    }
239
-
240
-    /**
241
-     * @param bool|string $ip
242
-     * @return array
243
-     */
244
-    public static function getIPData($ip = false): array
245
-    {
246
-        $ret = [];
247
-        if (is_object($GLOBALS['xoopsUser'])) {
248
-            $ret['uid']   = $GLOBALS['xoopsUser']->getVar('uid');
249
-            $ret['uname'] = $GLOBALS['xoopsUser']->getVar('uname');
250
-            $ret['email'] = $GLOBALS['xoopsUser']->getVar('email');
251
-        } else {
252
-            $ret['uid']   = 0;
253
-            $ret['uname'] = ($_REQUEST['uname'] ?? '');
254
-            $ret['email'] = ($_REQUEST['email'] ?? '');
255
-        }
256
-        $ret['agent'] = $_SERVER['HTTP_USER_AGENT'];
257
-        if ($ip) {
258
-            $ret['is_proxied']   = false;
259
-            $ret['network-addy'] = @gethostbyaddr($ip);
260
-            $ret['long']         = @ip2long($ip);
261
-            if (isIpv6($ip)) {
262
-                $ret['ip6'] = true;
263
-                $ret['ip4'] = false;
264
-            } else {
265
-                $ret['ip4'] = true;
266
-                $ret['ip6'] = false;
267
-            }
268
-            $ret['ip'] = $ip;
269
-        } elseif (Request::hasVar('HTTP_X_FORWARDED_FOR', 'SERVER')) {
270
-            $ip                  = $_SERVER['HTTP_X_FORWARDED_FOR'];
271
-            $ret['is_proxied']   = true;
272
-            $proxy_ip            = $_SERVER['REMOTE_ADDR'];
273
-            $ret['network-addy'] = @gethostbyaddr($ip);
274
-            $ret['long']         = @ip2long($ip);
275
-            if (isIpv6($ip)) {
276
-                $ret['ip6']       = true;
277
-                $ret['proxy-ip6'] = true;
278
-                $ret['ip4']       = false;
279
-                $ret['proxy-ip4'] = false;
280
-            } else {
281
-                $ret['ip4']       = true;
282
-                $ret['proxy-ip4'] = true;
283
-                $ret['ip6']       = false;
284
-                $ret['proxy-ip6'] = false;
285
-            }
286
-            $ret['ip']       = $ip;
287
-            $ret['proxy-ip'] = $proxy_ip;
288
-        } else {
289
-            $ret['is_proxied']   = false;
290
-            $ip                  = $_SERVER['REMOTE_ADDR'];
291
-            $ret['network-addy'] = @gethostbyaddr($ip);
292
-            $ret['long']         = @ip2long($ip);
293
-            if (isIpv6($ip)) {
294
-                $ret['ip6'] = true;
295
-                $ret['ip4'] = false;
296
-            } else {
297
-                $ret['ip4'] = true;
298
-                $ret['ip6'] = false;
299
-            }
300
-            $ret['ip'] = $ip;
301
-        }
302
-        $ret['made'] = time();
303
-
304
-        return $ret;
305
-    }
306
-
307
-    /**
308
-     * @param string $ip
309
-     * @return bool
310
-     */
311
-    public static function isIpv6($ip = ''): bool
312
-    {
313
-        if ('' == $ip) {
314
-            return false;
315
-        }
316
-
317
-        if (mb_substr_count($ip, ':') > 0) {
318
-            return true;
319
-        }
320
-
321
-        return false;
322
-    }
323
-
324
-    /**
325
-     * @param        $filter
326
-     * @param        $field
327
-     * @param string $sort
328
-     * @param string $op
329
-     * @param string $fct
330
-     * @return bool|\XoopsModules\Songlist\Form\SelectAlbumForm|\XoopsModules\Songlist\Form\SelectArtistForm|\XoopsModules\Songlist\Form\SelectCategoryForm|\XoopsModules\Songlist\Form\SelectGenreForm|\XoopsModules\Songlist\Form\SelectVoiceForm
331
-     */
332
-    public static function getFilterElement($filter, $field, $sort = 'created', $op = '', $fct = '')
333
-    {
334
-        $components = static::getFilterURLComponents($filter, $field, $sort);
335
-        $ele        = false;
336
-        require_once dirname(__DIR__) . '/include/songlist.object.php';
337
-        switch ($field) {
338
-            case 'gid':
339
-                if ('genre' !== $op) {
340
-                    $ele = new SelectGenreForm('', 'filter_' . $field . '', $components['value'], 1, false);
341
-                    $ele->setExtra(
342
-                        'onchange="window.open(\''
343
-                        . $_SERVER['SCRIPT_NAME']
344
-                        . '?'
345
-                        . $components['extra']
346
-                        . '&filter='
347
-                        . $components['filter']
348
-                        . (!empty($components['filter']) ? '|' : '')
349
-                        . $field
350
-                        . ',\'+this.options[this.selectedIndex].value'
351
-                        . (!empty($components['operator']) ? '+\','
352
-                                                             . $components['operator']
353
-                                                             . '\'' : '')
354
-                        . ',\'_self\')"'
355
-                    );
356
-                }
357
-                break;
358
-            case 'vcid':
359
-                if ('voice' !== $op) {
360
-                    $ele = new SelectVoiceForm('', 'filter_' . $field . '', $components['value'], 1, false);
361
-                    $ele->setExtra(
362
-                        'onchange="window.open(\''
363
-                        . $_SERVER['SCRIPT_NAME']
364
-                        . '?'
365
-                        . $components['extra']
366
-                        . '&filter='
367
-                        . $components['filter']
368
-                        . (!empty($components['filter']) ? '|' : '')
369
-                        . $field
370
-                        . ',\'+this.options[this.selectedIndex].value'
371
-                        . (!empty($components['operator']) ? '+\','
372
-                                                             . $components['operator']
373
-                                                             . '\'' : '')
374
-                        . ',\'_self\')"'
375
-                    );
376
-                }
377
-                break;
378
-            case 'cid':
379
-                if ('category' !== $op) {
380
-                    $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false);
381
-                    $ele->setExtra(
382
-                        'onchange="window.open(\''
383
-                        . $_SERVER['SCRIPT_NAME']
384
-                        . '?'
385
-                        . $components['extra']
386
-                        . '&filter='
387
-                        . $components['filter']
388
-                        . (!empty($components['filter']) ? '|' : '')
389
-                        . $field
390
-                        . ',\'+this.options[this.selectedIndex].value'
391
-                        . (!empty($components['operator']) ? '+\','
392
-                                                             . $components['operator']
393
-                                                             . '\'' : '')
394
-                        . ',\'_self\')"'
395
-                    );
396
-                }
397
-                break;
398
-            case 'pid':
399
-                $ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false);
400
-                $ele->setExtra(
401
-                    'onchange="window.open(\''
402
-                    . $_SERVER['SCRIPT_NAME']
403
-                    . '?'
404
-                    . $components['extra']
405
-                    . '&filter='
406
-                    . $components['filter']
407
-                    . (!empty($components['filter']) ? '|' : '')
408
-                    . $field
409
-                    . ',\'+this.options[this.selectedIndex].value'
410
-                    . (!empty($components['operator']) ? '+\','
411
-                                                         . $components['operator']
412
-                                                         . '\'' : '')
413
-                    . ',\'_self\')"'
414
-                );
415
-                break;
416
-            case 'abid':
417
-                if ('albums' !== $op) {
418
-                    $ele = new SelectAlbumForm('', 'filter_' . $field . '', $components['value'], 1, false);
419
-                    $ele->setExtra(
420
-                        'onchange="window.open(\''
421
-                        . $_SERVER['SCRIPT_NAME']
422
-                        . '?'
423
-                        . $components['extra']
424
-                        . '&filter='
425
-                        . $components['filter']
426
-                        . (!empty($components['filter']) ? '|' : '')
427
-                        . $field
428
-                        . ',\'+this.options[this.selectedIndex].value'
429
-                        . (!empty($components['operator']) ? '+\','
430
-                                                             . $components['operator']
431
-                                                             . '\'' : '')
432
-                        . ',\'_self\')"'
433
-                    );
434
-                }
435
-                break;
436
-            case 'aid':
437
-                if ('artists' !== $op) {
438
-                    $ele = new SelectArtistForm('', 'filter_' . $field . '', $components['value'], 1, false);
439
-                    $ele->setExtra(
440
-                        'onchange="window.open(\''
441
-                        . $_SERVER['SCRIPT_NAME']
442
-                        . '?'
443
-                        . $components['extra']
444
-                        . '&filter='
445
-                        . $components['filter']
446
-                        . (!empty($components['filter']) ? '|' : '')
447
-                        . $field
448
-                        . ',\'+this.options[this.selectedIndex].value'
449
-                        . (!empty($components['operator']) ? '+\','
450
-                                                             . $components['operator']
451
-                                                             . '\'' : '')
452
-                        . ',\'_self\')"'
453
-                    );
454
-                }
455
-                break;
456
-            case 'sid':
457
-                if ('songs' !== $op) {
458
-                    $ele = new SelectSongForm('', 'filter_' . $field . '', $components['value'], 1, false);
459
-                    $ele->setExtra(
460
-                        'onchange="window.open(\''
461
-                        . $_SERVER['SCRIPT_NAME']
462
-                        . '?'
463
-                        . $components['extra']
464
-                        . '&filter='
465
-                        . $components['filter']
466
-                        . (!empty($components['filter']) ? '|' : '')
467
-                        . $field
468
-                        . ',\'+this.options[this.selectedIndex].value'
469
-                        . (!empty($components['operator']) ? '+\','
470
-                                                             . $components['operator']
471
-                                                             . '\'' : '')
472
-                        . ',\'_self\')"'
473
-                    );
474
-                }
475
-                break;
476
-            case 'name':
477
-            case 'title':
478
-            case 'artists':
479
-            case 'albums':
480
-            case 'songs':
481
-            case 'hits':
482
-            case 'rank':
483
-            case 'votes':
484
-            case 'description':
485
-            case 'lyrics':
486
-            case 'songid':
487
-            case 'tags':
488
-                $ele = new \XoopsFormElementTray('');
489
-                $ele->addElement(new \XoopsFormText('', 'filter_' . $field . '', 11, 40, $components['value']));
490
-                $button = new \XoopsFormButton('', 'button_' . $field . '', '[+]');
491
-                $button->setExtra(
492
-                    'onclick="window.open(\''
493
-                    . $_SERVER['SCRIPT_NAME']
494
-                    . '?'
495
-                    . $components['extra']
496
-                    . '&filter='
497
-                    . $components['filter']
498
-                    . (!empty($components['filter']) ? '|' : '')
499
-                    . $field
500
-                    . ',\'+$(\'#filter_'
501
-                    . $field
502
-                    . '\').val()'
503
-                    . (!empty($components['operator']) ? '+\','
504
-                                                         . $components['operator']
505
-                                                         . '\'' : '')
506
-                    . ',\'_self\')"'
507
-                );
508
-                $ele->addElement($button);
509
-                break;
510
-        }
511
-
512
-        return $ele;
513
-    }
514
-
515
-    /**
516
-     * @param        $filter
517
-     * @param        $field
518
-     * @param string $sort
519
-     * @return array
520
-     */
521
-    public static function getFilterURLComponents($filter, $field, $sort = 'created'): array
522
-    {
523
-        $parts     = explode('|', $filter);
524
-        $ret       = [];
525
-        $value     = '';
526
-        $ele_value = '';
527
-        $operator  = '';
528
-        foreach ($parts as $part) {
529
-            $var = explode(',', $part);
530
-            if (count($var) > 1) {
531
-                if ($var[0] == $field) {
532
-                    $ele_value = $var[1];
533
-                    if (isset($var[2])) {
534
-                        $operator = $var[2];
535
-                    }
536
-                } elseif (1 != $var[0]) {
537
-                    $ret[] = implode(',', $var);
538
-                }
539
-            }
540
-        }
541
-        $pagenav          = [];
542
-        $pagenav['op']    = $_REQUEST['op'] ?? 'videos';
543
-        $pagenav['fct']   = $_REQUEST['fct'] ?? 'list';
544
-        $pagenav['limit'] = Request::getInt('limit', 30, 'REQUEST');
545
-        $pagenav['start'] = 0;
546
-        $pagenav['order'] = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC';
547
-        $pagenav['sort']  = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : $sort;
548
-        $retb             = [];
549
-        foreach ($pagenav as $key => $value) {
550
-            $retb[] = "$key=$value";
551
-        }
552
-
553
-        return ['value' => $ele_value, 'field' => $field, 'operator' => $operator, 'filter' => implode('|', $ret), 'extra' => implode('&', $retb)];
554
-    }
555
-
556
-    /**
557
-     * @param $objects
558
-     * @return array
559
-     */
560
-    public static function obj2array($objects): array
561
-    {
562
-        $ret = [];
563
-        foreach ((array)$objects as $key => $value) {
564
-            if (is_a($value, 'stdClass')) {
565
-                $ret[$key] = static::obj2array($value);
566
-            } elseif (is_array($value)) {
567
-                $ret[$key] = static::obj2array($value);
568
-            } else {
569
-                $ret[$key] = $value;
570
-            }
571
-        }
572
-
573
-        return $ret;
574
-    }
575
-
576
-    /**
577
-     * @param $url
578
-     * @return mixed
579
-     */
580
-    public static function shortenUrl($url)
581
-    {
582
-        /** @var \XoopsModuleHandler $moduleHandler */
583
-        $moduleHandler = xoops_getHandler('module');
584
-        /** @var \XoopsConfigHandler $configHandler */
585
-        $configHandler                   = xoops_getHandler('config');
586
-        $GLOBALS['songlistModule']       = $moduleHandler->getByDirname('songlist');
587
-        $GLOBALS['songlistModuleConfig'] = $configHandler->getConfigList($GLOBALS['songlistModule']->getVar('mid'));
588
-
589
-        if (!empty($GLOBALS['songlistModuleConfig']['bitly_username']) && !empty($GLOBALS['songlistModuleConfig']['bitly_apikey'])) {
590
-            $source_url = $GLOBALS['songlistModuleConfig']['bitly_apiurl'] . '/shorten?login=' . $GLOBALS['songlistModuleConfig']['bitly_username'] . '&apiKey=' . $GLOBALS['songlistModuleConfig']['bitly_apikey'] . '&format=json&longUrl=' . urlencode($url);
591
-            $cookies    = XOOPS_ROOT_PATH . '/uploads/songlist_' . md5($GLOBALS['songlistModuleConfig']['bitly_apikey']) . '.cookie';
592
-            if (!$ch = curl_init($source_url)) {
593
-                return $url;
594
-            }
595
-            curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
596
-            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
597
-            curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS['songlistModuleConfig']['user_agent']);
598
-            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $GLOBALS['songlistModuleConfig']['curl_connect_timeout']);
599
-            curl_setopt($ch, CURLOPT_TIMEOUT, $GLOBALS['songlistModuleConfig']['curl_timeout']);
600
-            $data = curl_exec($ch);
601
-            curl_close($ch);
602
-            $result                = songlist_object2array(json_decode($data));
603
-            $result['status_code'] = 200;
604
-            if ($result['status_code']) {
605
-                if (!empty($result['data']['url'])) {
606
-                    return $result['data']['url'];
607
-                }
608
-
609
-                return $url;
610
-            }
611
-
612
-            return $url;
613
-        }
614
-
615
-        return $url;
616
-    }
617
-
618
-    /**
619
-     * @param        $contents
620
-     * @param int    $get_attributes
621
-     * @param string $priority
622
-     * @return array|void
623
-     */
624
-    public static function xml2array($contents, $get_attributes = 1, $priority = 'tag')
625
-    {
626
-        if (!$contents) {
627
-            return [];
628
-        }
629
-
630
-        if (!function_exists('xml_parser_create')) {
631
-            return [];
632
-        }
633
-
634
-        //Get the XML parser of PHP - PHP must have this module for the parser to work
635
-        $parser = xml_parser_create('');
636
-        xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); # https://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
637
-        xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
638
-        xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
639
-        xml_parse_into_struct($parser, trim($contents), $xml_values);
640
-        xml_parser_free($parser);
641
-
642
-        if (!$xml_values) {
643
-            return;
644
-        }//Hmm...
645
-
646
-        //Initializations
647
-        $xml_array   = [];
648
-        $parents     = [];
649
-        $opened_tags = [];
650
-        $arr         = [];
651
-
652
-        $current = &$xml_array; //Refference
653
-
654
-        //Go through the tags.
655
-        $repeated_tag_index = []; //Multiple tags with same name will be turned into an array
656
-        foreach ($xml_values as $data) {
657
-            unset($attributes, $value); //Remove existing values, or there will be trouble
658
-
659
-            //This command will extract these variables into the foreach scope
660
-            // tag(string), type(string), level(int), attributes(array).
661
-            extract($data); //We could use the array by itself, but this cooler.
662
-
663
-            $result          = [];
664
-            $attributes_data = [];
665
-
666
-            if (isset($value)) {
667
-                if ('tag' === $priority) {
668
-                    $result = $value;
669
-                } else {
670
-                    $result['value'] = $value;
671
-                } //Put the value in a assoc array if we are in the 'Attribute' mode
672
-            }
673
-
674
-            //Set the attributes too.
675
-            if (isset($attributes) and $get_attributes) {
676
-                foreach ($attributes as $attr => $val) {
677
-                    if ('tag' === $priority) {
678
-                        $attributes_data[$attr] = $val;
679
-                    } else {
680
-                        $result['attr'][$attr] = $val;
681
-                    } //Set all the attributes in a array called 'attr'
682
-                }
683
-            }
684
-
685
-            //See tag status and do the needed.
686
-            if ('open' === $type) {//The starting of the tag '<tag>'
687
-                $parent[$level - 1] = &$current;
688
-                if (!is_array($current) or (!array_key_exists($tag, $current))) { //Insert New tag
689
-                    $current[$tag] = $result;
690
-                    if ($attributes_data) {
691
-                        $current[$tag . '_attr'] = $attributes_data;
692
-                    }
693
-                    $repeated_tag_index[$tag . '_' . $level] = 1;
694
-
695
-                    $current = &$current[$tag];
696
-                } else { //There was another element with the same tag name
697
-                    if (isset($current[$tag][0])) {//If there is a 0th element it is already an array
698
-                        $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
699
-                        $repeated_tag_index[$tag . '_' . $level]++;
700
-                    } else {//This section will make the value an array if multiple tags with the same name appear together
701
-                        $current[$tag]                           = [$current[$tag], $result]; //This will combine the existing item and the new item together to make an array
702
-                        $repeated_tag_index[$tag . '_' . $level] = 2;
703
-
704
-                        if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well
705
-                            $current[$tag]['0_attr'] = $current[$tag . '_attr'];
706
-                            unset($current[$tag . '_attr']);
707
-                        }
708
-                    }
709
-                    $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1;
710
-                    $current         = &$current[$tag][$last_item_index];
711
-                }
712
-            } elseif ('complete' === $type) { //Tags that ends in 1 line '<tag>'
713
-                //See if the key is already taken.
714
-                if (isset($current[$tag])) { //If taken, put all things inside a list(array)
715
-                    if (isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array...
716
-                        // ...push the new element into that array.
717
-                        $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
718
-
719
-                        if ('tag' === $priority and $get_attributes and $attributes_data) {
720
-                            $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
721
-                        }
722
-                        $repeated_tag_index[$tag . '_' . $level]++;
723
-                    } else { //If it is not an array...
724
-                        $current[$tag]                           = [$current[$tag], $result]; //...Make it an array using using the existing value and the new value
725
-                        $repeated_tag_index[$tag . '_' . $level] = 1;
726
-                        if ('tag' === $priority and $get_attributes) {
727
-                            if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well
728
-                                $current[$tag]['0_attr'] = $current[$tag . '_attr'];
729
-                                unset($current[$tag . '_attr']);
730
-                            }
731
-
732
-                            if ($attributes_data) {
733
-                                $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
734
-                            }
735
-                        }
736
-                        $repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken
737
-                    }
738
-                } else { //New Key
739
-                    $current[$tag]                           = $result;
740
-                    $repeated_tag_index[$tag . '_' . $level] = 1;
741
-                    if ('tag' === $priority and $attributes_data) {
742
-                        $current[$tag . '_attr'] = $attributes_data;
743
-                    }
744
-                }
745
-            } elseif ('close' === $type) { //End of tag '</tag>'
746
-                $current = &$parent[$level - 1];
747
-            }
748
-        }
749
-
750
-        return $xml_array;
751
-    }
752
-
753
-    /**
754
-     * @param $array
755
-     * @param $name
756
-     * @param $standalone
757
-     * @param $beginning
758
-     * @param $nested
759
-     * @return string
760
-     */
761
-    public static function toXml($array, $name, $standalone, $beginning, $nested): string
762
-    {
763
-        $output = '';
764
-        if ($beginning) {
765
-            if ($standalone) {
766
-                header('content-type:text/xml;charset=' . _CHARSET);
767
-            }
768
-            $output .= '<' . '?' . 'xml version="1.0" encoding="' . _CHARSET . '"' . '?' . '>' . "\n";
769
-            $output .= '<' . $name . '>' . "\n";
770
-            $nested = 0;
771
-        }
772
-
773
-        if (is_array($array)) {
774
-            foreach ($array as $key => $value) {
775
-                ++$nested;
776
-                if (is_array($value)) {
777
-                    $output .= str_repeat("\t", (int)$nested) . '<' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n";
778
-                    ++$nested;
779
-                    $output .= static::toXml($value, $name, false, false, $nested);
780
-                    $nested--;
781
-                    $output .= str_repeat("\t", (int)$nested) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n";
782
-                } elseif ('' != $value) {
783
-                    ++$nested;
784
-                    $output .= str_repeat("\t", (int)$nested) . '  <' . (is_string($key) ? $key : $name . '_' . $key) . '>' . trim($value) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n";
785
-                    $nested--;
786
-                }
787
-                $nested--;
788
-            }
789
-        } elseif ('' != $array) {
790
-            ++$nested;
791
-            $output .= str_repeat("\t", (int)$nested) . trim($array) . "\n";
792
-            $nested--;
793
-        }
794
-
795
-        if ($beginning) {
796
-            $output .= '</' . $name . '>';
797
-
798
-            return $output;
799
-        }
800
-
801
-        return $output;
802
-    }
19
+	//--------------- Custom module methods -----------------------------
20
+	/**
21
+	 * Function responsible for checking if a directory exists, we can also write in and create an index.html file
22
+	 *
23
+	 * @param string $folder The full path of the directory to check
24
+	 */
25
+	public static function createFolder($folder): void
26
+	{
27
+		//        try {
28
+		//            if (!is_dir($folder) && !mkdir($folder) && !is_dir($folder)) {
29
+		//                throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder));
30
+		//            } else {
31
+		//                file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
32
+		//            }
33
+		//        }
34
+		//        catch (\Exception $e) {
35
+		//            echo 'Caught exception: ', $e->getMessage(), "\n", '<br>';
36
+		//        }
37
+		try {
38
+			if (!\is_dir($folder)) {
39
+				if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) {
40
+					throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder));
41
+				}
42
+				file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
43
+			}
44
+		} catch (\Throwable $e) {
45
+			echo 'Caught exception: ', $e->getMessage(), "\n", '<br>';
46
+		}
47
+	}
48
+
49
+	/**
50
+	 * @param string $file
51
+	 * @param string $folder
52
+	 * @return bool
53
+	 */
54
+	public static function copyFile(string $file, string $folder): bool
55
+	{
56
+		return \copy($file, $folder);
57
+		//        try {
58
+		//            if (!is_dir($folder)) {
59
+		//                throw new \RuntimeException(sprintf('Unable to copy file as: %s ', $folder));
60
+		//            } else {
61
+		//                return copy($file, $folder);
62
+		//            }
63
+		//        } catch (\Exception $e) {
64
+		//            echo 'Caught exception: ', $e->getMessage(), "\n", "<br>";
65
+		//        }
66
+		//        return false;
67
+	}
68
+
69
+	/**
70
+	 * @param $src
71
+	 * @param $dst
72
+	 */
73
+	public static function recurseCopy($src, $dst): void
74
+	{
75
+		$dir = \opendir($src);
76
+		//    @mkdir($dst);
77
+		while (false !== ($file = \readdir($dir))) {
78
+			if (('.' !== $file) && ('..' !== $file)) {
79
+				if (\is_dir($src . '/' . $file)) {
80
+					self::recurseCopy($src . '/' . $file, $dst . '/' . $file);
81
+				} else {
82
+					\copy($src . '/' . $file, $dst . '/' . $file);
83
+				}
84
+			}
85
+		}
86
+		\closedir($dir);
87
+	}
88
+
89
+	/**
90
+	 * Verifies XOOPS version meets minimum requirements for this module
91
+	 * @static
92
+	 * @param \XoopsModule|null $module
93
+	 *
94
+	 * @param null|string       $requiredVer
95
+	 * @return bool true if meets requirements, false if not
96
+	 */
97
+	public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null): bool
98
+	{
99
+		$moduleDirName = \basename(\dirname(__DIR__));
100
+		if (null === $module) {
101
+			$module = \XoopsModule::getByDirname($moduleDirName);
102
+		}
103
+		\xoops_loadLanguage('admin', $moduleDirName);
104
+		\xoops_loadLanguage('common', $moduleDirName);
105
+
106
+		//check for minimum XOOPS version
107
+		$currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string
108
+		if (null === $requiredVer) {
109
+			$requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
110
+		}
111
+		$success = true;
112
+
113
+		if (\version_compare($currentVer, $requiredVer, '<')) {
114
+			$success = false;
115
+			$module->setErrors(\sprintf(\_AM_SONGLIST_ERROR_BAD_XOOPS, $requiredVer, $currentVer));
116
+		}
117
+
118
+		return $success;
119
+	}
120
+
121
+	/**
122
+	 * Verifies PHP version meets minimum requirements for this module
123
+	 * @static
124
+	 * @param \XoopsModule|bool|null $module
125
+	 *
126
+	 * @return bool true if meets requirements, false if not
127
+	 */
128
+	public static function checkVerPhp(\XoopsModule $module = null): bool
129
+	{
130
+		$moduleDirName      = \basename(\dirname(__DIR__, 2));
131
+		$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
132
+		if (null === $module) {
133
+			$module = \XoopsModule::getByDirname($moduleDirName);
134
+		}
135
+		\xoops_loadLanguage('admin', $moduleDirName);
136
+		\xoops_loadLanguage('common', $moduleDirName);
137
+
138
+		// check for minimum PHP version
139
+		$success = true;
140
+
141
+		$verNum = \PHP_VERSION;
142
+		$reqVer = &$module->getInfo('min_php');
143
+
144
+		if (false !== $reqVer && '' !== $reqVer) {
145
+			if (\version_compare($verNum, $reqVer, '<')) {
146
+				$module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
147
+				$success = false;
148
+			}
149
+		}
150
+
151
+		return $success;
152
+	}
153
+
154
+	/**
155
+	 * compares current module version with the latest GitHub release
156
+	 * @static
157
+	 *
158
+	 * @return string|array info about the latest module version, if newer
159
+	 */
160
+	public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array
161
+	{
162
+		$moduleDirName      = \basename(\dirname(__DIR__, 2));
163
+		$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
164
+		$update             = '';
165
+		$repository         = 'XoopsModules25x/' . $moduleDirName;
166
+		//        $repository         = 'XoopsModules25x/publisher'; //for testing only
167
+		$ret             = null;
168
+		$infoReleasesUrl = "https://api.github.com/repos/$repository/releases";
169
+		if ('github' === $source) {
170
+			if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) {
171
+				\curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl);
172
+				\curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true);
173
+				\curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized'
174
+				\curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]);
175
+				$curlReturn = \curl_exec($curlHandle);
176
+				if (false === $curlReturn) {
177
+					\trigger_error(\curl_error($curlHandle));
178
+				} elseif (false !== \mb_strpos($curlReturn, 'Not Found')) {
179
+					\trigger_error('Repository Not Found: ' . $infoReleasesUrl);
180
+				} else {
181
+					$file              = json_decode($curlReturn, false);
182
+					$latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default);
183
+					$latestVersion     = $file[0]->tag_name;
184
+					$prerelease        = $file[0]->prerelease;
185
+					if ('master' !== $latestVersionLink) {
186
+						$update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion;
187
+					}
188
+					//"PHP-standardized" version
189
+					$latestVersion = \mb_strtolower($latestVersion);
190
+					if (false !== mb_strpos($latestVersion, 'final')) {
191
+						$latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion));
192
+						$latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion));
193
+					}
194
+					$moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status'));
195
+					//"PHP-standardized" version
196
+					$moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion));
197
+					//                    $moduleVersion = '1.0'; //for testing only
198
+					//                    $moduleDirName = 'publisher'; //for testing only
199
+					if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) {
200
+						$ret   = [];
201
+						$ret[] = $update;
202
+						$ret[] = $latestVersionLink;
203
+					}
204
+				}
205
+				\curl_close($curlHandle);
206
+			}
207
+		}
208
+
209
+		return $ret;
210
+	}
211
+
212
+	//=========================================================
213
+
214
+	/**
215
+	 * @return mixed
216
+	 */
217
+	public static function getToken()
218
+	{
219
+		$sql    = 'SELECT md5(rand()/rand()*rand()/rand()*rand()*rand()/rand()*rand()) as `salt`';
220
+		$result = $GLOBALS['xoopsDB']->queryF($sql);
221
+		[$salt] = $GLOBALS['xoopsDB']->fetchRow($result);
222
+
223
+		return $salt;
224
+	}
225
+
226
+	/**
227
+	 * @param $string
228
+	 * @return string
229
+	 */
230
+	public static function ucword($string): string
231
+	{
232
+		$ret = [];
233
+		foreach (explode(' ', \mb_strtolower($string)) as $part) {
234
+			$ret[] = ucfirst($part);
235
+		}
236
+
237
+		return implode(' ', $ret);
238
+	}
239
+
240
+	/**
241
+	 * @param bool|string $ip
242
+	 * @return array
243
+	 */
244
+	public static function getIPData($ip = false): array
245
+	{
246
+		$ret = [];
247
+		if (is_object($GLOBALS['xoopsUser'])) {
248
+			$ret['uid']   = $GLOBALS['xoopsUser']->getVar('uid');
249
+			$ret['uname'] = $GLOBALS['xoopsUser']->getVar('uname');
250
+			$ret['email'] = $GLOBALS['xoopsUser']->getVar('email');
251
+		} else {
252
+			$ret['uid']   = 0;
253
+			$ret['uname'] = ($_REQUEST['uname'] ?? '');
254
+			$ret['email'] = ($_REQUEST['email'] ?? '');
255
+		}
256
+		$ret['agent'] = $_SERVER['HTTP_USER_AGENT'];
257
+		if ($ip) {
258
+			$ret['is_proxied']   = false;
259
+			$ret['network-addy'] = @gethostbyaddr($ip);
260
+			$ret['long']         = @ip2long($ip);
261
+			if (isIpv6($ip)) {
262
+				$ret['ip6'] = true;
263
+				$ret['ip4'] = false;
264
+			} else {
265
+				$ret['ip4'] = true;
266
+				$ret['ip6'] = false;
267
+			}
268
+			$ret['ip'] = $ip;
269
+		} elseif (Request::hasVar('HTTP_X_FORWARDED_FOR', 'SERVER')) {
270
+			$ip                  = $_SERVER['HTTP_X_FORWARDED_FOR'];
271
+			$ret['is_proxied']   = true;
272
+			$proxy_ip            = $_SERVER['REMOTE_ADDR'];
273
+			$ret['network-addy'] = @gethostbyaddr($ip);
274
+			$ret['long']         = @ip2long($ip);
275
+			if (isIpv6($ip)) {
276
+				$ret['ip6']       = true;
277
+				$ret['proxy-ip6'] = true;
278
+				$ret['ip4']       = false;
279
+				$ret['proxy-ip4'] = false;
280
+			} else {
281
+				$ret['ip4']       = true;
282
+				$ret['proxy-ip4'] = true;
283
+				$ret['ip6']       = false;
284
+				$ret['proxy-ip6'] = false;
285
+			}
286
+			$ret['ip']       = $ip;
287
+			$ret['proxy-ip'] = $proxy_ip;
288
+		} else {
289
+			$ret['is_proxied']   = false;
290
+			$ip                  = $_SERVER['REMOTE_ADDR'];
291
+			$ret['network-addy'] = @gethostbyaddr($ip);
292
+			$ret['long']         = @ip2long($ip);
293
+			if (isIpv6($ip)) {
294
+				$ret['ip6'] = true;
295
+				$ret['ip4'] = false;
296
+			} else {
297
+				$ret['ip4'] = true;
298
+				$ret['ip6'] = false;
299
+			}
300
+			$ret['ip'] = $ip;
301
+		}
302
+		$ret['made'] = time();
303
+
304
+		return $ret;
305
+	}
306
+
307
+	/**
308
+	 * @param string $ip
309
+	 * @return bool
310
+	 */
311
+	public static function isIpv6($ip = ''): bool
312
+	{
313
+		if ('' == $ip) {
314
+			return false;
315
+		}
316
+
317
+		if (mb_substr_count($ip, ':') > 0) {
318
+			return true;
319
+		}
320
+
321
+		return false;
322
+	}
323
+
324
+	/**
325
+	 * @param        $filter
326
+	 * @param        $field
327
+	 * @param string $sort
328
+	 * @param string $op
329
+	 * @param string $fct
330
+	 * @return bool|\XoopsModules\Songlist\Form\SelectAlbumForm|\XoopsModules\Songlist\Form\SelectArtistForm|\XoopsModules\Songlist\Form\SelectCategoryForm|\XoopsModules\Songlist\Form\SelectGenreForm|\XoopsModules\Songlist\Form\SelectVoiceForm
331
+	 */
332
+	public static function getFilterElement($filter, $field, $sort = 'created', $op = '', $fct = '')
333
+	{
334
+		$components = static::getFilterURLComponents($filter, $field, $sort);
335
+		$ele        = false;
336
+		require_once dirname(__DIR__) . '/include/songlist.object.php';
337
+		switch ($field) {
338
+			case 'gid':
339
+				if ('genre' !== $op) {
340
+					$ele = new SelectGenreForm('', 'filter_' . $field . '', $components['value'], 1, false);
341
+					$ele->setExtra(
342
+						'onchange="window.open(\''
343
+						. $_SERVER['SCRIPT_NAME']
344
+						. '?'
345
+						. $components['extra']
346
+						. '&filter='
347
+						. $components['filter']
348
+						. (!empty($components['filter']) ? '|' : '')
349
+						. $field
350
+						. ',\'+this.options[this.selectedIndex].value'
351
+						. (!empty($components['operator']) ? '+\','
352
+															 . $components['operator']
353
+															 . '\'' : '')
354
+						. ',\'_self\')"'
355
+					);
356
+				}
357
+				break;
358
+			case 'vcid':
359
+				if ('voice' !== $op) {
360
+					$ele = new SelectVoiceForm('', 'filter_' . $field . '', $components['value'], 1, false);
361
+					$ele->setExtra(
362
+						'onchange="window.open(\''
363
+						. $_SERVER['SCRIPT_NAME']
364
+						. '?'
365
+						. $components['extra']
366
+						. '&filter='
367
+						. $components['filter']
368
+						. (!empty($components['filter']) ? '|' : '')
369
+						. $field
370
+						. ',\'+this.options[this.selectedIndex].value'
371
+						. (!empty($components['operator']) ? '+\','
372
+															 . $components['operator']
373
+															 . '\'' : '')
374
+						. ',\'_self\')"'
375
+					);
376
+				}
377
+				break;
378
+			case 'cid':
379
+				if ('category' !== $op) {
380
+					$ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false);
381
+					$ele->setExtra(
382
+						'onchange="window.open(\''
383
+						. $_SERVER['SCRIPT_NAME']
384
+						. '?'
385
+						. $components['extra']
386
+						. '&filter='
387
+						. $components['filter']
388
+						. (!empty($components['filter']) ? '|' : '')
389
+						. $field
390
+						. ',\'+this.options[this.selectedIndex].value'
391
+						. (!empty($components['operator']) ? '+\','
392
+															 . $components['operator']
393
+															 . '\'' : '')
394
+						. ',\'_self\')"'
395
+					);
396
+				}
397
+				break;
398
+			case 'pid':
399
+				$ele = new SelectCategoryForm('', 'filter_' . $field . '', $components['value'], 1, false);
400
+				$ele->setExtra(
401
+					'onchange="window.open(\''
402
+					. $_SERVER['SCRIPT_NAME']
403
+					. '?'
404
+					. $components['extra']
405
+					. '&filter='
406
+					. $components['filter']
407
+					. (!empty($components['filter']) ? '|' : '')
408
+					. $field
409
+					. ',\'+this.options[this.selectedIndex].value'
410
+					. (!empty($components['operator']) ? '+\','
411
+														 . $components['operator']
412
+														 . '\'' : '')
413
+					. ',\'_self\')"'
414
+				);
415
+				break;
416
+			case 'abid':
417
+				if ('albums' !== $op) {
418
+					$ele = new SelectAlbumForm('', 'filter_' . $field . '', $components['value'], 1, false);
419
+					$ele->setExtra(
420
+						'onchange="window.open(\''
421
+						. $_SERVER['SCRIPT_NAME']
422
+						. '?'
423
+						. $components['extra']
424
+						. '&filter='
425
+						. $components['filter']
426
+						. (!empty($components['filter']) ? '|' : '')
427
+						. $field
428
+						. ',\'+this.options[this.selectedIndex].value'
429
+						. (!empty($components['operator']) ? '+\','
430
+															 . $components['operator']
431
+															 . '\'' : '')
432
+						. ',\'_self\')"'
433
+					);
434
+				}
435
+				break;
436
+			case 'aid':
437
+				if ('artists' !== $op) {
438
+					$ele = new SelectArtistForm('', 'filter_' . $field . '', $components['value'], 1, false);
439
+					$ele->setExtra(
440
+						'onchange="window.open(\''
441
+						. $_SERVER['SCRIPT_NAME']
442
+						. '?'
443
+						. $components['extra']
444
+						. '&filter='
445
+						. $components['filter']
446
+						. (!empty($components['filter']) ? '|' : '')
447
+						. $field
448
+						. ',\'+this.options[this.selectedIndex].value'
449
+						. (!empty($components['operator']) ? '+\','
450
+															 . $components['operator']
451
+															 . '\'' : '')
452
+						. ',\'_self\')"'
453
+					);
454
+				}
455
+				break;
456
+			case 'sid':
457
+				if ('songs' !== $op) {
458
+					$ele = new SelectSongForm('', 'filter_' . $field . '', $components['value'], 1, false);
459
+					$ele->setExtra(
460
+						'onchange="window.open(\''
461
+						. $_SERVER['SCRIPT_NAME']
462
+						. '?'
463
+						. $components['extra']
464
+						. '&filter='
465
+						. $components['filter']
466
+						. (!empty($components['filter']) ? '|' : '')
467
+						. $field
468
+						. ',\'+this.options[this.selectedIndex].value'
469
+						. (!empty($components['operator']) ? '+\','
470
+															 . $components['operator']
471
+															 . '\'' : '')
472
+						. ',\'_self\')"'
473
+					);
474
+				}
475
+				break;
476
+			case 'name':
477
+			case 'title':
478
+			case 'artists':
479
+			case 'albums':
480
+			case 'songs':
481
+			case 'hits':
482
+			case 'rank':
483
+			case 'votes':
484
+			case 'description':
485
+			case 'lyrics':
486
+			case 'songid':
487
+			case 'tags':
488
+				$ele = new \XoopsFormElementTray('');
489
+				$ele->addElement(new \XoopsFormText('', 'filter_' . $field . '', 11, 40, $components['value']));
490
+				$button = new \XoopsFormButton('', 'button_' . $field . '', '[+]');
491
+				$button->setExtra(
492
+					'onclick="window.open(\''
493
+					. $_SERVER['SCRIPT_NAME']
494
+					. '?'
495
+					. $components['extra']
496
+					. '&filter='
497
+					. $components['filter']
498
+					. (!empty($components['filter']) ? '|' : '')
499
+					. $field
500
+					. ',\'+$(\'#filter_'
501
+					. $field
502
+					. '\').val()'
503
+					. (!empty($components['operator']) ? '+\','
504
+														 . $components['operator']
505
+														 . '\'' : '')
506
+					. ',\'_self\')"'
507
+				);
508
+				$ele->addElement($button);
509
+				break;
510
+		}
511
+
512
+		return $ele;
513
+	}
514
+
515
+	/**
516
+	 * @param        $filter
517
+	 * @param        $field
518
+	 * @param string $sort
519
+	 * @return array
520
+	 */
521
+	public static function getFilterURLComponents($filter, $field, $sort = 'created'): array
522
+	{
523
+		$parts     = explode('|', $filter);
524
+		$ret       = [];
525
+		$value     = '';
526
+		$ele_value = '';
527
+		$operator  = '';
528
+		foreach ($parts as $part) {
529
+			$var = explode(',', $part);
530
+			if (count($var) > 1) {
531
+				if ($var[0] == $field) {
532
+					$ele_value = $var[1];
533
+					if (isset($var[2])) {
534
+						$operator = $var[2];
535
+					}
536
+				} elseif (1 != $var[0]) {
537
+					$ret[] = implode(',', $var);
538
+				}
539
+			}
540
+		}
541
+		$pagenav          = [];
542
+		$pagenav['op']    = $_REQUEST['op'] ?? 'videos';
543
+		$pagenav['fct']   = $_REQUEST['fct'] ?? 'list';
544
+		$pagenav['limit'] = Request::getInt('limit', 30, 'REQUEST');
545
+		$pagenav['start'] = 0;
546
+		$pagenav['order'] = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC';
547
+		$pagenav['sort']  = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : $sort;
548
+		$retb             = [];
549
+		foreach ($pagenav as $key => $value) {
550
+			$retb[] = "$key=$value";
551
+		}
552
+
553
+		return ['value' => $ele_value, 'field' => $field, 'operator' => $operator, 'filter' => implode('|', $ret), 'extra' => implode('&', $retb)];
554
+	}
555
+
556
+	/**
557
+	 * @param $objects
558
+	 * @return array
559
+	 */
560
+	public static function obj2array($objects): array
561
+	{
562
+		$ret = [];
563
+		foreach ((array)$objects as $key => $value) {
564
+			if (is_a($value, 'stdClass')) {
565
+				$ret[$key] = static::obj2array($value);
566
+			} elseif (is_array($value)) {
567
+				$ret[$key] = static::obj2array($value);
568
+			} else {
569
+				$ret[$key] = $value;
570
+			}
571
+		}
572
+
573
+		return $ret;
574
+	}
575
+
576
+	/**
577
+	 * @param $url
578
+	 * @return mixed
579
+	 */
580
+	public static function shortenUrl($url)
581
+	{
582
+		/** @var \XoopsModuleHandler $moduleHandler */
583
+		$moduleHandler = xoops_getHandler('module');
584
+		/** @var \XoopsConfigHandler $configHandler */
585
+		$configHandler                   = xoops_getHandler('config');
586
+		$GLOBALS['songlistModule']       = $moduleHandler->getByDirname('songlist');
587
+		$GLOBALS['songlistModuleConfig'] = $configHandler->getConfigList($GLOBALS['songlistModule']->getVar('mid'));
588
+
589
+		if (!empty($GLOBALS['songlistModuleConfig']['bitly_username']) && !empty($GLOBALS['songlistModuleConfig']['bitly_apikey'])) {
590
+			$source_url = $GLOBALS['songlistModuleConfig']['bitly_apiurl'] . '/shorten?login=' . $GLOBALS['songlistModuleConfig']['bitly_username'] . '&apiKey=' . $GLOBALS['songlistModuleConfig']['bitly_apikey'] . '&format=json&longUrl=' . urlencode($url);
591
+			$cookies    = XOOPS_ROOT_PATH . '/uploads/songlist_' . md5($GLOBALS['songlistModuleConfig']['bitly_apikey']) . '.cookie';
592
+			if (!$ch = curl_init($source_url)) {
593
+				return $url;
594
+			}
595
+			curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
596
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
597
+			curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS['songlistModuleConfig']['user_agent']);
598
+			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $GLOBALS['songlistModuleConfig']['curl_connect_timeout']);
599
+			curl_setopt($ch, CURLOPT_TIMEOUT, $GLOBALS['songlistModuleConfig']['curl_timeout']);
600
+			$data = curl_exec($ch);
601
+			curl_close($ch);
602
+			$result                = songlist_object2array(json_decode($data));
603
+			$result['status_code'] = 200;
604
+			if ($result['status_code']) {
605
+				if (!empty($result['data']['url'])) {
606
+					return $result['data']['url'];
607
+				}
608
+
609
+				return $url;
610
+			}
611
+
612
+			return $url;
613
+		}
614
+
615
+		return $url;
616
+	}
617
+
618
+	/**
619
+	 * @param        $contents
620
+	 * @param int    $get_attributes
621
+	 * @param string $priority
622
+	 * @return array|void
623
+	 */
624
+	public static function xml2array($contents, $get_attributes = 1, $priority = 'tag')
625
+	{
626
+		if (!$contents) {
627
+			return [];
628
+		}
629
+
630
+		if (!function_exists('xml_parser_create')) {
631
+			return [];
632
+		}
633
+
634
+		//Get the XML parser of PHP - PHP must have this module for the parser to work
635
+		$parser = xml_parser_create('');
636
+		xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); # https://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
637
+		xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
638
+		xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
639
+		xml_parse_into_struct($parser, trim($contents), $xml_values);
640
+		xml_parser_free($parser);
641
+
642
+		if (!$xml_values) {
643
+			return;
644
+		}//Hmm...
645
+
646
+		//Initializations
647
+		$xml_array   = [];
648
+		$parents     = [];
649
+		$opened_tags = [];
650
+		$arr         = [];
651
+
652
+		$current = &$xml_array; //Refference
653
+
654
+		//Go through the tags.
655
+		$repeated_tag_index = []; //Multiple tags with same name will be turned into an array
656
+		foreach ($xml_values as $data) {
657
+			unset($attributes, $value); //Remove existing values, or there will be trouble
658
+
659
+			//This command will extract these variables into the foreach scope
660
+			// tag(string), type(string), level(int), attributes(array).
661
+			extract($data); //We could use the array by itself, but this cooler.
662
+
663
+			$result          = [];
664
+			$attributes_data = [];
665
+
666
+			if (isset($value)) {
667
+				if ('tag' === $priority) {
668
+					$result = $value;
669
+				} else {
670
+					$result['value'] = $value;
671
+				} //Put the value in a assoc array if we are in the 'Attribute' mode
672
+			}
673
+
674
+			//Set the attributes too.
675
+			if (isset($attributes) and $get_attributes) {
676
+				foreach ($attributes as $attr => $val) {
677
+					if ('tag' === $priority) {
678
+						$attributes_data[$attr] = $val;
679
+					} else {
680
+						$result['attr'][$attr] = $val;
681
+					} //Set all the attributes in a array called 'attr'
682
+				}
683
+			}
684
+
685
+			//See tag status and do the needed.
686
+			if ('open' === $type) {//The starting of the tag '<tag>'
687
+				$parent[$level - 1] = &$current;
688
+				if (!is_array($current) or (!array_key_exists($tag, $current))) { //Insert New tag
689
+					$current[$tag] = $result;
690
+					if ($attributes_data) {
691
+						$current[$tag . '_attr'] = $attributes_data;
692
+					}
693
+					$repeated_tag_index[$tag . '_' . $level] = 1;
694
+
695
+					$current = &$current[$tag];
696
+				} else { //There was another element with the same tag name
697
+					if (isset($current[$tag][0])) {//If there is a 0th element it is already an array
698
+						$current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
699
+						$repeated_tag_index[$tag . '_' . $level]++;
700
+					} else {//This section will make the value an array if multiple tags with the same name appear together
701
+						$current[$tag]                           = [$current[$tag], $result]; //This will combine the existing item and the new item together to make an array
702
+						$repeated_tag_index[$tag . '_' . $level] = 2;
703
+
704
+						if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well
705
+							$current[$tag]['0_attr'] = $current[$tag . '_attr'];
706
+							unset($current[$tag . '_attr']);
707
+						}
708
+					}
709
+					$last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1;
710
+					$current         = &$current[$tag][$last_item_index];
711
+				}
712
+			} elseif ('complete' === $type) { //Tags that ends in 1 line '<tag>'
713
+				//See if the key is already taken.
714
+				if (isset($current[$tag])) { //If taken, put all things inside a list(array)
715
+					if (isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array...
716
+						// ...push the new element into that array.
717
+						$current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
718
+
719
+						if ('tag' === $priority and $get_attributes and $attributes_data) {
720
+							$current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
721
+						}
722
+						$repeated_tag_index[$tag . '_' . $level]++;
723
+					} else { //If it is not an array...
724
+						$current[$tag]                           = [$current[$tag], $result]; //...Make it an array using using the existing value and the new value
725
+						$repeated_tag_index[$tag . '_' . $level] = 1;
726
+						if ('tag' === $priority and $get_attributes) {
727
+							if (isset($current[$tag . '_attr'])) { //The attribute of the last(0th) tag must be moved as well
728
+								$current[$tag]['0_attr'] = $current[$tag . '_attr'];
729
+								unset($current[$tag . '_attr']);
730
+							}
731
+
732
+							if ($attributes_data) {
733
+								$current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
734
+							}
735
+						}
736
+						$repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken
737
+					}
738
+				} else { //New Key
739
+					$current[$tag]                           = $result;
740
+					$repeated_tag_index[$tag . '_' . $level] = 1;
741
+					if ('tag' === $priority and $attributes_data) {
742
+						$current[$tag . '_attr'] = $attributes_data;
743
+					}
744
+				}
745
+			} elseif ('close' === $type) { //End of tag '</tag>'
746
+				$current = &$parent[$level - 1];
747
+			}
748
+		}
749
+
750
+		return $xml_array;
751
+	}
752
+
753
+	/**
754
+	 * @param $array
755
+	 * @param $name
756
+	 * @param $standalone
757
+	 * @param $beginning
758
+	 * @param $nested
759
+	 * @return string
760
+	 */
761
+	public static function toXml($array, $name, $standalone, $beginning, $nested): string
762
+	{
763
+		$output = '';
764
+		if ($beginning) {
765
+			if ($standalone) {
766
+				header('content-type:text/xml;charset=' . _CHARSET);
767
+			}
768
+			$output .= '<' . '?' . 'xml version="1.0" encoding="' . _CHARSET . '"' . '?' . '>' . "\n";
769
+			$output .= '<' . $name . '>' . "\n";
770
+			$nested = 0;
771
+		}
772
+
773
+		if (is_array($array)) {
774
+			foreach ($array as $key => $value) {
775
+				++$nested;
776
+				if (is_array($value)) {
777
+					$output .= str_repeat("\t", (int)$nested) . '<' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n";
778
+					++$nested;
779
+					$output .= static::toXml($value, $name, false, false, $nested);
780
+					$nested--;
781
+					$output .= str_repeat("\t", (int)$nested) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n";
782
+				} elseif ('' != $value) {
783
+					++$nested;
784
+					$output .= str_repeat("\t", (int)$nested) . '  <' . (is_string($key) ? $key : $name . '_' . $key) . '>' . trim($value) . '</' . (is_string($key) ? $key : $name . '_' . $key) . '>' . "\n";
785
+					$nested--;
786
+				}
787
+				$nested--;
788
+			}
789
+		} elseif ('' != $array) {
790
+			++$nested;
791
+			$output .= str_repeat("\t", (int)$nested) . trim($array) . "\n";
792
+			$nested--;
793
+		}
794
+
795
+		if ($beginning) {
796
+			$output .= '</' . $name . '>';
797
+
798
+			return $output;
799
+		}
800
+
801
+		return $output;
802
+	}
803 803
 }
Please login to merge, or discard this patch.
class/Visibility.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@
 block discarded – undo
25 25
  */
26 26
 class Visibility extends XoopsObject
27 27
 {
28
-    public $field_id;
29
-    public $user_group;
30
-    public $profile_group;
28
+	public $field_id;
29
+	public $user_group;
30
+	public $profile_group;
31 31
 
32
-    public function __construct()
33
-    {
34
-        $this->initVar('field_id', \XOBJ_DTYPE_INT);
35
-        $this->initVar('user_group', \XOBJ_DTYPE_INT);
36
-        $this->initVar('profile_group', \XOBJ_DTYPE_INT);
37
-    }
32
+	public function __construct()
33
+	{
34
+		$this->initVar('field_id', \XOBJ_DTYPE_INT);
35
+		$this->initVar('user_group', \XOBJ_DTYPE_INT);
36
+		$this->initVar('profile_group', \XOBJ_DTYPE_INT);
37
+	}
38 38
 }
Please login to merge, or discard this patch.
class/Field.php 2 patches
Indentation   +481 added lines, -481 removed lines patch added patch discarded remove patch
@@ -10,512 +10,512 @@
 block discarded – undo
10 10
  */
11 11
 class Field extends \XoopsObject
12 12
 {
13
-    public $field_id;
14
-    public $cids;
15
-    public $field_type;
16
-    public $field_valuetype;
17
-    public $field_name;
18
-    public $field_title;
19
-    public $field_description;
20
-    public $field_required; //0 = no, 1 = yes
21
-    public $field_maxlength;
22
-    public $field_weight;
23
-    public $field_default;
24
-    public $field_notnull;
25
-    public $field_edit;
26
-    public $field_show;
27
-    public $field_config;
28
-    public $field_options;
13
+	public $field_id;
14
+	public $cids;
15
+	public $field_type;
16
+	public $field_valuetype;
17
+	public $field_name;
18
+	public $field_title;
19
+	public $field_description;
20
+	public $field_required; //0 = no, 1 = yes
21
+	public $field_maxlength;
22
+	public $field_weight;
23
+	public $field_default;
24
+	public $field_notnull;
25
+	public $field_edit;
26
+	public $field_show;
27
+	public $field_config;
28
+	public $field_options;
29 29
 
30
-    public function __construct()
31
-    {
32
-        $this->initVar('field_id', \XOBJ_DTYPE_INT, null);
33
-        $this->initVar('cids', \XOBJ_DTYPE_ARRAY, [0 => '0'], true);
34
-        $this->initVar('field_type', \XOBJ_DTYPE_TXTBOX);
35
-        $this->initVar('field_valuetype', \XOBJ_DTYPE_INT, null, true);
36
-        $this->initVar('field_name', \XOBJ_DTYPE_TXTBOX, null, true);
37
-        $this->initVar('field_title', \XOBJ_DTYPE_TXTBOX);
38
-        $this->initVar('field_description', \XOBJ_DTYPE_TXTAREA);
39
-        $this->initVar('field_required', \XOBJ_DTYPE_INT, 0); //0 = no, 1 = yes
40
-        $this->initVar('field_maxlength', \XOBJ_DTYPE_INT, 0);
41
-        $this->initVar('field_weight', \XOBJ_DTYPE_INT, 0);
42
-        $this->initVar('field_default', \XOBJ_DTYPE_TXTAREA, '');
43
-        $this->initVar('field_notnull', \XOBJ_DTYPE_INT, 1);
44
-        $this->initVar('field_edit', \XOBJ_DTYPE_INT, 0);
45
-        $this->initVar('field_show', \XOBJ_DTYPE_INT, 0);
46
-        $this->initVar('field_config', \XOBJ_DTYPE_INT, 0);
47
-        $this->initVar('field_options', \XOBJ_DTYPE_ARRAY, []);
48
-    }
30
+	public function __construct()
31
+	{
32
+		$this->initVar('field_id', \XOBJ_DTYPE_INT, null);
33
+		$this->initVar('cids', \XOBJ_DTYPE_ARRAY, [0 => '0'], true);
34
+		$this->initVar('field_type', \XOBJ_DTYPE_TXTBOX);
35
+		$this->initVar('field_valuetype', \XOBJ_DTYPE_INT, null, true);
36
+		$this->initVar('field_name', \XOBJ_DTYPE_TXTBOX, null, true);
37
+		$this->initVar('field_title', \XOBJ_DTYPE_TXTBOX);
38
+		$this->initVar('field_description', \XOBJ_DTYPE_TXTAREA);
39
+		$this->initVar('field_required', \XOBJ_DTYPE_INT, 0); //0 = no, 1 = yes
40
+		$this->initVar('field_maxlength', \XOBJ_DTYPE_INT, 0);
41
+		$this->initVar('field_weight', \XOBJ_DTYPE_INT, 0);
42
+		$this->initVar('field_default', \XOBJ_DTYPE_TXTAREA, '');
43
+		$this->initVar('field_notnull', \XOBJ_DTYPE_INT, 1);
44
+		$this->initVar('field_edit', \XOBJ_DTYPE_INT, 0);
45
+		$this->initVar('field_show', \XOBJ_DTYPE_INT, 0);
46
+		$this->initVar('field_config', \XOBJ_DTYPE_INT, 0);
47
+		$this->initVar('field_options', \XOBJ_DTYPE_ARRAY, []);
48
+	}
49 49
 
50
-    /**
51
-     * Extra treatment dealing with non latin encoding
52
-     * Tricky solution
53
-     * @param string $key
54
-     * @param mixed  $value
55
-     * @param bool   $not_gpc
56
-     */
57
-    public function setVar($key, $value, $not_gpc = false): void
58
-    {
59
-        if ('field_options' === $key && \is_array($value)) {
60
-            foreach (\array_keys($value) as $idx) {
61
-                $value[$idx] = base64_encode($value[$idx]);
62
-            }
63
-        }
64
-        parent::setVar($key, $value, $not_gpc);
65
-    }
50
+	/**
51
+	 * Extra treatment dealing with non latin encoding
52
+	 * Tricky solution
53
+	 * @param string $key
54
+	 * @param mixed  $value
55
+	 * @param bool   $not_gpc
56
+	 */
57
+	public function setVar($key, $value, $not_gpc = false): void
58
+	{
59
+		if ('field_options' === $key && \is_array($value)) {
60
+			foreach (\array_keys($value) as $idx) {
61
+				$value[$idx] = base64_encode($value[$idx]);
62
+			}
63
+		}
64
+		parent::setVar($key, $value, $not_gpc);
65
+	}
66 66
 
67
-    /**
68
-     * @param string $key
69
-     * @param string $format
70
-     * @return mixed
71
-     */
72
-    public function getVar($key, $format = 's')
73
-    {
74
-        $value = parent::getVar($key, $format);
75
-        if ('field_options' === $key && !empty($value)) {
76
-            foreach (\array_keys($value) as $idx) {
77
-                $value[$idx] = base64_decode($value[$idx], true);
78
-            }
79
-        }
67
+	/**
68
+	 * @param string $key
69
+	 * @param string $format
70
+	 * @return mixed
71
+	 */
72
+	public function getVar($key, $format = 's')
73
+	{
74
+		$value = parent::getVar($key, $format);
75
+		if ('field_options' === $key && !empty($value)) {
76
+			foreach (\array_keys($value) as $idx) {
77
+				$value[$idx] = base64_decode($value[$idx], true);
78
+			}
79
+		}
80 80
 
81
-        return $value;
82
-    }
81
+		return $value;
82
+	}
83 83
 
84
-    /**
85
-     * Returns a {@link XoopsFormElement} for editing the value of this field
86
-     *
87
-     * @param \XoopsUser     $user    {@link XoopsUser} object to edit the value of
88
-     * @param ObjectsProfile $profile {@link ObjectsProfile} object to edit the value of
89
-     *
90
-     * @return \\XoopsFormDhtmlTextArea|\\XoopsFormEditor|\\XoopsFormLabel|\\XoopsFormSelect|\\XoopsFormText|\\XoopsFormTextArea
91
-     */
92
-    public function getEditElement($user, $profile)
93
-    {
94
-        $value = \in_array($this->getVar('field_name'), $this->getPostVars(), true) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e');
95
-        if (null === $value) {
96
-            $value = $this->getVar('field_default');
97
-        }
98
-        $caption = $this->getVar('field_title');
99
-        $caption = \defined($caption) ? \constant($caption) : $caption;
100
-        $name    = $this->getVar('field_name', 'e');
101
-        $options = $this->getVar('field_options');
102
-        if (\is_array($options)) {
103
-            //asort($options);
84
+	/**
85
+	 * Returns a {@link XoopsFormElement} for editing the value of this field
86
+	 *
87
+	 * @param \XoopsUser     $user    {@link XoopsUser} object to edit the value of
88
+	 * @param ObjectsProfile $profile {@link ObjectsProfile} object to edit the value of
89
+	 *
90
+	 * @return \\XoopsFormDhtmlTextArea|\\XoopsFormEditor|\\XoopsFormLabel|\\XoopsFormSelect|\\XoopsFormText|\\XoopsFormTextArea
91
+	 */
92
+	public function getEditElement($user, $profile)
93
+	{
94
+		$value = \in_array($this->getVar('field_name'), $this->getPostVars(), true) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e');
95
+		if (null === $value) {
96
+			$value = $this->getVar('field_default');
97
+		}
98
+		$caption = $this->getVar('field_title');
99
+		$caption = \defined($caption) ? \constant($caption) : $caption;
100
+		$name    = $this->getVar('field_name', 'e');
101
+		$options = $this->getVar('field_options');
102
+		if (\is_array($options)) {
103
+			//asort($options);
104 104
 
105
-            foreach (\array_keys($options) as $key) {
106
-                $optval = \defined($options[$key]) ? \constant($options[$key]) : $options[$key];
107
-                $optkey = \defined((string)$key) ? \constant($key) : $key;
108
-                unset($options[$key]);
109
-                $options[$optkey] = $optval;
110
-            }
111
-        }
112
-        require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
113
-        switch ($this->getVar('field_type')) {
114
-            default:
115
-            case 'autotext':
116
-                //autotext is not for editing
117
-                $element = new \XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
118
-                break;
119
-            case 'textbox':
120
-                $element = new \XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
121
-                break;
122
-            case 'textarea':
123
-                $element = new \XoopsFormTextArea($caption, $name, $value, 4, 30);
124
-                break;
125
-            case 'dhtml':
126
-                $element = new \XoopsFormDhtmlTextArea($caption, $name, $value, 10, 30);
127
-                break;
128
-            case 'editor':
129
-                $editor_config['name']   = $name;
130
-                $editor_config['editor'] = $GLOBALS['songlistModuleConfig']['editor'];
131
-                $editor_config['value']  = $value;
132
-                $editor_config['width']  = $GLOBALS['songlistModuleConfig']['editor_width'];
133
-                $editor_config['height'] = $GLOBALS['songlistModuleConfig']['editor_height'];
134
-                $element                 = new \XoopsFormEditor($caption, $name, $editor_config);
135
-                break;
136
-            case 'select':
137
-                $element = new \XoopsFormSelect($caption, $name, $value);
138
-                // If options do not include an empty element, then add a blank option to prevent any default selection
139
-                if (!\array_key_exists('', $options)) {
140
-                    $element->addOption('', _NONE);
141
-                    //trabis
142
-                    if (1 == $this->getVar('field_required')) {
143
-                        $eltmsg                          = empty($caption) ? \sprintf(_FORM_ENTER, $name) : \sprintf(_FORM_ENTER, $caption);
144
-                        $eltmsg                          = \str_replace('"', '\"', \stripslashes($eltmsg));
145
-                        $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};"
146
-                                                           . "for (i = 0; i < selectBox.options.length; i++  ) { if ( selectBox.options[i].selected === true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }"
147
-                                                           . "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
148
-                    }
149
-                }
150
-                $element->addOptionArray($options);
151
-                break;
152
-            case 'select_multi':
153
-                $element = new \XoopsFormSelect($caption, $name, $value, 5, true);
154
-                $element->addOptionArray($options);
155
-                break;
156
-            case 'radio':
157
-                $element = new \XoopsFormRadio($caption, $name, $value);
158
-                $element->addOptionArray($options);
159
-                break;
160
-            case 'checkbox':
161
-                $element = new \XoopsFormCheckBox($caption, $name, $value);
162
-                $element->addOptionArray($options);
163
-                break;
164
-            case 'yesno':
165
-                $element = new \XoopsFormRadioYN($caption, $name, $value);
166
-                break;
167
-            case 'group':
168
-                $element = new \XoopsFormSelectGroup($caption, $name, true, $value);
169
-                break;
170
-            case 'group_multi':
171
-                $element = new \XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
172
-                break;
173
-            case 'language':
174
-                $element = new \XoopsFormSelectLang($caption, $name, $value);
175
-                break;
176
-            case 'date':
177
-                $element = new \XoopsFormTextDateSelect($caption, $name, 15, $value);
178
-                break;
179
-            case 'longdate':
180
-                $element = new \XoopsFormTextDateSelect($caption, $name, 15, \str_replace('-', '/', $value));
181
-                break;
182
-            case 'datetime':
183
-                $element = new XoopsFormDatetime($caption, $name, 15, $value);
184
-                break;
185
-            case 'list':
186
-                $element = new \XoopsFormSelect($caption, $name, $value, 1, $options[0]);
187
-                break;
188
-            case 'timezone':
189
-                $element = new \XoopsFormSelectTimezone($caption, $name, $value);
190
-                $element->setExtra("style='width: 280px;'");
191
-                break;
192
-            case 'rank':
193
-                $element = new \XoopsFormSelect($caption, $name, $value);
105
+			foreach (\array_keys($options) as $key) {
106
+				$optval = \defined($options[$key]) ? \constant($options[$key]) : $options[$key];
107
+				$optkey = \defined((string)$key) ? \constant($key) : $key;
108
+				unset($options[$key]);
109
+				$options[$optkey] = $optval;
110
+			}
111
+		}
112
+		require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
113
+		switch ($this->getVar('field_type')) {
114
+			default:
115
+			case 'autotext':
116
+				//autotext is not for editing
117
+				$element = new \XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
118
+				break;
119
+			case 'textbox':
120
+				$element = new \XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
121
+				break;
122
+			case 'textarea':
123
+				$element = new \XoopsFormTextArea($caption, $name, $value, 4, 30);
124
+				break;
125
+			case 'dhtml':
126
+				$element = new \XoopsFormDhtmlTextArea($caption, $name, $value, 10, 30);
127
+				break;
128
+			case 'editor':
129
+				$editor_config['name']   = $name;
130
+				$editor_config['editor'] = $GLOBALS['songlistModuleConfig']['editor'];
131
+				$editor_config['value']  = $value;
132
+				$editor_config['width']  = $GLOBALS['songlistModuleConfig']['editor_width'];
133
+				$editor_config['height'] = $GLOBALS['songlistModuleConfig']['editor_height'];
134
+				$element                 = new \XoopsFormEditor($caption, $name, $editor_config);
135
+				break;
136
+			case 'select':
137
+				$element = new \XoopsFormSelect($caption, $name, $value);
138
+				// If options do not include an empty element, then add a blank option to prevent any default selection
139
+				if (!\array_key_exists('', $options)) {
140
+					$element->addOption('', _NONE);
141
+					//trabis
142
+					if (1 == $this->getVar('field_required')) {
143
+						$eltmsg                          = empty($caption) ? \sprintf(_FORM_ENTER, $name) : \sprintf(_FORM_ENTER, $caption);
144
+						$eltmsg                          = \str_replace('"', '\"', \stripslashes($eltmsg));
145
+						$element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};"
146
+														   . "for (i = 0; i < selectBox.options.length; i++  ) { if ( selectBox.options[i].selected === true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }"
147
+														   . "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
148
+					}
149
+				}
150
+				$element->addOptionArray($options);
151
+				break;
152
+			case 'select_multi':
153
+				$element = new \XoopsFormSelect($caption, $name, $value, 5, true);
154
+				$element->addOptionArray($options);
155
+				break;
156
+			case 'radio':
157
+				$element = new \XoopsFormRadio($caption, $name, $value);
158
+				$element->addOptionArray($options);
159
+				break;
160
+			case 'checkbox':
161
+				$element = new \XoopsFormCheckBox($caption, $name, $value);
162
+				$element->addOptionArray($options);
163
+				break;
164
+			case 'yesno':
165
+				$element = new \XoopsFormRadioYN($caption, $name, $value);
166
+				break;
167
+			case 'group':
168
+				$element = new \XoopsFormSelectGroup($caption, $name, true, $value);
169
+				break;
170
+			case 'group_multi':
171
+				$element = new \XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
172
+				break;
173
+			case 'language':
174
+				$element = new \XoopsFormSelectLang($caption, $name, $value);
175
+				break;
176
+			case 'date':
177
+				$element = new \XoopsFormTextDateSelect($caption, $name, 15, $value);
178
+				break;
179
+			case 'longdate':
180
+				$element = new \XoopsFormTextDateSelect($caption, $name, 15, \str_replace('-', '/', $value));
181
+				break;
182
+			case 'datetime':
183
+				$element = new XoopsFormDatetime($caption, $name, 15, $value);
184
+				break;
185
+			case 'list':
186
+				$element = new \XoopsFormSelect($caption, $name, $value, 1, $options[0]);
187
+				break;
188
+			case 'timezone':
189
+				$element = new \XoopsFormSelectTimezone($caption, $name, $value);
190
+				$element->setExtra("style='width: 280px;'");
191
+				break;
192
+			case 'rank':
193
+				$element = new \XoopsFormSelect($caption, $name, $value);
194 194
 
195
-                require_once $GLOBALS['xoops']->path('class/xoopslists.php');
196
-                $ranks = \XoopsLists::getUserRankList();
197
-                $element->addOption(0, '--------------');
198
-                $element->addOptionArray($ranks);
199
-                break;
200
-            case 'theme':
201
-                $element = new \XoopsFormSelect($caption, $name, $value);
202
-                $element->addOption('0', \_AM_SONGLIST_OBJS_MF_SITEDEFAULT);
203
-                $handle  = \opendir(XOOPS_THEME_PATH . '/');
204
-                $dirlist = [];
205
-                while (false !== ($file = \readdir($handle))) {
206
-                    if (\is_dir(XOOPS_THEME_PATH . '/' . $file) && !\preg_match('/^[.]{1,2}$/', $file) && 'cvs' !== \mb_strtolower($file)) {
207
-                        if (\file_exists(XOOPS_THEME_PATH . '/' . $file . '/theme.tpl') && \in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'], true)) {
208
-                            $dirlist[$file] = $file;
209
-                        }
210
-                    }
211
-                }
212
-                \closedir($handle);
213
-                if (!empty($dirlist)) {
214
-                    \asort($dirlist);
215
-                    $element->addOptionArray($dirlist);
216
-                }
217
-                break;
218
-        }
219
-        if ('' != $this->getVar('field_description')) {
220
-            $element->setDescription($this->getVar('field_description'));
221
-        }
195
+				require_once $GLOBALS['xoops']->path('class/xoopslists.php');
196
+				$ranks = \XoopsLists::getUserRankList();
197
+				$element->addOption(0, '--------------');
198
+				$element->addOptionArray($ranks);
199
+				break;
200
+			case 'theme':
201
+				$element = new \XoopsFormSelect($caption, $name, $value);
202
+				$element->addOption('0', \_AM_SONGLIST_OBJS_MF_SITEDEFAULT);
203
+				$handle  = \opendir(XOOPS_THEME_PATH . '/');
204
+				$dirlist = [];
205
+				while (false !== ($file = \readdir($handle))) {
206
+					if (\is_dir(XOOPS_THEME_PATH . '/' . $file) && !\preg_match('/^[.]{1,2}$/', $file) && 'cvs' !== \mb_strtolower($file)) {
207
+						if (\file_exists(XOOPS_THEME_PATH . '/' . $file . '/theme.tpl') && \in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'], true)) {
208
+							$dirlist[$file] = $file;
209
+						}
210
+					}
211
+				}
212
+				\closedir($handle);
213
+				if (!empty($dirlist)) {
214
+					\asort($dirlist);
215
+					$element->addOptionArray($dirlist);
216
+				}
217
+				break;
218
+		}
219
+		if ('' != $this->getVar('field_description')) {
220
+			$element->setDescription($this->getVar('field_description'));
221
+		}
222 222
 
223
-        return $element;
224
-    }
223
+		return $element;
224
+	}
225 225
 
226
-    /**
227
-     * Returns a {@link XoopsFormElement} for editing the value of this field
228
-     * @return \\XoopsFormLabel|\\XoopsFormSelect|\\XoopsFormText|\\XoopsFormTextArea
229
-     * @internal param XoopsUser $user <a href='psi_element://XoopsUser'>XoopsUser</a> object to edit the value of object to edit the value of
230
-     * @internal param ObjectsProfile $profile <a href='psi_element://ObjectsProfile'>ObjectsProfile</a> object to edit the value of object to edit the value of
231
-     */
232
-    public function getSearchElement()
233
-    {
234
-        $caption = $this->getVar('field_title');
235
-        $caption = \defined($caption) ? \constant($caption) : $caption;
236
-        $name    = $this->getVar('field_name', 'e');
237
-        $options = $this->getVar('field_options');
238
-        if (\is_array($options)) {
239
-            //asort($options);
226
+	/**
227
+	 * Returns a {@link XoopsFormElement} for editing the value of this field
228
+	 * @return \\XoopsFormLabel|\\XoopsFormSelect|\\XoopsFormText|\\XoopsFormTextArea
229
+	 * @internal param XoopsUser $user <a href='psi_element://XoopsUser'>XoopsUser</a> object to edit the value of object to edit the value of
230
+	 * @internal param ObjectsProfile $profile <a href='psi_element://ObjectsProfile'>ObjectsProfile</a> object to edit the value of object to edit the value of
231
+	 */
232
+	public function getSearchElement()
233
+	{
234
+		$caption = $this->getVar('field_title');
235
+		$caption = \defined($caption) ? \constant($caption) : $caption;
236
+		$name    = $this->getVar('field_name', 'e');
237
+		$options = $this->getVar('field_options');
238
+		if (\is_array($options)) {
239
+			//asort($options);
240 240
 
241
-            foreach (\array_keys($options) as $key) {
242
-                $optval = \defined($options[$key]) ? \constant($options[$key]) : $options[$key];
243
-                $optkey = \defined($key) ? \constant($key) : $key;
244
-                unset($options[$key]);
245
-                $options[$optkey] = $optval;
246
-            }
247
-        }
248
-        require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
249
-        switch ($this->getVar('field_type')) {
250
-            default:
251
-            case 'autotext':
252
-                //autotext is not for editing
253
-                $element = new \XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
254
-                break;
255
-            case 'textbox':
256
-                $element = new \XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
257
-                break;
258
-            case 'textarea':
259
-                $element = new \XoopsFormTextArea($caption, $name, $value, 4, 30);
260
-                break;
261
-            case 'dhtml':
262
-                $element = new \XoopsFormText($caption, $name, 35, 255, $value);
263
-                break;
264
-            case 'select':
265
-                $element = new \XoopsFormSelect($caption, $name, $value);
266
-                // If options do not include an empty element, then add a blank option to prevent any default selection
267
-                if (!\array_key_exists('', $options)) {
268
-                    $element->addOption('', _NONE);
269
-                    //trabis
270
-                    if (1 == $this->getVar('field_required')) {
271
-                        $eltmsg                          = empty($caption) ? \sprintf(_FORM_ENTER, $name) : \sprintf(_FORM_ENTER, $caption);
272
-                        $eltmsg                          = \str_replace('"', '\"', \stripslashes($eltmsg));
273
-                        $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};"
274
-                                                           . "for (i = 0; i < selectBox.options.length; i++  ) { if ( selectBox.options[i].selected === true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }"
275
-                                                           . "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
276
-                    }
277
-                    //end
278
-                }
279
-                $element->addOptionArray($options);
280
-                break;
281
-            case 'editor':
282
-                $element = new \XoopsFormText($caption, $name, 35, 255, $value);
283
-                break;
284
-            case 'select_multi':
285
-                $element = new \XoopsFormSelect($caption, $name, $value, 5, true);
286
-                $element->addOptionArray($options);
287
-                break;
288
-            case 'radio':
289
-                $element = new \XoopsFormRadio($caption, $name, $value);
290
-                $element->addOptionArray($options);
291
-                break;
292
-            case 'checkbox':
293
-                $element = new \XoopsFormCheckBox($caption, $name, $value);
294
-                $element->addOptionArray($options);
295
-                break;
296
-            case 'yesno':
297
-                $element = new \XoopsFormRadioYN($caption, $name, $value);
298
-                break;
299
-            case 'group':
300
-                $element = new \XoopsFormSelectGroup($caption, $name, true, $value);
301
-                break;
302
-            case 'group_multi':
303
-                $element = new \XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
304
-                break;
305
-            case 'language':
306
-                $element = new \XoopsFormSelectLang($caption, $name, $value);
307
-                break;
308
-            case 'date':
309
-                $element = new \XoopsFormTextDateSelect($caption, $name, 15, $value);
310
-                break;
311
-            case 'longdate':
312
-                $element = new \XoopsFormTextDateSelect($caption, $name, 15, \str_replace('-', '/', $value));
313
-                break;
314
-            case 'datetime':
315
-                $element = new XoopsFormDatetime($caption, $name, 15, $value);
316
-                break;
317
-            case 'list':
318
-                $element = new \XoopsFormSelect($caption, $name, $value, 1, $options[0]);
319
-                break;
320
-            case 'timezone':
321
-                $element = new \XoopsFormSelectTimezone($caption, $name, $value);
322
-                $element->setExtra("style='width: 280px;'");
323
-                break;
324
-            case 'rank':
325
-                $element = new \XoopsFormSelect($caption, $name, $value);
241
+			foreach (\array_keys($options) as $key) {
242
+				$optval = \defined($options[$key]) ? \constant($options[$key]) : $options[$key];
243
+				$optkey = \defined($key) ? \constant($key) : $key;
244
+				unset($options[$key]);
245
+				$options[$optkey] = $optval;
246
+			}
247
+		}
248
+		require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
249
+		switch ($this->getVar('field_type')) {
250
+			default:
251
+			case 'autotext':
252
+				//autotext is not for editing
253
+				$element = new \XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
254
+				break;
255
+			case 'textbox':
256
+				$element = new \XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
257
+				break;
258
+			case 'textarea':
259
+				$element = new \XoopsFormTextArea($caption, $name, $value, 4, 30);
260
+				break;
261
+			case 'dhtml':
262
+				$element = new \XoopsFormText($caption, $name, 35, 255, $value);
263
+				break;
264
+			case 'select':
265
+				$element = new \XoopsFormSelect($caption, $name, $value);
266
+				// If options do not include an empty element, then add a blank option to prevent any default selection
267
+				if (!\array_key_exists('', $options)) {
268
+					$element->addOption('', _NONE);
269
+					//trabis
270
+					if (1 == $this->getVar('field_required')) {
271
+						$eltmsg                          = empty($caption) ? \sprintf(_FORM_ENTER, $name) : \sprintf(_FORM_ENTER, $caption);
272
+						$eltmsg                          = \str_replace('"', '\"', \stripslashes($eltmsg));
273
+						$element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};"
274
+														   . "for (i = 0; i < selectBox.options.length; i++  ) { if ( selectBox.options[i].selected === true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }"
275
+														   . "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
276
+					}
277
+					//end
278
+				}
279
+				$element->addOptionArray($options);
280
+				break;
281
+			case 'editor':
282
+				$element = new \XoopsFormText($caption, $name, 35, 255, $value);
283
+				break;
284
+			case 'select_multi':
285
+				$element = new \XoopsFormSelect($caption, $name, $value, 5, true);
286
+				$element->addOptionArray($options);
287
+				break;
288
+			case 'radio':
289
+				$element = new \XoopsFormRadio($caption, $name, $value);
290
+				$element->addOptionArray($options);
291
+				break;
292
+			case 'checkbox':
293
+				$element = new \XoopsFormCheckBox($caption, $name, $value);
294
+				$element->addOptionArray($options);
295
+				break;
296
+			case 'yesno':
297
+				$element = new \XoopsFormRadioYN($caption, $name, $value);
298
+				break;
299
+			case 'group':
300
+				$element = new \XoopsFormSelectGroup($caption, $name, true, $value);
301
+				break;
302
+			case 'group_multi':
303
+				$element = new \XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
304
+				break;
305
+			case 'language':
306
+				$element = new \XoopsFormSelectLang($caption, $name, $value);
307
+				break;
308
+			case 'date':
309
+				$element = new \XoopsFormTextDateSelect($caption, $name, 15, $value);
310
+				break;
311
+			case 'longdate':
312
+				$element = new \XoopsFormTextDateSelect($caption, $name, 15, \str_replace('-', '/', $value));
313
+				break;
314
+			case 'datetime':
315
+				$element = new XoopsFormDatetime($caption, $name, 15, $value);
316
+				break;
317
+			case 'list':
318
+				$element = new \XoopsFormSelect($caption, $name, $value, 1, $options[0]);
319
+				break;
320
+			case 'timezone':
321
+				$element = new \XoopsFormSelectTimezone($caption, $name, $value);
322
+				$element->setExtra("style='width: 280px;'");
323
+				break;
324
+			case 'rank':
325
+				$element = new \XoopsFormSelect($caption, $name, $value);
326 326
 
327
-                require_once $GLOBALS['xoops']->path('class/xoopslists.php');
328
-                $ranks = \XoopsLists::getUserRankList();
329
-                $element->addOption(0, '--------------');
330
-                $element->addOptionArray($ranks);
331
-                break;
332
-            case 'theme':
333
-                $element = new \XoopsFormSelect($caption, $name, $value);
334
-                $element->addOption('0', \_AM_SONGLIST_OBJS_MF_SITEDEFAULT);
335
-                $handle  = \opendir(XOOPS_THEME_PATH . '/');
336
-                $dirlist = [];
337
-                while (false !== ($file = \readdir($handle))) {
338
-                    if (\is_dir(XOOPS_THEME_PATH . '/' . $file) && !\preg_match('/^[.]{1,2}$/', $file) && 'cvs' !== \mb_strtolower($file)) {
339
-                        if (\file_exists(XOOPS_THEME_PATH . '/' . $file . '/theme.tpl') && \in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'], true)) {
340
-                            $dirlist[$file] = $file;
341
-                        }
342
-                    }
343
-                }
344
-                \closedir($handle);
345
-                if (!empty($dirlist)) {
346
-                    \asort($dirlist);
347
-                    $element->addOptionArray($dirlist);
348
-                }
349
-                break;
350
-        }
351
-        if ('' != $this->getVar('field_description')) {
352
-            $element->setDescription($this->getVar('field_description'));
353
-        }
327
+				require_once $GLOBALS['xoops']->path('class/xoopslists.php');
328
+				$ranks = \XoopsLists::getUserRankList();
329
+				$element->addOption(0, '--------------');
330
+				$element->addOptionArray($ranks);
331
+				break;
332
+			case 'theme':
333
+				$element = new \XoopsFormSelect($caption, $name, $value);
334
+				$element->addOption('0', \_AM_SONGLIST_OBJS_MF_SITEDEFAULT);
335
+				$handle  = \opendir(XOOPS_THEME_PATH . '/');
336
+				$dirlist = [];
337
+				while (false !== ($file = \readdir($handle))) {
338
+					if (\is_dir(XOOPS_THEME_PATH . '/' . $file) && !\preg_match('/^[.]{1,2}$/', $file) && 'cvs' !== \mb_strtolower($file)) {
339
+						if (\file_exists(XOOPS_THEME_PATH . '/' . $file . '/theme.tpl') && \in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'], true)) {
340
+							$dirlist[$file] = $file;
341
+						}
342
+					}
343
+				}
344
+				\closedir($handle);
345
+				if (!empty($dirlist)) {
346
+					\asort($dirlist);
347
+					$element->addOptionArray($dirlist);
348
+				}
349
+				break;
350
+		}
351
+		if ('' != $this->getVar('field_description')) {
352
+			$element->setDescription($this->getVar('field_description'));
353
+		}
354 354
 
355
-        return $element;
356
-    }
355
+		return $element;
356
+	}
357 357
 
358
-    /**
359
-     * Returns a value for output of this field
360
-     *
361
-     * @param \XoopsUser     $user    {@link XoopsUser} object to get the value of
362
-     * @param ObjectsProfile $profile object to get the value of
363
-     *
364
-     * @return mixed
365
-     **/
366
-    public function getOutputValue($user, $profile)
367
-    {
368
-        \xoops_loadLanguage('modinfo', 'objects');
358
+	/**
359
+	 * Returns a value for output of this field
360
+	 *
361
+	 * @param \XoopsUser     $user    {@link XoopsUser} object to get the value of
362
+	 * @param ObjectsProfile $profile object to get the value of
363
+	 *
364
+	 * @return mixed
365
+	 **/
366
+	public function getOutputValue($user, $profile)
367
+	{
368
+		\xoops_loadLanguage('modinfo', 'objects');
369 369
 
370
-        $value = \in_array($this->getVar('field_name'), $this->getPostVars(), true) ? $user->getVar($this->getVar('field_name')) : $profile->getVar($this->getVar('field_name'));
370
+		$value = \in_array($this->getVar('field_name'), $this->getPostVars(), true) ? $user->getVar($this->getVar('field_name')) : $profile->getVar($this->getVar('field_name'));
371 371
 
372
-        switch ($this->getVar('field_type')) {
373
-            default:
374
-            case 'textbox':
375
-                if ('url' === $this->getVar('field_name') && '' != $value) {
376
-                    return '<a href="' . \formatURL($value) . '" rel="external">' . $value . '</a>';
377
-                }
372
+		switch ($this->getVar('field_type')) {
373
+			default:
374
+			case 'textbox':
375
+				if ('url' === $this->getVar('field_name') && '' != $value) {
376
+					return '<a href="' . \formatURL($value) . '" rel="external">' . $value . '</a>';
377
+				}
378 378
 
379
-                return $value;
380
-                break;
381
-            case 'editor':
382
-            case 'textarea':
383
-            case 'dhtml':
384
-            case 'theme':
385
-            case 'language':
386
-            case 'list':
387
-                return $value;
388
-                break;
389
-            case 'select':
390
-            case 'radio':
391
-                $options = $this->getVar('field_options');
392
-                if (isset($options[$value])) {
393
-                    $value = \htmlspecialchars(\defined($options[$value]) ? \constant($options[$value]) : $options[$value], \ENT_QUOTES | \ENT_HTML5);
394
-                } else {
395
-                    $value = '';
396
-                }
379
+				return $value;
380
+				break;
381
+			case 'editor':
382
+			case 'textarea':
383
+			case 'dhtml':
384
+			case 'theme':
385
+			case 'language':
386
+			case 'list':
387
+				return $value;
388
+				break;
389
+			case 'select':
390
+			case 'radio':
391
+				$options = $this->getVar('field_options');
392
+				if (isset($options[$value])) {
393
+					$value = \htmlspecialchars(\defined($options[$value]) ? \constant($options[$value]) : $options[$value], \ENT_QUOTES | \ENT_HTML5);
394
+				} else {
395
+					$value = '';
396
+				}
397 397
 
398
-                return $value;
399
-                break;
400
-            case 'select_multi':
401
-            case 'checkbox':
402
-                $options = $this->getVar('field_options');
403
-                $ret     = [];
404
-                if (\count($options) > 0) {
405
-                    foreach (\array_keys($options) as $key) {
406
-                        if (\in_array($key, $value, true)) {
407
-                            $$ret[$key] = \htmlspecialchars(\defined($options[$key]) ? \constant($options[$key]) : $options[$key], \ENT_QUOTES | \ENT_HTML5);
408
-                        }
409
-                    }
410
-                }
398
+				return $value;
399
+				break;
400
+			case 'select_multi':
401
+			case 'checkbox':
402
+				$options = $this->getVar('field_options');
403
+				$ret     = [];
404
+				if (\count($options) > 0) {
405
+					foreach (\array_keys($options) as $key) {
406
+						if (\in_array($key, $value, true)) {
407
+							$$ret[$key] = \htmlspecialchars(\defined($options[$key]) ? \constant($options[$key]) : $options[$key], \ENT_QUOTES | \ENT_HTML5);
408
+						}
409
+					}
410
+				}
411 411
 
412
-                return $ret;
413
-                break;
414
-            case 'group':
415
-                //change to retrieve groups and return name of group
416
-                return $value;
417
-                break;
418
-            case 'group_multi':
419
-                //change to retrieve groups and return array of group names
420
-                return '';
421
-                break;
422
-            case 'longdate':
423
-                //return YYYY/MM/DD format - not optimal as it is not using local date format, but how do we do that
424
-                //when we cannot convert it to a UNIX timestamp?
425
-                return \str_replace('-', '/', $value);
426
-            case 'date':
427
-                return \formatTimestamp($value, 's');
428
-                break;
429
-            case 'datetime':
430
-                if (!empty($value)) {
431
-                    return \formatTimestamp($value, 'm');
432
-                }
412
+				return $ret;
413
+				break;
414
+			case 'group':
415
+				//change to retrieve groups and return name of group
416
+				return $value;
417
+				break;
418
+			case 'group_multi':
419
+				//change to retrieve groups and return array of group names
420
+				return '';
421
+				break;
422
+			case 'longdate':
423
+				//return YYYY/MM/DD format - not optimal as it is not using local date format, but how do we do that
424
+				//when we cannot convert it to a UNIX timestamp?
425
+				return \str_replace('-', '/', $value);
426
+			case 'date':
427
+				return \formatTimestamp($value, 's');
428
+				break;
429
+			case 'datetime':
430
+				if (!empty($value)) {
431
+					return \formatTimestamp($value, 'm');
432
+				}
433 433
 
434
-                return $value = \_MI_SONGLIST_DATENOTSET;
435
-                break;
436
-            case 'autotext':
437
-                $value = $user->getVar($this->getVar('field_name'), 'n'); //autotext can have HTML in it
438
-                $value = \str_replace('{X_UID}', $user->getVar('uid'), $value);
439
-                $value = \str_replace('{X_URL}', XOOPS_URL, $value);
440
-                $value = \str_replace('{X_UNAME}', $user->getVar('uname'), $value);
434
+				return $value = \_MI_SONGLIST_DATENOTSET;
435
+				break;
436
+			case 'autotext':
437
+				$value = $user->getVar($this->getVar('field_name'), 'n'); //autotext can have HTML in it
438
+				$value = \str_replace('{X_UID}', $user->getVar('uid'), $value);
439
+				$value = \str_replace('{X_URL}', XOOPS_URL, $value);
440
+				$value = \str_replace('{X_UNAME}', $user->getVar('uname'), $value);
441 441
 
442
-                return $value;
443
-                break;
444
-            case 'rank':
445
-                $userrank       = $user->rank();
446
-                $user_rankimage = '';
447
-                if (isset($userrank['image']) && '' != $userrank['image']) {
448
-                    $user_rankimage = '<img src="' . XOOPS_UPLOAD_URL . '/' . $userrank['image'] . '" alt="' . $userrank['title'] . '"><br>';
449
-                }
442
+				return $value;
443
+				break;
444
+			case 'rank':
445
+				$userrank       = $user->rank();
446
+				$user_rankimage = '';
447
+				if (isset($userrank['image']) && '' != $userrank['image']) {
448
+					$user_rankimage = '<img src="' . XOOPS_UPLOAD_URL . '/' . $userrank['image'] . '" alt="' . $userrank['title'] . '"><br>';
449
+				}
450 450
 
451
-                return $user_rankimage . $userrank['title'];
452
-                break;
453
-            case 'yesno':
454
-                return $value ? _YES : _NO;
455
-                break;
456
-            case 'timezone':
457
-                require_once $GLOBALS['xoops']->path('class/xoopslists.php');
458
-                $timezones = \XoopsLists::getTimeZoneList();
459
-                $value     = empty($value) ? '0' : (string)$value;
451
+				return $user_rankimage . $userrank['title'];
452
+				break;
453
+			case 'yesno':
454
+				return $value ? _YES : _NO;
455
+				break;
456
+			case 'timezone':
457
+				require_once $GLOBALS['xoops']->path('class/xoopslists.php');
458
+				$timezones = \XoopsLists::getTimeZoneList();
459
+				$value     = empty($value) ? '0' : (string)$value;
460 460
 
461
-                return $timezones[\str_replace('.0', '', $value)];
462
-                break;
463
-        }
464
-    }
461
+				return $timezones[\str_replace('.0', '', $value)];
462
+				break;
463
+		}
464
+	}
465 465
 
466
-    /**
467
-     * Returns a value ready to be saved in the database
468
-     *
469
-     * @param mixed $value Value to format
470
-     *
471
-     * @return mixed
472
-     */
473
-    public function getValueForSave($value)
474
-    {
475
-        switch ($this->getVar('field_type')) {
476
-            default:
477
-            case 'textbox':
478
-            case 'textarea':
479
-            case 'dhtml':
480
-            case 'yesno':
481
-            case 'timezone':
482
-            case 'theme':
483
-            case 'language':
484
-            case 'list':
485
-            case 'select':
486
-            case 'radio':
487
-            case 'select_multi':
488
-            case 'checkbox':
489
-            case 'group':
490
-            case 'group_multi':
491
-            case 'longdate':
492
-                return $value;
493
-            case 'date':
494
-                if ('' != $value) {
495
-                    return \strtotime((string)$value);
496
-                }
466
+	/**
467
+	 * Returns a value ready to be saved in the database
468
+	 *
469
+	 * @param mixed $value Value to format
470
+	 *
471
+	 * @return mixed
472
+	 */
473
+	public function getValueForSave($value)
474
+	{
475
+		switch ($this->getVar('field_type')) {
476
+			default:
477
+			case 'textbox':
478
+			case 'textarea':
479
+			case 'dhtml':
480
+			case 'yesno':
481
+			case 'timezone':
482
+			case 'theme':
483
+			case 'language':
484
+			case 'list':
485
+			case 'select':
486
+			case 'radio':
487
+			case 'select_multi':
488
+			case 'checkbox':
489
+			case 'group':
490
+			case 'group_multi':
491
+			case 'longdate':
492
+				return $value;
493
+			case 'date':
494
+				if ('' != $value) {
495
+					return \strtotime((string)$value);
496
+				}
497 497
 
498
-                return $value;
499
-                break;
500
-            case 'datetime':
501
-                if (!empty($value)) {
502
-                    return \strtotime($value['date'] ?? '') + (int)$value['time'];
503
-                }
498
+				return $value;
499
+				break;
500
+			case 'datetime':
501
+				if (!empty($value)) {
502
+					return \strtotime($value['date'] ?? '') + (int)$value['time'];
503
+				}
504 504
 
505
-                return $value;
506
-                break;
507
-        }
508
-    }
505
+				return $value;
506
+				break;
507
+		}
508
+	}
509 509
 
510
-    /**
511
-     * Get names of user variables
512
-     *
513
-     * @return array
514
-     */
515
-    public function getPostVars(): array
516
-    {
517
-        $objectsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Extras');
510
+	/**
511
+	 * Get names of user variables
512
+	 *
513
+	 * @return array
514
+	 */
515
+	public function getPostVars(): array
516
+	{
517
+		$objectsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Extras');
518 518
 
519
-        return $objectsHandler->getPostVars();
520
-    }
519
+		return $objectsHandler->getPostVars();
520
+	}
521 521
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function setVar($key, $value, $not_gpc = false): void
58 58
     {
59
-        if ('field_options' === $key && \is_array($value)) {
59
+        if ('field_options'===$key && \is_array($value)) {
60 60
             foreach (\array_keys($value) as $idx) {
61 61
                 $value[$idx] = base64_encode($value[$idx]);
62 62
             }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     public function getVar($key, $format = 's')
73 73
     {
74 74
         $value = parent::getVar($key, $format);
75
-        if ('field_options' === $key && !empty($value)) {
75
+        if ('field_options'===$key && !empty($value)) {
76 76
             foreach (\array_keys($value) as $idx) {
77 77
                 $value[$idx] = base64_decode($value[$idx], true);
78 78
             }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     public function getEditElement($user, $profile)
93 93
     {
94 94
         $value = \in_array($this->getVar('field_name'), $this->getPostVars(), true) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e');
95
-        if (null === $value) {
95
+        if (null===$value) {
96 96
             $value = $this->getVar('field_default');
97 97
         }
98 98
         $caption = $this->getVar('field_title');
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
             foreach (\array_keys($options) as $key) {
106 106
                 $optval = \defined($options[$key]) ? \constant($options[$key]) : $options[$key];
107
-                $optkey = \defined((string)$key) ? \constant($key) : $key;
107
+                $optkey = \defined((string) $key) ? \constant($key) : $key;
108 108
                 unset($options[$key]);
109 109
                 $options[$optkey] = $optval;
110 110
             }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                 if (!\array_key_exists('', $options)) {
140 140
                     $element->addOption('', _NONE);
141 141
                     //trabis
142
-                    if (1 == $this->getVar('field_required')) {
142
+                    if (1==$this->getVar('field_required')) {
143 143
                         $eltmsg                          = empty($caption) ? \sprintf(_FORM_ENTER, $name) : \sprintf(_FORM_ENTER, $caption);
144 144
                         $eltmsg                          = \str_replace('"', '\"', \stripslashes($eltmsg));
145 145
                         $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};"
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
             case 'theme':
201 201
                 $element = new \XoopsFormSelect($caption, $name, $value);
202 202
                 $element->addOption('0', \_AM_SONGLIST_OBJS_MF_SITEDEFAULT);
203
-                $handle  = \opendir(XOOPS_THEME_PATH . '/');
203
+                $handle  = \opendir(XOOPS_THEME_PATH.'/');
204 204
                 $dirlist = [];
205
-                while (false !== ($file = \readdir($handle))) {
206
-                    if (\is_dir(XOOPS_THEME_PATH . '/' . $file) && !\preg_match('/^[.]{1,2}$/', $file) && 'cvs' !== \mb_strtolower($file)) {
207
-                        if (\file_exists(XOOPS_THEME_PATH . '/' . $file . '/theme.tpl') && \in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'], true)) {
205
+                while (false!==($file = \readdir($handle))) {
206
+                    if (\is_dir(XOOPS_THEME_PATH.'/'.$file) && !\preg_match('/^[.]{1,2}$/', $file) && 'cvs'!==\mb_strtolower($file)) {
207
+                        if (\file_exists(XOOPS_THEME_PATH.'/'.$file.'/theme.tpl') && \in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'], true)) {
208 208
                             $dirlist[$file] = $file;
209 209
                         }
210 210
                     }
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
                 }
217 217
                 break;
218 218
         }
219
-        if ('' != $this->getVar('field_description')) {
219
+        if (''!=$this->getVar('field_description')) {
220 220
             $element->setDescription($this->getVar('field_description'));
221 221
         }
222 222
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
                 if (!\array_key_exists('', $options)) {
268 268
                     $element->addOption('', _NONE);
269 269
                     //trabis
270
-                    if (1 == $this->getVar('field_required')) {
270
+                    if (1==$this->getVar('field_required')) {
271 271
                         $eltmsg                          = empty($caption) ? \sprintf(_FORM_ENTER, $name) : \sprintf(_FORM_ENTER, $caption);
272 272
                         $eltmsg                          = \str_replace('"', '\"', \stripslashes($eltmsg));
273 273
                         $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};"
@@ -332,11 +332,11 @@  discard block
 block discarded – undo
332 332
             case 'theme':
333 333
                 $element = new \XoopsFormSelect($caption, $name, $value);
334 334
                 $element->addOption('0', \_AM_SONGLIST_OBJS_MF_SITEDEFAULT);
335
-                $handle  = \opendir(XOOPS_THEME_PATH . '/');
335
+                $handle  = \opendir(XOOPS_THEME_PATH.'/');
336 336
                 $dirlist = [];
337
-                while (false !== ($file = \readdir($handle))) {
338
-                    if (\is_dir(XOOPS_THEME_PATH . '/' . $file) && !\preg_match('/^[.]{1,2}$/', $file) && 'cvs' !== \mb_strtolower($file)) {
339
-                        if (\file_exists(XOOPS_THEME_PATH . '/' . $file . '/theme.tpl') && \in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'], true)) {
337
+                while (false!==($file = \readdir($handle))) {
338
+                    if (\is_dir(XOOPS_THEME_PATH.'/'.$file) && !\preg_match('/^[.]{1,2}$/', $file) && 'cvs'!==\mb_strtolower($file)) {
339
+                        if (\file_exists(XOOPS_THEME_PATH.'/'.$file.'/theme.tpl') && \in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'], true)) {
340 340
                             $dirlist[$file] = $file;
341 341
                         }
342 342
                     }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                 }
349 349
                 break;
350 350
         }
351
-        if ('' != $this->getVar('field_description')) {
351
+        if (''!=$this->getVar('field_description')) {
352 352
             $element->setDescription($this->getVar('field_description'));
353 353
         }
354 354
 
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
         switch ($this->getVar('field_type')) {
373 373
             default:
374 374
             case 'textbox':
375
-                if ('url' === $this->getVar('field_name') && '' != $value) {
376
-                    return '<a href="' . \formatURL($value) . '" rel="external">' . $value . '</a>';
375
+                if ('url'===$this->getVar('field_name') && ''!=$value) {
376
+                    return '<a href="'.\formatURL($value).'" rel="external">'.$value.'</a>';
377 377
                 }
378 378
 
379 379
                 return $value;
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
             case 'checkbox':
402 402
                 $options = $this->getVar('field_options');
403 403
                 $ret     = [];
404
-                if (\count($options) > 0) {
404
+                if (\count($options)>0) {
405 405
                     foreach (\array_keys($options) as $key) {
406 406
                         if (\in_array($key, $value, true)) {
407 407
                             $$ret[$key] = \htmlspecialchars(\defined($options[$key]) ? \constant($options[$key]) : $options[$key], \ENT_QUOTES | \ENT_HTML5);
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
             case 'rank':
445 445
                 $userrank       = $user->rank();
446 446
                 $user_rankimage = '';
447
-                if (isset($userrank['image']) && '' != $userrank['image']) {
448
-                    $user_rankimage = '<img src="' . XOOPS_UPLOAD_URL . '/' . $userrank['image'] . '" alt="' . $userrank['title'] . '"><br>';
447
+                if (isset($userrank['image']) && ''!=$userrank['image']) {
448
+                    $user_rankimage = '<img src="'.XOOPS_UPLOAD_URL.'/'.$userrank['image'].'" alt="'.$userrank['title'].'"><br>';
449 449
                 }
450 450
 
451
-                return $user_rankimage . $userrank['title'];
451
+                return $user_rankimage.$userrank['title'];
452 452
                 break;
453 453
             case 'yesno':
454 454
                 return $value ? _YES : _NO;
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
             case 'timezone':
457 457
                 require_once $GLOBALS['xoops']->path('class/xoopslists.php');
458 458
                 $timezones = \XoopsLists::getTimeZoneList();
459
-                $value     = empty($value) ? '0' : (string)$value;
459
+                $value     = empty($value) ? '0' : (string) $value;
460 460
 
461 461
                 return $timezones[\str_replace('.0', '', $value)];
462 462
                 break;
@@ -491,15 +491,15 @@  discard block
 block discarded – undo
491 491
             case 'longdate':
492 492
                 return $value;
493 493
             case 'date':
494
-                if ('' != $value) {
495
-                    return \strtotime((string)$value);
494
+                if (''!=$value) {
495
+                    return \strtotime((string) $value);
496 496
                 }
497 497
 
498 498
                 return $value;
499 499
                 break;
500 500
             case 'datetime':
501 501
                 if (!empty($value)) {
502
-                    return \strtotime($value['date'] ?? '') + (int)$value['time'];
502
+                    return \strtotime($value['date'] ?? '')+(int) $value['time'];
503 503
                 }
504 504
 
505 505
                 return $value;
Please login to merge, or discard this patch.
class/Votes.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@
 block discarded – undo
12 12
  */
13 13
 class Votes extends \XoopsObject
14 14
 {
15
-    public $vid;
16
-    public $sid;
17
-    public $uid;
18
-    public $ip;
19
-    public $netaddy;
20
-    public $rank;
21
-
22
-    /**
23
-     * Votes constructor.
24
-     * @param null $fid
25
-     */
26
-    public function __construct($fid = null)
27
-    {
28
-        $this->initVar('vid', \XOBJ_DTYPE_INT, 0, false);
29
-        $this->initVar('sid', \XOBJ_DTYPE_INT, 0, false);
30
-        $this->initVar('uid', \XOBJ_DTYPE_INT, 0, false);
31
-        $this->initVar('ip', \XOBJ_DTYPE_TXTBOX, null, false, 64);
32
-        $this->initVar('netaddy', \XOBJ_DTYPE_TXTBOX, null, false, 255);
33
-        $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
34
-    }
35
-
36
-    /**
37
-     * @param bool $as_array
38
-     * @return array|string
39
-     */
40
-    public function getForm($as_array = false)
41
-    {
42
-        return FormController::votes_get_form($this, $as_array);
43
-    }
44
-
45
-    /**
46
-     * @return array
47
-     */
48
-    public function toArray(): array
49
-    {
50
-        $ret  = parent::toArray();
51
-        $form = $this->getForm(true);
52
-        foreach ($form as $key => $element) {
53
-            $ret['form'][$key] = $element->render();
54
-        }
55
-
56
-        $ret['rank'] = \number_format($this->getVar('rank'), 2) . \_MI_SONGLIST_OFTEN;
57
-
58
-        return $ret;
59
-    }
15
+	public $vid;
16
+	public $sid;
17
+	public $uid;
18
+	public $ip;
19
+	public $netaddy;
20
+	public $rank;
21
+
22
+	/**
23
+	 * Votes constructor.
24
+	 * @param null $fid
25
+	 */
26
+	public function __construct($fid = null)
27
+	{
28
+		$this->initVar('vid', \XOBJ_DTYPE_INT, 0, false);
29
+		$this->initVar('sid', \XOBJ_DTYPE_INT, 0, false);
30
+		$this->initVar('uid', \XOBJ_DTYPE_INT, 0, false);
31
+		$this->initVar('ip', \XOBJ_DTYPE_TXTBOX, null, false, 64);
32
+		$this->initVar('netaddy', \XOBJ_DTYPE_TXTBOX, null, false, 255);
33
+		$this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
34
+	}
35
+
36
+	/**
37
+	 * @param bool $as_array
38
+	 * @return array|string
39
+	 */
40
+	public function getForm($as_array = false)
41
+	{
42
+		return FormController::votes_get_form($this, $as_array);
43
+	}
44
+
45
+	/**
46
+	 * @return array
47
+	 */
48
+	public function toArray(): array
49
+	{
50
+		$ret  = parent::toArray();
51
+		$form = $this->getForm(true);
52
+		foreach ($form as $key => $element) {
53
+			$ret['form'][$key] = $element->render();
54
+		}
55
+
56
+		$ret['rank'] = \number_format($this->getVar('rank'), 2) . \_MI_SONGLIST_OFTEN;
57
+
58
+		return $ret;
59
+	}
60 60
 }
Please login to merge, or discard this patch.
class/Utf8map.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -16,51 +16,51 @@
 block discarded – undo
16 16
  */
17 17
 class Utf8map extends XoopsObject
18 18
 {
19
-    public $utfid;
20
-    public $from;
21
-    public $to;
22
-    public $created;
23
-    public $updated;
19
+	public $utfid;
20
+	public $from;
21
+	public $to;
22
+	public $created;
23
+	public $updated;
24 24
 
25
-    /**
26
-     * Utf8map constructor.
27
-     * @param null $fid
28
-     */
29
-    public function __construct($fid = null)
30
-    {
31
-        $this->initVar('utfid', \XOBJ_DTYPE_INT, 0, false);
32
-        $this->initVar('from', \XOBJ_DTYPE_TXTBOX, null, false, 2);
33
-        $this->initVar('to', \XOBJ_DTYPE_TXTBOX, null, false, 2);
34
-        $this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
35
-        $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
36
-    }
25
+	/**
26
+	 * Utf8map constructor.
27
+	 * @param null $fid
28
+	 */
29
+	public function __construct($fid = null)
30
+	{
31
+		$this->initVar('utfid', \XOBJ_DTYPE_INT, 0, false);
32
+		$this->initVar('from', \XOBJ_DTYPE_TXTBOX, null, false, 2);
33
+		$this->initVar('to', \XOBJ_DTYPE_TXTBOX, null, false, 2);
34
+		$this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
35
+		$this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
36
+	}
37 37
 
38
-    /**
39
-     * @param bool $as_array
40
-     * @return array|string
41
-     */
42
-    public function getForm($as_array = false)
43
-    {
44
-        return FormController::getFormUtf8map($this, $as_array);
45
-    }
38
+	/**
39
+	 * @param bool $as_array
40
+	 * @return array|string
41
+	 */
42
+	public function getForm($as_array = false)
43
+	{
44
+		return FormController::getFormUtf8map($this, $as_array);
45
+	}
46 46
 
47
-    /**
48
-     * @return array
49
-     */
50
-    public function toArray(): array
51
-    {
52
-        $ret  = parent::toArray();
53
-        $form = $this->getForm(true);
54
-        foreach ($form as $key => $element) {
55
-            $ret['form'][$key] = $element->render();
56
-        }
57
-        foreach (['created', 'updated'] as $key) {
58
-            if ($this->getVar($key) > 0) {
59
-                $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
60
-                $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
61
-            }
62
-        }
47
+	/**
48
+	 * @return array
49
+	 */
50
+	public function toArray(): array
51
+	{
52
+		$ret  = parent::toArray();
53
+		$form = $this->getForm(true);
54
+		foreach ($form as $key => $element) {
55
+			$ret['form'][$key] = $element->render();
56
+		}
57
+		foreach (['created', 'updated'] as $key) {
58
+			if ($this->getVar($key) > 0) {
59
+				$ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
60
+				$ret[$key]         = \date(_DATESTRING, $this->getVar($key));
61
+			}
62
+		}
63 63
 
64
-        return $ret;
65
-    }
64
+		return $ret;
65
+	}
66 66
 }
Please login to merge, or discard this patch.
class/Form/FormController.php 2 patches
Indentation   +1296 added lines, -1296 removed lines patch added patch discarded remove patch
@@ -16,1301 +16,1301 @@
 block discarded – undo
16 16
 
17 17
 class FormController
18 18
 {
19
-    /**
20
-     * Get {@link XoopsThemeForm} for adding/editing fields
21
-     *
22
-     * @param object $field  {@link ProfileField} object to get edit form for
23
-     * @param mixed  $action URL to submit to - or false for $_SERVER['SCRIPT_NAME']
24
-     *
25
-     * @return object
26
-     */
27
-    public static function getFieldForm($field, $action = false)
28
-    {
29
-        if (false === $action) {
30
-            $action = $_SERVER['SCRIPT_NAME'];
31
-        }
32
-
33
-        $helper = Helper::getInstance();
34
-        $helper->loadLanguage('forms');
35
-
36
-        $title = $field->isNew() ? sprintf(_FRM_SONGLIST_FIELDS_ADD, _FRM_SONGLIST_FIELDS_FIELD) : sprintf(_FRM_SONGLIST_FIELDS_EDIT, _FRM_SONGLIST_FIELDS_FIELD);
37
-
38
-        xoops_load('XoopsFormLoader');
39
-
40
-        $form = new \XoopsThemeForm($title, 'form', $action, 'post', true);
41
-
42
-        $form->addElement(new \XoopsFormText(_FRM_SONGLIST_FIELDS_TITLE, 'field_title', 35, 255, $field->getVar('field_title', 'e')));
43
-        $form->addElement(new \XoopsFormTextArea(_FRM_SONGLIST_FIELDS_DESCRIPTION, 'field_description', $field->getVar('field_description', 'e')));
44
-
45
-        if ($field->isNew()) {
46
-            $fieldcid = [1 => 0];
47
-        } else {
48
-            $fieldcid = $field->getVar('cids');
49
-        }
50
-        $categoryHandler = Helper::getInstance()
51
-                                 ->getHandler('Category');
52
-        $cat_select      = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_CATEGORY, 'cids', $fieldcid, 7, true);
53
-        $cat_select->addOption(0, _FRM_SONGLIST_FIELDS_DEFAULT);
54
-        foreach ($categoryHandler->getObjects(null, true) as $cid => $category) {
55
-            $cat_select->addOption($cid, $category->getVar('name'));
56
-        }
57
-        $form->addElement($cat_select);
58
-        $form->addElement(new \XoopsFormText(_FRM_SONGLIST_FIELDS_WEIGHT, 'field_weight', 10, 10, $field->getVar('field_weight', 'e')));
59
-        if ($field->getVar('field_config') || $field->isNew()) {
60
-            if ($field->isNew()) {
61
-                $form->addElement(new \XoopsFormText(_FRM_SONGLIST_FIELDS_NAME, 'field_name', 35, 255, $field->getVar('field_name', 'e')));
62
-            } else {
63
-                $form->addElement(new \XoopsFormLabel(_FRM_SONGLIST_FIELDS_NAME, $field->getVar('field_name')));
64
-                $form->addElement(new \XoopsFormHidden('id', $field->getVar('field_id')));
65
-            }
66
-
67
-            //autotext and theme left out of this one as fields of that type should never be changed (valid assumption, I think)
68
-            $fieldtypes = [
69
-                'checkbox'     => _FRM_SONGLIST_FIELDS_CHECKBOX,
70
-                'date'         => _FRM_SONGLIST_FIELDS_DATE,
71
-                'datetime'     => _FRM_SONGLIST_FIELDS_DATETIME,
72
-                'longdate'     => _FRM_SONGLIST_FIELDS_LONGDATE,
73
-                'group'        => _FRM_SONGLIST_FIELDS_GROUP,
74
-                'group_multi'  => _FRM_SONGLIST_FIELDS_GROUPMULTI,
75
-                'language'     => _FRM_SONGLIST_FIELDS_LANGUAGE,
76
-                'radio'        => _FRM_SONGLIST_FIELDS_RADIO,
77
-                'select'       => _FRM_SONGLIST_FIELDS_SELECT,
78
-                'select_multi' => _FRM_SONGLIST_FIELDS_SELECTMULTI,
79
-                'textarea'     => _FRM_SONGLIST_FIELDS_TEXTAREA,
80
-                'dhtml'        => _FRM_SONGLIST_FIELDS_DHTMLTEXTAREA,
81
-                'textbox'      => _FRM_SONGLIST_FIELDS_TEXTBOX,
82
-                'timezone'     => _FRM_SONGLIST_FIELDS_TIMEZONE,
83
-                'yesno'        => _FRM_SONGLIST_FIELDS_YESNO,
84
-            ];
85
-
86
-            $element_select = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_TYPE, 'field_type', $field->getVar('field_type', 'e'));
87
-            $element_select->addOptionArray($fieldtypes);
88
-
89
-            $form->addElement($element_select);
90
-
91
-            switch ($field->getVar('field_type')) {
92
-                case 'textbox':
93
-                    $valuetypes = [
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
-
105
-                    $type_select = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
106
-                    $type_select->addOptionArray($valuetypes);
107
-                    $form->addElement($type_select);
108
-                    break;
109
-                case 'select':
110
-                case 'radio':
111
-                    $valuetypes = [
112
-                        XOBJ_DTYPE_ARRAY   => _FRM_SONGLIST_FIELDS_ARRAY,
113
-                        XOBJ_DTYPE_EMAIL   => _FRM_SONGLIST_FIELDS_EMAIL,
114
-                        XOBJ_DTYPE_INT     => _FRM_SONGLIST_FIELDS_INT,
115
-                        XOBJ_DTYPE_FLOAT   => _FRM_SONGLIST_FIELDS_FLOAT,
116
-                        XOBJ_DTYPE_DECIMAL => _FRM_SONGLIST_FIELDS_DECIMAL,
117
-                        XOBJ_DTYPE_TXTAREA => _FRM_SONGLIST_FIELDS_TXTAREA,
118
-                        XOBJ_DTYPE_TXTBOX  => _FRM_SONGLIST_FIELDS_TXTBOX,
119
-                        XOBJ_DTYPE_URL     => _FRM_SONGLIST_FIELDS_URL,
120
-                        XOBJ_DTYPE_OTHER   => _FRM_SONGLIST_FIELDS_OTHER,
121
-                    ];
122
-
123
-                    $type_select = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
124
-                    $type_select->addOptionArray($valuetypes);
125
-                    $form->addElement($type_select);
126
-                    break;
127
-            }
128
-
129
-            //$form->addElement(new \XoopsFormRadioYN(_FRM_SONGLIST_FIELDS_NOTNULL, 'field_notnull', $field->getVar('field_notnull', 'e') ));
130
-
131
-            if ('select' === $field->getVar('field_type') || 'select_multi' === $field->getVar('field_type') || 'radio' === $field->getVar('field_type') || 'checkbox' === $field->getVar('field_type')) {
132
-                $options = $field->getVar('field_options');
133
-                if (count($options) > 0) {
134
-                    $remove_options          = new \XoopsFormCheckBox(_FRM_SONGLIST_FIELDS_REMOVEOPTIONS, 'removeOptions');
135
-                    $remove_options->columns = 3;
136
-                    asort($options);
137
-                    foreach (array_keys($options) as $key) {
138
-                        $options[$key] .= "[{$key}]";
139
-                    }
140
-                    $remove_options->addOptionArray($options);
141
-                    $form->addElement($remove_options);
142
-                }
143
-
144
-                $option_text = "<table  cellspacing='1'><tr><td width='20%'>" . _FRM_SONGLIST_FIELDS_KEY . '</td><td>' . _FRM_SONGLIST_FIELDS_VALUE . '</td></tr>';
145
-                for ($i = 0; $i < 3; ++$i) {
146
-                    $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>";
147
-                    $option_text .= "<tr height='3px'><td colspan='2'> </td></tr>";
148
-                }
149
-                $option_text .= '</table>';
150
-                $form->addElement(new \XoopsFormLabel(_FRM_SONGLIST_FIELDS_ADDOPTION, $option_text));
151
-            }
152
-        }
153
-
154
-        if ($field->getVar('field_edit')) {
155
-            switch ($field->getVar('field_type')) {
156
-                case 'textbox':
157
-                case 'textarea':
158
-                case 'dhtml':
159
-                    $form->addElement(new \XoopsFormText(_FRM_SONGLIST_FIELDS_MAXLENGTH, 'field_maxlength', 35, 35, $field->getVar('field_maxlength', 'e')));
160
-                    $form->addElement(new \XoopsFormTextArea(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
161
-                    break;
162
-                case 'checkbox':
163
-                case 'select_multi':
164
-                    $def_value = null !== $field->getVar('field_default', 'e') ? unserialize(($field->getVar('field_default', 'n')) ?? '') : null;
165
-                    $element   = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $def_value, 8, true);
166
-                    $options   = $field->getVar('field_options');
167
-                    asort($options);
168
-                    // If options do not include an empty element, then add a blank option to prevent any default selection
169
-                    if (!array_key_exists('', $options)) {
170
-                        $element->addOption('', _NONE);
171
-                    }
172
-                    $element->addOptionArray($options);
173
-                    $form->addElement($element);
174
-                    break;
175
-                case 'select':
176
-                case 'radio':
177
-                    $def_value = null !== $field->getVar('field_default', 'e') ? $field->getVar('field_default') : null;
178
-                    $element   = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $def_value);
179
-                    $options   = $field->getVar('field_options');
180
-                    asort($options);
181
-                    // If options do not include an empty element, then add a blank option to prevent any default selection
182
-                    if (!array_key_exists('', $options)) {
183
-                        $element->addOption('', _NONE);
184
-                    }
185
-                    $element->addOptionArray($options);
186
-                    $form->addElement($element);
187
-                    break;
188
-                case 'date':
189
-                    $form->addElement(new \XoopsFormTextDateSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', 15, $field->getVar('field_default', 'e')));
190
-                    break;
191
-                case 'longdate':
192
-                    $form->addElement(new \XoopsFormTextDateSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', 15, strtotime($field->getVar('field_default', 'e'))));
193
-                    break;
194
-                case 'datetime':
195
-                    $form->addElement(new \XoopsFormDateTime(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', 15, $field->getVar('field_default', 'e')));
196
-                    break;
197
-                case 'yesno':
198
-                    $form->addElement(new \XoopsFormRadioYN(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
199
-                    break;
200
-                case 'timezone':
201
-                    $form->addElement(new \XoopsFormSelectTimezone(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
202
-                    break;
203
-                case 'language':
204
-                    $form->addElement(new \XoopsFormSelectLang(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
205
-                    break;
206
-                case 'group':
207
-                    $form->addElement(new \XoopsFormSelectGroup(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', true, $field->getVar('field_default', 'e')));
208
-                    break;
209
-                case 'group_multi':
210
-                    $form->addElement(new \XoopsFormSelectGroup(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', true, $field->getVar('field_default', 'e'), 5, true));
211
-                    break;
212
-                case 'theme':
213
-                    $form->addElement(new \XoopsFormSelectTheme(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
214
-                    break;
215
-                case 'autotext':
216
-                    $form->addElement(new \XoopsFormTextArea(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
217
-                    break;
218
-            }
219
-        }
220
-
221
-        /** @var \XoopsGroupPermHandler $grouppermHandler */
222
-        $grouppermHandler = xoops_getHandler('groupperm');
223
-        $searchable_types = [
224
-            'textbox',
225
-            'select',
226
-            'radio',
227
-            'yesno',
228
-            'date',
229
-            'datetime',
230
-            'timezone',
231
-            'language',
232
-        ];
233
-        if (in_array($field->getVar('field_type'), $searchable_types, true)) {
234
-            $search_groups = $grouppermHandler->getGroupIds('songlist_search', $field->getVar('field_id'), $GLOBALS['songlistModule']->getVar('mid'));
235
-            $form->addElement(new \XoopsFormSelectGroup(_FRM_SONGLIST_FIELDS_PROF_SEARCH, 'songlist_search', true, $search_groups, 5, true));
236
-        }
237
-        if ($field->getVar('field_edit') || $field->isNew()) {
238
-            if ($field->isNew()) {
239
-                $editable_groups = [];
240
-            } else {
241
-                //Load groups
242
-                $editable_groups = $grouppermHandler->getGroupIds('songlist_edit', $field->getVar('field_id'), $GLOBALS['songlistModule']->getVar('mid'));
243
-            }
244
-            $form->addElement(new \XoopsFormSelectGroup(_FRM_SONGLIST_FIELDS_PROF_EDITABLE, 'songlist_edit', false, $editable_groups, 5, true));
19
+	/**
20
+	 * Get {@link XoopsThemeForm} for adding/editing fields
21
+	 *
22
+	 * @param object $field  {@link ProfileField} object to get edit form for
23
+	 * @param mixed  $action URL to submit to - or false for $_SERVER['SCRIPT_NAME']
24
+	 *
25
+	 * @return object
26
+	 */
27
+	public static function getFieldForm($field, $action = false)
28
+	{
29
+		if (false === $action) {
30
+			$action = $_SERVER['SCRIPT_NAME'];
31
+		}
32
+
33
+		$helper = Helper::getInstance();
34
+		$helper->loadLanguage('forms');
35
+
36
+		$title = $field->isNew() ? sprintf(_FRM_SONGLIST_FIELDS_ADD, _FRM_SONGLIST_FIELDS_FIELD) : sprintf(_FRM_SONGLIST_FIELDS_EDIT, _FRM_SONGLIST_FIELDS_FIELD);
37
+
38
+		xoops_load('XoopsFormLoader');
39
+
40
+		$form = new \XoopsThemeForm($title, 'form', $action, 'post', true);
41
+
42
+		$form->addElement(new \XoopsFormText(_FRM_SONGLIST_FIELDS_TITLE, 'field_title', 35, 255, $field->getVar('field_title', 'e')));
43
+		$form->addElement(new \XoopsFormTextArea(_FRM_SONGLIST_FIELDS_DESCRIPTION, 'field_description', $field->getVar('field_description', 'e')));
44
+
45
+		if ($field->isNew()) {
46
+			$fieldcid = [1 => 0];
47
+		} else {
48
+			$fieldcid = $field->getVar('cids');
49
+		}
50
+		$categoryHandler = Helper::getInstance()
51
+								 ->getHandler('Category');
52
+		$cat_select      = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_CATEGORY, 'cids', $fieldcid, 7, true);
53
+		$cat_select->addOption(0, _FRM_SONGLIST_FIELDS_DEFAULT);
54
+		foreach ($categoryHandler->getObjects(null, true) as $cid => $category) {
55
+			$cat_select->addOption($cid, $category->getVar('name'));
56
+		}
57
+		$form->addElement($cat_select);
58
+		$form->addElement(new \XoopsFormText(_FRM_SONGLIST_FIELDS_WEIGHT, 'field_weight', 10, 10, $field->getVar('field_weight', 'e')));
59
+		if ($field->getVar('field_config') || $field->isNew()) {
60
+			if ($field->isNew()) {
61
+				$form->addElement(new \XoopsFormText(_FRM_SONGLIST_FIELDS_NAME, 'field_name', 35, 255, $field->getVar('field_name', 'e')));
62
+			} else {
63
+				$form->addElement(new \XoopsFormLabel(_FRM_SONGLIST_FIELDS_NAME, $field->getVar('field_name')));
64
+				$form->addElement(new \XoopsFormHidden('id', $field->getVar('field_id')));
65
+			}
66
+
67
+			//autotext and theme left out of this one as fields of that type should never be changed (valid assumption, I think)
68
+			$fieldtypes = [
69
+				'checkbox'     => _FRM_SONGLIST_FIELDS_CHECKBOX,
70
+				'date'         => _FRM_SONGLIST_FIELDS_DATE,
71
+				'datetime'     => _FRM_SONGLIST_FIELDS_DATETIME,
72
+				'longdate'     => _FRM_SONGLIST_FIELDS_LONGDATE,
73
+				'group'        => _FRM_SONGLIST_FIELDS_GROUP,
74
+				'group_multi'  => _FRM_SONGLIST_FIELDS_GROUPMULTI,
75
+				'language'     => _FRM_SONGLIST_FIELDS_LANGUAGE,
76
+				'radio'        => _FRM_SONGLIST_FIELDS_RADIO,
77
+				'select'       => _FRM_SONGLIST_FIELDS_SELECT,
78
+				'select_multi' => _FRM_SONGLIST_FIELDS_SELECTMULTI,
79
+				'textarea'     => _FRM_SONGLIST_FIELDS_TEXTAREA,
80
+				'dhtml'        => _FRM_SONGLIST_FIELDS_DHTMLTEXTAREA,
81
+				'textbox'      => _FRM_SONGLIST_FIELDS_TEXTBOX,
82
+				'timezone'     => _FRM_SONGLIST_FIELDS_TIMEZONE,
83
+				'yesno'        => _FRM_SONGLIST_FIELDS_YESNO,
84
+			];
85
+
86
+			$element_select = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_TYPE, 'field_type', $field->getVar('field_type', 'e'));
87
+			$element_select->addOptionArray($fieldtypes);
88
+
89
+			$form->addElement($element_select);
90
+
91
+			switch ($field->getVar('field_type')) {
92
+				case 'textbox':
93
+					$valuetypes = [
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
+
105
+					$type_select = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
106
+					$type_select->addOptionArray($valuetypes);
107
+					$form->addElement($type_select);
108
+					break;
109
+				case 'select':
110
+				case 'radio':
111
+					$valuetypes = [
112
+						XOBJ_DTYPE_ARRAY   => _FRM_SONGLIST_FIELDS_ARRAY,
113
+						XOBJ_DTYPE_EMAIL   => _FRM_SONGLIST_FIELDS_EMAIL,
114
+						XOBJ_DTYPE_INT     => _FRM_SONGLIST_FIELDS_INT,
115
+						XOBJ_DTYPE_FLOAT   => _FRM_SONGLIST_FIELDS_FLOAT,
116
+						XOBJ_DTYPE_DECIMAL => _FRM_SONGLIST_FIELDS_DECIMAL,
117
+						XOBJ_DTYPE_TXTAREA => _FRM_SONGLIST_FIELDS_TXTAREA,
118
+						XOBJ_DTYPE_TXTBOX  => _FRM_SONGLIST_FIELDS_TXTBOX,
119
+						XOBJ_DTYPE_URL     => _FRM_SONGLIST_FIELDS_URL,
120
+						XOBJ_DTYPE_OTHER   => _FRM_SONGLIST_FIELDS_OTHER,
121
+					];
122
+
123
+					$type_select = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
124
+					$type_select->addOptionArray($valuetypes);
125
+					$form->addElement($type_select);
126
+					break;
127
+			}
128
+
129
+			//$form->addElement(new \XoopsFormRadioYN(_FRM_SONGLIST_FIELDS_NOTNULL, 'field_notnull', $field->getVar('field_notnull', 'e') ));
130
+
131
+			if ('select' === $field->getVar('field_type') || 'select_multi' === $field->getVar('field_type') || 'radio' === $field->getVar('field_type') || 'checkbox' === $field->getVar('field_type')) {
132
+				$options = $field->getVar('field_options');
133
+				if (count($options) > 0) {
134
+					$remove_options          = new \XoopsFormCheckBox(_FRM_SONGLIST_FIELDS_REMOVEOPTIONS, 'removeOptions');
135
+					$remove_options->columns = 3;
136
+					asort($options);
137
+					foreach (array_keys($options) as $key) {
138
+						$options[$key] .= "[{$key}]";
139
+					}
140
+					$remove_options->addOptionArray($options);
141
+					$form->addElement($remove_options);
142
+				}
143
+
144
+				$option_text = "<table  cellspacing='1'><tr><td width='20%'>" . _FRM_SONGLIST_FIELDS_KEY . '</td><td>' . _FRM_SONGLIST_FIELDS_VALUE . '</td></tr>';
145
+				for ($i = 0; $i < 3; ++$i) {
146
+					$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>";
147
+					$option_text .= "<tr height='3px'><td colspan='2'> </td></tr>";
148
+				}
149
+				$option_text .= '</table>';
150
+				$form->addElement(new \XoopsFormLabel(_FRM_SONGLIST_FIELDS_ADDOPTION, $option_text));
151
+			}
152
+		}
153
+
154
+		if ($field->getVar('field_edit')) {
155
+			switch ($field->getVar('field_type')) {
156
+				case 'textbox':
157
+				case 'textarea':
158
+				case 'dhtml':
159
+					$form->addElement(new \XoopsFormText(_FRM_SONGLIST_FIELDS_MAXLENGTH, 'field_maxlength', 35, 35, $field->getVar('field_maxlength', 'e')));
160
+					$form->addElement(new \XoopsFormTextArea(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
161
+					break;
162
+				case 'checkbox':
163
+				case 'select_multi':
164
+					$def_value = null !== $field->getVar('field_default', 'e') ? unserialize(($field->getVar('field_default', 'n')) ?? '') : null;
165
+					$element   = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $def_value, 8, true);
166
+					$options   = $field->getVar('field_options');
167
+					asort($options);
168
+					// If options do not include an empty element, then add a blank option to prevent any default selection
169
+					if (!array_key_exists('', $options)) {
170
+						$element->addOption('', _NONE);
171
+					}
172
+					$element->addOptionArray($options);
173
+					$form->addElement($element);
174
+					break;
175
+				case 'select':
176
+				case 'radio':
177
+					$def_value = null !== $field->getVar('field_default', 'e') ? $field->getVar('field_default') : null;
178
+					$element   = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $def_value);
179
+					$options   = $field->getVar('field_options');
180
+					asort($options);
181
+					// If options do not include an empty element, then add a blank option to prevent any default selection
182
+					if (!array_key_exists('', $options)) {
183
+						$element->addOption('', _NONE);
184
+					}
185
+					$element->addOptionArray($options);
186
+					$form->addElement($element);
187
+					break;
188
+				case 'date':
189
+					$form->addElement(new \XoopsFormTextDateSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', 15, $field->getVar('field_default', 'e')));
190
+					break;
191
+				case 'longdate':
192
+					$form->addElement(new \XoopsFormTextDateSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', 15, strtotime($field->getVar('field_default', 'e'))));
193
+					break;
194
+				case 'datetime':
195
+					$form->addElement(new \XoopsFormDateTime(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', 15, $field->getVar('field_default', 'e')));
196
+					break;
197
+				case 'yesno':
198
+					$form->addElement(new \XoopsFormRadioYN(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
199
+					break;
200
+				case 'timezone':
201
+					$form->addElement(new \XoopsFormSelectTimezone(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
202
+					break;
203
+				case 'language':
204
+					$form->addElement(new \XoopsFormSelectLang(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
205
+					break;
206
+				case 'group':
207
+					$form->addElement(new \XoopsFormSelectGroup(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', true, $field->getVar('field_default', 'e')));
208
+					break;
209
+				case 'group_multi':
210
+					$form->addElement(new \XoopsFormSelectGroup(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', true, $field->getVar('field_default', 'e'), 5, true));
211
+					break;
212
+				case 'theme':
213
+					$form->addElement(new \XoopsFormSelectTheme(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
214
+					break;
215
+				case 'autotext':
216
+					$form->addElement(new \XoopsFormTextArea(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
217
+					break;
218
+			}
219
+		}
220
+
221
+		/** @var \XoopsGroupPermHandler $grouppermHandler */
222
+		$grouppermHandler = xoops_getHandler('groupperm');
223
+		$searchable_types = [
224
+			'textbox',
225
+			'select',
226
+			'radio',
227
+			'yesno',
228
+			'date',
229
+			'datetime',
230
+			'timezone',
231
+			'language',
232
+		];
233
+		if (in_array($field->getVar('field_type'), $searchable_types, true)) {
234
+			$search_groups = $grouppermHandler->getGroupIds('songlist_search', $field->getVar('field_id'), $GLOBALS['songlistModule']->getVar('mid'));
235
+			$form->addElement(new \XoopsFormSelectGroup(_FRM_SONGLIST_FIELDS_PROF_SEARCH, 'songlist_search', true, $search_groups, 5, true));
236
+		}
237
+		if ($field->getVar('field_edit') || $field->isNew()) {
238
+			if ($field->isNew()) {
239
+				$editable_groups = [];
240
+			} else {
241
+				//Load groups
242
+				$editable_groups = $grouppermHandler->getGroupIds('songlist_edit', $field->getVar('field_id'), $GLOBALS['songlistModule']->getVar('mid'));
243
+			}
244
+			$form->addElement(new \XoopsFormSelectGroup(_FRM_SONGLIST_FIELDS_PROF_EDITABLE, 'songlist_edit', false, $editable_groups, 5, true));
245 245
 //            $form->addElement($steps_select);
246
-        }
247
-        $form->addElement(new \XoopsFormHidden('op', 'save'));
248
-        $form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
249
-
250
-        return $form;
251
-    }
252
-
253
-    /**
254
-     * Get {@link XoopsThemeForm} for editing a user
255
-     *
256
-     * @param bool $action
257
-     * @return object
258
-     * @internal param object $user <a href='psi_element://XoopsUser'>XoopsUser</a> to edit to edit
259
-     */
260
-    public static function getUserSearchForm($action = false)
261
-    {
262
-        xoops_loadLanguage('forms', 'songlist');
263
-
264
-        if (!$action) {
265
-            $action = $_SERVER['SCRIPT_NAME'];
266
-        }
267
-        if (empty($GLOBALS['xoopsConfigUser'])) {
268
-            /** @var \XoopsConfigHandler $configHandler */
269
-            $configHandler              = xoops_getHandler('config');
270
-            $GLOBALS['xoopsConfigUser'] = $configHandler->getConfigsByCat(XOOPS_CONF_USER);
271
-        }
272
-
273
-        $helper = Helper::getInstance();
274
-
275
-        $title = _FRM_SONGLIST_FIELDS_SEARCH;
276
-
277
-        $form = new \XoopsThemeForm($title, 'search', $action, 'post', true);
278
-
279
-        $songlistHandler = Helper::getInstance()
280
-                                 ->getHandler('Profile', 'objects');
281
-        // Get fields
282
-        $fields = $songlistHandler->loadFields();
283
-
284
-        /** @var \XoopsGroupPermHandler $grouppermHandler */
285
-        $grouppermHandler = xoops_getHandler('groupperm');
286
-        /** @var \XoopsConfigHandler $configHandler */
287
-        $configHandler = xoops_getHandler('config');
288
-        $groups        = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS];
289
-        /** @var \XoopsModuleHandler $moduleHandler */
290
-        $moduleHandler = xoops_getHandler('module');
291
-        $xoModule      = $moduleHandler->getByDirname('objects');
292
-        $modid         = $xoModule->getVar('mid');
293
-
294
-        // Get ids of fields that can be edited
295
-        /** @var \XoopsGroupPermHandler $grouppermHandler */
296
-        $grouppermHandler = xoops_getHandler('groupperm');
297
-
298
-        $editable_fields = $grouppermHandler->getItemIds('songlist_search', $groups, $modid);
299
-
300
-        $catHandler = Helper::getInstance()
301
-                            ->getHandler('Category');
302
-
303
-        $selcat = new \XoopsFormSelect('Form', 'cid', !empty($_REQUEST['cid']) ? Request::getInt('cid', 0, 'REQUEST') : 0, 1, false, false, false, true);
304
-        $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"');
305
-
306
-        $form->addElement($selcat, true);
307
-
308
-        $categories = [];
309
-
310
-        $criteria       = new \CriteriaCompo(new \Criteria('cid', !empty($_REQUEST['cid']) ? Request::getInt('cid', 0, 'REQUEST') : '0'), 'OR');
311
-        $all_categories = $catHandler->getObjects($criteria, true, false);
312
-        $count_fields   = count($fields);
313
-
314
-        foreach (array_keys($fields) as $i) {
315
-            if (in_array($fields[$i]->getVar('field_id'), $editable_fields, true)) {
316
-                // Set default value for user fields if available
317
-                $fieldinfo['element']  = $fields[$i]->getSearchElement();
318
-                $fieldinfo['required'] = false;
319
-
320
-                foreach ($fields[$i]->getVar('cids') as $catidid => $cid) {
321
-                    if (array_key_exists($cid, $all_categories)) {
322
-                        $key              = $all_categories[$cid]['cat_weight'] * $count_fields + $cid;
323
-                        $elements[$key][] = $fieldinfo;
324
-                        $weights[$key][]  = $fields[$i]->getVar('field_weight');
325
-                        $categories[$key] = $all_categories[$cid];
326
-                    } elseif (in_array(0, $fields[$i]->getVar('cids'), true)) {
327
-                        $key              = $all_categories[$cid]['cat_weight'] * $count_fields + $cid;
328
-                        $elements[$key][] = $fieldinfo;
329
-                        $weights[$key][]  = $fields[$i]->getVar('field_weight');
330
-                        $categories[$key] = $all_categories[$cid];
331
-                    }
332
-                }
333
-            }
334
-        }
335
-
336
-        ksort($elements);
337
-        foreach (array_keys($elements) as $k) {
338
-            array_multisort($weights[$k], SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]);
339
-            $title = isset($categories[$k]) ? $categories[$k]['cat_title'] : _FRM_SONGLIST_FORM_DEFAULT;
340
-            $desc  = isset($categories[$k]) ? $categories[$k]['cat_description'] : '';
341
-            $form->addElement(new \XoopsFormLabel("<h3>{$title}</h3>", $desc), false);
342
-            foreach (array_keys($elements[$k]) as $i) {
343
-                $form->addElement($elements[$k][$i]['element'], $elements[$k][$i]['required']);
344
-            }
345
-        }
346
-
347
-        $form->addElement(new \XoopsFormHidden('fct', 'objects'));
348
-        $form->addElement(new \XoopsFormHidden('op', 'search'));
349
-        $form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
350
-
351
-        return $form;
352
-    }
353
-
354
-    /**
355
-     * @param bool $as_array
356
-     * @return string
357
-     */
358
-    public static function  getFormImport($as_array = false): string
359
-    {
360
-        xoops_loadLanguage('forms', 'songlist');
361
-
362
-        $sform = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_IMPORT, 'import', $_SERVER['SCRIPT_NAME'], 'post', true);
363
-        $sform->setExtra("enctype='multipart/form-data'");
364
-
365
-        $ele['op']      = new \XoopsFormHidden('op', 'import');
366
-        $ele['fct']     = new \XoopsFormHidden('fct', 'upload');
367
-        $ele['xmlfile'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_UPLOAD_XML : ''), 'xmlfile', 1024 * 1024 * 1024 * 32);
368
-        $ele['xmlfile']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_UPLOAD_XML_DESC : ''));
369
-        $ele['file'] = new \XoopsFormSelect((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_EXISTING_XML : ''), 'file');
370
-        $ele['file']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_EXISTING_XML_DESC : ''));
371
-        $ele['file']->addOption('', '*********');
372
-        xoops_load('XoopsLists');
373
-        foreach (\XoopsLists::getFileListAsArray($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $file) {
374
-            if ('xml' === mb_substr($file, mb_strlen($file) - 3, 3)) {
375
-                $ele['file']->addOption($file, $file);
376
-            }
377
-        }
378
-        $ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
379
-
380
-        $required = [];
381
-
382
-        foreach ($ele as $id => $obj) {
383
-            if (in_array($id, $required, true)) {
384
-                $sform->addElement($obj, true);
385
-            } else {
386
-                $sform->addElement($obj, false);
387
-            }
388
-        }
389
-
390
-        return $sform->render();
391
-    }
392
-
393
-    /**
394
-     * @param      $file
395
-     * @param bool $as_array
396
-     * @return string
397
-     */
398
-    public static function  getFormImportb($file, $as_array = false): string
399
-    {
400
-        xoops_loadLanguage('forms', 'songlist');
401
-
402
-        $sform = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_ELEMENTS, 'elements', $_SERVER['SCRIPT_NAME'], 'post', true);
403
-
404
-        $filesize = filesize($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $file));
405
-        $mb       = floor($filesize / 1024 / 1024);
406
-        if ($mb > 32) {
407
-            ini_set('memory_limit', ($mb + 128) . 'M');
408
-        }
409
-        set_time_limit(3600);
410
-
411
-        $i = 0;
412
-        foreach (file($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $_SESSION['xmlfile'])) as $data) {
413
-            ++$i;
414
-            if ($i < 20) {
415
-                $line .= htmlspecialchars($data, ENT_QUOTES | ENT_HTML5) . ($i < 19 ? "\n" : '');
416
-            }
417
-        }
418
-
419
-        $ele['op']      = new \XoopsFormHidden('op', 'import');
420
-        $ele['fct']     = new \XoopsFormHidden('fct', 'import');
421
-        $ele['example'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_EXAMPLE : ''), '<pre>' . $line . '</pre>');
422
-        $ele['example']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_EXAMPLE_DESC : ''));
423
-        $ele['collection'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_COLLECTION : ''), 'collection', 32, 128, 'collection');
424
-        $ele['collection']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_COLLECTION_DESC : ''));
425
-        $ele['record'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_RECORD : ''), 'record', 32, 128, 'record');
426
-        $ele['record']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_RECORD_DESC : ''));
427
-        $ele['genre'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_GENRES : ''), 'genre', 32, 128, 'genre');
428
-        $ele['genre']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_GENRES_DESC : ''));
429
-        $ele['voice'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_VOICE : ''), 'voice', 32, 128, 'voice');
430
-        $ele['voice']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_VOICE_DESC : ''));
431
-        $ele['category'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_CATEGORY : ''), 'category', 32, 128, 'category');
432
-        $ele['category']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_CATEGORY_DESC : ''));
433
-        $ele['artist'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_ARTIST : ''), 'artist', 32, 128, 'artist');
434
-        $ele['artist']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_ARTIST_DESC : ''));
435
-        $ele['album'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_ALBUM : ''), 'album', 32, 128, 'album');
436
-        $ele['album']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_ALBUM_DESC : ''));
437
-        $ele['songid'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_SONGID : ''), 'songid', 32, 128, 'songid');
438
-        $ele['songid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_SONGID_DESC : ''));
439
-        $ele['traxid'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_TRAXID : ''), 'traxid', 32, 128, 'trackno');
440
-        $ele['traxid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_TRAXID_DESC : ''));
441
-        $ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_TITLE : ''), 'title', 32, 128, 'title');
442
-        $ele['title']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_TITLE_DESC : ''));
443
-        $ele['lyrics'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_LYRICS : ''), 'lyrics', 32, 128, 'lyric');
444
-        $ele['lyrics']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_LYRICS_DESC : ''));
445
-        $ele['tags'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_TAGS : ''), 'tags', 32, 128, 'tags');
446
-        $ele['tags']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_TAGS_DESC : ''));
447
-        $ele['mp3'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_MP3 : ''), 'mp3', 32, 128, 'mp3');
448
-        $ele['mp3']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_MP3_DESC : ''));
449
-        $extrasHandler = Helper::getInstance()
450
-                               ->getHandler('Extras');
451
-        $fields        = $extrasHandler->getFields(null);
452
-        foreach ($fields as $field) {
453
-            $ele[$field->getVar('field_name')] = new \XoopsFormText((!$as_array ? $field->getVar('field_title') : ''), $field->getVar('field_name'), 32, 128, $field->getVar('field_name'));
454
-            $ele[$field->getVar('field_name')]->setDescription((!$as_array ? $field->getVar('field_description') : ''));
455
-        }
456
-        $ele['limiting'] = new \XoopsFormRadioYN((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_LIMITING : ''), 'limiting');
457
-        $ele['limiting']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_LIMITING_DESC : ''));
458
-        $ele['records'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_RECORDS : ''), 'records', 10, 10, '250');
459
-        $ele['records']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_RECORDS_DESC : ''));
460
-        $ele['wait'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_WAIT : ''), 'wait', 10, 10, '40');
461
-        $ele['wait']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_WAIT_DESC : ''));
462
-
463
-        $ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
464
-
465
-        $required = [];
466
-
467
-        foreach ($ele as $id => $obj) {
468
-            if (in_array($id, $required, true)) {
469
-                $sform->addElement($obj, true);
470
-            } else {
471
-                $sform->addElement($obj, false);
472
-            }
473
-        }
474
-
475
-        return $sform->render();
476
-    }
477
-
478
-    /**
479
-     * @param      $object
480
-     * @param bool $as_array
481
-     * @return array|string
482
-     */
483
-    public static function  getFormGenre($object, $as_array = false)
484
-    {
485
-        if (!is_object($object)) {
486
-            $handler = Helper::getInstance()
487
-                             ->getHandler('Genre');
488
-            $object  = $handler->create();
489
-        }
490
-
491
-        xoops_loadLanguage('forms', 'songlist');
492
-        $ele = [];
493
-
494
-        if ($object->isNew()) {
495
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_GENRE, 'genre', $_SERVER['SCRIPT_NAME'], 'post', true);
496
-            $ele['mode'] = new \XoopsFormHidden('mode', 'new');
497
-        } else {
498
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_GENRE, 'genre', $_SERVER['SCRIPT_NAME'], 'post', true);
499
-            $ele['mode'] = new \XoopsFormHidden('mode', 'edit');
500
-        }
501
-
502
-        $sform->setExtra("enctype='multipart/form-data'");
503
-
504
-        $id = $object->getVar('gid');
505
-        if (empty($id)) {
506
-            $id = '0';
507
-        }
508
-
509
-        $ele['op']  = new \XoopsFormHidden('op', 'genre');
510
-        $ele['fct'] = new \XoopsFormHidden('fct', 'save');
511
-        if ($as_array) {
512
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
513
-        } else {
514
-            $ele['id'] = new \XoopsFormHidden('id', $id);
515
-        }
516
-        $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
517
-        $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
518
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
519
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
520
-        $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
521
-
522
-        $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_GENRE_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
523
-        $ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_GENRE_NAME_DESC : ''));
524
-        $ele['albums']  = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_ALBUMS : ''), $object->getVar('albums'));
525
-        $ele['artists'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_ARTISTS : ''), $object->getVar('artists'));
526
-        $ele['songs']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_SONGS : ''), $object->getVar('songs'));
527
-        $ele['hits']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_HITS : ''), $object->getVar('hits'));
528
-        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
529
-        if ($object->getVar('created') > 0) {
530
-            $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
531
-        }
532
-        if ($object->getVar('updated') > 0) {
533
-            $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
534
-        }
535
-
536
-        if ($as_array) {
537
-            return $ele;
538
-        }
539
-
540
-        $ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
541
-
542
-        $required = ['name'];
543
-
544
-        foreach ($ele as $id => $obj) {
545
-            if (in_array($id, $required, true)) {
546
-                $sform->addElement($obj, true);
547
-            } else {
548
-                $sform->addElement($obj, false);
549
-            }
550
-        }
551
-
552
-        return $sform->render();
553
-    }
554
-
555
-    /**
556
-     * @param      $object
557
-     * @param bool $as_array
558
-     * @return array|string
559
-     */
560
-    public static function  getFormVoice($object, $as_array = false)
561
-    {
562
-        if (!is_object($object)) {
563
-            $handler = Helper::getInstance()
564
-                             ->getHandler('Voice');
565
-            $object  = $handler->create();
566
-        }
567
-
568
-        xoops_loadLanguage('forms', 'songlist');
569
-        $ele = [];
570
-
571
-        if ($object->isNew()) {
572
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_VOICE, 'voice', $_SERVER['SCRIPT_NAME'], 'post', true);
573
-            $ele['mode'] = new \XoopsFormHidden('mode', 'new');
574
-        } else {
575
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_VOICE, 'voice', $_SERVER['SCRIPT_NAME'], 'post', true);
576
-            $ele['mode'] = new \XoopsFormHidden('mode', 'edit');
577
-        }
578
-
579
-        $sform->setExtra("enctype='multipart/form-data'");
580
-
581
-        $id = $object->getVar('vcid');
582
-        if (empty($id)) {
583
-            $id = '0';
584
-        }
585
-
586
-        $ele['op']  = new \XoopsFormHidden('op', 'voice');
587
-        $ele['fct'] = new \XoopsFormHidden('fct', 'save');
588
-        if ($as_array) {
589
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
590
-        } else {
591
-            $ele['id'] = new \XoopsFormHidden('id', $id);
592
-        }
593
-        $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
594
-        $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
595
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
596
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
597
-        $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
598
-
599
-        $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_VOICE_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
600
-        $ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_VOICE_NAME_DESC : ''));
601
-        $ele['albums']  = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_ALBUMS : ''), $object->getVar('albums'));
602
-        $ele['artists'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_ARTISTS : ''), $object->getVar('artists'));
603
-        $ele['songs']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_SONGS : ''), $object->getVar('songs'));
604
-        $ele['hits']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_HITS : ''), $object->getVar('hits'));
605
-        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
606
-        if ($object->getVar('created') > 0) {
607
-            $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
608
-        }
609
-        if ($object->getVar('updated') > 0) {
610
-            $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
611
-        }
612
-
613
-        if ($as_array) {
614
-            return $ele;
615
-        }
616
-
617
-        $ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
618
-
619
-        $required = ['name'];
620
-
621
-        foreach ($ele as $id => $obj) {
622
-            if (in_array($id, $required, true)) {
623
-                $sform->addElement($obj, true);
624
-            } else {
625
-                $sform->addElement($obj, false);
626
-            }
627
-        }
628
-
629
-        return $sform->render();
630
-    }
631
-
632
-    /**
633
-     * @param      $object
634
-     * @param bool $as_array
635
-     * @return array|string
636
-     */
637
-    public static function  getFormAlbums($object, $as_array = false)
638
-    {
639
-        if (!is_object($object)) {
640
-            $handler = Helper::getInstance()
641
-                             ->getHandler('Albums');
642
-            $object  = $handler->create();
643
-        }
644
-
645
-        xoops_loadLanguage('forms', 'songlist');
646
-        $ele = [];
647
-
648
-        if ($object->isNew()) {
649
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_ALBUMS, 'albums', $_SERVER['SCRIPT_NAME'], 'post', true);
650
-            $ele['mode'] = new \XoopsFormHidden('mode', 'new');
651
-        } else {
652
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_ALBUMS, 'albums', $_SERVER['SCRIPT_NAME'], 'post', true);
653
-            $ele['mode'] = new \XoopsFormHidden('mode', 'edit');
654
-        }
655
-
656
-        $sform->setExtra("enctype='multipart/form-data'");
657
-
658
-        $id = $object->getVar('abid');
659
-        if (empty($id)) {
660
-            $id = '0';
661
-        }
662
-
663
-        $ele['op']  = new \XoopsFormHidden('op', 'albums');
664
-        $ele['fct'] = new \XoopsFormHidden('fct', 'save');
665
-        if ($as_array) {
666
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
667
-        } else {
668
-            $ele['id'] = new \XoopsFormHidden('id', $id);
669
-        }
670
-        $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
671
-        $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
672
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
673
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
674
-        $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
675
-
676
-        $ele['cid'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_CATEGORY : ''), $id . '[cid]', $object->getVar('cid'), 1, false, false, false);
677
-        $ele['cid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_CATEGORY_DESC : ''));
678
-        $ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_TITLE : ''), $id . '[title]', (!$as_array ? 55 : 21), 128, $object->getVar('title'));
679
-        $ele['title']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_TITLE_DESC : ''));
680
-        $ele['image'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_UPLOAD_POSTER : ''), 'image', $GLOBALS['songlistModuleConfig']['filesize_upload']);
681
-        $ele['image']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_UPLOAD_POSTER_DESC : ''));
682
-        if ('' != $object->getVar('image') && file_exists($GLOBALS['xoops']->path($object->getVar('path') . $object->getVar('image')))) {
683
-            $ele['image_preview'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_POSTER : ''), '<img src="' . $object->getImage('image') . '" width="340px">');
684
-            $ele['image_preview']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_POSTER_DESC : ''));
685
-        }
686
-        $ele['artists'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_ARTISTS : ''), $object->getVar('artists'));
687
-        $ele['songs']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_SONGS : ''), $object->getVar('songs'));
688
-        $ele['hits']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_HITS : ''), $object->getVar('hits'));
689
-        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
690
-        if ($object->getVar('created') > 0) {
691
-            $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
692
-        }
693
-        if ($object->getVar('updated') > 0) {
694
-            $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
695
-        }
696
-
697
-        if ($as_array) {
698
-            return $ele;
699
-        }
700
-
701
-        $ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
702
-
703
-        $required = ['name', 'id', 'source'];
704
-
705
-        foreach ($ele as $id => $obj) {
706
-            if (in_array($id, $required, true)) {
707
-                $sform->addElement($obj, true);
708
-            } else {
709
-                $sform->addElement($obj, false);
710
-            }
711
-        }
712
-
713
-        return $sform->render();
714
-    }
715
-
716
-    /**
717
-     * @param Songlist\Artists $object
718
-     * @param bool             $as_array
719
-     * @return array|string
720
-     */
721
-    public static function  getFormArtists($object, $as_array = false)
722
-    {
723
-        if (!is_object($object)) {
724
-            $handler = Helper::getInstance()
725
-                             ->getHandler('Artists');
726
-            $object  = $handler->create();
727
-        }
728
-
729
-        xoops_loadLanguage('forms', 'songlist');
730
-        $ele = [];
731
-
732
-        if ($object->isNew()) {
733
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_ARTISTS, 'artists', $_SERVER['SCRIPT_NAME'], 'post', true);
734
-            $ele['mode'] = new \XoopsFormHidden('mode', 'new');
735
-        } else {
736
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_ARTISTS, 'artists', $_SERVER['SCRIPT_NAME'], 'post', true);
737
-            $ele['mode'] = new \XoopsFormHidden('mode', 'edit');
738
-        }
739
-
740
-        $id = $object->getVar('aid');
741
-        if (empty($id)) {
742
-            $id = '0';
743
-        }
744
-
745
-        $ele['op']  = new \XoopsFormHidden('op', 'artists');
746
-        $ele['fct'] = new \XoopsFormHidden('fct', 'save');
747
-        if ($as_array) {
748
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
749
-        } else {
750
-            $ele['id'] = new \XoopsFormHidden('id', $id);
751
-        }
752
-        $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
753
-        $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
754
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
755
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
756
-        $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
757
-
758
-        $ele['cids'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_CATEGORY : ''), $id . '[cids]', $object->getVar('cids'), 7, true, false, false);
759
-        $ele['cids']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_CATEGORY_DESC : ''));
760
-        //$ele['singer'] = new \XoopsModules\Songlist\Form\SelectSingerForm(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_SINGER:''), $id.'[singer]', $object->getVar('singer'), 1, false, false, false);
761
-        //$ele['singer']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_SINGER_DESC:''));
762
-        $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
763
-        $ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_NAME_DESC : ''));
764
-        $ele['albums'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_ALBUMS : ''), $object->getVar('albums'));
765
-        $ele['songs']  = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_SONGS : ''), $object->getVar('songs'));
766
-        $ele['hits']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_HITS : ''), $object->getVar('hits'));
767
-        $ele['rank']   = new \XoopsFormLabel((!$as_array ? _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');
768
-        if ($object->getVar('created') > 0) {
769
-            $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
770
-        }
771
-        if ($object->getVar('updated') > 0) {
772
-            $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
773
-        }
774
-
775
-        if ($as_array) {
776
-            return $ele;
777
-        }
778
-
779
-        $ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
780
-
781
-        $required = ['name', 'mimetype', 'support'];
782
-
783
-        foreach ($ele as $id => $obj) {
784
-            if (in_array($id, $required, true)) {
785
-                $sform->addElement($obj, true);
786
-            } else {
787
-                $sform->addElement($obj, false);
788
-            }
789
-        }
790
-
791
-        return $sform->render();
792
-    }
793
-
794
-    /**
795
-     * @param      $object
796
-     * @param bool $as_array
797
-     * @return array|string
798
-     */
799
-    public static function  getFormCategory($object, $as_array = false)
800
-    {
801
-        if (!is_object($object)) {
802
-            $handler = Helper::getInstance()
803
-                             ->getHandler('Category');
804
-            $object  = $handler->create();
805
-        }
806
-
807
-        xoops_loadLanguage('forms', 'songlist');
808
-        $ele = [];
809
-
810
-        if ($object->isNew()) {
811
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_CATEGORY, 'category', $_SERVER['SCRIPT_NAME'], 'post', true);
812
-            $ele['mode'] = new \XoopsFormHidden('mode', 'new');
813
-        } else {
814
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_CATEGORY, 'category', $_SERVER['SCRIPT_NAME'], 'post', true);
815
-            $ele['mode'] = new \XoopsFormHidden('mode', 'edit');
816
-        }
817
-
818
-        $sform->setExtra("enctype='multipart/form-data'");
819
-
820
-        $id = $object->getVar('cid');
821
-        if (empty($id)) {
822
-            $id = '0';
823
-        }
824
-
825
-        $ele['op']  = new \XoopsFormHidden('op', 'category');
826
-        $ele['fct'] = new \XoopsFormHidden('fct', 'save');
827
-        if ($as_array) {
828
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
829
-        } else {
830
-            $ele['id'] = new \XoopsFormHidden('id', $id);
831
-        }
832
-        $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
833
-        $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
834
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
835
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
836
-        $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
837
-
838
-        $ele['pid'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_PARENT : ''), $id . '[pid]', $object->getVar('pid'), 1, false, $object->getVar('cid'));
839
-        $ele['pid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_PARENT_DESC : ''));
840
-        $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
841
-        $ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_NAME_DESC : ''));
842
-        $description_configs           = [];
843
-        $description_configs['name']   = $id . '[description]';
844
-        $description_configs['value']  = $object->getVar('description');
845
-        $description_configs['rows']   = 35;
846
-        $description_configs['cols']   = 60;
847
-        $description_configs['width']  = '100%';
848
-        $description_configs['height'] = '400px';
849
-        $ele['description']            = new \XoopsFormEditor(_FRM_SONGLIST_FORM_CATEGORY_DESCRIPTION, $GLOBALS['songlistModuleConfig']['editor'], $description_configs);
850
-        $ele['description']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_DESCRIPTION_DESC : ''));
851
-        $ele['image'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_UPLOAD_POSTER : ''), 'image', $GLOBALS['songlistModuleConfig']['filesize_upload']);
852
-        $ele['image']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_UPLOAD_POSTER_DESC : ''));
853
-        if ('' != $object->getVar('image') && file_exists($GLOBALS['xoops']->path($object->getVar('path') . $object->getVar('image')))) {
854
-            $ele['image_preview'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_POSTER : ''), '<img src="' . $object->getImage('image') . '" width="340px">');
855
-            $ele['image_preview']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_POSTER_DESC : ''));
856
-        }
857
-        $ele['artists'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_ARTISTS : ''), $object->getVar('artists'));
858
-        $ele['songs']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_SONGS : ''), $object->getVar('songs'));
859
-        $ele['hits']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_HITS : ''), $object->getVar('hits'));
860
-        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
861
-        if ($object->getVar('created') > 0) {
862
-            $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
863
-        }
864
-        if ($object->getVar('updated') > 0) {
865
-            $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
866
-        }
867
-
868
-        if ($as_array) {
869
-            return $ele;
870
-        }
871
-
872
-        $ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
873
-
874
-        $required = ['name', 'id', 'source'];
875
-
876
-        foreach ($ele as $id => $obj) {
877
-            if (in_array($id, $required, true)) {
878
-                $sform->addElement($obj, true);
879
-            } else {
880
-                $sform->addElement($obj, false);
881
-            }
882
-        }
883
-
884
-        return $sform->render();
885
-    }
886
-
887
-    /**
888
-     * @param      $object
889
-     * @param bool $as_array
890
-     * @return array|string
891
-     */
892
-    public static function  getFormUtf8map($object, $as_array = false)
893
-    {
894
-        if (!is_object($object)) {
895
-            $handler = Helper::getInstance()
896
-                             ->getHandler('Utf8map');
897
-            $object  = $handler->create();
898
-        }
899
-
900
-        xoops_loadLanguage('forms', 'songlist');
901
-        $ele = [];
902
-
903
-        if ($object->isNew()) {
904
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_UTF8MAP, 'utf8map', $_SERVER['SCRIPT_NAME'], 'post', true);
905
-            $ele['mode'] = new \XoopsFormHidden('mode', 'new');
906
-        } else {
907
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_UTF8MAP, 'utf8map', $_SERVER['SCRIPT_NAME'], 'post', true);
908
-            $ele['mode'] = new \XoopsFormHidden('mode', 'edit');
909
-        }
910
-
911
-        $sform->setExtra("enctype='multipart/form-data'");
912
-
913
-        $id = $object->getVar('utfid');
914
-        if (empty($id)) {
915
-            $id = '0';
916
-        }
917
-
918
-        $ele['op']  = new \XoopsFormHidden('op', 'utf8map');
919
-        $ele['fct'] = new \XoopsFormHidden('fct', 'save');
920
-        if ($as_array) {
921
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
922
-        } else {
923
-            $ele['id'] = new \XoopsFormHidden('id', $id);
924
-        }
925
-        $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
926
-        $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
927
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
928
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
929
-        $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
930
-
931
-        $ele['from'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_FROM : ''), $id . '[from]', (!$as_array ? 6 : 4), 2, $object->getVar('from'));
932
-        $ele['from']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_FROM_DESC : ''));
933
-        $ele['to'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_TO : ''), $id . '[to]', (!$as_array ? 6 : 4), 2, $object->getVar('to'));
934
-        $ele['to']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_TO_DESC : ''));
935
-
936
-        if ($object->getVar('created') > 0) {
937
-            $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
938
-        }
939
-        if ($object->getVar('updated') > 0) {
940
-            $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
941
-        }
942
-
943
-        if ($as_array) {
944
-            return $ele;
945
-        }
946
-
947
-        $ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
948
-
949
-        $required = ['from', 'to'];
950
-
951
-        foreach ($ele as $id => $obj) {
952
-            if (in_array($id, $required, true)) {
953
-                $sform->addElement($obj, true);
954
-            } else {
955
-                $sform->addElement($obj, false);
956
-            }
957
-        }
958
-
959
-        return $sform->render();
960
-    }
961
-
962
-    /**
963
-     * @param      $object
964
-     * @param bool $as_array
965
-     * @return array|string
966
-     */
967
-    public static function  getFormRequests($object, $as_array = false)
968
-    {
969
-        if (!is_object($object)) {
970
-            $handler = Helper::getInstance()
971
-                             ->getHandler('Requests');
972
-            $object  = $handler->create();
973
-        }
974
-
975
-        xoops_loadLanguage('forms', 'songlist');
976
-        $ele = [];
977
-
978
-        if ($object->isNew()) {
979
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_REQUESTS, 'requests', $_SERVER['SCRIPT_NAME'], 'post', true);
980
-            $ele['mode'] = new \XoopsFormHidden('mode', 'new');
981
-        } else {
982
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_REQUESTS, 'requests', $_SERVER['SCRIPT_NAME'], 'post', true);
983
-            $ele['mode'] = new \XoopsFormHidden('mode', 'edit');
984
-        }
985
-
986
-        $sform->setExtra("enctype='multipart/form-data'");
987
-
988
-        $id = $object->getVar('rid');
989
-        if (empty($id)) {
990
-            $id = '0';
991
-        }
992
-
993
-        $ele['op']  = new \XoopsFormHidden('op', 'requests');
994
-        $ele['fct'] = new \XoopsFormHidden('fct', 'save');
995
-        if ($as_array) {
996
-            $ele['id'] = new \XoopsFormHidden('id', $id);
997
-        } else {
998
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
999
-        }
1000
-        $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
1001
-        $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
1002
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
1003
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
1004
-        $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
1005
-
1006
-        $ele['artist'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ARTIST : ''), $id . '[artist]', (!$as_array ? 55 : 21), 128, $object->getVar('artist'));
1007
-        $ele['artist']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ARTIST_DESC : ''));
1008
-        $ele['album'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ALBUM : ''), $id . '[album]', (!$as_array ? 55 : 21), 128, $object->getVar('album'));
1009
-        $ele['album']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ALBUM_DESC : ''));
1010
-        $ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_TITLE : ''), $id . '[title]', (!$as_array ? 55 : 21), 128, $object->getVar('title'));
1011
-        $ele['title']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_TITLE_DESC : ''));
1012
-        $ele['lyrics'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_LYRICS : ''), $id . '[lyrics]', (!$as_array ? 55 : 21), 128, $object->getVar('lyrics'));
1013
-        $ele['lyrics']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_LYRICS_DESC : ''));
1014
-
1015
-        if (is_object($GLOBALS['xoopsUser'])) {
1016
-            $ele['uid']  = new \XoopsFormHidden('uid', $GLOBALS['xoopsUser']->getVar('uid'));
1017
-            $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? $GLOBALS['xoopsUser']->getVar('name') : $object->getVar('name')));
1018
-            $ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME_DESC : ''));
1019
-            $ele['email'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL : ''), $id . '[email]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? $GLOBALS['xoopsUser']->getVar('email') : $object->getVar('email')));
1020
-            $ele['email']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL_DESC : ''));
1021
-        } else {
1022
-            $ele['uid']  = new \XoopsFormHidden('uid', 0);
1023
-            $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? '' : $object->getVar('name')));
1024
-            $ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME_DESC : ''));
1025
-            $ele['email'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL : ''), $id . '[email]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? '' : $object->getVar('email')));
1026
-            $ele['email']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL_DESC : ''));
1027
-        }
1028
-        if ($object->getVar('created') > 0) {
1029
-            $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
1030
-        }
1031
-        if ($object->getVar('updated') > 0) {
1032
-            $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
1033
-        }
1034
-
1035
-        if ($as_array) {
1036
-            return $ele;
1037
-        }
1038
-
1039
-        $ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
1040
-
1041
-        $required = ['name', 'email'];
1042
-
1043
-        foreach ($ele as $id => $obj) {
1044
-            if (in_array($id, $required, true)) {
1045
-                $sform->addElement($obj, true);
1046
-            } else {
1047
-                $sform->addElement($obj, false);
1048
-            }
1049
-        }
1050
-
1051
-        return $sform->render();
1052
-    }
1053
-
1054
-    /**
1055
-     * @param      $object
1056
-     * @param bool $as_array
1057
-     * @return array|string
1058
-     */
1059
-    public static function  getFormSongs($object, $as_array = false)
1060
-    {
1061
-        if (!is_object($object)) {
1062
-            $handler = Helper::getInstance()
1063
-                             ->getHandler('Songs');
1064
-            $object  = $handler->create();
1065
-        }
1066
-
1067
-        xoops_loadLanguage('forms', 'songlist');
1068
-        $ele = [];
1069
-
1070
-        if ($object->isNew()) {
1071
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_SONGS, 'songs', $_SERVER['SCRIPT_NAME'], 'post', true);
1072
-            $ele['mode'] = new \XoopsFormHidden('mode', 'new');
1073
-        } else {
1074
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_SONGS, 'songs', $_SERVER['SCRIPT_NAME'], 'post', true);
1075
-            $ele['mode'] = new \XoopsFormHidden('mode', 'edit');
1076
-        }
1077
-
1078
-        $sform->setExtra("enctype='multipart/form-data'");
1079
-
1080
-        $id = $object->getVar('sid');
1081
-        if (empty($id)) {
1082
-            $id = '0';
1083
-        }
1084
-
1085
-        $ele['op']  = new \XoopsFormHidden('op', 'songs');
1086
-        $ele['fct'] = new \XoopsFormHidden('fct', 'save');
1087
-        if ($as_array) {
1088
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
1089
-        } else {
1090
-            $ele['id'] = new \XoopsFormHidden('id', $id);
1091
-        }
1092
-        $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
1093
-        $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
1094
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
1095
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
1096
-        $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
1097
-
1098
-        $ele['cid'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_CATEGORY : ''), $id . '[cid]', ($_REQUEST['cid'] ?? $object->getVar('cid')), 1, false);
1099
-        $ele['cid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_CATEGORY_DESC : ''));
1100
-        if ($GLOBALS['songlistModuleConfig']['genre']) {
1101
-            $ele['gids'] = new SelectGenreForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_GENRE : ''), $id . '[gids]', ($_REQUEST['gids'] ?? $object->getVar('gids')), 8, true);
1102
-            $ele['gids']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_GENRE_DESC : ''));
1103
-        }
1104
-        if ($GLOBALS['songlistModuleConfig']['voice']) {
1105
-            $ele['vcid'] = new SelectVoiceForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_VOICE : ''), $id . '[vcid]', ($_REQUEST['vcid'] ?? $object->getVar('vcid')), 1, false);
1106
-            $ele['vcid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_VOICE_DESC : ''));
1107
-        }
1108
-        if ($GLOBALS['songlistModuleConfig']['album']) {
1109
-            $ele['abid'] = new SelectAlbumForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ALBUM : ''), $id . '[abid]', $object->getVar('abid'), 1, false);
1110
-            $ele['abid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ALBUM_DESC : ''));
1111
-        }
1112
-        $ele['aids'] = new SelectArtistForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ARTISTS : ''), $id . '[aids]', $object->getVar('aids'), 7, true);
1113
-        $ele['aids']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ARTISTS_DESC : ''));
1114
-        $ele['songid'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_SONGS_SONGID : ''), $id . '[songid]', (!$as_array ? 25 : 15), 32, $object->getVar('songid'));
1115
-        $ele['songid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_SONGID_DESC : ''));
1116
-        $ele['traxid'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TRAXID : ''), $id . '[traxid]', (!$as_array ? 25 : 15), 32, $object->getVar('traxid'));
1117
-        $ele['traxid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TRAXID_DESC : ''));
1118
-        $ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TITLE : ''), $id . '[title]', (!$as_array ? 55 : 21), 128, $object->getVar('title'));
1119
-        $ele['title']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TITLE_DESC : ''));
1120
-        $description_configs           = [];
1121
-        $description_configs['name']   = $id . '[lyrics]';
1122
-        $description_configs['value']  = $object->getVar('lyrics');
1123
-        $description_configs['rows']   = 35;
1124
-        $description_configs['cols']   = 60;
1125
-        $description_configs['width']  = '100%';
1126
-        $description_configs['height'] = '400px';
1127
-        $ele['lyrics']                 = new \XoopsFormEditor(_FRM_SONGLIST_FORM_SONGS_LYRICS, $GLOBALS['songlistModuleConfig']['editor'], $description_configs);
1128
-        $ele['lyrics']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_LYRICS_DESC : ''));
1129
-        $ele['mp3'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_SONGS_MP3 : ''), 'mp3' . $id, $GLOBALS['songlistModuleConfig']['mp3_filesize']);
1130
-        $ele['mp3']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_MP3_DESC : ''));
1131
-        $categoryHandler = Helper::getInstance()
1132
-                                 ->getHandler('Category');
1133
-        $criteria        = new \CriteriaCompo(new \Criteria('cid', !empty($_REQUEST['cid']) ? Request::getInt('cid', 0, 'REQUEST') : $object->getVar('cid')));
1134
-        $all_categories  = $categoryHandler->getObjects($criteria, true, false);
1135
-
1136
-        // Dynamic fields
1137
-        $extrasHandler = Helper::getInstance()
1138
-                               ->getHandler('Extras');
1139
-        /** @var \XoopsGroupPermHandler $grouppermHandler */
1140
-        $grouppermHandler = xoops_getHandler('groupperm');
1141
-        /** @var \XoopsModuleHandler $moduleHandler */
1142
-        $moduleHandler = xoops_getHandler('module');
1143
-        $xoModule      = $moduleHandler->getByDirname('songlist');
1144
-        $modid         = $xoModule->getVar('mid');
1145
-
1146
-        if (is_object($GLOBALS['xoopsUser'])) {
1147
-            $groups = $GLOBALS['xoopsUser']->getGroups();
1148
-        } else {
1149
-            $groups = [XOOPS_GROUP_ANONYMOUS => XOOPS_GROUP_ANONYMOUS];
1150
-        }
1151
-
1152
-        $count_fields = 0;
1153
-        $fields       = $extrasHandler->loadFields();
1154
-
1155
-        $required = [];
1156
-        $elements = [];
1157
-        $weights  = [];
1158
-        if ($object->getVar('sid') > 0) {
1159
-            $extra = $extrasHandler->get($object->getVar('sid'));
1160
-        } else {
1161
-            $extra = $extrasHandler->create();
1162
-        }
1163
-        $allnames = [];
1164
-        if (is_array($fields)) {
1165
-            foreach (array_keys($fields) as $i) {
1166
-                if ((0 != $object->getVar('sid') && $grouppermHandler->checkRight('songlist_edit', $fields[$i]->getVar('field_id'), $groups, $modid))
1167
-                    || (0 == $object->getVar('sid') && $grouppermHandler->checkRight('songlist_post', $fields[$i]->getVar('field_id'), $groups, $modid))) {
1168
-                    $fieldinfo['element']  = $fields[$i]->getEditElement($object, $extra);
1169
-                    $fieldinfo['required'] = $fields[$i]->getVar('field_required');
1170
-                    foreach ($fields[$i]->getVar('cids') as $catidid => $cid) {
1171
-                        if (!in_array($fields[$i]->getVar('field_name'), $allnames, true)) {
1172
-                            $allnames[] = $fields[$i]->getVar('field_name');
1173
-                            if (array_key_exists($cid, $all_categories)
1174
-                                || $cid == (!empty($_REQUEST['cid'])
1175
-                                    ? Request::getInt('cid', 0, 'REQUEST')
1176
-                                    : $object->getVar('cid'))) {
1177
-                                $key              = (isset($all_categories[$cid]) ? $all_categories[$cid]['weight'] : 0)
1178
-                                                    * $count_fields + $object->getVar('cid');
1179
-                                $elements[$key][] = $fieldinfo;
1180
-                                $weights[$key][]  = $fields[$i]->getVar('field_weight');
1181
-                            } elseif (in_array(0, $fields[$i]->getVar('cids'), true)) {
1182
-                                $key              = (isset($all_categories[$cid]) ? $all_categories[$cid]['weight'] : 0) * $count_fields + $object->getVar('cid');
1183
-                                $elements[$key][] = $fieldinfo;
1184
-                                $weights[$key][]  = $fields[$i]->getVar('field_weight');
1185
-                            }
1186
-                        }
1187
-                    }
1188
-                }
1189
-            }
1190
-        }
1191
-        if (is_array($elements)) {
1192
-            ksort($elements);
1193
-            foreach (array_keys($elements) as $k) {
1194
-                array_multisort($weights[$k], SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]);
1195
-                foreach (array_keys($elements[$k]) as $i) {
1196
-                    $ele[$k] = $elements[$k][$i]['element'];
1197
-                    if (true === $elements[$k][$i]['required']) {
1198
-                        $required[$k] = $elements[$k][$i]['element']->getName();
1199
-                    }
1200
-                }
1201
-            }
1202
-        }
1203
-
1204
-        if (class_exists(\XoopsModules\Tag\FormTag::class)) {
1205
-            $ele['tags'] = new \XoopsModules\Tag\FormTag('tags', 60, 255, $object->getVar('sid'), $object->getVar('cid'));
1206
-        } else {
1207
-            $ele['tags'] = new \XoopsFormHidden('tags', $object->getVar('tags'));
1208
-        }
1209
-
1210
-        $ele['hits'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_SONGS_HITS : ''), $object->getVar('hits'));
1211
-        $ele['rank'] = new \XoopsFormLabel((!$as_array ? _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');
1212
-        if ($object->getVar('created') > 0) {
1213
-            $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_SONGS_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
1214
-        }
1215
-        if ($object->getVar('updated') > 0) {
1216
-            $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_SONGS_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
1217
-        }
1218
-        if ($as_array) {
1219
-            return $ele;
1220
-        }
1221
-
1222
-        $ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
1223
-
1224
-        foreach ($ele as $id => $obj) {
1225
-            if (in_array($id, $required, true)) {
1226
-                $sform->addElement($obj, true);
1227
-            } else {
1228
-                $sform->addElement($obj, false);
1229
-            }
1230
-        }
1231
-
1232
-        return $sform->render();
1233
-    }
1234
-
1235
-    /**
1236
-     * @param      $object
1237
-     * @param bool $as_array
1238
-     * @return array|string
1239
-     */
1240
-    public static function  getFormVotes($object, $as_array = false)
1241
-    {
1242
-        if (!is_object($object)) {
1243
-            $handler = Helper::getInstance()
1244
-                             ->getHandler('Votes');
1245
-            $object  = $handler->create();
1246
-        }
1247
-
1248
-        xoops_loadLanguage('forms', 'songlist');
1249
-        $ele = [];
1250
-
1251
-        if ($object->isNew()) {
1252
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_CART, 'votes', $_SERVER['SCRIPT_NAME'], 'post', true);
1253
-            $ele['mode'] = new \XoopsFormHidden('mode', 'new');
1254
-        } else {
1255
-            $sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_CART, 'votes', $_SERVER['SCRIPT_NAME'], 'post', true);
1256
-            $ele['mode'] = new \XoopsFormHidden('mode', 'edit');
1257
-        }
1258
-
1259
-        $sform->setExtra("enctype='multipart/form-data'");
1260
-
1261
-        $id = $object->getVar('cid');
1262
-        if (empty($id)) {
1263
-            $id = '0';
1264
-        }
1265
-
1266
-        $ele['op']  = new \XoopsFormHidden('op', 'votes');
1267
-        $ele['fct'] = new \XoopsFormHidden('fct', 'save');
1268
-        if ($as_array) {
1269
-            $ele['id'] = new \XoopsFormHidden('id', $id);
1270
-        } else {
1271
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
1272
-        }
1273
-        $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
1274
-        $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
1275
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
1276
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
1277
-        $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
1278
-
1279
-        $songsHandler = Helper::getInstance()
1280
-                              ->getHandler('Songs');
1281
-        $userHandler  = xoops_getHandler('user');
1282
-        $song         = $songsHandler->get($object->getVar('sid'));
1283
-        $user         = $userHandler->get($object->getVar('uid'));
1284
-        if (is_object($song)) {
1285
-            $ele['sid'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_SONG : ''), $song->getVar('title'));
1286
-        } else {
1287
-            $ele['sid'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_SONG : ''), $object->getVar('sid'));
1288
-        }
1289
-        if (is_object($user)) {
1290
-            $ele['uid'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_USER : ''), $user->getVar('uname'));
1291
-        } else {
1292
-            $ele['uid'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_USER : ''), _GUESTS);
1293
-        }
1294
-        $ele['ip']      = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_IP : ''), $object->getVar('ip'));
1295
-        $ele['netaddy'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_NETADDY : ''), $object->getVar('netaddy'));
1296
-        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_RANK : ''), $object->getVar('rank') . ' of 10');
1297
-
1298
-        if ($as_array) {
1299
-            return $ele;
1300
-        }
1301
-
1302
-        $ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
1303
-
1304
-        $required = [];
1305
-
1306
-        foreach ($ele as $id => $obj) {
1307
-            if (in_array($id, $required, true)) {
1308
-                $sform->addElement($obj, true);
1309
-            } else {
1310
-                $sform->addElement($obj, false);
1311
-            }
1312
-        }
1313
-
1314
-        return $sform->render();
1315
-    }
246
+		}
247
+		$form->addElement(new \XoopsFormHidden('op', 'save'));
248
+		$form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
249
+
250
+		return $form;
251
+	}
252
+
253
+	/**
254
+	 * Get {@link XoopsThemeForm} for editing a user
255
+	 *
256
+	 * @param bool $action
257
+	 * @return object
258
+	 * @internal param object $user <a href='psi_element://XoopsUser'>XoopsUser</a> to edit to edit
259
+	 */
260
+	public static function getUserSearchForm($action = false)
261
+	{
262
+		xoops_loadLanguage('forms', 'songlist');
263
+
264
+		if (!$action) {
265
+			$action = $_SERVER['SCRIPT_NAME'];
266
+		}
267
+		if (empty($GLOBALS['xoopsConfigUser'])) {
268
+			/** @var \XoopsConfigHandler $configHandler */
269
+			$configHandler              = xoops_getHandler('config');
270
+			$GLOBALS['xoopsConfigUser'] = $configHandler->getConfigsByCat(XOOPS_CONF_USER);
271
+		}
272
+
273
+		$helper = Helper::getInstance();
274
+
275
+		$title = _FRM_SONGLIST_FIELDS_SEARCH;
276
+
277
+		$form = new \XoopsThemeForm($title, 'search', $action, 'post', true);
278
+
279
+		$songlistHandler = Helper::getInstance()
280
+								 ->getHandler('Profile', 'objects');
281
+		// Get fields
282
+		$fields = $songlistHandler->loadFields();
283
+
284
+		/** @var \XoopsGroupPermHandler $grouppermHandler */
285
+		$grouppermHandler = xoops_getHandler('groupperm');
286
+		/** @var \XoopsConfigHandler $configHandler */
287
+		$configHandler = xoops_getHandler('config');
288
+		$groups        = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS];
289
+		/** @var \XoopsModuleHandler $moduleHandler */
290
+		$moduleHandler = xoops_getHandler('module');
291
+		$xoModule      = $moduleHandler->getByDirname('objects');
292
+		$modid         = $xoModule->getVar('mid');
293
+
294
+		// Get ids of fields that can be edited
295
+		/** @var \XoopsGroupPermHandler $grouppermHandler */
296
+		$grouppermHandler = xoops_getHandler('groupperm');
297
+
298
+		$editable_fields = $grouppermHandler->getItemIds('songlist_search', $groups, $modid);
299
+
300
+		$catHandler = Helper::getInstance()
301
+							->getHandler('Category');
302
+
303
+		$selcat = new \XoopsFormSelect('Form', 'cid', !empty($_REQUEST['cid']) ? Request::getInt('cid', 0, 'REQUEST') : 0, 1, false, false, false, true);
304
+		$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"');
305
+
306
+		$form->addElement($selcat, true);
307
+
308
+		$categories = [];
309
+
310
+		$criteria       = new \CriteriaCompo(new \Criteria('cid', !empty($_REQUEST['cid']) ? Request::getInt('cid', 0, 'REQUEST') : '0'), 'OR');
311
+		$all_categories = $catHandler->getObjects($criteria, true, false);
312
+		$count_fields   = count($fields);
313
+
314
+		foreach (array_keys($fields) as $i) {
315
+			if (in_array($fields[$i]->getVar('field_id'), $editable_fields, true)) {
316
+				// Set default value for user fields if available
317
+				$fieldinfo['element']  = $fields[$i]->getSearchElement();
318
+				$fieldinfo['required'] = false;
319
+
320
+				foreach ($fields[$i]->getVar('cids') as $catidid => $cid) {
321
+					if (array_key_exists($cid, $all_categories)) {
322
+						$key              = $all_categories[$cid]['cat_weight'] * $count_fields + $cid;
323
+						$elements[$key][] = $fieldinfo;
324
+						$weights[$key][]  = $fields[$i]->getVar('field_weight');
325
+						$categories[$key] = $all_categories[$cid];
326
+					} elseif (in_array(0, $fields[$i]->getVar('cids'), true)) {
327
+						$key              = $all_categories[$cid]['cat_weight'] * $count_fields + $cid;
328
+						$elements[$key][] = $fieldinfo;
329
+						$weights[$key][]  = $fields[$i]->getVar('field_weight');
330
+						$categories[$key] = $all_categories[$cid];
331
+					}
332
+				}
333
+			}
334
+		}
335
+
336
+		ksort($elements);
337
+		foreach (array_keys($elements) as $k) {
338
+			array_multisort($weights[$k], SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]);
339
+			$title = isset($categories[$k]) ? $categories[$k]['cat_title'] : _FRM_SONGLIST_FORM_DEFAULT;
340
+			$desc  = isset($categories[$k]) ? $categories[$k]['cat_description'] : '';
341
+			$form->addElement(new \XoopsFormLabel("<h3>{$title}</h3>", $desc), false);
342
+			foreach (array_keys($elements[$k]) as $i) {
343
+				$form->addElement($elements[$k][$i]['element'], $elements[$k][$i]['required']);
344
+			}
345
+		}
346
+
347
+		$form->addElement(new \XoopsFormHidden('fct', 'objects'));
348
+		$form->addElement(new \XoopsFormHidden('op', 'search'));
349
+		$form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
350
+
351
+		return $form;
352
+	}
353
+
354
+	/**
355
+	 * @param bool $as_array
356
+	 * @return string
357
+	 */
358
+	public static function  getFormImport($as_array = false): string
359
+	{
360
+		xoops_loadLanguage('forms', 'songlist');
361
+
362
+		$sform = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_IMPORT, 'import', $_SERVER['SCRIPT_NAME'], 'post', true);
363
+		$sform->setExtra("enctype='multipart/form-data'");
364
+
365
+		$ele['op']      = new \XoopsFormHidden('op', 'import');
366
+		$ele['fct']     = new \XoopsFormHidden('fct', 'upload');
367
+		$ele['xmlfile'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_UPLOAD_XML : ''), 'xmlfile', 1024 * 1024 * 1024 * 32);
368
+		$ele['xmlfile']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_UPLOAD_XML_DESC : ''));
369
+		$ele['file'] = new \XoopsFormSelect((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_EXISTING_XML : ''), 'file');
370
+		$ele['file']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_EXISTING_XML_DESC : ''));
371
+		$ele['file']->addOption('', '*********');
372
+		xoops_load('XoopsLists');
373
+		foreach (\XoopsLists::getFileListAsArray($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $file) {
374
+			if ('xml' === mb_substr($file, mb_strlen($file) - 3, 3)) {
375
+				$ele['file']->addOption($file, $file);
376
+			}
377
+		}
378
+		$ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
379
+
380
+		$required = [];
381
+
382
+		foreach ($ele as $id => $obj) {
383
+			if (in_array($id, $required, true)) {
384
+				$sform->addElement($obj, true);
385
+			} else {
386
+				$sform->addElement($obj, false);
387
+			}
388
+		}
389
+
390
+		return $sform->render();
391
+	}
392
+
393
+	/**
394
+	 * @param      $file
395
+	 * @param bool $as_array
396
+	 * @return string
397
+	 */
398
+	public static function  getFormImportb($file, $as_array = false): string
399
+	{
400
+		xoops_loadLanguage('forms', 'songlist');
401
+
402
+		$sform = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_ELEMENTS, 'elements', $_SERVER['SCRIPT_NAME'], 'post', true);
403
+
404
+		$filesize = filesize($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $file));
405
+		$mb       = floor($filesize / 1024 / 1024);
406
+		if ($mb > 32) {
407
+			ini_set('memory_limit', ($mb + 128) . 'M');
408
+		}
409
+		set_time_limit(3600);
410
+
411
+		$i = 0;
412
+		foreach (file($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $_SESSION['xmlfile'])) as $data) {
413
+			++$i;
414
+			if ($i < 20) {
415
+				$line .= htmlspecialchars($data, ENT_QUOTES | ENT_HTML5) . ($i < 19 ? "\n" : '');
416
+			}
417
+		}
418
+
419
+		$ele['op']      = new \XoopsFormHidden('op', 'import');
420
+		$ele['fct']     = new \XoopsFormHidden('fct', 'import');
421
+		$ele['example'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_EXAMPLE : ''), '<pre>' . $line . '</pre>');
422
+		$ele['example']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_EXAMPLE_DESC : ''));
423
+		$ele['collection'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_COLLECTION : ''), 'collection', 32, 128, 'collection');
424
+		$ele['collection']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_COLLECTION_DESC : ''));
425
+		$ele['record'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_RECORD : ''), 'record', 32, 128, 'record');
426
+		$ele['record']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_RECORD_DESC : ''));
427
+		$ele['genre'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_GENRES : ''), 'genre', 32, 128, 'genre');
428
+		$ele['genre']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_GENRES_DESC : ''));
429
+		$ele['voice'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_VOICE : ''), 'voice', 32, 128, 'voice');
430
+		$ele['voice']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_VOICE_DESC : ''));
431
+		$ele['category'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_CATEGORY : ''), 'category', 32, 128, 'category');
432
+		$ele['category']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_CATEGORY_DESC : ''));
433
+		$ele['artist'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_ARTIST : ''), 'artist', 32, 128, 'artist');
434
+		$ele['artist']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_ARTIST_DESC : ''));
435
+		$ele['album'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_ALBUM : ''), 'album', 32, 128, 'album');
436
+		$ele['album']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_ALBUM_DESC : ''));
437
+		$ele['songid'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_SONGID : ''), 'songid', 32, 128, 'songid');
438
+		$ele['songid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_SONGID_DESC : ''));
439
+		$ele['traxid'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_TRAXID : ''), 'traxid', 32, 128, 'trackno');
440
+		$ele['traxid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_TRAXID_DESC : ''));
441
+		$ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_TITLE : ''), 'title', 32, 128, 'title');
442
+		$ele['title']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_TITLE_DESC : ''));
443
+		$ele['lyrics'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_LYRICS : ''), 'lyrics', 32, 128, 'lyric');
444
+		$ele['lyrics']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_LYRICS_DESC : ''));
445
+		$ele['tags'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_TAGS : ''), 'tags', 32, 128, 'tags');
446
+		$ele['tags']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_TAGS_DESC : ''));
447
+		$ele['mp3'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_MP3 : ''), 'mp3', 32, 128, 'mp3');
448
+		$ele['mp3']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_MP3_DESC : ''));
449
+		$extrasHandler = Helper::getInstance()
450
+							   ->getHandler('Extras');
451
+		$fields        = $extrasHandler->getFields(null);
452
+		foreach ($fields as $field) {
453
+			$ele[$field->getVar('field_name')] = new \XoopsFormText((!$as_array ? $field->getVar('field_title') : ''), $field->getVar('field_name'), 32, 128, $field->getVar('field_name'));
454
+			$ele[$field->getVar('field_name')]->setDescription((!$as_array ? $field->getVar('field_description') : ''));
455
+		}
456
+		$ele['limiting'] = new \XoopsFormRadioYN((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_LIMITING : ''), 'limiting');
457
+		$ele['limiting']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_LIMITING_DESC : ''));
458
+		$ele['records'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_RECORDS : ''), 'records', 10, 10, '250');
459
+		$ele['records']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_RECORDS_DESC : ''));
460
+		$ele['wait'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_WAIT : ''), 'wait', 10, 10, '40');
461
+		$ele['wait']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_WAIT_DESC : ''));
462
+
463
+		$ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
464
+
465
+		$required = [];
466
+
467
+		foreach ($ele as $id => $obj) {
468
+			if (in_array($id, $required, true)) {
469
+				$sform->addElement($obj, true);
470
+			} else {
471
+				$sform->addElement($obj, false);
472
+			}
473
+		}
474
+
475
+		return $sform->render();
476
+	}
477
+
478
+	/**
479
+	 * @param      $object
480
+	 * @param bool $as_array
481
+	 * @return array|string
482
+	 */
483
+	public static function  getFormGenre($object, $as_array = false)
484
+	{
485
+		if (!is_object($object)) {
486
+			$handler = Helper::getInstance()
487
+							 ->getHandler('Genre');
488
+			$object  = $handler->create();
489
+		}
490
+
491
+		xoops_loadLanguage('forms', 'songlist');
492
+		$ele = [];
493
+
494
+		if ($object->isNew()) {
495
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_GENRE, 'genre', $_SERVER['SCRIPT_NAME'], 'post', true);
496
+			$ele['mode'] = new \XoopsFormHidden('mode', 'new');
497
+		} else {
498
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_GENRE, 'genre', $_SERVER['SCRIPT_NAME'], 'post', true);
499
+			$ele['mode'] = new \XoopsFormHidden('mode', 'edit');
500
+		}
501
+
502
+		$sform->setExtra("enctype='multipart/form-data'");
503
+
504
+		$id = $object->getVar('gid');
505
+		if (empty($id)) {
506
+			$id = '0';
507
+		}
508
+
509
+		$ele['op']  = new \XoopsFormHidden('op', 'genre');
510
+		$ele['fct'] = new \XoopsFormHidden('fct', 'save');
511
+		if ($as_array) {
512
+			$ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
513
+		} else {
514
+			$ele['id'] = new \XoopsFormHidden('id', $id);
515
+		}
516
+		$ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
517
+		$ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
518
+		$ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
519
+		$ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
520
+		$ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
521
+
522
+		$ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_GENRE_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
523
+		$ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_GENRE_NAME_DESC : ''));
524
+		$ele['albums']  = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_ALBUMS : ''), $object->getVar('albums'));
525
+		$ele['artists'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_ARTISTS : ''), $object->getVar('artists'));
526
+		$ele['songs']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_SONGS : ''), $object->getVar('songs'));
527
+		$ele['hits']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_HITS : ''), $object->getVar('hits'));
528
+		$ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
529
+		if ($object->getVar('created') > 0) {
530
+			$ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
531
+		}
532
+		if ($object->getVar('updated') > 0) {
533
+			$ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
534
+		}
535
+
536
+		if ($as_array) {
537
+			return $ele;
538
+		}
539
+
540
+		$ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
541
+
542
+		$required = ['name'];
543
+
544
+		foreach ($ele as $id => $obj) {
545
+			if (in_array($id, $required, true)) {
546
+				$sform->addElement($obj, true);
547
+			} else {
548
+				$sform->addElement($obj, false);
549
+			}
550
+		}
551
+
552
+		return $sform->render();
553
+	}
554
+
555
+	/**
556
+	 * @param      $object
557
+	 * @param bool $as_array
558
+	 * @return array|string
559
+	 */
560
+	public static function  getFormVoice($object, $as_array = false)
561
+	{
562
+		if (!is_object($object)) {
563
+			$handler = Helper::getInstance()
564
+							 ->getHandler('Voice');
565
+			$object  = $handler->create();
566
+		}
567
+
568
+		xoops_loadLanguage('forms', 'songlist');
569
+		$ele = [];
570
+
571
+		if ($object->isNew()) {
572
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_VOICE, 'voice', $_SERVER['SCRIPT_NAME'], 'post', true);
573
+			$ele['mode'] = new \XoopsFormHidden('mode', 'new');
574
+		} else {
575
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_VOICE, 'voice', $_SERVER['SCRIPT_NAME'], 'post', true);
576
+			$ele['mode'] = new \XoopsFormHidden('mode', 'edit');
577
+		}
578
+
579
+		$sform->setExtra("enctype='multipart/form-data'");
580
+
581
+		$id = $object->getVar('vcid');
582
+		if (empty($id)) {
583
+			$id = '0';
584
+		}
585
+
586
+		$ele['op']  = new \XoopsFormHidden('op', 'voice');
587
+		$ele['fct'] = new \XoopsFormHidden('fct', 'save');
588
+		if ($as_array) {
589
+			$ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
590
+		} else {
591
+			$ele['id'] = new \XoopsFormHidden('id', $id);
592
+		}
593
+		$ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
594
+		$ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
595
+		$ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
596
+		$ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
597
+		$ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
598
+
599
+		$ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_VOICE_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
600
+		$ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_VOICE_NAME_DESC : ''));
601
+		$ele['albums']  = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_ALBUMS : ''), $object->getVar('albums'));
602
+		$ele['artists'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_ARTISTS : ''), $object->getVar('artists'));
603
+		$ele['songs']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_SONGS : ''), $object->getVar('songs'));
604
+		$ele['hits']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_HITS : ''), $object->getVar('hits'));
605
+		$ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
606
+		if ($object->getVar('created') > 0) {
607
+			$ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
608
+		}
609
+		if ($object->getVar('updated') > 0) {
610
+			$ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
611
+		}
612
+
613
+		if ($as_array) {
614
+			return $ele;
615
+		}
616
+
617
+		$ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
618
+
619
+		$required = ['name'];
620
+
621
+		foreach ($ele as $id => $obj) {
622
+			if (in_array($id, $required, true)) {
623
+				$sform->addElement($obj, true);
624
+			} else {
625
+				$sform->addElement($obj, false);
626
+			}
627
+		}
628
+
629
+		return $sform->render();
630
+	}
631
+
632
+	/**
633
+	 * @param      $object
634
+	 * @param bool $as_array
635
+	 * @return array|string
636
+	 */
637
+	public static function  getFormAlbums($object, $as_array = false)
638
+	{
639
+		if (!is_object($object)) {
640
+			$handler = Helper::getInstance()
641
+							 ->getHandler('Albums');
642
+			$object  = $handler->create();
643
+		}
644
+
645
+		xoops_loadLanguage('forms', 'songlist');
646
+		$ele = [];
647
+
648
+		if ($object->isNew()) {
649
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_ALBUMS, 'albums', $_SERVER['SCRIPT_NAME'], 'post', true);
650
+			$ele['mode'] = new \XoopsFormHidden('mode', 'new');
651
+		} else {
652
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_ALBUMS, 'albums', $_SERVER['SCRIPT_NAME'], 'post', true);
653
+			$ele['mode'] = new \XoopsFormHidden('mode', 'edit');
654
+		}
655
+
656
+		$sform->setExtra("enctype='multipart/form-data'");
657
+
658
+		$id = $object->getVar('abid');
659
+		if (empty($id)) {
660
+			$id = '0';
661
+		}
662
+
663
+		$ele['op']  = new \XoopsFormHidden('op', 'albums');
664
+		$ele['fct'] = new \XoopsFormHidden('fct', 'save');
665
+		if ($as_array) {
666
+			$ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
667
+		} else {
668
+			$ele['id'] = new \XoopsFormHidden('id', $id);
669
+		}
670
+		$ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
671
+		$ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
672
+		$ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
673
+		$ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
674
+		$ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
675
+
676
+		$ele['cid'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_CATEGORY : ''), $id . '[cid]', $object->getVar('cid'), 1, false, false, false);
677
+		$ele['cid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_CATEGORY_DESC : ''));
678
+		$ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_TITLE : ''), $id . '[title]', (!$as_array ? 55 : 21), 128, $object->getVar('title'));
679
+		$ele['title']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_TITLE_DESC : ''));
680
+		$ele['image'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_UPLOAD_POSTER : ''), 'image', $GLOBALS['songlistModuleConfig']['filesize_upload']);
681
+		$ele['image']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_UPLOAD_POSTER_DESC : ''));
682
+		if ('' != $object->getVar('image') && file_exists($GLOBALS['xoops']->path($object->getVar('path') . $object->getVar('image')))) {
683
+			$ele['image_preview'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_POSTER : ''), '<img src="' . $object->getImage('image') . '" width="340px">');
684
+			$ele['image_preview']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_POSTER_DESC : ''));
685
+		}
686
+		$ele['artists'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_ARTISTS : ''), $object->getVar('artists'));
687
+		$ele['songs']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_SONGS : ''), $object->getVar('songs'));
688
+		$ele['hits']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_HITS : ''), $object->getVar('hits'));
689
+		$ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
690
+		if ($object->getVar('created') > 0) {
691
+			$ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
692
+		}
693
+		if ($object->getVar('updated') > 0) {
694
+			$ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
695
+		}
696
+
697
+		if ($as_array) {
698
+			return $ele;
699
+		}
700
+
701
+		$ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
702
+
703
+		$required = ['name', 'id', 'source'];
704
+
705
+		foreach ($ele as $id => $obj) {
706
+			if (in_array($id, $required, true)) {
707
+				$sform->addElement($obj, true);
708
+			} else {
709
+				$sform->addElement($obj, false);
710
+			}
711
+		}
712
+
713
+		return $sform->render();
714
+	}
715
+
716
+	/**
717
+	 * @param Songlist\Artists $object
718
+	 * @param bool             $as_array
719
+	 * @return array|string
720
+	 */
721
+	public static function  getFormArtists($object, $as_array = false)
722
+	{
723
+		if (!is_object($object)) {
724
+			$handler = Helper::getInstance()
725
+							 ->getHandler('Artists');
726
+			$object  = $handler->create();
727
+		}
728
+
729
+		xoops_loadLanguage('forms', 'songlist');
730
+		$ele = [];
731
+
732
+		if ($object->isNew()) {
733
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_ARTISTS, 'artists', $_SERVER['SCRIPT_NAME'], 'post', true);
734
+			$ele['mode'] = new \XoopsFormHidden('mode', 'new');
735
+		} else {
736
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_ARTISTS, 'artists', $_SERVER['SCRIPT_NAME'], 'post', true);
737
+			$ele['mode'] = new \XoopsFormHidden('mode', 'edit');
738
+		}
739
+
740
+		$id = $object->getVar('aid');
741
+		if (empty($id)) {
742
+			$id = '0';
743
+		}
744
+
745
+		$ele['op']  = new \XoopsFormHidden('op', 'artists');
746
+		$ele['fct'] = new \XoopsFormHidden('fct', 'save');
747
+		if ($as_array) {
748
+			$ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
749
+		} else {
750
+			$ele['id'] = new \XoopsFormHidden('id', $id);
751
+		}
752
+		$ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
753
+		$ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
754
+		$ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
755
+		$ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
756
+		$ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
757
+
758
+		$ele['cids'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_CATEGORY : ''), $id . '[cids]', $object->getVar('cids'), 7, true, false, false);
759
+		$ele['cids']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_CATEGORY_DESC : ''));
760
+		//$ele['singer'] = new \XoopsModules\Songlist\Form\SelectSingerForm(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_SINGER:''), $id.'[singer]', $object->getVar('singer'), 1, false, false, false);
761
+		//$ele['singer']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_SINGER_DESC:''));
762
+		$ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
763
+		$ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_NAME_DESC : ''));
764
+		$ele['albums'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_ALBUMS : ''), $object->getVar('albums'));
765
+		$ele['songs']  = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_SONGS : ''), $object->getVar('songs'));
766
+		$ele['hits']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_HITS : ''), $object->getVar('hits'));
767
+		$ele['rank']   = new \XoopsFormLabel((!$as_array ? _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');
768
+		if ($object->getVar('created') > 0) {
769
+			$ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
770
+		}
771
+		if ($object->getVar('updated') > 0) {
772
+			$ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
773
+		}
774
+
775
+		if ($as_array) {
776
+			return $ele;
777
+		}
778
+
779
+		$ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
780
+
781
+		$required = ['name', 'mimetype', 'support'];
782
+
783
+		foreach ($ele as $id => $obj) {
784
+			if (in_array($id, $required, true)) {
785
+				$sform->addElement($obj, true);
786
+			} else {
787
+				$sform->addElement($obj, false);
788
+			}
789
+		}
790
+
791
+		return $sform->render();
792
+	}
793
+
794
+	/**
795
+	 * @param      $object
796
+	 * @param bool $as_array
797
+	 * @return array|string
798
+	 */
799
+	public static function  getFormCategory($object, $as_array = false)
800
+	{
801
+		if (!is_object($object)) {
802
+			$handler = Helper::getInstance()
803
+							 ->getHandler('Category');
804
+			$object  = $handler->create();
805
+		}
806
+
807
+		xoops_loadLanguage('forms', 'songlist');
808
+		$ele = [];
809
+
810
+		if ($object->isNew()) {
811
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_CATEGORY, 'category', $_SERVER['SCRIPT_NAME'], 'post', true);
812
+			$ele['mode'] = new \XoopsFormHidden('mode', 'new');
813
+		} else {
814
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_CATEGORY, 'category', $_SERVER['SCRIPT_NAME'], 'post', true);
815
+			$ele['mode'] = new \XoopsFormHidden('mode', 'edit');
816
+		}
817
+
818
+		$sform->setExtra("enctype='multipart/form-data'");
819
+
820
+		$id = $object->getVar('cid');
821
+		if (empty($id)) {
822
+			$id = '0';
823
+		}
824
+
825
+		$ele['op']  = new \XoopsFormHidden('op', 'category');
826
+		$ele['fct'] = new \XoopsFormHidden('fct', 'save');
827
+		if ($as_array) {
828
+			$ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
829
+		} else {
830
+			$ele['id'] = new \XoopsFormHidden('id', $id);
831
+		}
832
+		$ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
833
+		$ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
834
+		$ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
835
+		$ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
836
+		$ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
837
+
838
+		$ele['pid'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_PARENT : ''), $id . '[pid]', $object->getVar('pid'), 1, false, $object->getVar('cid'));
839
+		$ele['pid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_PARENT_DESC : ''));
840
+		$ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
841
+		$ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_NAME_DESC : ''));
842
+		$description_configs           = [];
843
+		$description_configs['name']   = $id . '[description]';
844
+		$description_configs['value']  = $object->getVar('description');
845
+		$description_configs['rows']   = 35;
846
+		$description_configs['cols']   = 60;
847
+		$description_configs['width']  = '100%';
848
+		$description_configs['height'] = '400px';
849
+		$ele['description']            = new \XoopsFormEditor(_FRM_SONGLIST_FORM_CATEGORY_DESCRIPTION, $GLOBALS['songlistModuleConfig']['editor'], $description_configs);
850
+		$ele['description']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_DESCRIPTION_DESC : ''));
851
+		$ele['image'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_UPLOAD_POSTER : ''), 'image', $GLOBALS['songlistModuleConfig']['filesize_upload']);
852
+		$ele['image']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_UPLOAD_POSTER_DESC : ''));
853
+		if ('' != $object->getVar('image') && file_exists($GLOBALS['xoops']->path($object->getVar('path') . $object->getVar('image')))) {
854
+			$ele['image_preview'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_POSTER : ''), '<img src="' . $object->getImage('image') . '" width="340px">');
855
+			$ele['image_preview']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_POSTER_DESC : ''));
856
+		}
857
+		$ele['artists'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_ARTISTS : ''), $object->getVar('artists'));
858
+		$ele['songs']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_SONGS : ''), $object->getVar('songs'));
859
+		$ele['hits']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_HITS : ''), $object->getVar('hits'));
860
+		$ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
861
+		if ($object->getVar('created') > 0) {
862
+			$ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
863
+		}
864
+		if ($object->getVar('updated') > 0) {
865
+			$ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
866
+		}
867
+
868
+		if ($as_array) {
869
+			return $ele;
870
+		}
871
+
872
+		$ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
873
+
874
+		$required = ['name', 'id', 'source'];
875
+
876
+		foreach ($ele as $id => $obj) {
877
+			if (in_array($id, $required, true)) {
878
+				$sform->addElement($obj, true);
879
+			} else {
880
+				$sform->addElement($obj, false);
881
+			}
882
+		}
883
+
884
+		return $sform->render();
885
+	}
886
+
887
+	/**
888
+	 * @param      $object
889
+	 * @param bool $as_array
890
+	 * @return array|string
891
+	 */
892
+	public static function  getFormUtf8map($object, $as_array = false)
893
+	{
894
+		if (!is_object($object)) {
895
+			$handler = Helper::getInstance()
896
+							 ->getHandler('Utf8map');
897
+			$object  = $handler->create();
898
+		}
899
+
900
+		xoops_loadLanguage('forms', 'songlist');
901
+		$ele = [];
902
+
903
+		if ($object->isNew()) {
904
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_UTF8MAP, 'utf8map', $_SERVER['SCRIPT_NAME'], 'post', true);
905
+			$ele['mode'] = new \XoopsFormHidden('mode', 'new');
906
+		} else {
907
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_UTF8MAP, 'utf8map', $_SERVER['SCRIPT_NAME'], 'post', true);
908
+			$ele['mode'] = new \XoopsFormHidden('mode', 'edit');
909
+		}
910
+
911
+		$sform->setExtra("enctype='multipart/form-data'");
912
+
913
+		$id = $object->getVar('utfid');
914
+		if (empty($id)) {
915
+			$id = '0';
916
+		}
917
+
918
+		$ele['op']  = new \XoopsFormHidden('op', 'utf8map');
919
+		$ele['fct'] = new \XoopsFormHidden('fct', 'save');
920
+		if ($as_array) {
921
+			$ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
922
+		} else {
923
+			$ele['id'] = new \XoopsFormHidden('id', $id);
924
+		}
925
+		$ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
926
+		$ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
927
+		$ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
928
+		$ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
929
+		$ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
930
+
931
+		$ele['from'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_FROM : ''), $id . '[from]', (!$as_array ? 6 : 4), 2, $object->getVar('from'));
932
+		$ele['from']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_FROM_DESC : ''));
933
+		$ele['to'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_TO : ''), $id . '[to]', (!$as_array ? 6 : 4), 2, $object->getVar('to'));
934
+		$ele['to']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_TO_DESC : ''));
935
+
936
+		if ($object->getVar('created') > 0) {
937
+			$ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
938
+		}
939
+		if ($object->getVar('updated') > 0) {
940
+			$ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
941
+		}
942
+
943
+		if ($as_array) {
944
+			return $ele;
945
+		}
946
+
947
+		$ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
948
+
949
+		$required = ['from', 'to'];
950
+
951
+		foreach ($ele as $id => $obj) {
952
+			if (in_array($id, $required, true)) {
953
+				$sform->addElement($obj, true);
954
+			} else {
955
+				$sform->addElement($obj, false);
956
+			}
957
+		}
958
+
959
+		return $sform->render();
960
+	}
961
+
962
+	/**
963
+	 * @param      $object
964
+	 * @param bool $as_array
965
+	 * @return array|string
966
+	 */
967
+	public static function  getFormRequests($object, $as_array = false)
968
+	{
969
+		if (!is_object($object)) {
970
+			$handler = Helper::getInstance()
971
+							 ->getHandler('Requests');
972
+			$object  = $handler->create();
973
+		}
974
+
975
+		xoops_loadLanguage('forms', 'songlist');
976
+		$ele = [];
977
+
978
+		if ($object->isNew()) {
979
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_REQUESTS, 'requests', $_SERVER['SCRIPT_NAME'], 'post', true);
980
+			$ele['mode'] = new \XoopsFormHidden('mode', 'new');
981
+		} else {
982
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_REQUESTS, 'requests', $_SERVER['SCRIPT_NAME'], 'post', true);
983
+			$ele['mode'] = new \XoopsFormHidden('mode', 'edit');
984
+		}
985
+
986
+		$sform->setExtra("enctype='multipart/form-data'");
987
+
988
+		$id = $object->getVar('rid');
989
+		if (empty($id)) {
990
+			$id = '0';
991
+		}
992
+
993
+		$ele['op']  = new \XoopsFormHidden('op', 'requests');
994
+		$ele['fct'] = new \XoopsFormHidden('fct', 'save');
995
+		if ($as_array) {
996
+			$ele['id'] = new \XoopsFormHidden('id', $id);
997
+		} else {
998
+			$ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
999
+		}
1000
+		$ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
1001
+		$ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
1002
+		$ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
1003
+		$ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
1004
+		$ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
1005
+
1006
+		$ele['artist'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ARTIST : ''), $id . '[artist]', (!$as_array ? 55 : 21), 128, $object->getVar('artist'));
1007
+		$ele['artist']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ARTIST_DESC : ''));
1008
+		$ele['album'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ALBUM : ''), $id . '[album]', (!$as_array ? 55 : 21), 128, $object->getVar('album'));
1009
+		$ele['album']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ALBUM_DESC : ''));
1010
+		$ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_TITLE : ''), $id . '[title]', (!$as_array ? 55 : 21), 128, $object->getVar('title'));
1011
+		$ele['title']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_TITLE_DESC : ''));
1012
+		$ele['lyrics'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_LYRICS : ''), $id . '[lyrics]', (!$as_array ? 55 : 21), 128, $object->getVar('lyrics'));
1013
+		$ele['lyrics']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_LYRICS_DESC : ''));
1014
+
1015
+		if (is_object($GLOBALS['xoopsUser'])) {
1016
+			$ele['uid']  = new \XoopsFormHidden('uid', $GLOBALS['xoopsUser']->getVar('uid'));
1017
+			$ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? $GLOBALS['xoopsUser']->getVar('name') : $object->getVar('name')));
1018
+			$ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME_DESC : ''));
1019
+			$ele['email'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL : ''), $id . '[email]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? $GLOBALS['xoopsUser']->getVar('email') : $object->getVar('email')));
1020
+			$ele['email']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL_DESC : ''));
1021
+		} else {
1022
+			$ele['uid']  = new \XoopsFormHidden('uid', 0);
1023
+			$ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? '' : $object->getVar('name')));
1024
+			$ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME_DESC : ''));
1025
+			$ele['email'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL : ''), $id . '[email]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? '' : $object->getVar('email')));
1026
+			$ele['email']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL_DESC : ''));
1027
+		}
1028
+		if ($object->getVar('created') > 0) {
1029
+			$ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
1030
+		}
1031
+		if ($object->getVar('updated') > 0) {
1032
+			$ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
1033
+		}
1034
+
1035
+		if ($as_array) {
1036
+			return $ele;
1037
+		}
1038
+
1039
+		$ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
1040
+
1041
+		$required = ['name', 'email'];
1042
+
1043
+		foreach ($ele as $id => $obj) {
1044
+			if (in_array($id, $required, true)) {
1045
+				$sform->addElement($obj, true);
1046
+			} else {
1047
+				$sform->addElement($obj, false);
1048
+			}
1049
+		}
1050
+
1051
+		return $sform->render();
1052
+	}
1053
+
1054
+	/**
1055
+	 * @param      $object
1056
+	 * @param bool $as_array
1057
+	 * @return array|string
1058
+	 */
1059
+	public static function  getFormSongs($object, $as_array = false)
1060
+	{
1061
+		if (!is_object($object)) {
1062
+			$handler = Helper::getInstance()
1063
+							 ->getHandler('Songs');
1064
+			$object  = $handler->create();
1065
+		}
1066
+
1067
+		xoops_loadLanguage('forms', 'songlist');
1068
+		$ele = [];
1069
+
1070
+		if ($object->isNew()) {
1071
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_SONGS, 'songs', $_SERVER['SCRIPT_NAME'], 'post', true);
1072
+			$ele['mode'] = new \XoopsFormHidden('mode', 'new');
1073
+		} else {
1074
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_SONGS, 'songs', $_SERVER['SCRIPT_NAME'], 'post', true);
1075
+			$ele['mode'] = new \XoopsFormHidden('mode', 'edit');
1076
+		}
1077
+
1078
+		$sform->setExtra("enctype='multipart/form-data'");
1079
+
1080
+		$id = $object->getVar('sid');
1081
+		if (empty($id)) {
1082
+			$id = '0';
1083
+		}
1084
+
1085
+		$ele['op']  = new \XoopsFormHidden('op', 'songs');
1086
+		$ele['fct'] = new \XoopsFormHidden('fct', 'save');
1087
+		if ($as_array) {
1088
+			$ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
1089
+		} else {
1090
+			$ele['id'] = new \XoopsFormHidden('id', $id);
1091
+		}
1092
+		$ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
1093
+		$ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
1094
+		$ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
1095
+		$ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
1096
+		$ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
1097
+
1098
+		$ele['cid'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_CATEGORY : ''), $id . '[cid]', ($_REQUEST['cid'] ?? $object->getVar('cid')), 1, false);
1099
+		$ele['cid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_CATEGORY_DESC : ''));
1100
+		if ($GLOBALS['songlistModuleConfig']['genre']) {
1101
+			$ele['gids'] = new SelectGenreForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_GENRE : ''), $id . '[gids]', ($_REQUEST['gids'] ?? $object->getVar('gids')), 8, true);
1102
+			$ele['gids']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_GENRE_DESC : ''));
1103
+		}
1104
+		if ($GLOBALS['songlistModuleConfig']['voice']) {
1105
+			$ele['vcid'] = new SelectVoiceForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_VOICE : ''), $id . '[vcid]', ($_REQUEST['vcid'] ?? $object->getVar('vcid')), 1, false);
1106
+			$ele['vcid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_VOICE_DESC : ''));
1107
+		}
1108
+		if ($GLOBALS['songlistModuleConfig']['album']) {
1109
+			$ele['abid'] = new SelectAlbumForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ALBUM : ''), $id . '[abid]', $object->getVar('abid'), 1, false);
1110
+			$ele['abid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ALBUM_DESC : ''));
1111
+		}
1112
+		$ele['aids'] = new SelectArtistForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ARTISTS : ''), $id . '[aids]', $object->getVar('aids'), 7, true);
1113
+		$ele['aids']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ARTISTS_DESC : ''));
1114
+		$ele['songid'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_SONGS_SONGID : ''), $id . '[songid]', (!$as_array ? 25 : 15), 32, $object->getVar('songid'));
1115
+		$ele['songid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_SONGID_DESC : ''));
1116
+		$ele['traxid'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TRAXID : ''), $id . '[traxid]', (!$as_array ? 25 : 15), 32, $object->getVar('traxid'));
1117
+		$ele['traxid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TRAXID_DESC : ''));
1118
+		$ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TITLE : ''), $id . '[title]', (!$as_array ? 55 : 21), 128, $object->getVar('title'));
1119
+		$ele['title']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TITLE_DESC : ''));
1120
+		$description_configs           = [];
1121
+		$description_configs['name']   = $id . '[lyrics]';
1122
+		$description_configs['value']  = $object->getVar('lyrics');
1123
+		$description_configs['rows']   = 35;
1124
+		$description_configs['cols']   = 60;
1125
+		$description_configs['width']  = '100%';
1126
+		$description_configs['height'] = '400px';
1127
+		$ele['lyrics']                 = new \XoopsFormEditor(_FRM_SONGLIST_FORM_SONGS_LYRICS, $GLOBALS['songlistModuleConfig']['editor'], $description_configs);
1128
+		$ele['lyrics']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_LYRICS_DESC : ''));
1129
+		$ele['mp3'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_SONGS_MP3 : ''), 'mp3' . $id, $GLOBALS['songlistModuleConfig']['mp3_filesize']);
1130
+		$ele['mp3']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_MP3_DESC : ''));
1131
+		$categoryHandler = Helper::getInstance()
1132
+								 ->getHandler('Category');
1133
+		$criteria        = new \CriteriaCompo(new \Criteria('cid', !empty($_REQUEST['cid']) ? Request::getInt('cid', 0, 'REQUEST') : $object->getVar('cid')));
1134
+		$all_categories  = $categoryHandler->getObjects($criteria, true, false);
1135
+
1136
+		// Dynamic fields
1137
+		$extrasHandler = Helper::getInstance()
1138
+							   ->getHandler('Extras');
1139
+		/** @var \XoopsGroupPermHandler $grouppermHandler */
1140
+		$grouppermHandler = xoops_getHandler('groupperm');
1141
+		/** @var \XoopsModuleHandler $moduleHandler */
1142
+		$moduleHandler = xoops_getHandler('module');
1143
+		$xoModule      = $moduleHandler->getByDirname('songlist');
1144
+		$modid         = $xoModule->getVar('mid');
1145
+
1146
+		if (is_object($GLOBALS['xoopsUser'])) {
1147
+			$groups = $GLOBALS['xoopsUser']->getGroups();
1148
+		} else {
1149
+			$groups = [XOOPS_GROUP_ANONYMOUS => XOOPS_GROUP_ANONYMOUS];
1150
+		}
1151
+
1152
+		$count_fields = 0;
1153
+		$fields       = $extrasHandler->loadFields();
1154
+
1155
+		$required = [];
1156
+		$elements = [];
1157
+		$weights  = [];
1158
+		if ($object->getVar('sid') > 0) {
1159
+			$extra = $extrasHandler->get($object->getVar('sid'));
1160
+		} else {
1161
+			$extra = $extrasHandler->create();
1162
+		}
1163
+		$allnames = [];
1164
+		if (is_array($fields)) {
1165
+			foreach (array_keys($fields) as $i) {
1166
+				if ((0 != $object->getVar('sid') && $grouppermHandler->checkRight('songlist_edit', $fields[$i]->getVar('field_id'), $groups, $modid))
1167
+					|| (0 == $object->getVar('sid') && $grouppermHandler->checkRight('songlist_post', $fields[$i]->getVar('field_id'), $groups, $modid))) {
1168
+					$fieldinfo['element']  = $fields[$i]->getEditElement($object, $extra);
1169
+					$fieldinfo['required'] = $fields[$i]->getVar('field_required');
1170
+					foreach ($fields[$i]->getVar('cids') as $catidid => $cid) {
1171
+						if (!in_array($fields[$i]->getVar('field_name'), $allnames, true)) {
1172
+							$allnames[] = $fields[$i]->getVar('field_name');
1173
+							if (array_key_exists($cid, $all_categories)
1174
+								|| $cid == (!empty($_REQUEST['cid'])
1175
+									? Request::getInt('cid', 0, 'REQUEST')
1176
+									: $object->getVar('cid'))) {
1177
+								$key              = (isset($all_categories[$cid]) ? $all_categories[$cid]['weight'] : 0)
1178
+													* $count_fields + $object->getVar('cid');
1179
+								$elements[$key][] = $fieldinfo;
1180
+								$weights[$key][]  = $fields[$i]->getVar('field_weight');
1181
+							} elseif (in_array(0, $fields[$i]->getVar('cids'), true)) {
1182
+								$key              = (isset($all_categories[$cid]) ? $all_categories[$cid]['weight'] : 0) * $count_fields + $object->getVar('cid');
1183
+								$elements[$key][] = $fieldinfo;
1184
+								$weights[$key][]  = $fields[$i]->getVar('field_weight');
1185
+							}
1186
+						}
1187
+					}
1188
+				}
1189
+			}
1190
+		}
1191
+		if (is_array($elements)) {
1192
+			ksort($elements);
1193
+			foreach (array_keys($elements) as $k) {
1194
+				array_multisort($weights[$k], SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]);
1195
+				foreach (array_keys($elements[$k]) as $i) {
1196
+					$ele[$k] = $elements[$k][$i]['element'];
1197
+					if (true === $elements[$k][$i]['required']) {
1198
+						$required[$k] = $elements[$k][$i]['element']->getName();
1199
+					}
1200
+				}
1201
+			}
1202
+		}
1203
+
1204
+		if (class_exists(\XoopsModules\Tag\FormTag::class)) {
1205
+			$ele['tags'] = new \XoopsModules\Tag\FormTag('tags', 60, 255, $object->getVar('sid'), $object->getVar('cid'));
1206
+		} else {
1207
+			$ele['tags'] = new \XoopsFormHidden('tags', $object->getVar('tags'));
1208
+		}
1209
+
1210
+		$ele['hits'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_SONGS_HITS : ''), $object->getVar('hits'));
1211
+		$ele['rank'] = new \XoopsFormLabel((!$as_array ? _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');
1212
+		if ($object->getVar('created') > 0) {
1213
+			$ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_SONGS_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
1214
+		}
1215
+		if ($object->getVar('updated') > 0) {
1216
+			$ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_SONGS_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
1217
+		}
1218
+		if ($as_array) {
1219
+			return $ele;
1220
+		}
1221
+
1222
+		$ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
1223
+
1224
+		foreach ($ele as $id => $obj) {
1225
+			if (in_array($id, $required, true)) {
1226
+				$sform->addElement($obj, true);
1227
+			} else {
1228
+				$sform->addElement($obj, false);
1229
+			}
1230
+		}
1231
+
1232
+		return $sform->render();
1233
+	}
1234
+
1235
+	/**
1236
+	 * @param      $object
1237
+	 * @param bool $as_array
1238
+	 * @return array|string
1239
+	 */
1240
+	public static function  getFormVotes($object, $as_array = false)
1241
+	{
1242
+		if (!is_object($object)) {
1243
+			$handler = Helper::getInstance()
1244
+							 ->getHandler('Votes');
1245
+			$object  = $handler->create();
1246
+		}
1247
+
1248
+		xoops_loadLanguage('forms', 'songlist');
1249
+		$ele = [];
1250
+
1251
+		if ($object->isNew()) {
1252
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_CART, 'votes', $_SERVER['SCRIPT_NAME'], 'post', true);
1253
+			$ele['mode'] = new \XoopsFormHidden('mode', 'new');
1254
+		} else {
1255
+			$sform       = new \XoopsThemeForm(_FRM_SONGLIST_FORM_EDIT_CART, 'votes', $_SERVER['SCRIPT_NAME'], 'post', true);
1256
+			$ele['mode'] = new \XoopsFormHidden('mode', 'edit');
1257
+		}
1258
+
1259
+		$sform->setExtra("enctype='multipart/form-data'");
1260
+
1261
+		$id = $object->getVar('cid');
1262
+		if (empty($id)) {
1263
+			$id = '0';
1264
+		}
1265
+
1266
+		$ele['op']  = new \XoopsFormHidden('op', 'votes');
1267
+		$ele['fct'] = new \XoopsFormHidden('fct', 'save');
1268
+		if ($as_array) {
1269
+			$ele['id'] = new \XoopsFormHidden('id', $id);
1270
+		} else {
1271
+			$ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
1272
+		}
1273
+		$ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
1274
+		$ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
1275
+		$ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
1276
+		$ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
1277
+		$ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
1278
+
1279
+		$songsHandler = Helper::getInstance()
1280
+							  ->getHandler('Songs');
1281
+		$userHandler  = xoops_getHandler('user');
1282
+		$song         = $songsHandler->get($object->getVar('sid'));
1283
+		$user         = $userHandler->get($object->getVar('uid'));
1284
+		if (is_object($song)) {
1285
+			$ele['sid'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_SONG : ''), $song->getVar('title'));
1286
+		} else {
1287
+			$ele['sid'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_SONG : ''), $object->getVar('sid'));
1288
+		}
1289
+		if (is_object($user)) {
1290
+			$ele['uid'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_USER : ''), $user->getVar('uname'));
1291
+		} else {
1292
+			$ele['uid'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_USER : ''), _GUESTS);
1293
+		}
1294
+		$ele['ip']      = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_IP : ''), $object->getVar('ip'));
1295
+		$ele['netaddy'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_NETADDY : ''), $object->getVar('netaddy'));
1296
+		$ele['rank']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_RANK : ''), $object->getVar('rank') . ' of 10');
1297
+
1298
+		if ($as_array) {
1299
+			return $ele;
1300
+		}
1301
+
1302
+		$ele['submit'] = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit');
1303
+
1304
+		$required = [];
1305
+
1306
+		foreach ($ele as $id => $obj) {
1307
+			if (in_array($id, $required, true)) {
1308
+				$sform->addElement($obj, true);
1309
+			} else {
1310
+				$sform->addElement($obj, false);
1311
+			}
1312
+		}
1313
+
1314
+		return $sform->render();
1315
+	}
1316 1316
 }
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public static function getFieldForm($field, $action = false)
28 28
     {
29
-        if (false === $action) {
29
+        if (false===$action) {
30 30
             $action = $_SERVER['SCRIPT_NAME'];
31 31
         }
32 32
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 
129 129
             //$form->addElement(new \XoopsFormRadioYN(_FRM_SONGLIST_FIELDS_NOTNULL, 'field_notnull', $field->getVar('field_notnull', 'e') ));
130 130
 
131
-            if ('select' === $field->getVar('field_type') || 'select_multi' === $field->getVar('field_type') || 'radio' === $field->getVar('field_type') || 'checkbox' === $field->getVar('field_type')) {
131
+            if ('select'===$field->getVar('field_type') || 'select_multi'===$field->getVar('field_type') || 'radio'===$field->getVar('field_type') || 'checkbox'===$field->getVar('field_type')) {
132 132
                 $options = $field->getVar('field_options');
133
-                if (count($options) > 0) {
133
+                if (count($options)>0) {
134 134
                     $remove_options          = new \XoopsFormCheckBox(_FRM_SONGLIST_FIELDS_REMOVEOPTIONS, 'removeOptions');
135 135
                     $remove_options->columns = 3;
136 136
                     asort($options);
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
                     $form->addElement($remove_options);
142 142
                 }
143 143
 
144
-                $option_text = "<table  cellspacing='1'><tr><td width='20%'>" . _FRM_SONGLIST_FIELDS_KEY . '</td><td>' . _FRM_SONGLIST_FIELDS_VALUE . '</td></tr>';
145
-                for ($i = 0; $i < 3; ++$i) {
144
+                $option_text = "<table  cellspacing='1'><tr><td width='20%'>"._FRM_SONGLIST_FIELDS_KEY.'</td><td>'._FRM_SONGLIST_FIELDS_VALUE.'</td></tr>';
145
+                for ($i = 0; $i<3; ++$i) {
146 146
                     $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>";
147 147
                     $option_text .= "<tr height='3px'><td colspan='2'> </td></tr>";
148 148
                 }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
                     break;
162 162
                 case 'checkbox':
163 163
                 case 'select_multi':
164
-                    $def_value = null !== $field->getVar('field_default', 'e') ? unserialize(($field->getVar('field_default', 'n')) ?? '') : null;
164
+                    $def_value = null!==$field->getVar('field_default', 'e') ? unserialize(($field->getVar('field_default', 'n')) ?? '') : null;
165 165
                     $element   = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $def_value, 8, true);
166 166
                     $options   = $field->getVar('field_options');
167 167
                     asort($options);
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
                     break;
175 175
                 case 'select':
176 176
                 case 'radio':
177
-                    $def_value = null !== $field->getVar('field_default', 'e') ? $field->getVar('field_default') : null;
177
+                    $def_value = null!==$field->getVar('field_default', 'e') ? $field->getVar('field_default') : null;
178 178
                     $element   = new \XoopsFormSelect(_FRM_SONGLIST_FIELDS_DEFAULT, 'field_default', $def_value);
179 179
                     $options   = $field->getVar('field_options');
180 180
                     asort($options);
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
                             ->getHandler('Category');
302 302
 
303 303
         $selcat = new \XoopsFormSelect('Form', 'cid', !empty($_REQUEST['cid']) ? Request::getInt('cid', 0, 'REQUEST') : 0, 1, false, false, false, true);
304
-        $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"');
304
+        $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"');
305 305
 
306 306
         $form->addElement($selcat, true);
307 307
 
@@ -319,12 +319,12 @@  discard block
 block discarded – undo
319 319
 
320 320
                 foreach ($fields[$i]->getVar('cids') as $catidid => $cid) {
321 321
                     if (array_key_exists($cid, $all_categories)) {
322
-                        $key              = $all_categories[$cid]['cat_weight'] * $count_fields + $cid;
322
+                        $key              = $all_categories[$cid]['cat_weight']*$count_fields+$cid;
323 323
                         $elements[$key][] = $fieldinfo;
324 324
                         $weights[$key][]  = $fields[$i]->getVar('field_weight');
325 325
                         $categories[$key] = $all_categories[$cid];
326 326
                     } elseif (in_array(0, $fields[$i]->getVar('cids'), true)) {
327
-                        $key              = $all_categories[$cid]['cat_weight'] * $count_fields + $cid;
327
+                        $key              = $all_categories[$cid]['cat_weight']*$count_fields+$cid;
328 328
                         $elements[$key][] = $fieldinfo;
329 329
                         $weights[$key][]  = $fields[$i]->getVar('field_weight');
330 330
                         $categories[$key] = $all_categories[$cid];
@@ -364,14 +364,14 @@  discard block
 block discarded – undo
364 364
 
365 365
         $ele['op']      = new \XoopsFormHidden('op', 'import');
366 366
         $ele['fct']     = new \XoopsFormHidden('fct', 'upload');
367
-        $ele['xmlfile'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_UPLOAD_XML : ''), 'xmlfile', 1024 * 1024 * 1024 * 32);
367
+        $ele['xmlfile'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_UPLOAD_XML : ''), 'xmlfile', 1024*1024*1024*32);
368 368
         $ele['xmlfile']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_UPLOAD_XML_DESC : ''));
369 369
         $ele['file'] = new \XoopsFormSelect((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_EXISTING_XML : ''), 'file');
370 370
         $ele['file']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_IMPORT_EXISTING_XML_DESC : ''));
371 371
         $ele['file']->addOption('', '*********');
372 372
         xoops_load('XoopsLists');
373 373
         foreach (\XoopsLists::getFileListAsArray($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $file) {
374
-            if ('xml' === mb_substr($file, mb_strlen($file) - 3, 3)) {
374
+            if ('xml'===mb_substr($file, mb_strlen($file)-3, 3)) {
375 375
                 $ele['file']->addOption($file, $file);
376 376
             }
377 377
         }
@@ -401,24 +401,24 @@  discard block
 block discarded – undo
401 401
 
402 402
         $sform = new \XoopsThemeForm(_FRM_SONGLIST_FORM_ISNEW_ELEMENTS, 'elements', $_SERVER['SCRIPT_NAME'], 'post', true);
403 403
 
404
-        $filesize = filesize($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $file));
405
-        $mb       = floor($filesize / 1024 / 1024);
406
-        if ($mb > 32) {
407
-            ini_set('memory_limit', ($mb + 128) . 'M');
404
+        $filesize = filesize($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'].$file));
405
+        $mb       = floor($filesize/1024/1024);
406
+        if ($mb>32) {
407
+            ini_set('memory_limit', ($mb+128).'M');
408 408
         }
409 409
         set_time_limit(3600);
410 410
 
411 411
         $i = 0;
412
-        foreach (file($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $_SESSION['xmlfile'])) as $data) {
412
+        foreach (file($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'].$_SESSION['xmlfile'])) as $data) {
413 413
             ++$i;
414
-            if ($i < 20) {
415
-                $line .= htmlspecialchars($data, ENT_QUOTES | ENT_HTML5) . ($i < 19 ? "\n" : '');
414
+            if ($i<20) {
415
+                $line .= htmlspecialchars($data, ENT_QUOTES | ENT_HTML5).($i<19 ? "\n" : '');
416 416
             }
417 417
         }
418 418
 
419 419
         $ele['op']      = new \XoopsFormHidden('op', 'import');
420 420
         $ele['fct']     = new \XoopsFormHidden('fct', 'import');
421
-        $ele['example'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_EXAMPLE : ''), '<pre>' . $line . '</pre>');
421
+        $ele['example'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_EXAMPLE : ''), '<pre>'.$line.'</pre>');
422 422
         $ele['example']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_EXAMPLE_DESC : ''));
423 423
         $ele['collection'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_COLLECTION : ''), 'collection', 32, 128, 'collection');
424 424
         $ele['collection']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ELEMENT_COLLECTION_DESC : ''));
@@ -509,27 +509,27 @@  discard block
 block discarded – undo
509 509
         $ele['op']  = new \XoopsFormHidden('op', 'genre');
510 510
         $ele['fct'] = new \XoopsFormHidden('fct', 'save');
511 511
         if ($as_array) {
512
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
512
+            $ele['id'] = new \XoopsFormHidden('id['.$id.']', $id);
513 513
         } else {
514 514
             $ele['id'] = new \XoopsFormHidden('id', $id);
515 515
         }
516 516
         $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
517 517
         $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
518
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
519
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
518
+        $ele['start']  = new \XoopsFormHidden('start', (string) Request::getInt('start', 0, 'REQUEST'));
519
+        $ele['limit']  = new \XoopsFormHidden('limit', (string) Request::getInt('limit', 0, 'REQUEST'));
520 520
         $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
521 521
 
522
-        $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_GENRE_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
522
+        $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_GENRE_NAME : ''), $id.'[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
523 523
         $ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_GENRE_NAME_DESC : ''));
524 524
         $ele['albums']  = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_ALBUMS : ''), $object->getVar('albums'));
525 525
         $ele['artists'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_ARTISTS : ''), $object->getVar('artists'));
526 526
         $ele['songs']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_SONGS : ''), $object->getVar('songs'));
527 527
         $ele['hits']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_HITS : ''), $object->getVar('hits'));
528
-        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
529
-        if ($object->getVar('created') > 0) {
528
+        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
529
+        if ($object->getVar('created')>0) {
530 530
             $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
531 531
         }
532
-        if ($object->getVar('updated') > 0) {
532
+        if ($object->getVar('updated')>0) {
533 533
             $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_GENRE_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
534 534
         }
535 535
 
@@ -586,27 +586,27 @@  discard block
 block discarded – undo
586 586
         $ele['op']  = new \XoopsFormHidden('op', 'voice');
587 587
         $ele['fct'] = new \XoopsFormHidden('fct', 'save');
588 588
         if ($as_array) {
589
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
589
+            $ele['id'] = new \XoopsFormHidden('id['.$id.']', $id);
590 590
         } else {
591 591
             $ele['id'] = new \XoopsFormHidden('id', $id);
592 592
         }
593 593
         $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
594 594
         $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
595
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
596
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
595
+        $ele['start']  = new \XoopsFormHidden('start', (string) Request::getInt('start', 0, 'REQUEST'));
596
+        $ele['limit']  = new \XoopsFormHidden('limit', (string) Request::getInt('limit', 0, 'REQUEST'));
597 597
         $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
598 598
 
599
-        $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_VOICE_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
599
+        $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_VOICE_NAME : ''), $id.'[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
600 600
         $ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_VOICE_NAME_DESC : ''));
601 601
         $ele['albums']  = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_ALBUMS : ''), $object->getVar('albums'));
602 602
         $ele['artists'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_ARTISTS : ''), $object->getVar('artists'));
603 603
         $ele['songs']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_SONGS : ''), $object->getVar('songs'));
604 604
         $ele['hits']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_HITS : ''), $object->getVar('hits'));
605
-        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
606
-        if ($object->getVar('created') > 0) {
605
+        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
606
+        if ($object->getVar('created')>0) {
607 607
             $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
608 608
         }
609
-        if ($object->getVar('updated') > 0) {
609
+        if ($object->getVar('updated')>0) {
610 610
             $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOICE_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
611 611
         }
612 612
 
@@ -663,34 +663,34 @@  discard block
 block discarded – undo
663 663
         $ele['op']  = new \XoopsFormHidden('op', 'albums');
664 664
         $ele['fct'] = new \XoopsFormHidden('fct', 'save');
665 665
         if ($as_array) {
666
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
666
+            $ele['id'] = new \XoopsFormHidden('id['.$id.']', $id);
667 667
         } else {
668 668
             $ele['id'] = new \XoopsFormHidden('id', $id);
669 669
         }
670 670
         $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
671 671
         $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
672
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
673
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
672
+        $ele['start']  = new \XoopsFormHidden('start', (string) Request::getInt('start', 0, 'REQUEST'));
673
+        $ele['limit']  = new \XoopsFormHidden('limit', (string) Request::getInt('limit', 0, 'REQUEST'));
674 674
         $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
675 675
 
676
-        $ele['cid'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_CATEGORY : ''), $id . '[cid]', $object->getVar('cid'), 1, false, false, false);
676
+        $ele['cid'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_CATEGORY : ''), $id.'[cid]', $object->getVar('cid'), 1, false, false, false);
677 677
         $ele['cid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_CATEGORY_DESC : ''));
678
-        $ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_TITLE : ''), $id . '[title]', (!$as_array ? 55 : 21), 128, $object->getVar('title'));
678
+        $ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_TITLE : ''), $id.'[title]', (!$as_array ? 55 : 21), 128, $object->getVar('title'));
679 679
         $ele['title']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_TITLE_DESC : ''));
680 680
         $ele['image'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_UPLOAD_POSTER : ''), 'image', $GLOBALS['songlistModuleConfig']['filesize_upload']);
681 681
         $ele['image']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_UPLOAD_POSTER_DESC : ''));
682
-        if ('' != $object->getVar('image') && file_exists($GLOBALS['xoops']->path($object->getVar('path') . $object->getVar('image')))) {
683
-            $ele['image_preview'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_POSTER : ''), '<img src="' . $object->getImage('image') . '" width="340px">');
682
+        if (''!=$object->getVar('image') && file_exists($GLOBALS['xoops']->path($object->getVar('path').$object->getVar('image')))) {
683
+            $ele['image_preview'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_POSTER : ''), '<img src="'.$object->getImage('image').'" width="340px">');
684 684
             $ele['image_preview']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_POSTER_DESC : ''));
685 685
         }
686 686
         $ele['artists'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_ARTISTS : ''), $object->getVar('artists'));
687 687
         $ele['songs']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_SONGS : ''), $object->getVar('songs'));
688 688
         $ele['hits']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_HITS : ''), $object->getVar('hits'));
689
-        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
690
-        if ($object->getVar('created') > 0) {
689
+        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
690
+        if ($object->getVar('created')>0) {
691 691
             $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
692 692
         }
693
-        if ($object->getVar('updated') > 0) {
693
+        if ($object->getVar('updated')>0) {
694 694
             $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ALBUMS_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
695 695
         }
696 696
 
@@ -745,30 +745,30 @@  discard block
 block discarded – undo
745 745
         $ele['op']  = new \XoopsFormHidden('op', 'artists');
746 746
         $ele['fct'] = new \XoopsFormHidden('fct', 'save');
747 747
         if ($as_array) {
748
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
748
+            $ele['id'] = new \XoopsFormHidden('id['.$id.']', $id);
749 749
         } else {
750 750
             $ele['id'] = new \XoopsFormHidden('id', $id);
751 751
         }
752 752
         $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
753 753
         $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
754
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
755
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
754
+        $ele['start']  = new \XoopsFormHidden('start', (string) Request::getInt('start', 0, 'REQUEST'));
755
+        $ele['limit']  = new \XoopsFormHidden('limit', (string) Request::getInt('limit', 0, 'REQUEST'));
756 756
         $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
757 757
 
758
-        $ele['cids'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_CATEGORY : ''), $id . '[cids]', $object->getVar('cids'), 7, true, false, false);
758
+        $ele['cids'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_CATEGORY : ''), $id.'[cids]', $object->getVar('cids'), 7, true, false, false);
759 759
         $ele['cids']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_CATEGORY_DESC : ''));
760 760
         //$ele['singer'] = new \XoopsModules\Songlist\Form\SelectSingerForm(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_SINGER:''), $id.'[singer]', $object->getVar('singer'), 1, false, false, false);
761 761
         //$ele['singer']->setDescription(($as_array==false?_FRM_SONGLIST_FORM_ARTISTS_SINGER_DESC:''));
762
-        $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
762
+        $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_NAME : ''), $id.'[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
763 763
         $ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_NAME_DESC : ''));
764 764
         $ele['albums'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_ALBUMS : ''), $object->getVar('albums'));
765 765
         $ele['songs']  = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_SONGS : ''), $object->getVar('songs'));
766 766
         $ele['hits']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_HITS : ''), $object->getVar('hits'));
767
-        $ele['rank']   = new \XoopsFormLabel((!$as_array ? _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');
768
-        if ($object->getVar('created') > 0) {
767
+        $ele['rank']   = new \XoopsFormLabel((!$as_array ? _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');
768
+        if ($object->getVar('created')>0) {
769 769
             $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
770 770
         }
771
-        if ($object->getVar('updated') > 0) {
771
+        if ($object->getVar('updated')>0) {
772 772
             $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_ARTISTS_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
773 773
         }
774 774
 
@@ -825,22 +825,22 @@  discard block
 block discarded – undo
825 825
         $ele['op']  = new \XoopsFormHidden('op', 'category');
826 826
         $ele['fct'] = new \XoopsFormHidden('fct', 'save');
827 827
         if ($as_array) {
828
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
828
+            $ele['id'] = new \XoopsFormHidden('id['.$id.']', $id);
829 829
         } else {
830 830
             $ele['id'] = new \XoopsFormHidden('id', $id);
831 831
         }
832 832
         $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
833 833
         $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
834
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
835
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
834
+        $ele['start']  = new \XoopsFormHidden('start', (string) Request::getInt('start', 0, 'REQUEST'));
835
+        $ele['limit']  = new \XoopsFormHidden('limit', (string) Request::getInt('limit', 0, 'REQUEST'));
836 836
         $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
837 837
 
838
-        $ele['pid'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_PARENT : ''), $id . '[pid]', $object->getVar('pid'), 1, false, $object->getVar('cid'));
838
+        $ele['pid'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_PARENT : ''), $id.'[pid]', $object->getVar('pid'), 1, false, $object->getVar('cid'));
839 839
         $ele['pid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_PARENT_DESC : ''));
840
-        $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
840
+        $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_NAME : ''), $id.'[name]', (!$as_array ? 55 : 21), 128, $object->getVar('name'));
841 841
         $ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_NAME_DESC : ''));
842 842
         $description_configs           = [];
843
-        $description_configs['name']   = $id . '[description]';
843
+        $description_configs['name']   = $id.'[description]';
844 844
         $description_configs['value']  = $object->getVar('description');
845 845
         $description_configs['rows']   = 35;
846 846
         $description_configs['cols']   = 60;
@@ -850,18 +850,18 @@  discard block
 block discarded – undo
850 850
         $ele['description']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_DESCRIPTION_DESC : ''));
851 851
         $ele['image'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_UPLOAD_POSTER : ''), 'image', $GLOBALS['songlistModuleConfig']['filesize_upload']);
852 852
         $ele['image']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_UPLOAD_POSTER_DESC : ''));
853
-        if ('' != $object->getVar('image') && file_exists($GLOBALS['xoops']->path($object->getVar('path') . $object->getVar('image')))) {
854
-            $ele['image_preview'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_POSTER : ''), '<img src="' . $object->getImage('image') . '" width="340px">');
853
+        if (''!=$object->getVar('image') && file_exists($GLOBALS['xoops']->path($object->getVar('path').$object->getVar('image')))) {
854
+            $ele['image_preview'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_POSTER : ''), '<img src="'.$object->getImage('image').'" width="340px">');
855 855
             $ele['image_preview']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_POSTER_DESC : ''));
856 856
         }
857 857
         $ele['artists'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_ARTISTS : ''), $object->getVar('artists'));
858 858
         $ele['songs']   = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_SONGS : ''), $object->getVar('songs'));
859 859
         $ele['hits']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_HITS : ''), $object->getVar('hits'));
860
-        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
861
-        if ($object->getVar('created') > 0) {
860
+        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _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');
861
+        if ($object->getVar('created')>0) {
862 862
             $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
863 863
         }
864
-        if ($object->getVar('updated') > 0) {
864
+        if ($object->getVar('updated')>0) {
865 865
             $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_CATEGORY_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
866 866
         }
867 867
 
@@ -918,25 +918,25 @@  discard block
 block discarded – undo
918 918
         $ele['op']  = new \XoopsFormHidden('op', 'utf8map');
919 919
         $ele['fct'] = new \XoopsFormHidden('fct', 'save');
920 920
         if ($as_array) {
921
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
921
+            $ele['id'] = new \XoopsFormHidden('id['.$id.']', $id);
922 922
         } else {
923 923
             $ele['id'] = new \XoopsFormHidden('id', $id);
924 924
         }
925 925
         $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
926 926
         $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
927
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
928
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
927
+        $ele['start']  = new \XoopsFormHidden('start', (string) Request::getInt('start', 0, 'REQUEST'));
928
+        $ele['limit']  = new \XoopsFormHidden('limit', (string) Request::getInt('limit', 0, 'REQUEST'));
929 929
         $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
930 930
 
931
-        $ele['from'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_FROM : ''), $id . '[from]', (!$as_array ? 6 : 4), 2, $object->getVar('from'));
931
+        $ele['from'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_FROM : ''), $id.'[from]', (!$as_array ? 6 : 4), 2, $object->getVar('from'));
932 932
         $ele['from']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_FROM_DESC : ''));
933
-        $ele['to'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_TO : ''), $id . '[to]', (!$as_array ? 6 : 4), 2, $object->getVar('to'));
933
+        $ele['to'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_TO : ''), $id.'[to]', (!$as_array ? 6 : 4), 2, $object->getVar('to'));
934 934
         $ele['to']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_TO_DESC : ''));
935 935
 
936
-        if ($object->getVar('created') > 0) {
936
+        if ($object->getVar('created')>0) {
937 937
             $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
938 938
         }
939
-        if ($object->getVar('updated') > 0) {
939
+        if ($object->getVar('updated')>0) {
940 940
             $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_UTF8MAP_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
941 941
         }
942 942
 
@@ -995,40 +995,40 @@  discard block
 block discarded – undo
995 995
         if ($as_array) {
996 996
             $ele['id'] = new \XoopsFormHidden('id', $id);
997 997
         } else {
998
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
998
+            $ele['id'] = new \XoopsFormHidden('id['.$id.']', $id);
999 999
         }
1000 1000
         $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
1001 1001
         $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
1002
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
1003
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
1002
+        $ele['start']  = new \XoopsFormHidden('start', (string) Request::getInt('start', 0, 'REQUEST'));
1003
+        $ele['limit']  = new \XoopsFormHidden('limit', (string) Request::getInt('limit', 0, 'REQUEST'));
1004 1004
         $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
1005 1005
 
1006
-        $ele['artist'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ARTIST : ''), $id . '[artist]', (!$as_array ? 55 : 21), 128, $object->getVar('artist'));
1006
+        $ele['artist'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ARTIST : ''), $id.'[artist]', (!$as_array ? 55 : 21), 128, $object->getVar('artist'));
1007 1007
         $ele['artist']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ARTIST_DESC : ''));
1008
-        $ele['album'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ALBUM : ''), $id . '[album]', (!$as_array ? 55 : 21), 128, $object->getVar('album'));
1008
+        $ele['album'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ALBUM : ''), $id.'[album]', (!$as_array ? 55 : 21), 128, $object->getVar('album'));
1009 1009
         $ele['album']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_ALBUM_DESC : ''));
1010
-        $ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_TITLE : ''), $id . '[title]', (!$as_array ? 55 : 21), 128, $object->getVar('title'));
1010
+        $ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_TITLE : ''), $id.'[title]', (!$as_array ? 55 : 21), 128, $object->getVar('title'));
1011 1011
         $ele['title']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_TITLE_DESC : ''));
1012
-        $ele['lyrics'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_LYRICS : ''), $id . '[lyrics]', (!$as_array ? 55 : 21), 128, $object->getVar('lyrics'));
1012
+        $ele['lyrics'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_LYRICS : ''), $id.'[lyrics]', (!$as_array ? 55 : 21), 128, $object->getVar('lyrics'));
1013 1013
         $ele['lyrics']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_LYRICS_DESC : ''));
1014 1014
 
1015 1015
         if (is_object($GLOBALS['xoopsUser'])) {
1016 1016
             $ele['uid']  = new \XoopsFormHidden('uid', $GLOBALS['xoopsUser']->getVar('uid'));
1017
-            $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? $GLOBALS['xoopsUser']->getVar('name') : $object->getVar('name')));
1017
+            $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME : ''), $id.'[name]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? $GLOBALS['xoopsUser']->getVar('name') : $object->getVar('name')));
1018 1018
             $ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME_DESC : ''));
1019
-            $ele['email'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL : ''), $id . '[email]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? $GLOBALS['xoopsUser']->getVar('email') : $object->getVar('email')));
1019
+            $ele['email'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL : ''), $id.'[email]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? $GLOBALS['xoopsUser']->getVar('email') : $object->getVar('email')));
1020 1020
             $ele['email']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL_DESC : ''));
1021 1021
         } else {
1022 1022
             $ele['uid']  = new \XoopsFormHidden('uid', 0);
1023
-            $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME : ''), $id . '[name]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? '' : $object->getVar('name')));
1023
+            $ele['name'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME : ''), $id.'[name]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? '' : $object->getVar('name')));
1024 1024
             $ele['name']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_NAME_DESC : ''));
1025
-            $ele['email'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL : ''), $id . '[email]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? '' : $object->getVar('email')));
1025
+            $ele['email'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL : ''), $id.'[email]', (!$as_array ? 55 : 21), 128, ($object->isNew() ? '' : $object->getVar('email')));
1026 1026
             $ele['email']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_EMAIL_DESC : ''));
1027 1027
         }
1028
-        if ($object->getVar('created') > 0) {
1028
+        if ($object->getVar('created')>0) {
1029 1029
             $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
1030 1030
         }
1031
-        if ($object->getVar('updated') > 0) {
1031
+        if ($object->getVar('updated')>0) {
1032 1032
             $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_REQUESTS_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
1033 1033
         }
1034 1034
 
@@ -1085,40 +1085,40 @@  discard block
 block discarded – undo
1085 1085
         $ele['op']  = new \XoopsFormHidden('op', 'songs');
1086 1086
         $ele['fct'] = new \XoopsFormHidden('fct', 'save');
1087 1087
         if ($as_array) {
1088
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
1088
+            $ele['id'] = new \XoopsFormHidden('id['.$id.']', $id);
1089 1089
         } else {
1090 1090
             $ele['id'] = new \XoopsFormHidden('id', $id);
1091 1091
         }
1092 1092
         $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
1093 1093
         $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
1094
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
1095
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
1094
+        $ele['start']  = new \XoopsFormHidden('start', (string) Request::getInt('start', 0, 'REQUEST'));
1095
+        $ele['limit']  = new \XoopsFormHidden('limit', (string) Request::getInt('limit', 0, 'REQUEST'));
1096 1096
         $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
1097 1097
 
1098
-        $ele['cid'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_CATEGORY : ''), $id . '[cid]', ($_REQUEST['cid'] ?? $object->getVar('cid')), 1, false);
1098
+        $ele['cid'] = new SelectCategoryForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_CATEGORY : ''), $id.'[cid]', ($_REQUEST['cid'] ?? $object->getVar('cid')), 1, false);
1099 1099
         $ele['cid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_CATEGORY_DESC : ''));
1100 1100
         if ($GLOBALS['songlistModuleConfig']['genre']) {
1101
-            $ele['gids'] = new SelectGenreForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_GENRE : ''), $id . '[gids]', ($_REQUEST['gids'] ?? $object->getVar('gids')), 8, true);
1101
+            $ele['gids'] = new SelectGenreForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_GENRE : ''), $id.'[gids]', ($_REQUEST['gids'] ?? $object->getVar('gids')), 8, true);
1102 1102
             $ele['gids']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_GENRE_DESC : ''));
1103 1103
         }
1104 1104
         if ($GLOBALS['songlistModuleConfig']['voice']) {
1105
-            $ele['vcid'] = new SelectVoiceForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_VOICE : ''), $id . '[vcid]', ($_REQUEST['vcid'] ?? $object->getVar('vcid')), 1, false);
1105
+            $ele['vcid'] = new SelectVoiceForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_VOICE : ''), $id.'[vcid]', ($_REQUEST['vcid'] ?? $object->getVar('vcid')), 1, false);
1106 1106
             $ele['vcid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_VOICE_DESC : ''));
1107 1107
         }
1108 1108
         if ($GLOBALS['songlistModuleConfig']['album']) {
1109
-            $ele['abid'] = new SelectAlbumForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ALBUM : ''), $id . '[abid]', $object->getVar('abid'), 1, false);
1109
+            $ele['abid'] = new SelectAlbumForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ALBUM : ''), $id.'[abid]', $object->getVar('abid'), 1, false);
1110 1110
             $ele['abid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ALBUM_DESC : ''));
1111 1111
         }
1112
-        $ele['aids'] = new SelectArtistForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ARTISTS : ''), $id . '[aids]', $object->getVar('aids'), 7, true);
1112
+        $ele['aids'] = new SelectArtistForm((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ARTISTS : ''), $id.'[aids]', $object->getVar('aids'), 7, true);
1113 1113
         $ele['aids']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_ARTISTS_DESC : ''));
1114
-        $ele['songid'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_SONGS_SONGID : ''), $id . '[songid]', (!$as_array ? 25 : 15), 32, $object->getVar('songid'));
1114
+        $ele['songid'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_SONGS_SONGID : ''), $id.'[songid]', (!$as_array ? 25 : 15), 32, $object->getVar('songid'));
1115 1115
         $ele['songid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_SONGID_DESC : ''));
1116
-        $ele['traxid'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TRAXID : ''), $id . '[traxid]', (!$as_array ? 25 : 15), 32, $object->getVar('traxid'));
1116
+        $ele['traxid'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TRAXID : ''), $id.'[traxid]', (!$as_array ? 25 : 15), 32, $object->getVar('traxid'));
1117 1117
         $ele['traxid']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TRAXID_DESC : ''));
1118
-        $ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TITLE : ''), $id . '[title]', (!$as_array ? 55 : 21), 128, $object->getVar('title'));
1118
+        $ele['title'] = new \XoopsFormText((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TITLE : ''), $id.'[title]', (!$as_array ? 55 : 21), 128, $object->getVar('title'));
1119 1119
         $ele['title']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_TITLE_DESC : ''));
1120 1120
         $description_configs           = [];
1121
-        $description_configs['name']   = $id . '[lyrics]';
1121
+        $description_configs['name']   = $id.'[lyrics]';
1122 1122
         $description_configs['value']  = $object->getVar('lyrics');
1123 1123
         $description_configs['rows']   = 35;
1124 1124
         $description_configs['cols']   = 60;
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
         $description_configs['height'] = '400px';
1127 1127
         $ele['lyrics']                 = new \XoopsFormEditor(_FRM_SONGLIST_FORM_SONGS_LYRICS, $GLOBALS['songlistModuleConfig']['editor'], $description_configs);
1128 1128
         $ele['lyrics']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_LYRICS_DESC : ''));
1129
-        $ele['mp3'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_SONGS_MP3 : ''), 'mp3' . $id, $GLOBALS['songlistModuleConfig']['mp3_filesize']);
1129
+        $ele['mp3'] = new \XoopsFormFile((!$as_array ? _FRM_SONGLIST_FORM_SONGS_MP3 : ''), 'mp3'.$id, $GLOBALS['songlistModuleConfig']['mp3_filesize']);
1130 1130
         $ele['mp3']->setDescription((!$as_array ? _FRM_SONGLIST_FORM_SONGS_MP3_DESC : ''));
1131 1131
         $categoryHandler = Helper::getInstance()
1132 1132
                                  ->getHandler('Category');
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
         $required = [];
1156 1156
         $elements = [];
1157 1157
         $weights  = [];
1158
-        if ($object->getVar('sid') > 0) {
1158
+        if ($object->getVar('sid')>0) {
1159 1159
             $extra = $extrasHandler->get($object->getVar('sid'));
1160 1160
         } else {
1161 1161
             $extra = $extrasHandler->create();
@@ -1163,23 +1163,23 @@  discard block
 block discarded – undo
1163 1163
         $allnames = [];
1164 1164
         if (is_array($fields)) {
1165 1165
             foreach (array_keys($fields) as $i) {
1166
-                if ((0 != $object->getVar('sid') && $grouppermHandler->checkRight('songlist_edit', $fields[$i]->getVar('field_id'), $groups, $modid))
1167
-                    || (0 == $object->getVar('sid') && $grouppermHandler->checkRight('songlist_post', $fields[$i]->getVar('field_id'), $groups, $modid))) {
1166
+                if ((0!=$object->getVar('sid') && $grouppermHandler->checkRight('songlist_edit', $fields[$i]->getVar('field_id'), $groups, $modid))
1167
+                    || (0==$object->getVar('sid') && $grouppermHandler->checkRight('songlist_post', $fields[$i]->getVar('field_id'), $groups, $modid))) {
1168 1168
                     $fieldinfo['element']  = $fields[$i]->getEditElement($object, $extra);
1169 1169
                     $fieldinfo['required'] = $fields[$i]->getVar('field_required');
1170 1170
                     foreach ($fields[$i]->getVar('cids') as $catidid => $cid) {
1171 1171
                         if (!in_array($fields[$i]->getVar('field_name'), $allnames, true)) {
1172 1172
                             $allnames[] = $fields[$i]->getVar('field_name');
1173 1173
                             if (array_key_exists($cid, $all_categories)
1174
-                                || $cid == (!empty($_REQUEST['cid'])
1174
+                                || $cid==(!empty($_REQUEST['cid'])
1175 1175
                                     ? Request::getInt('cid', 0, 'REQUEST')
1176 1176
                                     : $object->getVar('cid'))) {
1177 1177
                                 $key              = (isset($all_categories[$cid]) ? $all_categories[$cid]['weight'] : 0)
1178
-                                                    * $count_fields + $object->getVar('cid');
1178
+                                                    * $count_fields+$object->getVar('cid');
1179 1179
                                 $elements[$key][] = $fieldinfo;
1180 1180
                                 $weights[$key][]  = $fields[$i]->getVar('field_weight');
1181 1181
                             } elseif (in_array(0, $fields[$i]->getVar('cids'), true)) {
1182
-                                $key              = (isset($all_categories[$cid]) ? $all_categories[$cid]['weight'] : 0) * $count_fields + $object->getVar('cid');
1182
+                                $key              = (isset($all_categories[$cid]) ? $all_categories[$cid]['weight'] : 0)*$count_fields+$object->getVar('cid');
1183 1183
                                 $elements[$key][] = $fieldinfo;
1184 1184
                                 $weights[$key][]  = $fields[$i]->getVar('field_weight');
1185 1185
                             }
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
                 array_multisort($weights[$k], SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]);
1195 1195
                 foreach (array_keys($elements[$k]) as $i) {
1196 1196
                     $ele[$k] = $elements[$k][$i]['element'];
1197
-                    if (true === $elements[$k][$i]['required']) {
1197
+                    if (true===$elements[$k][$i]['required']) {
1198 1198
                         $required[$k] = $elements[$k][$i]['element']->getName();
1199 1199
                     }
1200 1200
                 }
@@ -1208,11 +1208,11 @@  discard block
 block discarded – undo
1208 1208
         }
1209 1209
 
1210 1210
         $ele['hits'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_SONGS_HITS : ''), $object->getVar('hits'));
1211
-        $ele['rank'] = new \XoopsFormLabel((!$as_array ? _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');
1212
-        if ($object->getVar('created') > 0) {
1211
+        $ele['rank'] = new \XoopsFormLabel((!$as_array ? _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');
1212
+        if ($object->getVar('created')>0) {
1213 1213
             $ele['created'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_SONGS_CREATED : ''), date(_DATESTRING, $object->getVar('created')));
1214 1214
         }
1215
-        if ($object->getVar('updated') > 0) {
1215
+        if ($object->getVar('updated')>0) {
1216 1216
             $ele['updated'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_SONGS_UPDATED : ''), date(_DATESTRING, $object->getVar('updated')));
1217 1217
         }
1218 1218
         if ($as_array) {
@@ -1268,12 +1268,12 @@  discard block
 block discarded – undo
1268 1268
         if ($as_array) {
1269 1269
             $ele['id'] = new \XoopsFormHidden('id', $id);
1270 1270
         } else {
1271
-            $ele['id'] = new \XoopsFormHidden('id[' . $id . ']', $id);
1271
+            $ele['id'] = new \XoopsFormHidden('id['.$id.']', $id);
1272 1272
         }
1273 1273
         $ele['sort']   = new \XoopsFormHidden('sort', $_REQUEST['sort'] ?? 'created');
1274 1274
         $ele['order']  = new \XoopsFormHidden('order', $_REQUEST['order'] ?? 'DESC');
1275
-        $ele['start']  = new \XoopsFormHidden('start', (string)Request::getInt('start', 0, 'REQUEST'));
1276
-        $ele['limit']  = new \XoopsFormHidden('limit', (string)Request::getInt('limit', 0, 'REQUEST'));
1275
+        $ele['start']  = new \XoopsFormHidden('start', (string) Request::getInt('start', 0, 'REQUEST'));
1276
+        $ele['limit']  = new \XoopsFormHidden('limit', (string) Request::getInt('limit', 0, 'REQUEST'));
1277 1277
         $ele['filter'] = new \XoopsFormHidden('filter', $_REQUEST['filter'] ?? '1,1');
1278 1278
 
1279 1279
         $songsHandler = Helper::getInstance()
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
         }
1294 1294
         $ele['ip']      = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_IP : ''), $object->getVar('ip'));
1295 1295
         $ele['netaddy'] = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_NETADDY : ''), $object->getVar('netaddy'));
1296
-        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_RANK : ''), $object->getVar('rank') . ' of 10');
1296
+        $ele['rank']    = new \XoopsFormLabel((!$as_array ? _FRM_SONGLIST_FORM_VOTES_RANK : ''), $object->getVar('rank').' of 10');
1297 1297
 
1298 1298
         if ($as_array) {
1299 1299
             return $ele;
Please login to merge, or discard this patch.