@@ -10,84 +10,84 @@ discard block |
||
10 | 10 | |
11 | 11 | $op = (!empty($_GET['op']) ? $_GET['op'] : (!empty($_POST['op']) ? $_POST['op'] : (!empty($_REQUEST['id']) ? 'edit' : 'list'))); |
12 | 12 | $fieldHandler = Helper::getInstance() |
13 | - ->getHandler('Field'); |
|
13 | + ->getHandler('Field'); |
|
14 | 14 | switch ($op) { |
15 | - default: |
|
16 | - case 'list': |
|
17 | - $adminObject = Admin::getInstance(); |
|
18 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
15 | + default: |
|
16 | + case 'list': |
|
17 | + $adminObject = Admin::getInstance(); |
|
18 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
19 | 19 | |
20 | - $fields = $fieldHandler->getObjects(null, false, false); |
|
20 | + $fields = $fieldHandler->getObjects(null, false, false); |
|
21 | 21 | |
22 | - /** @var \XoopsModuleHandler $moduleHandler */ |
|
23 | - $moduleHandler = xoops_getHandler('module'); |
|
24 | - $modules = $moduleHandler->getObjects(null, true); |
|
22 | + /** @var \XoopsModuleHandler $moduleHandler */ |
|
23 | + $moduleHandler = xoops_getHandler('module'); |
|
24 | + $modules = $moduleHandler->getObjects(null, true); |
|
25 | 25 | |
26 | - $categories = []; |
|
27 | - $weights = []; |
|
26 | + $categories = []; |
|
27 | + $weights = []; |
|
28 | 28 | |
29 | - $GLOBALS['categoryHandler'] = Helper::getInstance() |
|
30 | - ->getHandler('Category'); |
|
31 | - $criteria = new \CriteriaCompo(); |
|
32 | - $criteria->setSort('weight'); |
|
33 | - $category = $GLOBALS['categoryHandler']->getObjects($criteria, true); |
|
34 | - $fieldcategories = []; |
|
35 | - if ($category) { |
|
36 | - unset($criteria); |
|
29 | + $GLOBALS['categoryHandler'] = Helper::getInstance() |
|
30 | + ->getHandler('Category'); |
|
31 | + $criteria = new \CriteriaCompo(); |
|
32 | + $criteria->setSort('weight'); |
|
33 | + $category = $GLOBALS['categoryHandler']->getObjects($criteria, true); |
|
34 | + $fieldcategories = []; |
|
35 | + if ($category) { |
|
36 | + unset($criteria); |
|
37 | 37 | |
38 | - $categories[0] = ['cid' => 0, 'name' => _AM_SONGLIST_FIELDS_DEFAULT]; |
|
39 | - if (count($category) > 0) { |
|
40 | - foreach (array_keys($category) as $i) { |
|
41 | - $categories[$category[$i]->getVar('cid')] = ['cid' => $category[$i]->getVar('cid'), 'name' => $category[$i]->getVar('name')]; |
|
42 | - } |
|
43 | - } |
|
44 | - $GLOBALS['xoopsTpl']->assign('categories', $categories); |
|
45 | - } |
|
38 | + $categories[0] = ['cid' => 0, 'name' => _AM_SONGLIST_FIELDS_DEFAULT]; |
|
39 | + if (count($category) > 0) { |
|
40 | + foreach (array_keys($category) as $i) { |
|
41 | + $categories[$category[$i]->getVar('cid')] = ['cid' => $category[$i]->getVar('cid'), 'name' => $category[$i]->getVar('name')]; |
|
42 | + } |
|
43 | + } |
|
44 | + $GLOBALS['xoopsTpl']->assign('categories', $categories); |
|
45 | + } |
|
46 | 46 | |
47 | - $valuetypes = [ |
|
48 | - XOBJ_DTYPE_ARRAY => _AM_SONGLIST_FIELDS_ARRAY, |
|
49 | - XOBJ_DTYPE_EMAIL => _AM_SONGLIST_FIELDS_EMAIL, |
|
50 | - XOBJ_DTYPE_INT => _AM_SONGLIST_FIELDS_INT, |
|
51 | - XOBJ_DTYPE_TXTAREA => _AM_SONGLIST_FIELDS_TXTAREA, |
|
52 | - XOBJ_DTYPE_TXTBOX => _AM_SONGLIST_FIELDS_TXTBOX, |
|
53 | - XOBJ_DTYPE_URL => _AM_SONGLIST_FIELDS_URL, |
|
54 | - XOBJ_DTYPE_OTHER => _AM_SONGLIST_FIELDS_OTHER, |
|
55 | - XOBJ_DTYPE_MTIME => _AM_SONGLIST_FIELDS_DATE, |
|
56 | - ]; |
|
47 | + $valuetypes = [ |
|
48 | + XOBJ_DTYPE_ARRAY => _AM_SONGLIST_FIELDS_ARRAY, |
|
49 | + XOBJ_DTYPE_EMAIL => _AM_SONGLIST_FIELDS_EMAIL, |
|
50 | + XOBJ_DTYPE_INT => _AM_SONGLIST_FIELDS_INT, |
|
51 | + XOBJ_DTYPE_TXTAREA => _AM_SONGLIST_FIELDS_TXTAREA, |
|
52 | + XOBJ_DTYPE_TXTBOX => _AM_SONGLIST_FIELDS_TXTBOX, |
|
53 | + XOBJ_DTYPE_URL => _AM_SONGLIST_FIELDS_URL, |
|
54 | + XOBJ_DTYPE_OTHER => _AM_SONGLIST_FIELDS_OTHER, |
|
55 | + XOBJ_DTYPE_MTIME => _AM_SONGLIST_FIELDS_DATE, |
|
56 | + ]; |
|
57 | 57 | |
58 | - $fieldtypes = [ |
|
59 | - 'checkbox' => _AM_SONGLIST_FIELDS_CHECKBOX, |
|
60 | - 'group' => _AM_SONGLIST_FIELDS_GROUP, |
|
61 | - 'group_multi' => _AM_SONGLIST_FIELDS_GROUPMULTI, |
|
62 | - 'language' => _AM_SONGLIST_FIELDS_LANGUAGE, |
|
63 | - 'radio' => _AM_SONGLIST_FIELDS_RADIO, |
|
64 | - 'select' => _AM_SONGLIST_FIELDS_SELECT, |
|
65 | - 'select_multi' => _AM_SONGLIST_FIELDS_SELECTMULTI, |
|
66 | - 'textarea' => _AM_SONGLIST_FIELDS_TEXTAREA, |
|
67 | - 'dhtml' => _AM_SONGLIST_FIELDS_DHTMLTEXTAREA, |
|
68 | - 'editor' => _AM_SONGLIST_FIELDS_EDITOR, |
|
69 | - 'textbox' => _AM_SONGLIST_FIELDS_TEXTBOX, |
|
70 | - 'timezone' => _AM_SONGLIST_FIELDS_TIMEZONE, |
|
71 | - 'yesno' => _AM_SONGLIST_FIELDS_YESNO, |
|
72 | - 'date' => _AM_SONGLIST_FIELDS_DATE, |
|
73 | - 'datetime' => _AM_SONGLIST_FIELDS_DATETIME, |
|
74 | - 'longdate' => _AM_SONGLIST_FIELDS_LONGDATE, |
|
75 | - 'theme' => _AM_SONGLIST_FIELDS_THEME, |
|
76 | - 'autotext' => _AM_SONGLIST_FIELDS_AUTOTEXT, |
|
77 | - 'rank' => _AM_SONGLIST_FIELDS_RANK, |
|
78 | - ]; |
|
58 | + $fieldtypes = [ |
|
59 | + 'checkbox' => _AM_SONGLIST_FIELDS_CHECKBOX, |
|
60 | + 'group' => _AM_SONGLIST_FIELDS_GROUP, |
|
61 | + 'group_multi' => _AM_SONGLIST_FIELDS_GROUPMULTI, |
|
62 | + 'language' => _AM_SONGLIST_FIELDS_LANGUAGE, |
|
63 | + 'radio' => _AM_SONGLIST_FIELDS_RADIO, |
|
64 | + 'select' => _AM_SONGLIST_FIELDS_SELECT, |
|
65 | + 'select_multi' => _AM_SONGLIST_FIELDS_SELECTMULTI, |
|
66 | + 'textarea' => _AM_SONGLIST_FIELDS_TEXTAREA, |
|
67 | + 'dhtml' => _AM_SONGLIST_FIELDS_DHTMLTEXTAREA, |
|
68 | + 'editor' => _AM_SONGLIST_FIELDS_EDITOR, |
|
69 | + 'textbox' => _AM_SONGLIST_FIELDS_TEXTBOX, |
|
70 | + 'timezone' => _AM_SONGLIST_FIELDS_TIMEZONE, |
|
71 | + 'yesno' => _AM_SONGLIST_FIELDS_YESNO, |
|
72 | + 'date' => _AM_SONGLIST_FIELDS_DATE, |
|
73 | + 'datetime' => _AM_SONGLIST_FIELDS_DATETIME, |
|
74 | + 'longdate' => _AM_SONGLIST_FIELDS_LONGDATE, |
|
75 | + 'theme' => _AM_SONGLIST_FIELDS_THEME, |
|
76 | + 'autotext' => _AM_SONGLIST_FIELDS_AUTOTEXT, |
|
77 | + 'rank' => _AM_SONGLIST_FIELDS_RANK, |
|
78 | + ]; |
|
79 | 79 | |
80 | - foreach (array_keys($fields) as $i) { |
|
81 | - $fields[$i]['canEdit'] = $fields[$i]['field_config'] || $fields[$i]['field_show'] || $fields[$i]['field_edit']; |
|
82 | - $fields[$i]['canDelete'] = $fields[$i]['field_config']; |
|
83 | - $fields[$i]['fieldtype'] = $fieldtypes[$fields[$i]['field_type']]; |
|
84 | - $fields[$i]['valuetype'] = $valuetypes[$fields[$i]['field_valuetype']]; |
|
85 | - $fieldcategories[$i][] = $fields[$i]; |
|
86 | - $weights[$i] = $fields[$i]['field_weight']; |
|
87 | - } |
|
88 | - //sort fields order in categories |
|
80 | + foreach (array_keys($fields) as $i) { |
|
81 | + $fields[$i]['canEdit'] = $fields[$i]['field_config'] || $fields[$i]['field_show'] || $fields[$i]['field_edit']; |
|
82 | + $fields[$i]['canDelete'] = $fields[$i]['field_config']; |
|
83 | + $fields[$i]['fieldtype'] = $fieldtypes[$fields[$i]['field_type']]; |
|
84 | + $fields[$i]['valuetype'] = $valuetypes[$fields[$i]['field_valuetype']]; |
|
85 | + $fieldcategories[$i][] = $fields[$i]; |
|
86 | + $weights[$i] = $fields[$i]['field_weight']; |
|
87 | + } |
|
88 | + //sort fields order in categories |
|
89 | 89 | // ray('$fields', $fields); |
90 | - foreach (array_keys($fields) as $i) { |
|
90 | + foreach (array_keys($fields) as $i) { |
|
91 | 91 | // ray('$i = ' . $i)->red(); |
92 | 92 | // ray('$weights: <br>' , $weights)->red(); |
93 | 93 | // ray('$fieldcategories: <br>' , $fieldcategories)->red(); |
@@ -95,237 +95,237 @@ discard block |
||
95 | 95 | // ray('$categories: <br>', $categories)->red(); |
96 | 96 | // ray('$categories[$i]: <br>', $categories[$i])->red(); |
97 | 97 | |
98 | - array_multisort( |
|
99 | - $weights |
|
100 | - , |
|
101 | - SORT_ASC |
|
102 | - , |
|
103 | - array_keys($fieldcategories) |
|
104 | - , |
|
105 | - SORT_ASC |
|
106 | - , |
|
107 | - $categories[$i] |
|
108 | - ); |
|
98 | + array_multisort( |
|
99 | + $weights |
|
100 | + , |
|
101 | + SORT_ASC |
|
102 | + , |
|
103 | + array_keys($fieldcategories) |
|
104 | + , |
|
105 | + SORT_ASC |
|
106 | + , |
|
107 | + $categories[$i] |
|
108 | + ); |
|
109 | 109 | // ray($i)->blue(); |
110 | 110 | // ray('$weights: <br>', $weights)->blue(); |
111 | 111 | // ray('$fieldcategories: <br>', $fieldcategories)->blue(); |
112 | 112 | // ray(array_keys($fieldcategories))->blue(); |
113 | 113 | // ray('Categories: <br>', $categories)->blue(); |
114 | 114 | // ray('$categories[$i]: <br>', $categories[$i])->blue(); |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | - ksort($categories); |
|
118 | - $GLOBALS['xoopsTpl']->assign('fieldcategories', $fieldcategories); |
|
119 | - $GLOBALS['xoopsTpl']->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML()); |
|
120 | - $template_main = 'songlist_cpanel_fieldlist.tpl'; |
|
121 | - break; |
|
122 | - case 'new': |
|
123 | - $adminObject = Admin::getInstance(); |
|
124 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
125 | - $obj = $fieldHandler->create(); |
|
126 | - $form = FormController::getFieldForm($obj); |
|
127 | - $form->display(); |
|
128 | - break; |
|
129 | - case 'edit': |
|
130 | - $adminObject = Admin::getInstance(); |
|
131 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
132 | - $obj = $fieldHandler->get($_REQUEST['id']); |
|
133 | - if (!$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit')) { //If no configs exist |
|
134 | - redirect_header('field.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
135 | - } |
|
136 | - $form = FormController::getFieldForm($obj); |
|
137 | - $form->display(); |
|
138 | - break; |
|
139 | - case 'reorder': |
|
140 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
141 | - redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
142 | - } |
|
117 | + ksort($categories); |
|
118 | + $GLOBALS['xoopsTpl']->assign('fieldcategories', $fieldcategories); |
|
119 | + $GLOBALS['xoopsTpl']->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML()); |
|
120 | + $template_main = 'songlist_cpanel_fieldlist.tpl'; |
|
121 | + break; |
|
122 | + case 'new': |
|
123 | + $adminObject = Admin::getInstance(); |
|
124 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
125 | + $obj = $fieldHandler->create(); |
|
126 | + $form = FormController::getFieldForm($obj); |
|
127 | + $form->display(); |
|
128 | + break; |
|
129 | + case 'edit': |
|
130 | + $adminObject = Admin::getInstance(); |
|
131 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
132 | + $obj = $fieldHandler->get($_REQUEST['id']); |
|
133 | + if (!$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit')) { //If no configs exist |
|
134 | + redirect_header('field.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
135 | + } |
|
136 | + $form = FormController::getFieldForm($obj); |
|
137 | + $form->display(); |
|
138 | + break; |
|
139 | + case 'reorder': |
|
140 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
141 | + redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
142 | + } |
|
143 | 143 | |
144 | - if (Request::hasVar('field_ids', 'POST') && count($_POST['field_ids']) > 0) { |
|
145 | - $oldweight = $_POST['oldweight']; |
|
146 | - $oldcat = $_POST['oldcat']; |
|
147 | - $oldcategories = $_POST['oldcategories']; |
|
148 | - $categories = $_POST['categories']; |
|
149 | - $weight = $_POST['weight']; |
|
150 | - $ids = []; |
|
151 | - foreach ($_POST['field_ids'] as $field_id) { |
|
152 | - if ($oldweight[$field_id] != $weight[$field_id] || $oldcat[$field_id] != $category[$field_id] || count($oldcategories[$field_id]) != count(array_unique(array_merge($categories[$field_id], $oldcategories[$field_id])))) { |
|
153 | - //if field has changed |
|
154 | - $ids[] = (int)$field_id; |
|
155 | - } |
|
156 | - } |
|
157 | - if (count($ids) > 0) { |
|
158 | - $errors = []; |
|
159 | - //if there are changed fields, fetch the fieldcategory objects |
|
160 | - $fieldHandler = Helper::getInstance() |
|
161 | - ->getHandler('Field'); |
|
162 | - $fields = $fieldHandler->getObjects(new \Criteria('field_id', '(' . implode(',', $ids) . ')', 'IN'), true); |
|
163 | - foreach ($ids as $i) { |
|
164 | - $fields[$i]->setVar('field_weight', (int)$weight[$i]); |
|
165 | - $fields[$i]->setVar('cids', $categories[$i]); |
|
166 | - if (!$fieldHandler->insert($fields[$i])) { |
|
167 | - $errors = array_merge($errors, $fields[$i]->getErrors()); |
|
168 | - } |
|
169 | - } |
|
170 | - if (0 == count($errors)) { |
|
171 | - //no errors |
|
172 | - redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS)); |
|
173 | - } else { |
|
174 | - redirect_header('field.php', 3, implode('<br>', $errors)); |
|
175 | - } |
|
176 | - } |
|
177 | - } |
|
178 | - redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS)); |
|
179 | - break; |
|
180 | - case 'save': |
|
181 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
182 | - redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
183 | - } |
|
184 | - $redirect_to_edit = false; |
|
185 | - if (Request::hasVar('id', 'REQUEST')) { |
|
186 | - $obj = $fieldHandler->get($_REQUEST['id']); |
|
187 | - if (!$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit')) { //If no configs exist |
|
188 | - redirect_header('fields.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
189 | - } |
|
190 | - } else { |
|
191 | - $obj = $fieldHandler->create(); |
|
192 | - $obj->setVar('field_name', $_REQUEST['field_name']); |
|
193 | - $obj->setVar('field_moduleid', $GLOBALS['songlistModule']->getVar('mid')); |
|
194 | - $obj->setVar('field_show', 1); |
|
195 | - $obj->setVar('field_edit', 1); |
|
196 | - $obj->setVar('field_config', 1); |
|
197 | - $redirect_to_edit = true; |
|
198 | - } |
|
199 | - $obj->setVar('field_title', $_REQUEST['field_title']); |
|
200 | - $obj->setVar('field_description', $_REQUEST['field_description']); |
|
201 | - if ($obj->getVar('field_config')) { |
|
202 | - $obj->setVar('field_type', $_REQUEST['field_type']); |
|
203 | - if (Request::hasVar('field_valuetype', 'REQUEST')) { |
|
204 | - $obj->setVar('field_valuetype', $_REQUEST['field_valuetype']); |
|
205 | - } |
|
206 | - $options = $obj->getVar('field_options'); |
|
144 | + if (Request::hasVar('field_ids', 'POST') && count($_POST['field_ids']) > 0) { |
|
145 | + $oldweight = $_POST['oldweight']; |
|
146 | + $oldcat = $_POST['oldcat']; |
|
147 | + $oldcategories = $_POST['oldcategories']; |
|
148 | + $categories = $_POST['categories']; |
|
149 | + $weight = $_POST['weight']; |
|
150 | + $ids = []; |
|
151 | + foreach ($_POST['field_ids'] as $field_id) { |
|
152 | + if ($oldweight[$field_id] != $weight[$field_id] || $oldcat[$field_id] != $category[$field_id] || count($oldcategories[$field_id]) != count(array_unique(array_merge($categories[$field_id], $oldcategories[$field_id])))) { |
|
153 | + //if field has changed |
|
154 | + $ids[] = (int)$field_id; |
|
155 | + } |
|
156 | + } |
|
157 | + if (count($ids) > 0) { |
|
158 | + $errors = []; |
|
159 | + //if there are changed fields, fetch the fieldcategory objects |
|
160 | + $fieldHandler = Helper::getInstance() |
|
161 | + ->getHandler('Field'); |
|
162 | + $fields = $fieldHandler->getObjects(new \Criteria('field_id', '(' . implode(',', $ids) . ')', 'IN'), true); |
|
163 | + foreach ($ids as $i) { |
|
164 | + $fields[$i]->setVar('field_weight', (int)$weight[$i]); |
|
165 | + $fields[$i]->setVar('cids', $categories[$i]); |
|
166 | + if (!$fieldHandler->insert($fields[$i])) { |
|
167 | + $errors = array_merge($errors, $fields[$i]->getErrors()); |
|
168 | + } |
|
169 | + } |
|
170 | + if (0 == count($errors)) { |
|
171 | + //no errors |
|
172 | + redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS)); |
|
173 | + } else { |
|
174 | + redirect_header('field.php', 3, implode('<br>', $errors)); |
|
175 | + } |
|
176 | + } |
|
177 | + } |
|
178 | + redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS)); |
|
179 | + break; |
|
180 | + case 'save': |
|
181 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
182 | + redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
183 | + } |
|
184 | + $redirect_to_edit = false; |
|
185 | + if (Request::hasVar('id', 'REQUEST')) { |
|
186 | + $obj = $fieldHandler->get($_REQUEST['id']); |
|
187 | + if (!$obj->getVar('field_config') && !$obj->getVar('field_show') && !$obj->getVar('field_edit')) { //If no configs exist |
|
188 | + redirect_header('fields.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
189 | + } |
|
190 | + } else { |
|
191 | + $obj = $fieldHandler->create(); |
|
192 | + $obj->setVar('field_name', $_REQUEST['field_name']); |
|
193 | + $obj->setVar('field_moduleid', $GLOBALS['songlistModule']->getVar('mid')); |
|
194 | + $obj->setVar('field_show', 1); |
|
195 | + $obj->setVar('field_edit', 1); |
|
196 | + $obj->setVar('field_config', 1); |
|
197 | + $redirect_to_edit = true; |
|
198 | + } |
|
199 | + $obj->setVar('field_title', $_REQUEST['field_title']); |
|
200 | + $obj->setVar('field_description', $_REQUEST['field_description']); |
|
201 | + if ($obj->getVar('field_config')) { |
|
202 | + $obj->setVar('field_type', $_REQUEST['field_type']); |
|
203 | + if (Request::hasVar('field_valuetype', 'REQUEST')) { |
|
204 | + $obj->setVar('field_valuetype', $_REQUEST['field_valuetype']); |
|
205 | + } |
|
206 | + $options = $obj->getVar('field_options'); |
|
207 | 207 | |
208 | - if (Request::hasVar('removeOptions', 'REQUEST') && is_array($_REQUEST['removeOptions'])) { |
|
209 | - foreach ($_REQUEST['removeOptions'] as $index) { |
|
210 | - unset($options[$index]); |
|
211 | - } |
|
212 | - $redirect_to_edit = true; |
|
213 | - } |
|
208 | + if (Request::hasVar('removeOptions', 'REQUEST') && is_array($_REQUEST['removeOptions'])) { |
|
209 | + foreach ($_REQUEST['removeOptions'] as $index) { |
|
210 | + unset($options[$index]); |
|
211 | + } |
|
212 | + $redirect_to_edit = true; |
|
213 | + } |
|
214 | 214 | |
215 | - if (Request::hasVar('addOption', 'REQUEST')) { |
|
216 | - foreach ($_REQUEST['addOption'] as $option) { |
|
217 | - if (empty($option['value'])) { |
|
218 | - continue; |
|
219 | - } |
|
220 | - $options[$option['key']] = $option['value']; |
|
221 | - $redirect_to_edit = true; |
|
222 | - } |
|
223 | - } |
|
224 | - $obj->setVar('field_options', $options); |
|
225 | - } |
|
226 | - if ($obj->getVar('field_edit')) { |
|
227 | - $required = Request::getInt('field_required', 0, 'REQUEST'); |
|
228 | - $obj->setVar('field_required', $required); //0 = no, 1 = yes |
|
229 | - if (Request::hasVar('field_maxlength', 'REQUEST')) { |
|
230 | - $obj->setVar('field_maxlength', $_REQUEST['field_maxlength']); |
|
231 | - } |
|
232 | - if (Request::hasVar('field_default', 'REQUEST')) { |
|
233 | - $field_default = $obj->getValueForSave($_REQUEST['field_default']); |
|
234 | - //Check for multiple selections |
|
235 | - if (is_array($field_default)) { |
|
236 | - $obj->setVar('field_default', serialize($field_default)); |
|
237 | - } else { |
|
238 | - $obj->setVar('field_default', $field_default); |
|
239 | - } |
|
240 | - } |
|
241 | - } |
|
215 | + if (Request::hasVar('addOption', 'REQUEST')) { |
|
216 | + foreach ($_REQUEST['addOption'] as $option) { |
|
217 | + if (empty($option['value'])) { |
|
218 | + continue; |
|
219 | + } |
|
220 | + $options[$option['key']] = $option['value']; |
|
221 | + $redirect_to_edit = true; |
|
222 | + } |
|
223 | + } |
|
224 | + $obj->setVar('field_options', $options); |
|
225 | + } |
|
226 | + if ($obj->getVar('field_edit')) { |
|
227 | + $required = Request::getInt('field_required', 0, 'REQUEST'); |
|
228 | + $obj->setVar('field_required', $required); //0 = no, 1 = yes |
|
229 | + if (Request::hasVar('field_maxlength', 'REQUEST')) { |
|
230 | + $obj->setVar('field_maxlength', $_REQUEST['field_maxlength']); |
|
231 | + } |
|
232 | + if (Request::hasVar('field_default', 'REQUEST')) { |
|
233 | + $field_default = $obj->getValueForSave($_REQUEST['field_default']); |
|
234 | + //Check for multiple selections |
|
235 | + if (is_array($field_default)) { |
|
236 | + $obj->setVar('field_default', serialize($field_default)); |
|
237 | + } else { |
|
238 | + $obj->setVar('field_default', $field_default); |
|
239 | + } |
|
240 | + } |
|
241 | + } |
|
242 | 242 | |
243 | - $obj->setVar('field_weight', $_REQUEST['field_weight']); |
|
244 | - $obj->setVar('cids', $_REQUEST['cids']); |
|
243 | + $obj->setVar('field_weight', $_REQUEST['field_weight']); |
|
244 | + $obj->setVar('cids', $_REQUEST['cids']); |
|
245 | 245 | |
246 | - if ($fieldHandler->insert($obj)) { |
|
247 | - /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
248 | - $grouppermHandler = xoops_getHandler('groupperm'); |
|
246 | + if ($fieldHandler->insert($obj)) { |
|
247 | + /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
248 | + $grouppermHandler = xoops_getHandler('groupperm'); |
|
249 | 249 | |
250 | - $perm_arr = []; |
|
251 | - if ($obj->getVar('field_show')) { |
|
252 | - $perm_arr[] = 'songlist_show'; |
|
253 | - $perm_arr[] = 'songlist_visible'; |
|
254 | - } |
|
255 | - if ($obj->getVar('field_edit')) { |
|
256 | - $perm_arr[] = 'songlist_edit'; |
|
257 | - } |
|
258 | - if ($obj->getVar('field_edit') || $obj->getVar('field_show')) { |
|
259 | - $perm_arr[] = 'songlist_search'; |
|
260 | - } |
|
261 | - if (count($perm_arr) > 0) { |
|
262 | - foreach ($perm_arr as $perm) { |
|
263 | - $criteria = new \CriteriaCompo(new \Criteria('gperm_name', $perm)); |
|
264 | - $criteria->add(new \Criteria('gperm_itemid', (int)$obj->getVar('field_id'))); |
|
265 | - $criteria->add(new \Criteria('gperm_modid', (int)$GLOBALS['songlistModule']->getVar('mid'))); |
|
266 | - if (isset($_REQUEST[$perm]) && is_array($_REQUEST[$perm])) { |
|
267 | - $perms = $grouppermHandler->getObjects($criteria); |
|
268 | - if (count($perms) > 0) { |
|
269 | - foreach (array_keys($perms) as $i) { |
|
270 | - $groups[$perms[$i]->getVar('gperm_groupid')] = $perms[$i]; |
|
271 | - } |
|
272 | - } else { |
|
273 | - $groups = []; |
|
274 | - } |
|
275 | - foreach ($_REQUEST[$perm] as $grouoid) { |
|
276 | - $grouoid = (int)$grouoid; |
|
277 | - if (!isset($groups[$grouoid])) { |
|
278 | - $perm_obj = $grouppermHandler->create(); |
|
279 | - $perm_obj->setVar('gperm_name', $perm); |
|
280 | - $perm_obj->setVar('gperm_itemid', (int)$obj->getVar('field_id')); |
|
281 | - $perm_obj->setVar('gperm_modid', $GLOBALS['songlistModule']->getVar('mid')); |
|
282 | - $perm_obj->setVar('gperm_groupid', $grouoid); |
|
283 | - $grouppermHandler->insert($perm_obj); |
|
284 | - unset($perm_obj); |
|
285 | - } |
|
286 | - } |
|
287 | - $removed_groups = array_diff(array_keys($groups), $_REQUEST[$perm]); |
|
288 | - if (count($removed_groups) > 0) { |
|
289 | - $criteria->add(new \Criteria('gperm_groupid', '(' . implode(',', $removed_groups) . ')', 'IN')); |
|
290 | - $grouppermHandler->deleteAll($criteria); |
|
291 | - } |
|
292 | - unset($groups); |
|
293 | - } else { |
|
294 | - $grouppermHandler->deleteAll($criteria); |
|
295 | - } |
|
296 | - unset($criteria); |
|
297 | - } |
|
298 | - } |
|
299 | - $url = $redirect_to_edit ? 'field.php?op=edit&id=' . $obj->getVar('field_id') : 'field.php'; |
|
300 | - redirect_header($url, 3, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD)); |
|
301 | - } |
|
250 | + $perm_arr = []; |
|
251 | + if ($obj->getVar('field_show')) { |
|
252 | + $perm_arr[] = 'songlist_show'; |
|
253 | + $perm_arr[] = 'songlist_visible'; |
|
254 | + } |
|
255 | + if ($obj->getVar('field_edit')) { |
|
256 | + $perm_arr[] = 'songlist_edit'; |
|
257 | + } |
|
258 | + if ($obj->getVar('field_edit') || $obj->getVar('field_show')) { |
|
259 | + $perm_arr[] = 'songlist_search'; |
|
260 | + } |
|
261 | + if (count($perm_arr) > 0) { |
|
262 | + foreach ($perm_arr as $perm) { |
|
263 | + $criteria = new \CriteriaCompo(new \Criteria('gperm_name', $perm)); |
|
264 | + $criteria->add(new \Criteria('gperm_itemid', (int)$obj->getVar('field_id'))); |
|
265 | + $criteria->add(new \Criteria('gperm_modid', (int)$GLOBALS['songlistModule']->getVar('mid'))); |
|
266 | + if (isset($_REQUEST[$perm]) && is_array($_REQUEST[$perm])) { |
|
267 | + $perms = $grouppermHandler->getObjects($criteria); |
|
268 | + if (count($perms) > 0) { |
|
269 | + foreach (array_keys($perms) as $i) { |
|
270 | + $groups[$perms[$i]->getVar('gperm_groupid')] = $perms[$i]; |
|
271 | + } |
|
272 | + } else { |
|
273 | + $groups = []; |
|
274 | + } |
|
275 | + foreach ($_REQUEST[$perm] as $grouoid) { |
|
276 | + $grouoid = (int)$grouoid; |
|
277 | + if (!isset($groups[$grouoid])) { |
|
278 | + $perm_obj = $grouppermHandler->create(); |
|
279 | + $perm_obj->setVar('gperm_name', $perm); |
|
280 | + $perm_obj->setVar('gperm_itemid', (int)$obj->getVar('field_id')); |
|
281 | + $perm_obj->setVar('gperm_modid', $GLOBALS['songlistModule']->getVar('mid')); |
|
282 | + $perm_obj->setVar('gperm_groupid', $grouoid); |
|
283 | + $grouppermHandler->insert($perm_obj); |
|
284 | + unset($perm_obj); |
|
285 | + } |
|
286 | + } |
|
287 | + $removed_groups = array_diff(array_keys($groups), $_REQUEST[$perm]); |
|
288 | + if (count($removed_groups) > 0) { |
|
289 | + $criteria->add(new \Criteria('gperm_groupid', '(' . implode(',', $removed_groups) . ')', 'IN')); |
|
290 | + $grouppermHandler->deleteAll($criteria); |
|
291 | + } |
|
292 | + unset($groups); |
|
293 | + } else { |
|
294 | + $grouppermHandler->deleteAll($criteria); |
|
295 | + } |
|
296 | + unset($criteria); |
|
297 | + } |
|
298 | + } |
|
299 | + $url = $redirect_to_edit ? 'field.php?op=edit&id=' . $obj->getVar('field_id') : 'field.php'; |
|
300 | + redirect_header($url, 3, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD)); |
|
301 | + } |
|
302 | 302 | |
303 | - echo $obj->getHtmlErrors(); |
|
304 | - $form = FormController::getFieldForm($obj); |
|
305 | - $form->display(); |
|
306 | - break; |
|
307 | - case 'delete': |
|
308 | - $obj = $fieldHandler->get($_REQUEST['id']); |
|
309 | - if (!$obj->getVar('field_config')) { |
|
310 | - redirect_header('index.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
311 | - } |
|
312 | - if (Request::hasVar('ok', 'REQUEST') && 1 == $_REQUEST['ok']) { |
|
313 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
314 | - redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
315 | - } |
|
316 | - if ($fieldHandler->delete($obj)) { |
|
317 | - redirect_header('field.php', 3, sprintf(_AM_SONGLIST_FIELDS_DELETEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD)); |
|
318 | - } else { |
|
319 | - echo $obj->getHtmlErrors(); |
|
320 | - } |
|
321 | - } else { |
|
322 | - xoops_confirm(['ok' => 1, 'id' => $_REQUEST['id'], 'op' => 'delete'], $_SERVER['REQUEST_URI'], sprintf(_AM_SONGLIST_FIELDS_RUSUREDEL, $obj->getVar('field_title'))); |
|
323 | - } |
|
324 | - break; |
|
303 | + echo $obj->getHtmlErrors(); |
|
304 | + $form = FormController::getFieldForm($obj); |
|
305 | + $form->display(); |
|
306 | + break; |
|
307 | + case 'delete': |
|
308 | + $obj = $fieldHandler->get($_REQUEST['id']); |
|
309 | + if (!$obj->getVar('field_config')) { |
|
310 | + redirect_header('index.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
|
311 | + } |
|
312 | + if (Request::hasVar('ok', 'REQUEST') && 1 == $_REQUEST['ok']) { |
|
313 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
314 | + redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
315 | + } |
|
316 | + if ($fieldHandler->delete($obj)) { |
|
317 | + redirect_header('field.php', 3, sprintf(_AM_SONGLIST_FIELDS_DELETEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD)); |
|
318 | + } else { |
|
319 | + echo $obj->getHtmlErrors(); |
|
320 | + } |
|
321 | + } else { |
|
322 | + xoops_confirm(['ok' => 1, 'id' => $_REQUEST['id'], 'op' => 'delete'], $_SERVER['REQUEST_URI'], sprintf(_AM_SONGLIST_FIELDS_RUSUREDEL, $obj->getVar('field_title'))); |
|
323 | + } |
|
324 | + break; |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | if (isset($template_main)) { |
328 | - $GLOBALS['xoopsTpl']->display("db:{$template_main}"); |
|
328 | + $GLOBALS['xoopsTpl']->display("db:{$template_main}"); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | xoops_cp_footer(); |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use XoopsModules\Songlist\Helper; |
6 | 6 | use XoopsModules\Songlist\Form\FormController; |
7 | 7 | |
8 | -require_once __DIR__ . '/header.php'; |
|
8 | +require_once __DIR__.'/header.php'; |
|
9 | 9 | xoops_cp_header(); |
10 | 10 | |
11 | 11 | $op = (!empty($_GET['op']) ? $_GET['op'] : (!empty($_POST['op']) ? $_POST['op'] : (!empty($_REQUEST['id']) ? 'edit' : 'list'))); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | unset($criteria); |
37 | 37 | |
38 | 38 | $categories[0] = ['cid' => 0, 'name' => _AM_SONGLIST_FIELDS_DEFAULT]; |
39 | - if (count($category) > 0) { |
|
39 | + if (count($category)>0) { |
|
40 | 40 | foreach (array_keys($category) as $i) { |
41 | 41 | $categories[$category[$i]->getVar('cid')] = ['cid' => $category[$i]->getVar('cid'), 'name' => $category[$i]->getVar('name')]; |
42 | 42 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
142 | 142 | } |
143 | 143 | |
144 | - if (Request::hasVar('field_ids', 'POST') && count($_POST['field_ids']) > 0) { |
|
144 | + if (Request::hasVar('field_ids', 'POST') && count($_POST['field_ids'])>0) { |
|
145 | 145 | $oldweight = $_POST['oldweight']; |
146 | 146 | $oldcat = $_POST['oldcat']; |
147 | 147 | $oldcategories = $_POST['oldcategories']; |
@@ -149,25 +149,25 @@ discard block |
||
149 | 149 | $weight = $_POST['weight']; |
150 | 150 | $ids = []; |
151 | 151 | foreach ($_POST['field_ids'] as $field_id) { |
152 | - if ($oldweight[$field_id] != $weight[$field_id] || $oldcat[$field_id] != $category[$field_id] || count($oldcategories[$field_id]) != count(array_unique(array_merge($categories[$field_id], $oldcategories[$field_id])))) { |
|
152 | + if ($oldweight[$field_id]!=$weight[$field_id] || $oldcat[$field_id]!=$category[$field_id] || count($oldcategories[$field_id])!=count(array_unique(array_merge($categories[$field_id], $oldcategories[$field_id])))) { |
|
153 | 153 | //if field has changed |
154 | - $ids[] = (int)$field_id; |
|
154 | + $ids[] = (int) $field_id; |
|
155 | 155 | } |
156 | 156 | } |
157 | - if (count($ids) > 0) { |
|
157 | + if (count($ids)>0) { |
|
158 | 158 | $errors = []; |
159 | 159 | //if there are changed fields, fetch the fieldcategory objects |
160 | 160 | $fieldHandler = Helper::getInstance() |
161 | 161 | ->getHandler('Field'); |
162 | - $fields = $fieldHandler->getObjects(new \Criteria('field_id', '(' . implode(',', $ids) . ')', 'IN'), true); |
|
162 | + $fields = $fieldHandler->getObjects(new \Criteria('field_id', '('.implode(',', $ids).')', 'IN'), true); |
|
163 | 163 | foreach ($ids as $i) { |
164 | - $fields[$i]->setVar('field_weight', (int)$weight[$i]); |
|
164 | + $fields[$i]->setVar('field_weight', (int) $weight[$i]); |
|
165 | 165 | $fields[$i]->setVar('cids', $categories[$i]); |
166 | 166 | if (!$fieldHandler->insert($fields[$i])) { |
167 | 167 | $errors = array_merge($errors, $fields[$i]->getErrors()); |
168 | 168 | } |
169 | 169 | } |
170 | - if (0 == count($errors)) { |
|
170 | + if (0==count($errors)) { |
|
171 | 171 | //no errors |
172 | 172 | redirect_header('field.php', 2, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELDS)); |
173 | 173 | } else { |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | if ($obj->getVar('field_edit') || $obj->getVar('field_show')) { |
259 | 259 | $perm_arr[] = 'songlist_search'; |
260 | 260 | } |
261 | - if (count($perm_arr) > 0) { |
|
261 | + if (count($perm_arr)>0) { |
|
262 | 262 | foreach ($perm_arr as $perm) { |
263 | 263 | $criteria = new \CriteriaCompo(new \Criteria('gperm_name', $perm)); |
264 | - $criteria->add(new \Criteria('gperm_itemid', (int)$obj->getVar('field_id'))); |
|
265 | - $criteria->add(new \Criteria('gperm_modid', (int)$GLOBALS['songlistModule']->getVar('mid'))); |
|
264 | + $criteria->add(new \Criteria('gperm_itemid', (int) $obj->getVar('field_id'))); |
|
265 | + $criteria->add(new \Criteria('gperm_modid', (int) $GLOBALS['songlistModule']->getVar('mid'))); |
|
266 | 266 | if (isset($_REQUEST[$perm]) && is_array($_REQUEST[$perm])) { |
267 | 267 | $perms = $grouppermHandler->getObjects($criteria); |
268 | - if (count($perms) > 0) { |
|
268 | + if (count($perms)>0) { |
|
269 | 269 | foreach (array_keys($perms) as $i) { |
270 | 270 | $groups[$perms[$i]->getVar('gperm_groupid')] = $perms[$i]; |
271 | 271 | } |
@@ -273,11 +273,11 @@ discard block |
||
273 | 273 | $groups = []; |
274 | 274 | } |
275 | 275 | foreach ($_REQUEST[$perm] as $grouoid) { |
276 | - $grouoid = (int)$grouoid; |
|
276 | + $grouoid = (int) $grouoid; |
|
277 | 277 | if (!isset($groups[$grouoid])) { |
278 | 278 | $perm_obj = $grouppermHandler->create(); |
279 | 279 | $perm_obj->setVar('gperm_name', $perm); |
280 | - $perm_obj->setVar('gperm_itemid', (int)$obj->getVar('field_id')); |
|
280 | + $perm_obj->setVar('gperm_itemid', (int) $obj->getVar('field_id')); |
|
281 | 281 | $perm_obj->setVar('gperm_modid', $GLOBALS['songlistModule']->getVar('mid')); |
282 | 282 | $perm_obj->setVar('gperm_groupid', $grouoid); |
283 | 283 | $grouppermHandler->insert($perm_obj); |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | } |
286 | 286 | } |
287 | 287 | $removed_groups = array_diff(array_keys($groups), $_REQUEST[$perm]); |
288 | - if (count($removed_groups) > 0) { |
|
289 | - $criteria->add(new \Criteria('gperm_groupid', '(' . implode(',', $removed_groups) . ')', 'IN')); |
|
288 | + if (count($removed_groups)>0) { |
|
289 | + $criteria->add(new \Criteria('gperm_groupid', '('.implode(',', $removed_groups).')', 'IN')); |
|
290 | 290 | $grouppermHandler->deleteAll($criteria); |
291 | 291 | } |
292 | 292 | unset($groups); |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | unset($criteria); |
297 | 297 | } |
298 | 298 | } |
299 | - $url = $redirect_to_edit ? 'field.php?op=edit&id=' . $obj->getVar('field_id') : 'field.php'; |
|
299 | + $url = $redirect_to_edit ? 'field.php?op=edit&id='.$obj->getVar('field_id') : 'field.php'; |
|
300 | 300 | redirect_header($url, 3, sprintf(_AM_SONGLIST_FIELDS_SAVEDSUCCESS, _AM_SONGLIST_FIELDS_FIELD)); |
301 | 301 | } |
302 | 302 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | if (!$obj->getVar('field_config')) { |
310 | 310 | redirect_header('index.php', 2, _AM_SONGLIST_FIELDS_FIELDNOTCONFIGURABLE); |
311 | 311 | } |
312 | - if (Request::hasVar('ok', 'REQUEST') && 1 == $_REQUEST['ok']) { |
|
312 | + if (Request::hasVar('ok', 'REQUEST') && 1==$_REQUEST['ok']) { |
|
313 | 313 | if (!$GLOBALS['xoopsSecurity']->check()) { |
314 | 314 | redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
315 | 315 | } |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | use Xmf\Request; |
24 | 24 | use Xmf\Module\Admin; |
25 | 25 | use XoopsModules\Songlist\{ |
26 | - Common\Configurator, |
|
27 | - Common\Migrate, |
|
28 | - Helper |
|
26 | + Common\Configurator, |
|
27 | + Common\Migrate, |
|
28 | + Helper |
|
29 | 29 | }; |
30 | 30 | |
31 | 31 | /** @var Admin $adminObject */ |
@@ -68,31 +68,31 @@ discard block |
||
68 | 68 | $message = ''; |
69 | 69 | |
70 | 70 | switch ($op) { |
71 | - case 'show': |
|
72 | - default: |
|
73 | - $queue = $migrator->getSynchronizeDDL(); |
|
74 | - if (!empty($queue)) { |
|
75 | - echo "<pre>\n"; |
|
76 | - foreach ($queue as $line) { |
|
77 | - echo $line . ";\n"; |
|
78 | - } |
|
79 | - echo "</pre>\n"; |
|
80 | - } |
|
81 | - break; |
|
82 | - case 'migrate': |
|
83 | - $migrator->synchronizeSchema(); |
|
84 | - $message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK'); |
|
85 | - break; |
|
86 | - case 'schema': |
|
87 | - xoops_confirm(['op' => 'confirmwrite'], 'migrate.php', constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM')); |
|
88 | - break; |
|
89 | - case 'confirmwrite': |
|
90 | - if ($GLOBALS['xoopsSecurity']->check()) { |
|
91 | - $migrator->saveCurrentSchema(); |
|
92 | - |
|
93 | - $message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK'); |
|
94 | - } |
|
95 | - break; |
|
71 | + case 'show': |
|
72 | + default: |
|
73 | + $queue = $migrator->getSynchronizeDDL(); |
|
74 | + if (!empty($queue)) { |
|
75 | + echo "<pre>\n"; |
|
76 | + foreach ($queue as $line) { |
|
77 | + echo $line . ";\n"; |
|
78 | + } |
|
79 | + echo "</pre>\n"; |
|
80 | + } |
|
81 | + break; |
|
82 | + case 'migrate': |
|
83 | + $migrator->synchronizeSchema(); |
|
84 | + $message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK'); |
|
85 | + break; |
|
86 | + case 'schema': |
|
87 | + xoops_confirm(['op' => 'confirmwrite'], 'migrate.php', constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM')); |
|
88 | + break; |
|
89 | + case 'confirmwrite': |
|
90 | + if ($GLOBALS['xoopsSecurity']->check()) { |
|
91 | + $migrator->saveCurrentSchema(); |
|
92 | + |
|
93 | + $message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK'); |
|
94 | + } |
|
95 | + break; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | echo "<div>$message</div>"; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** @var Configurator $configurator */ |
33 | 33 | /** @var Migrate $migrator */ |
34 | 34 | |
35 | -require __DIR__ . '/admin_header.php'; |
|
35 | +require __DIR__.'/admin_header.php'; |
|
36 | 36 | xoops_cp_header(); |
37 | 37 | |
38 | 38 | $adminObject->displayNavigation(basename(__FILE__)); |
@@ -74,27 +74,27 @@ discard block |
||
74 | 74 | if (!empty($queue)) { |
75 | 75 | echo "<pre>\n"; |
76 | 76 | foreach ($queue as $line) { |
77 | - echo $line . ";\n"; |
|
77 | + echo $line.";\n"; |
|
78 | 78 | } |
79 | 79 | echo "</pre>\n"; |
80 | 80 | } |
81 | 81 | break; |
82 | 82 | case 'migrate': |
83 | 83 | $migrator->synchronizeSchema(); |
84 | - $message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK'); |
|
84 | + $message = constant('CO_'.$moduleDirNameUpper.'_'.'MIGRATE_OK'); |
|
85 | 85 | break; |
86 | 86 | case 'schema': |
87 | - xoops_confirm(['op' => 'confirmwrite'], 'migrate.php', constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM')); |
|
87 | + xoops_confirm(['op' => 'confirmwrite'], 'migrate.php', constant('CO_'.$moduleDirNameUpper.'_'.'MIGRATE_WARNING'), constant('CO_'.$moduleDirNameUpper.'_'.'CONFIRM')); |
|
88 | 88 | break; |
89 | 89 | case 'confirmwrite': |
90 | 90 | if ($GLOBALS['xoopsSecurity']->check()) { |
91 | 91 | $migrator->saveCurrentSchema(); |
92 | 92 | |
93 | - $message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK'); |
|
93 | + $message = constant('CO_'.$moduleDirNameUpper.'_'.'MIGRATE_SCHEMA_OK'); |
|
94 | 94 | } |
95 | 95 | break; |
96 | 96 | } |
97 | 97 | |
98 | 98 | echo "<div>$message</div>"; |
99 | 99 | |
100 | -require_once __DIR__ . '/admin_footer.php'; |
|
100 | +require_once __DIR__.'/admin_footer.php'; |
@@ -21,156 +21,156 @@ |
||
21 | 21 | $filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
22 | 22 | |
23 | 23 | switch ($op) { |
24 | - default: |
|
25 | - case 'artists': |
|
26 | - switch ($fct) { |
|
27 | - default: |
|
28 | - case 'list': |
|
29 | - $adminObject = Admin::getInstance(); |
|
30 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
31 | - |
|
32 | - /** @var ArtistsHandler $artistsHandler */ |
|
33 | - $artistsHandler = Helper::getInstance()->getHandler('Artists'); |
|
34 | - |
|
35 | - $criteria = $artistsHandler->getFilterCriteria($GLOBALS['filter']); |
|
36 | - $ttl = $artistsHandler->getCount($criteria); |
|
37 | - $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
38 | - |
|
39 | - $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']); |
|
40 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
41 | - |
|
42 | - foreach ($artistsHandler->filterFields() as $id => $key) { |
|
43 | - $GLOBALS['xoopsTpl']->assign( |
|
44 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
45 | - '<a href="' |
|
46 | - . $_SERVER['SCRIPT_NAME'] |
|
47 | - . '?start=' |
|
48 | - . $GLOBALS['start'] |
|
49 | - . '&limit=' |
|
50 | - . $GLOBALS['limit'] |
|
51 | - . '&sort=' |
|
52 | - . $key |
|
53 | - . '&order=' |
|
54 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
55 | - . '&op=' |
|
56 | - . $GLOBALS['op'] |
|
57 | - . '&filter=' |
|
58 | - . $GLOBALS['filter'] |
|
59 | - . '">' |
|
60 | - . (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))) |
|
61 | - . '</a>' |
|
62 | - ); |
|
63 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $artistsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
64 | - } |
|
65 | - |
|
66 | - $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
67 | - $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
68 | - $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
69 | - $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
70 | - $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
71 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
72 | - |
|
73 | - $criteria->setStart($GLOBALS['start']); |
|
74 | - $criteria->setLimit($GLOBALS['limit']); |
|
75 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
76 | - $criteria->setOrder($GLOBALS['order']); |
|
77 | - |
|
78 | - $artistsArray = $artistsHandler->getObjects($criteria, true); |
|
79 | - foreach ($artistsArray as $cid => $artist) { |
|
80 | - if (is_object($artist)) { |
|
81 | - $GLOBALS['xoopsTpl']->append('artists', $artist->toArray()); |
|
82 | - } |
|
83 | - } |
|
84 | - $GLOBALS['xoopsTpl']->assign('form', FormController::getFormArtists(false)); |
|
85 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
86 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_artists_list.tpl'); |
|
87 | - break; |
|
88 | - case 'new': |
|
89 | - case 'edit': |
|
90 | - $adminObject = Admin::getInstance(); |
|
91 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
92 | - |
|
93 | - $artistsHandler = Helper::getInstance()->getHandler('Artists'); |
|
94 | - if (Request::hasVar('id', 'REQUEST')) { |
|
95 | - $artist = $artistsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
96 | - } else { |
|
97 | - $artist = $artistsHandler->create(); |
|
98 | - } |
|
99 | - |
|
100 | - $GLOBALS['xoopsTpl']->assign('form', $artist->getForm()); |
|
101 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
102 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_artists_edit.tpl'); |
|
103 | - break; |
|
104 | - case 'save': |
|
105 | - $artistsHandler = Helper::getInstance()->getHandler('Artists'); |
|
106 | - $id = 0; |
|
107 | - $id = Request::getInt('id', 0, 'REQUEST'); |
|
108 | - if ($id) { |
|
109 | - $artist = $artistsHandler->get($id); |
|
110 | - } else { |
|
111 | - $artist = $artistsHandler->create(); |
|
112 | - } |
|
113 | - $artist->setVars($_POST[$id]); |
|
114 | - |
|
115 | - if (!$id = $artistsHandler->insert($artist)) { |
|
116 | - 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_ARTISTS_FAILEDTOSAVE); |
|
117 | - exit(0); |
|
118 | - } |
|
119 | - if ('new' === isset($_REQUEST['state']) ? $_REQUEST['state'][$_REQUEST['id']]:'') { |
|
120 | - redirect_header( |
|
121 | - $_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'], |
|
122 | - 10, |
|
123 | - _AM_SONGLIST_MSG_ARTISTS_SAVEDOKEY |
|
124 | - ); |
|
125 | - } else { |
|
126 | - 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_ARTISTS_SAVEDOKEY); |
|
127 | - } |
|
128 | - exit(0); |
|
129 | - |
|
130 | - break; |
|
131 | - case 'savelist': |
|
132 | - $artistsHandler = Helper::getInstance()->getHandler('Artists'); |
|
133 | - foreach ($_REQUEST['id'] as $id) { |
|
134 | - $artist = $artistsHandler->get($id); |
|
135 | - $artist->setVars($_POST[$id]); |
|
136 | - if (!$artistsHandler->insert($artist)) { |
|
137 | - redirect_header( |
|
138 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
139 | - 10, |
|
140 | - _AM_SONGLIST_MSG_ARTISTS_FAILEDTOSAVE |
|
141 | - ); |
|
142 | - exit(0); |
|
143 | - } |
|
144 | - } |
|
145 | - 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_ARTISTS_SAVEDOKEY); |
|
146 | - exit(0); |
|
147 | - break; |
|
148 | - case 'delete': |
|
149 | - $artistsHandler = Helper::getInstance()->getHandler('Artists'); |
|
150 | - $id = 0; |
|
151 | - if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
152 | - $artist = $artistsHandler->get($id); |
|
153 | - if (!$artistsHandler->delete($artist)) { |
|
154 | - redirect_header( |
|
155 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
156 | - 10, |
|
157 | - _AM_SONGLIST_MSG_ARTISTS_FAILEDTODELETE |
|
158 | - ); |
|
159 | - exit(0); |
|
160 | - } |
|
161 | - 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_ARTISTS_DELETED); |
|
162 | - exit(0); |
|
163 | - } |
|
164 | - $artist = $artistsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
165 | - xoops_confirm( |
|
166 | - ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
167 | - $_SERVER['SCRIPT_NAME'], |
|
168 | - sprintf(_AM_SONGLIST_MSG_ARTISTS_DELETE, $artist->getVar('name')) |
|
169 | - ); |
|
170 | - |
|
171 | - break; |
|
172 | - } |
|
173 | - break; |
|
24 | + default: |
|
25 | + case 'artists': |
|
26 | + switch ($fct) { |
|
27 | + default: |
|
28 | + case 'list': |
|
29 | + $adminObject = Admin::getInstance(); |
|
30 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
31 | + |
|
32 | + /** @var ArtistsHandler $artistsHandler */ |
|
33 | + $artistsHandler = Helper::getInstance()->getHandler('Artists'); |
|
34 | + |
|
35 | + $criteria = $artistsHandler->getFilterCriteria($GLOBALS['filter']); |
|
36 | + $ttl = $artistsHandler->getCount($criteria); |
|
37 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
38 | + |
|
39 | + $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']); |
|
40 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
41 | + |
|
42 | + foreach ($artistsHandler->filterFields() as $id => $key) { |
|
43 | + $GLOBALS['xoopsTpl']->assign( |
|
44 | + \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
45 | + '<a href="' |
|
46 | + . $_SERVER['SCRIPT_NAME'] |
|
47 | + . '?start=' |
|
48 | + . $GLOBALS['start'] |
|
49 | + . '&limit=' |
|
50 | + . $GLOBALS['limit'] |
|
51 | + . '&sort=' |
|
52 | + . $key |
|
53 | + . '&order=' |
|
54 | + . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
55 | + . '&op=' |
|
56 | + . $GLOBALS['op'] |
|
57 | + . '&filter=' |
|
58 | + . $GLOBALS['filter'] |
|
59 | + . '">' |
|
60 | + . (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))) |
|
61 | + . '</a>' |
|
62 | + ); |
|
63 | + $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $artistsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
64 | + } |
|
65 | + |
|
66 | + $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
67 | + $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
68 | + $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
69 | + $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
70 | + $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
71 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
72 | + |
|
73 | + $criteria->setStart($GLOBALS['start']); |
|
74 | + $criteria->setLimit($GLOBALS['limit']); |
|
75 | + $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
76 | + $criteria->setOrder($GLOBALS['order']); |
|
77 | + |
|
78 | + $artistsArray = $artistsHandler->getObjects($criteria, true); |
|
79 | + foreach ($artistsArray as $cid => $artist) { |
|
80 | + if (is_object($artist)) { |
|
81 | + $GLOBALS['xoopsTpl']->append('artists', $artist->toArray()); |
|
82 | + } |
|
83 | + } |
|
84 | + $GLOBALS['xoopsTpl']->assign('form', FormController::getFormArtists(false)); |
|
85 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
86 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_artists_list.tpl'); |
|
87 | + break; |
|
88 | + case 'new': |
|
89 | + case 'edit': |
|
90 | + $adminObject = Admin::getInstance(); |
|
91 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
92 | + |
|
93 | + $artistsHandler = Helper::getInstance()->getHandler('Artists'); |
|
94 | + if (Request::hasVar('id', 'REQUEST')) { |
|
95 | + $artist = $artistsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
96 | + } else { |
|
97 | + $artist = $artistsHandler->create(); |
|
98 | + } |
|
99 | + |
|
100 | + $GLOBALS['xoopsTpl']->assign('form', $artist->getForm()); |
|
101 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
102 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_artists_edit.tpl'); |
|
103 | + break; |
|
104 | + case 'save': |
|
105 | + $artistsHandler = Helper::getInstance()->getHandler('Artists'); |
|
106 | + $id = 0; |
|
107 | + $id = Request::getInt('id', 0, 'REQUEST'); |
|
108 | + if ($id) { |
|
109 | + $artist = $artistsHandler->get($id); |
|
110 | + } else { |
|
111 | + $artist = $artistsHandler->create(); |
|
112 | + } |
|
113 | + $artist->setVars($_POST[$id]); |
|
114 | + |
|
115 | + if (!$id = $artistsHandler->insert($artist)) { |
|
116 | + 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_ARTISTS_FAILEDTOSAVE); |
|
117 | + exit(0); |
|
118 | + } |
|
119 | + if ('new' === isset($_REQUEST['state']) ? $_REQUEST['state'][$_REQUEST['id']]:'') { |
|
120 | + redirect_header( |
|
121 | + $_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'], |
|
122 | + 10, |
|
123 | + _AM_SONGLIST_MSG_ARTISTS_SAVEDOKEY |
|
124 | + ); |
|
125 | + } else { |
|
126 | + 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_ARTISTS_SAVEDOKEY); |
|
127 | + } |
|
128 | + exit(0); |
|
129 | + |
|
130 | + break; |
|
131 | + case 'savelist': |
|
132 | + $artistsHandler = Helper::getInstance()->getHandler('Artists'); |
|
133 | + foreach ($_REQUEST['id'] as $id) { |
|
134 | + $artist = $artistsHandler->get($id); |
|
135 | + $artist->setVars($_POST[$id]); |
|
136 | + if (!$artistsHandler->insert($artist)) { |
|
137 | + redirect_header( |
|
138 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
139 | + 10, |
|
140 | + _AM_SONGLIST_MSG_ARTISTS_FAILEDTOSAVE |
|
141 | + ); |
|
142 | + exit(0); |
|
143 | + } |
|
144 | + } |
|
145 | + 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_ARTISTS_SAVEDOKEY); |
|
146 | + exit(0); |
|
147 | + break; |
|
148 | + case 'delete': |
|
149 | + $artistsHandler = Helper::getInstance()->getHandler('Artists'); |
|
150 | + $id = 0; |
|
151 | + if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
152 | + $artist = $artistsHandler->get($id); |
|
153 | + if (!$artistsHandler->delete($artist)) { |
|
154 | + redirect_header( |
|
155 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
156 | + 10, |
|
157 | + _AM_SONGLIST_MSG_ARTISTS_FAILEDTODELETE |
|
158 | + ); |
|
159 | + exit(0); |
|
160 | + } |
|
161 | + 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_ARTISTS_DELETED); |
|
162 | + exit(0); |
|
163 | + } |
|
164 | + $artist = $artistsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
165 | + xoops_confirm( |
|
166 | + ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
167 | + $_SERVER['SCRIPT_NAME'], |
|
168 | + sprintf(_AM_SONGLIST_MSG_ARTISTS_DELETE, $artist->getVar('name')) |
|
169 | + ); |
|
170 | + |
|
171 | + break; |
|
172 | + } |
|
173 | + break; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | xoops_cp_footer(); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use XoopsModules\Songlist\ArtistsHandler; |
7 | 7 | use XoopsModules\Songlist\Form\FormController; |
8 | 8 | |
9 | -require __DIR__ . '/header.php'; |
|
9 | +require __DIR__.'/header.php'; |
|
10 | 10 | |
11 | 11 | xoops_loadLanguage('admin', 'songlist'); |
12 | 12 | |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | $limit = Request::getInt('limit', 30, 'REQUEST'); |
18 | 18 | $start = Request::getInt('start', 0, 'REQUEST'); |
19 | 19 | $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
20 | -$sort = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
21 | -$filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
|
20 | +$sort = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
21 | +$filter = !empty($_REQUEST['filter']) ? ''.$_REQUEST['filter'].'' : '1,1'; |
|
22 | 22 | |
23 | 23 | switch ($op) { |
24 | 24 | default: |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | |
35 | 35 | $criteria = $artistsHandler->getFilterCriteria($GLOBALS['filter']); |
36 | 36 | $ttl = $artistsHandler->getCount($criteria); |
37 | - $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
37 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
38 | 38 | |
39 | - $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']); |
|
39 | + $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']); |
|
40 | 40 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
41 | 41 | |
42 | 42 | foreach ($artistsHandler->filterFields() as $id => $key) { |
43 | 43 | $GLOBALS['xoopsTpl']->assign( |
44 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
44 | + \mb_strtolower(str_replace('-', '_', $key).'_th'), |
|
45 | 45 | '<a href="' |
46 | 46 | . $_SERVER['SCRIPT_NAME'] |
47 | 47 | . '?start=' |
@@ -51,16 +51,16 @@ discard block |
||
51 | 51 | . '&sort=' |
52 | 52 | . $key |
53 | 53 | . '&order=' |
54 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
54 | + . (($key==$GLOBALS['sort']) ? ('DESC'===$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
55 | 55 | . '&op=' |
56 | 56 | . $GLOBALS['op'] |
57 | 57 | . '&filter=' |
58 | 58 | . $GLOBALS['filter'] |
59 | 59 | . '">' |
60 | - . (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))) |
|
60 | + . (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))) |
|
61 | 61 | . '</a>' |
62 | 62 | ); |
63 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $artistsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
63 | + $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $artistsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | $criteria->setStart($GLOBALS['start']); |
74 | 74 | $criteria->setLimit($GLOBALS['limit']); |
75 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
75 | + $criteria->setSort('`'.$GLOBALS['sort'].'`'); |
|
76 | 76 | $criteria->setOrder($GLOBALS['order']); |
77 | 77 | |
78 | 78 | $artistsArray = $artistsHandler->getObjects($criteria, true); |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | $artist->setVars($_POST[$id]); |
114 | 114 | |
115 | 115 | if (!$id = $artistsHandler->insert($artist)) { |
116 | - 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_ARTISTS_FAILEDTOSAVE); |
|
116 | + 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_ARTISTS_FAILEDTOSAVE); |
|
117 | 117 | exit(0); |
118 | 118 | } |
119 | - if ('new' === isset($_REQUEST['state']) ? $_REQUEST['state'][$_REQUEST['id']]:'') { |
|
119 | + if ('new'===isset($_REQUEST['state']) ? $_REQUEST['state'][$_REQUEST['id']] : '') { |
|
120 | 120 | redirect_header( |
121 | - $_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'], |
|
121 | + $_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'], |
|
122 | 122 | 10, |
123 | 123 | _AM_SONGLIST_MSG_ARTISTS_SAVEDOKEY |
124 | 124 | ); |
125 | 125 | } else { |
126 | - 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_ARTISTS_SAVEDOKEY); |
|
126 | + 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_ARTISTS_SAVEDOKEY); |
|
127 | 127 | } |
128 | 128 | exit(0); |
129 | 129 | |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | $artist->setVars($_POST[$id]); |
136 | 136 | if (!$artistsHandler->insert($artist)) { |
137 | 137 | redirect_header( |
138 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
138 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
139 | 139 | 10, |
140 | 140 | _AM_SONGLIST_MSG_ARTISTS_FAILEDTOSAVE |
141 | 141 | ); |
142 | 142 | exit(0); |
143 | 143 | } |
144 | 144 | } |
145 | - 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_ARTISTS_SAVEDOKEY); |
|
145 | + 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_ARTISTS_SAVEDOKEY); |
|
146 | 146 | exit(0); |
147 | 147 | break; |
148 | 148 | case 'delete': |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | $artist = $artistsHandler->get($id); |
153 | 153 | if (!$artistsHandler->delete($artist)) { |
154 | 154 | redirect_header( |
155 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
155 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
156 | 156 | 10, |
157 | 157 | _AM_SONGLIST_MSG_ARTISTS_FAILEDTODELETE |
158 | 158 | ); |
159 | 159 | exit(0); |
160 | 160 | } |
161 | - 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_ARTISTS_DELETED); |
|
161 | + 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_ARTISTS_DELETED); |
|
162 | 162 | exit(0); |
163 | 163 | } |
164 | 164 | $artist = $artistsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
@@ -16,11 +16,11 @@ |
||
16 | 16 | */ |
17 | 17 | /** @var \Xmf\Module\Admin $adminObject */ |
18 | 18 | |
19 | -require_once __DIR__ . '/admin_header.php'; |
|
19 | +require_once __DIR__.'/admin_header.php'; |
|
20 | 20 | xoops_cp_header(); |
21 | 21 | |
22 | 22 | $adminObject->displayNavigation(basename(__FILE__)); |
23 | 23 | $adminObject::setPaypal('[email protected]'); |
24 | 24 | $adminObject->displayAbout(false); |
25 | 25 | |
26 | -require_once __DIR__ . '/admin_footer.php'; |
|
26 | +require_once __DIR__.'/admin_footer.php'; |
@@ -21,156 +21,156 @@ |
||
21 | 21 | $filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
22 | 22 | |
23 | 23 | switch ($op) { |
24 | - default: |
|
25 | - case 'utf8map': |
|
26 | - switch ($fct) { |
|
27 | - default: |
|
28 | - case 'list': |
|
29 | - $adminObject = Admin::getInstance(); |
|
30 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
31 | - |
|
32 | - /** @var Utf8mapHandler $utf8mapHandler */ |
|
33 | - $utf8mapHandler = Helper::getInstance()->getHandler('Utf8map'); |
|
34 | - |
|
35 | - $criteria = $utf8mapHandler->getFilterCriteria($GLOBALS['filter']); |
|
36 | - $ttl = $utf8mapHandler->getCount($criteria); |
|
37 | - $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
38 | - |
|
39 | - $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']); |
|
40 | - $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
41 | - |
|
42 | - foreach ($utf8mapHandler->filterFields() as $id => $key) { |
|
43 | - $GLOBALS['xoopsTpl']->assign( |
|
44 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
45 | - '<a href="' |
|
46 | - . $_SERVER['SCRIPT_NAME'] |
|
47 | - . '?start=' |
|
48 | - . $GLOBALS['start'] |
|
49 | - . '&limit=' |
|
50 | - . $GLOBALS['limit'] |
|
51 | - . '&sort=' |
|
52 | - . $key |
|
53 | - . '&order=' |
|
54 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
55 | - . '&op=' |
|
56 | - . $GLOBALS['op'] |
|
57 | - . '&filter=' |
|
58 | - . $GLOBALS['filter'] |
|
59 | - . '">' |
|
60 | - . (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))) |
|
61 | - . '</a>' |
|
62 | - ); |
|
63 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $utf8mapHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
64 | - } |
|
65 | - |
|
66 | - $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
67 | - $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
68 | - $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
69 | - $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
70 | - $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
71 | - $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
72 | - |
|
73 | - $criteria->setStart($GLOBALS['start']); |
|
74 | - $criteria->setLimit($GLOBALS['limit']); |
|
75 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
76 | - $criteria->setOrder($GLOBALS['order']); |
|
77 | - |
|
78 | - $utf8maps = $utf8mapHandler->getObjects($criteria, true); |
|
79 | - foreach ($utf8maps as $cid => $utf8map) { |
|
80 | - if (is_object($utf8map)) { |
|
81 | - $GLOBALS['xoopsTpl']->append('utf8map', $utf8map->toArray()); |
|
82 | - } |
|
83 | - } |
|
84 | - $GLOBALS['xoopsTpl']->assign('form', FormController::getFormUtf8map(false)); |
|
85 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
86 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_utf8map_list.tpl'); |
|
87 | - break; |
|
88 | - case 'new': |
|
89 | - case 'edit': |
|
90 | - $adminObject = Admin::getInstance(); |
|
91 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
92 | - |
|
93 | - $utf8mapHandler = Helper::getInstance()->getHandler('Utf8map'); |
|
94 | - if (Request::hasVar('id', 'REQUEST')) { |
|
95 | - $utf8map = $utf8mapHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
96 | - } else { |
|
97 | - $utf8map = $utf8mapHandler->create(); |
|
98 | - } |
|
99 | - |
|
100 | - $GLOBALS['xoopsTpl']->assign('form', $utf8map->getForm()); |
|
101 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
102 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_utf8map_edit.tpl'); |
|
103 | - break; |
|
104 | - case 'save': |
|
105 | - $utf8mapHandler = Helper::getInstance()->getHandler('Utf8map'); |
|
106 | - $id = 0; |
|
107 | - $id = Request::getInt('id', 0, 'REQUEST'); |
|
108 | - if ($id) { |
|
109 | - $utf8map = $utf8mapHandler->get($id); |
|
110 | - } else { |
|
111 | - $utf8map = $utf8mapHandler->create(); |
|
112 | - } |
|
113 | - $utf8map->setVars($_POST[$id]); |
|
114 | - |
|
115 | - if (!$id = $utf8mapHandler->insert($utf8map)) { |
|
116 | - 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_UTF8MAP_FAILEDTOSAVE); |
|
117 | - exit(0); |
|
118 | - } |
|
119 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
120 | - redirect_header( |
|
121 | - $_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'], |
|
122 | - 10, |
|
123 | - _AM_SONGLIST_MSG_UTF8MAP_SAVEDOKEY |
|
124 | - ); |
|
125 | - } else { |
|
126 | - 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_UTF8MAP_SAVEDOKEY); |
|
127 | - } |
|
128 | - exit(0); |
|
129 | - |
|
130 | - break; |
|
131 | - case 'savelist': |
|
132 | - $utf8mapHandler = Helper::getInstance()->getHandler('Utf8map'); |
|
133 | - foreach ($_REQUEST['id'] as $id) { |
|
134 | - $utf8map = $utf8mapHandler->get($id); |
|
135 | - $utf8map->setVars($_POST[$id]); |
|
136 | - if (!$utf8mapHandler->insert($utf8map)) { |
|
137 | - redirect_header( |
|
138 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
139 | - 10, |
|
140 | - _AM_SONGLIST_MSG_UTF8MAP_FAILEDTOSAVE |
|
141 | - ); |
|
142 | - exit(0); |
|
143 | - } |
|
144 | - } |
|
145 | - 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_UTF8MAP_SAVEDOKEY); |
|
146 | - exit(0); |
|
147 | - break; |
|
148 | - case 'delete': |
|
149 | - $utf8mapHandler = Helper::getInstance()->getHandler('Utf8map'); |
|
150 | - $id = 0; |
|
151 | - if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
152 | - $utf8map = $utf8mapHandler->get($id); |
|
153 | - if (!$utf8mapHandler->delete($utf8map)) { |
|
154 | - redirect_header( |
|
155 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
156 | - 10, |
|
157 | - _AM_SONGLIST_MSG_UTF8MAP_FAILEDTODELETE |
|
158 | - ); |
|
159 | - exit(0); |
|
160 | - } |
|
161 | - 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_UTF8MAP_DELETED); |
|
162 | - exit(0); |
|
163 | - } |
|
164 | - $utf8map = $utf8mapHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
165 | - xoops_confirm( |
|
166 | - ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
167 | - $_SERVER['SCRIPT_NAME'], |
|
168 | - sprintf(_AM_SONGLIST_MSG_UTF8MAP_DELETE, $utf8map->getVar('from'), $utf8map->getVar('to')) |
|
169 | - ); |
|
170 | - |
|
171 | - break; |
|
172 | - } |
|
173 | - break; |
|
24 | + default: |
|
25 | + case 'utf8map': |
|
26 | + switch ($fct) { |
|
27 | + default: |
|
28 | + case 'list': |
|
29 | + $adminObject = Admin::getInstance(); |
|
30 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
31 | + |
|
32 | + /** @var Utf8mapHandler $utf8mapHandler */ |
|
33 | + $utf8mapHandler = Helper::getInstance()->getHandler('Utf8map'); |
|
34 | + |
|
35 | + $criteria = $utf8mapHandler->getFilterCriteria($GLOBALS['filter']); |
|
36 | + $ttl = $utf8mapHandler->getCount($criteria); |
|
37 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
38 | + |
|
39 | + $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']); |
|
40 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
|
41 | + |
|
42 | + foreach ($utf8mapHandler->filterFields() as $id => $key) { |
|
43 | + $GLOBALS['xoopsTpl']->assign( |
|
44 | + \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
45 | + '<a href="' |
|
46 | + . $_SERVER['SCRIPT_NAME'] |
|
47 | + . '?start=' |
|
48 | + . $GLOBALS['start'] |
|
49 | + . '&limit=' |
|
50 | + . $GLOBALS['limit'] |
|
51 | + . '&sort=' |
|
52 | + . $key |
|
53 | + . '&order=' |
|
54 | + . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
55 | + . '&op=' |
|
56 | + . $GLOBALS['op'] |
|
57 | + . '&filter=' |
|
58 | + . $GLOBALS['filter'] |
|
59 | + . '">' |
|
60 | + . (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))) |
|
61 | + . '</a>' |
|
62 | + ); |
|
63 | + $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $utf8mapHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
64 | + } |
|
65 | + |
|
66 | + $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
|
67 | + $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
|
68 | + $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
|
69 | + $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
|
70 | + $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
|
71 | + $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
|
72 | + |
|
73 | + $criteria->setStart($GLOBALS['start']); |
|
74 | + $criteria->setLimit($GLOBALS['limit']); |
|
75 | + $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
76 | + $criteria->setOrder($GLOBALS['order']); |
|
77 | + |
|
78 | + $utf8maps = $utf8mapHandler->getObjects($criteria, true); |
|
79 | + foreach ($utf8maps as $cid => $utf8map) { |
|
80 | + if (is_object($utf8map)) { |
|
81 | + $GLOBALS['xoopsTpl']->append('utf8map', $utf8map->toArray()); |
|
82 | + } |
|
83 | + } |
|
84 | + $GLOBALS['xoopsTpl']->assign('form', FormController::getFormUtf8map(false)); |
|
85 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
86 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_utf8map_list.tpl'); |
|
87 | + break; |
|
88 | + case 'new': |
|
89 | + case 'edit': |
|
90 | + $adminObject = Admin::getInstance(); |
|
91 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
92 | + |
|
93 | + $utf8mapHandler = Helper::getInstance()->getHandler('Utf8map'); |
|
94 | + if (Request::hasVar('id', 'REQUEST')) { |
|
95 | + $utf8map = $utf8mapHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
96 | + } else { |
|
97 | + $utf8map = $utf8mapHandler->create(); |
|
98 | + } |
|
99 | + |
|
100 | + $GLOBALS['xoopsTpl']->assign('form', $utf8map->getForm()); |
|
101 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
102 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_utf8map_edit.tpl'); |
|
103 | + break; |
|
104 | + case 'save': |
|
105 | + $utf8mapHandler = Helper::getInstance()->getHandler('Utf8map'); |
|
106 | + $id = 0; |
|
107 | + $id = Request::getInt('id', 0, 'REQUEST'); |
|
108 | + if ($id) { |
|
109 | + $utf8map = $utf8mapHandler->get($id); |
|
110 | + } else { |
|
111 | + $utf8map = $utf8mapHandler->create(); |
|
112 | + } |
|
113 | + $utf8map->setVars($_POST[$id]); |
|
114 | + |
|
115 | + if (!$id = $utf8mapHandler->insert($utf8map)) { |
|
116 | + 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_UTF8MAP_FAILEDTOSAVE); |
|
117 | + exit(0); |
|
118 | + } |
|
119 | + if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
120 | + redirect_header( |
|
121 | + $_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'], |
|
122 | + 10, |
|
123 | + _AM_SONGLIST_MSG_UTF8MAP_SAVEDOKEY |
|
124 | + ); |
|
125 | + } else { |
|
126 | + 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_UTF8MAP_SAVEDOKEY); |
|
127 | + } |
|
128 | + exit(0); |
|
129 | + |
|
130 | + break; |
|
131 | + case 'savelist': |
|
132 | + $utf8mapHandler = Helper::getInstance()->getHandler('Utf8map'); |
|
133 | + foreach ($_REQUEST['id'] as $id) { |
|
134 | + $utf8map = $utf8mapHandler->get($id); |
|
135 | + $utf8map->setVars($_POST[$id]); |
|
136 | + if (!$utf8mapHandler->insert($utf8map)) { |
|
137 | + redirect_header( |
|
138 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
139 | + 10, |
|
140 | + _AM_SONGLIST_MSG_UTF8MAP_FAILEDTOSAVE |
|
141 | + ); |
|
142 | + exit(0); |
|
143 | + } |
|
144 | + } |
|
145 | + 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_UTF8MAP_SAVEDOKEY); |
|
146 | + exit(0); |
|
147 | + break; |
|
148 | + case 'delete': |
|
149 | + $utf8mapHandler = Helper::getInstance()->getHandler('Utf8map'); |
|
150 | + $id = 0; |
|
151 | + if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
|
152 | + $utf8map = $utf8mapHandler->get($id); |
|
153 | + if (!$utf8mapHandler->delete($utf8map)) { |
|
154 | + redirect_header( |
|
155 | + $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
156 | + 10, |
|
157 | + _AM_SONGLIST_MSG_UTF8MAP_FAILEDTODELETE |
|
158 | + ); |
|
159 | + exit(0); |
|
160 | + } |
|
161 | + 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_UTF8MAP_DELETED); |
|
162 | + exit(0); |
|
163 | + } |
|
164 | + $utf8map = $utf8mapHandler->get(Request::getInt('id', 0, 'REQUEST')); |
|
165 | + xoops_confirm( |
|
166 | + ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
|
167 | + $_SERVER['SCRIPT_NAME'], |
|
168 | + sprintf(_AM_SONGLIST_MSG_UTF8MAP_DELETE, $utf8map->getVar('from'), $utf8map->getVar('to')) |
|
169 | + ); |
|
170 | + |
|
171 | + break; |
|
172 | + } |
|
173 | + break; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | xoops_cp_footer(); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use XoopsModules\Songlist\Utf8mapHandler; |
7 | 7 | use XoopsModules\Songlist\Form\FormController; |
8 | 8 | |
9 | -require __DIR__ . '/header.php'; |
|
9 | +require __DIR__.'/header.php'; |
|
10 | 10 | |
11 | 11 | xoops_loadLanguage('admin', 'songlist'); |
12 | 12 | |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | $limit = Request::getInt('limit', 30, 'REQUEST'); |
18 | 18 | $start = Request::getInt('start', 0, 'REQUEST'); |
19 | 19 | $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
20 | -$sort = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
21 | -$filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
|
20 | +$sort = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
21 | +$filter = !empty($_REQUEST['filter']) ? ''.$_REQUEST['filter'].'' : '1,1'; |
|
22 | 22 | |
23 | 23 | switch ($op) { |
24 | 24 | default: |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | |
35 | 35 | $criteria = $utf8mapHandler->getFilterCriteria($GLOBALS['filter']); |
36 | 36 | $ttl = $utf8mapHandler->getCount($criteria); |
37 | - $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
37 | + $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
38 | 38 | |
39 | - $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']); |
|
39 | + $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']); |
|
40 | 40 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
41 | 41 | |
42 | 42 | foreach ($utf8mapHandler->filterFields() as $id => $key) { |
43 | 43 | $GLOBALS['xoopsTpl']->assign( |
44 | - \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
|
44 | + \mb_strtolower(str_replace('-', '_', $key).'_th'), |
|
45 | 45 | '<a href="' |
46 | 46 | . $_SERVER['SCRIPT_NAME'] |
47 | 47 | . '?start=' |
@@ -51,16 +51,16 @@ discard block |
||
51 | 51 | . '&sort=' |
52 | 52 | . $key |
53 | 53 | . '&order=' |
54 | - . (($key == $GLOBALS['sort']) ? ('DESC' === $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
54 | + . (($key==$GLOBALS['sort']) ? ('DESC'===$GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
|
55 | 55 | . '&op=' |
56 | 56 | . $GLOBALS['op'] |
57 | 57 | . '&filter=' |
58 | 58 | . $GLOBALS['filter'] |
59 | 59 | . '">' |
60 | - . (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))) |
|
60 | + . (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))) |
|
61 | 61 | . '</a>' |
62 | 62 | ); |
63 | - $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $utf8mapHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
63 | + $GLOBALS['xoopsTpl']->assign('filter_'.\mb_strtolower(str_replace('-', '_', $key)).'_th', $utf8mapHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | $criteria->setStart($GLOBALS['start']); |
74 | 74 | $criteria->setLimit($GLOBALS['limit']); |
75 | - $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
|
75 | + $criteria->setSort('`'.$GLOBALS['sort'].'`'); |
|
76 | 76 | $criteria->setOrder($GLOBALS['order']); |
77 | 77 | |
78 | 78 | $utf8maps = $utf8mapHandler->getObjects($criteria, true); |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | $utf8map->setVars($_POST[$id]); |
114 | 114 | |
115 | 115 | if (!$id = $utf8mapHandler->insert($utf8map)) { |
116 | - 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_UTF8MAP_FAILEDTOSAVE); |
|
116 | + 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_UTF8MAP_FAILEDTOSAVE); |
|
117 | 117 | exit(0); |
118 | 118 | } |
119 | - if ('new' === $_REQUEST['state'][$_REQUEST['id']]) { |
|
119 | + if ('new'===$_REQUEST['state'][$_REQUEST['id']]) { |
|
120 | 120 | redirect_header( |
121 | - $_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'], |
|
121 | + $_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'], |
|
122 | 122 | 10, |
123 | 123 | _AM_SONGLIST_MSG_UTF8MAP_SAVEDOKEY |
124 | 124 | ); |
125 | 125 | } else { |
126 | - 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_UTF8MAP_SAVEDOKEY); |
|
126 | + 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_UTF8MAP_SAVEDOKEY); |
|
127 | 127 | } |
128 | 128 | exit(0); |
129 | 129 | |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | $utf8map->setVars($_POST[$id]); |
136 | 136 | if (!$utf8mapHandler->insert($utf8map)) { |
137 | 137 | redirect_header( |
138 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
138 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
139 | 139 | 10, |
140 | 140 | _AM_SONGLIST_MSG_UTF8MAP_FAILEDTOSAVE |
141 | 141 | ); |
142 | 142 | exit(0); |
143 | 143 | } |
144 | 144 | } |
145 | - 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_UTF8MAP_SAVEDOKEY); |
|
145 | + 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_UTF8MAP_SAVEDOKEY); |
|
146 | 146 | exit(0); |
147 | 147 | break; |
148 | 148 | case 'delete': |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | $utf8map = $utf8mapHandler->get($id); |
153 | 153 | if (!$utf8mapHandler->delete($utf8map)) { |
154 | 154 | redirect_header( |
155 | - $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
|
155 | + $_SERVER['SCRIPT_NAME'].'?op='.$GLOBALS['op'].'&fct=list&limit='.$GLOBALS['limit'].'&start='.$GLOBALS['start'].'&order='.$GLOBALS['order'].'&sort='.$GLOBALS['sort'].'&filter='.$GLOBALS['filter'], |
|
156 | 156 | 10, |
157 | 157 | _AM_SONGLIST_MSG_UTF8MAP_FAILEDTODELETE |
158 | 158 | ); |
159 | 159 | exit(0); |
160 | 160 | } |
161 | - 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_UTF8MAP_DELETED); |
|
161 | + 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_UTF8MAP_DELETED); |
|
162 | 162 | exit(0); |
163 | 163 | } |
164 | 164 | $utf8map = $utf8mapHandler->get(Request::getInt('id', 0, 'REQUEST')); |
@@ -33,68 +33,68 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class forum_XoopsGroupPermForm extends \XoopsGroupPermForm |
35 | 35 | { |
36 | - /** |
|
37 | - * forum_XoopsGroupPermForm constructor. |
|
38 | - * @param $title |
|
39 | - * @param $modid |
|
40 | - * @param $permname |
|
41 | - * @param $permdesc |
|
42 | - * @param string $url |
|
43 | - */ |
|
44 | - public function __construct($title, $modid, $permname, $permdesc, $url = '') |
|
45 | - { |
|
46 | - parent::__construct($title, $modid, $permname, $permdesc, $url); |
|
47 | - } |
|
36 | + /** |
|
37 | + * forum_XoopsGroupPermForm constructor. |
|
38 | + * @param $title |
|
39 | + * @param $modid |
|
40 | + * @param $permname |
|
41 | + * @param $permdesc |
|
42 | + * @param string $url |
|
43 | + */ |
|
44 | + public function __construct($title, $modid, $permname, $permdesc, $url = '') |
|
45 | + { |
|
46 | + parent::__construct($title, $modid, $permname, $permdesc, $url); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - public function render(): string |
|
53 | - { |
|
54 | - // load all child ids for javascript codes |
|
55 | - foreach (array_keys($this->_itemTree) as $item_id) { |
|
56 | - $this->_itemTree[$item_id]['allchild'] = []; |
|
57 | - $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']); |
|
58 | - } |
|
59 | - /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
60 | - $grouppermHandler = xoops_getHandler('groupperm'); |
|
61 | - /** @var \XoopsMemberHandler $memberHandler */ |
|
62 | - $memberHandler = xoops_getHandler('member'); |
|
63 | - $glist = $memberHandler->getGroupList(); |
|
64 | - foreach (array_keys($glist) as $i) { |
|
65 | - // get selected item id(s) for each group |
|
66 | - $selected = $grouppermHandler->getItemIds($this->_permName, $i, $this->_modid); |
|
67 | - $ele = new forum_XoopsGroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected); |
|
68 | - $ele->setOptionTree($this->_itemTree); |
|
69 | - $this->addElement($ele); |
|
70 | - unset($ele); |
|
71 | - } |
|
72 | - $tray = new \XoopsFormElementTray(''); |
|
73 | - $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
74 | - $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
75 | - $this->addElement($tray); |
|
76 | - $ret = '<h4>' . $this->getTitle() . '</h4>' . $this->_permDesc . '<br>'; |
|
77 | - $ret .= "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n<table width='100%' class='outer' cellspacing='1' valign='top'>\n"; |
|
78 | - $elements = $this->getElements(); |
|
79 | - $hidden = ''; |
|
80 | - foreach (array_keys($elements) as $i) { |
|
81 | - if (!is_object($elements[$i])) { |
|
82 | - $ret .= $elements[$i]; |
|
83 | - } elseif ($elements[$i]->isHidden()) { |
|
84 | - $hidden .= $elements[$i]->render(); |
|
85 | - } else { |
|
86 | - $ret .= "<tr valign='top' align='left'><td class='head'>" . $elements[$i]->getCaption(); |
|
87 | - if ('' != $elements[$i]->getDescription()) { |
|
88 | - $ret .= '<br><br><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>'; |
|
89 | - } |
|
90 | - $ret .= "</td>\n<td class='even'>\n" . $elements[$i]->render() . "\n</td></tr>\n"; |
|
91 | - } |
|
92 | - } |
|
93 | - $ret .= "</table>$hidden</form>"; |
|
94 | - $ret .= $this->renderValidationJS(true); |
|
49 | + /** |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + public function render(): string |
|
53 | + { |
|
54 | + // load all child ids for javascript codes |
|
55 | + foreach (array_keys($this->_itemTree) as $item_id) { |
|
56 | + $this->_itemTree[$item_id]['allchild'] = []; |
|
57 | + $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']); |
|
58 | + } |
|
59 | + /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
60 | + $grouppermHandler = xoops_getHandler('groupperm'); |
|
61 | + /** @var \XoopsMemberHandler $memberHandler */ |
|
62 | + $memberHandler = xoops_getHandler('member'); |
|
63 | + $glist = $memberHandler->getGroupList(); |
|
64 | + foreach (array_keys($glist) as $i) { |
|
65 | + // get selected item id(s) for each group |
|
66 | + $selected = $grouppermHandler->getItemIds($this->_permName, $i, $this->_modid); |
|
67 | + $ele = new forum_XoopsGroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected); |
|
68 | + $ele->setOptionTree($this->_itemTree); |
|
69 | + $this->addElement($ele); |
|
70 | + unset($ele); |
|
71 | + } |
|
72 | + $tray = new \XoopsFormElementTray(''); |
|
73 | + $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
74 | + $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
75 | + $this->addElement($tray); |
|
76 | + $ret = '<h4>' . $this->getTitle() . '</h4>' . $this->_permDesc . '<br>'; |
|
77 | + $ret .= "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n<table width='100%' class='outer' cellspacing='1' valign='top'>\n"; |
|
78 | + $elements = $this->getElements(); |
|
79 | + $hidden = ''; |
|
80 | + foreach (array_keys($elements) as $i) { |
|
81 | + if (!is_object($elements[$i])) { |
|
82 | + $ret .= $elements[$i]; |
|
83 | + } elseif ($elements[$i]->isHidden()) { |
|
84 | + $hidden .= $elements[$i]->render(); |
|
85 | + } else { |
|
86 | + $ret .= "<tr valign='top' align='left'><td class='head'>" . $elements[$i]->getCaption(); |
|
87 | + if ('' != $elements[$i]->getDescription()) { |
|
88 | + $ret .= '<br><br><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>'; |
|
89 | + } |
|
90 | + $ret .= "</td>\n<td class='even'>\n" . $elements[$i]->render() . "\n</td></tr>\n"; |
|
91 | + } |
|
92 | + } |
|
93 | + $ret .= "</table>$hidden</form>"; |
|
94 | + $ret .= $this->renderValidationJS(true); |
|
95 | 95 | |
96 | - return $ret; |
|
97 | - } |
|
96 | + return $ret; |
|
97 | + } |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -102,93 +102,93 @@ discard block |
||
102 | 102 | */ |
103 | 103 | class forum_XoopsGroupFormCheckBox extends \XoopsGroupFormCheckBox |
104 | 104 | { |
105 | - /** |
|
106 | - * forum_XoopsGroupFormCheckBox constructor. |
|
107 | - * @param $caption |
|
108 | - * @param $name |
|
109 | - * @param $groupId |
|
110 | - * @param null $values |
|
111 | - */ |
|
112 | - public function __construct($caption, $name, $groupId, $values = null) |
|
113 | - { |
|
114 | - parent::__construct($caption, $name, $groupId, $values); |
|
115 | - } |
|
105 | + /** |
|
106 | + * forum_XoopsGroupFormCheckBox constructor. |
|
107 | + * @param $caption |
|
108 | + * @param $name |
|
109 | + * @param $groupId |
|
110 | + * @param null $values |
|
111 | + */ |
|
112 | + public function __construct($caption, $name, $groupId, $values = null) |
|
113 | + { |
|
114 | + parent::__construct($caption, $name, $groupId, $values); |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * Renders checkbox options for this group |
|
119 | - * |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - public function render(): string |
|
123 | - { |
|
124 | - $ret = '<table class="outer"><tr><td class="odd"><table><tr>'; |
|
125 | - $cols = 1; |
|
126 | - foreach ($this->_optionTree[0]['children'] as $topitem) { |
|
127 | - if ($cols > 4) { |
|
128 | - $ret .= '</tr><tr>'; |
|
129 | - $cols = 1; |
|
130 | - } |
|
131 | - $tree = '<td valign="top">'; |
|
132 | - $prefix = ''; |
|
133 | - $this->_renderOptionTree($tree, $this->_optionTree[$topitem], $prefix); |
|
134 | - $ret .= $tree . '</td>'; |
|
135 | - ++$cols; |
|
136 | - } |
|
137 | - $ret .= '</tr></table></td><td class="even">'; |
|
138 | - foreach (array_keys($this->_optionTree) as $id) { |
|
139 | - if (!empty($id)) { |
|
140 | - $option_ids[] = "'" . $this->getName() . '[groups][' . $this->_groupId . '][' . $id . ']' . "'"; |
|
141 | - } |
|
142 | - } |
|
143 | - $checkallbtn_id = $this->getName() . '[checkallbtn][' . $this->_groupId . ']'; |
|
144 | - $option_ids_str = implode(', ', $option_ids); |
|
145 | - $ret .= _ALL . ' <input id="' . $checkallbtn_id . '" type="checkbox" value="" onclick="var optionids = new Array(' . $option_ids_str . "); xoopsCheckAllElements(optionids, '" . $checkallbtn_id . "');\">"; |
|
146 | - $ret .= '</td></tr></table>'; |
|
117 | + /** |
|
118 | + * Renders checkbox options for this group |
|
119 | + * |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + public function render(): string |
|
123 | + { |
|
124 | + $ret = '<table class="outer"><tr><td class="odd"><table><tr>'; |
|
125 | + $cols = 1; |
|
126 | + foreach ($this->_optionTree[0]['children'] as $topitem) { |
|
127 | + if ($cols > 4) { |
|
128 | + $ret .= '</tr><tr>'; |
|
129 | + $cols = 1; |
|
130 | + } |
|
131 | + $tree = '<td valign="top">'; |
|
132 | + $prefix = ''; |
|
133 | + $this->_renderOptionTree($tree, $this->_optionTree[$topitem], $prefix); |
|
134 | + $ret .= $tree . '</td>'; |
|
135 | + ++$cols; |
|
136 | + } |
|
137 | + $ret .= '</tr></table></td><td class="even">'; |
|
138 | + foreach (array_keys($this->_optionTree) as $id) { |
|
139 | + if (!empty($id)) { |
|
140 | + $option_ids[] = "'" . $this->getName() . '[groups][' . $this->_groupId . '][' . $id . ']' . "'"; |
|
141 | + } |
|
142 | + } |
|
143 | + $checkallbtn_id = $this->getName() . '[checkallbtn][' . $this->_groupId . ']'; |
|
144 | + $option_ids_str = implode(', ', $option_ids); |
|
145 | + $ret .= _ALL . ' <input id="' . $checkallbtn_id . '" type="checkbox" value="" onclick="var optionids = new Array(' . $option_ids_str . "); xoopsCheckAllElements(optionids, '" . $checkallbtn_id . "');\">"; |
|
146 | + $ret .= '</td></tr></table>'; |
|
147 | 147 | |
148 | - return $ret; |
|
149 | - } |
|
148 | + return $ret; |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * @param string $tree |
|
153 | - * @param array $option |
|
154 | - * @param string $prefix |
|
155 | - * @param array $parentIds |
|
156 | - */ |
|
157 | - public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = []): void |
|
158 | - { |
|
159 | - if ($option['id'] > 0) : |
|
160 | - $tree .= $prefix . '<input type="checkbox" name="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" id="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" onclick="'; |
|
161 | - foreach ($parentIds as $pid) { |
|
162 | - if ($pid <= 0) { |
|
163 | - continue; |
|
164 | - } |
|
165 | - $parent_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $pid . ']'; |
|
166 | - $tree .= "var ele = xoopsGetElementById('" . $parent_ele . "'); if(ele.checked !== true) {ele.checked = this.checked;}"; |
|
167 | - } |
|
168 | - foreach ($option['allchild'] as $cid) { |
|
169 | - $child_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $cid . ']'; |
|
170 | - $tree .= "var ele = xoopsGetElementById('" . $child_ele . "'); if(this.checked !== true) {ele.checked = false;}"; |
|
171 | - } |
|
172 | - $tree .= '" value="1"'; |
|
173 | - if (in_array($option['id'], $this->_value, true)) { |
|
174 | - $tree .= ' checked'; |
|
175 | - } |
|
176 | - $tree .= '>' . $option['name'] . '<input type="hidden" name="' . $this->getName() . '[parents][' . $option['id'] . ']" value="' . implode(':', $parentIds) . '"><input type="hidden" name="' . $this->getName() . '[itemname][' . $option['id'] . ']" value="' . htmlspecialchars( |
|
177 | - $option['name'], |
|
178 | - ENT_QUOTES | ENT_HTML5 |
|
179 | - ) . "\"><br>\n"; |
|
180 | - else : |
|
181 | - $tree .= $prefix . $option['name'] . '<input type="hidden" id="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . "]\"><br>\n"; |
|
182 | - endif; |
|
183 | - if (isset($option['children'])) { |
|
184 | - foreach ($option['children'] as $child) { |
|
185 | - if ($option['id'] > 0) { |
|
186 | - $parentIds[] = $option['id']; |
|
187 | - } |
|
188 | - $this->_renderOptionTree($tree, $this->_optionTree[$child], $prefix . ' -', $parentIds); |
|
189 | - } |
|
190 | - } |
|
191 | - } |
|
151 | + /** |
|
152 | + * @param string $tree |
|
153 | + * @param array $option |
|
154 | + * @param string $prefix |
|
155 | + * @param array $parentIds |
|
156 | + */ |
|
157 | + public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = []): void |
|
158 | + { |
|
159 | + if ($option['id'] > 0) : |
|
160 | + $tree .= $prefix . '<input type="checkbox" name="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" id="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" onclick="'; |
|
161 | + foreach ($parentIds as $pid) { |
|
162 | + if ($pid <= 0) { |
|
163 | + continue; |
|
164 | + } |
|
165 | + $parent_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $pid . ']'; |
|
166 | + $tree .= "var ele = xoopsGetElementById('" . $parent_ele . "'); if(ele.checked !== true) {ele.checked = this.checked;}"; |
|
167 | + } |
|
168 | + foreach ($option['allchild'] as $cid) { |
|
169 | + $child_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $cid . ']'; |
|
170 | + $tree .= "var ele = xoopsGetElementById('" . $child_ele . "'); if(this.checked !== true) {ele.checked = false;}"; |
|
171 | + } |
|
172 | + $tree .= '" value="1"'; |
|
173 | + if (in_array($option['id'], $this->_value, true)) { |
|
174 | + $tree .= ' checked'; |
|
175 | + } |
|
176 | + $tree .= '>' . $option['name'] . '<input type="hidden" name="' . $this->getName() . '[parents][' . $option['id'] . ']" value="' . implode(':', $parentIds) . '"><input type="hidden" name="' . $this->getName() . '[itemname][' . $option['id'] . ']" value="' . htmlspecialchars( |
|
177 | + $option['name'], |
|
178 | + ENT_QUOTES | ENT_HTML5 |
|
179 | + ) . "\"><br>\n"; |
|
180 | + else : |
|
181 | + $tree .= $prefix . $option['name'] . '<input type="hidden" id="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . "]\"><br>\n"; |
|
182 | + endif; |
|
183 | + if (isset($option['children'])) { |
|
184 | + foreach ($option['children'] as $child) { |
|
185 | + if ($option['id'] > 0) { |
|
186 | + $parentIds[] = $option['id']; |
|
187 | + } |
|
188 | + $this->_renderOptionTree($tree, $this->_optionTree[$child], $prefix . ' -', $parentIds); |
|
189 | + } |
|
190 | + } |
|
191 | + } |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | xoops_cp_header(); |
@@ -200,204 +200,204 @@ discard block |
||
200 | 200 | $perms = array_map('\trim', explode(',', FORUM_PERM_ITEMS)); |
201 | 201 | |
202 | 202 | switch ($action) { |
203 | - case 'template': |
|
204 | - $opform = new \XoopsSimpleForm(_AM_SONGLIST_PERM_ACTION, 'actionform', 'permissions.php', 'get'); |
|
205 | - $op_select = new \XoopsFormSelect('', 'action'); |
|
206 | - $op_select->setExtra('onchange="document.forms.actionform.submit()"'); |
|
207 | - $op_select->addOptionArray( |
|
208 | - [ |
|
209 | - 'no' => _SELECT, |
|
210 | - 'template' => _AM_SONGLIST_PERM_TEMPLATE, |
|
211 | - 'apply' => _AM_SONGLIST_PERM_TEMPLATEAPP, |
|
212 | - 'default' => _AM_SONGLIST_PERM_SETBYGROUP, |
|
213 | - ] |
|
214 | - ); |
|
215 | - $opform->addElement($op_select); |
|
216 | - $opform->display(); |
|
203 | + case 'template': |
|
204 | + $opform = new \XoopsSimpleForm(_AM_SONGLIST_PERM_ACTION, 'actionform', 'permissions.php', 'get'); |
|
205 | + $op_select = new \XoopsFormSelect('', 'action'); |
|
206 | + $op_select->setExtra('onchange="document.forms.actionform.submit()"'); |
|
207 | + $op_select->addOptionArray( |
|
208 | + [ |
|
209 | + 'no' => _SELECT, |
|
210 | + 'template' => _AM_SONGLIST_PERM_TEMPLATE, |
|
211 | + 'apply' => _AM_SONGLIST_PERM_TEMPLATEAPP, |
|
212 | + 'default' => _AM_SONGLIST_PERM_SETBYGROUP, |
|
213 | + ] |
|
214 | + ); |
|
215 | + $opform->addElement($op_select); |
|
216 | + $opform->display(); |
|
217 | 217 | |
218 | - /** @var \XoopsMemberHandler $memberHandler */ |
|
219 | - $memberHandler = xoops_getHandler('member'); |
|
220 | - $glist = $memberHandler->getGroupList(); |
|
221 | - $elements = []; |
|
222 | - $songlistpermHandler = Helper::getInstance()->getHandler('Permission'); |
|
223 | - $perm_template = $songlistpermHandler->getTemplate($groupid = 0); |
|
224 | - foreach (array_keys($glist) as $i) { |
|
225 | - $selected = !empty($perm_template[$i]) ? array_keys($perm_template[$i]) : []; |
|
226 | - $ret_ele = '<tr align="left" valign="top"><td class="head">' . $glist[$i] . '</td>'; |
|
227 | - $ret_ele .= '<td class="even">'; |
|
228 | - $ret_ele .= '<table class="outer"><tr><td class="odd"><table><tr>'; |
|
229 | - $ii = 0; |
|
230 | - $option_ids = []; |
|
231 | - foreach ($perms as $perm) { |
|
232 | - ++$ii; |
|
233 | - if (0 == $ii % 5) { |
|
234 | - $ret_ele .= '</tr><tr>'; |
|
235 | - } |
|
236 | - $checked = in_array('forum_' . $perm, $selected, true) ? ' checked' : ''; |
|
237 | - $option_id = $perm . '_' . $i; |
|
238 | - $option_ids[] = $option_id; |
|
239 | - $ret_ele .= '<td><input name="perms[' . $i . '][' . 'forum_' . $perm . ']" id="' . $option_id . '" onclick="" value="1" type="checkbox"' . $checked . '>' . constant('_AM_SONGLIST_CAN_' . \mb_strtoupper($perm)) . '<br></td>'; |
|
240 | - } |
|
241 | - $ret_ele .= '</tr></table></td><td class="even">'; |
|
242 | - $ret_ele .= _ALL . ' <input id="checkall[' . $i . ']" type="checkbox" value="" onclick="var optionids = new Array(' . implode(', ', $option_ids) . '); xoopsCheckAllElements(optionids, \'checkall[' . $i . ']\')">'; |
|
243 | - $ret_ele .= '</td></tr></table>'; |
|
244 | - $ret_ele .= '</td></tr>'; |
|
245 | - $elements[] = $ret_ele; |
|
246 | - } |
|
247 | - $tray = new \XoopsFormElementTray(''); |
|
248 | - $tray->addElement(new \XoopsFormHidden('action', 'template_save')); |
|
249 | - $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
250 | - $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
251 | - $ret = '<h4>' . _AM_SONGLIST_PERM_TEMPLATE . '</h4>' . _AM_SONGLIST_PERM_TEMPLATE_DESC . '<br><br><br>'; |
|
252 | - $ret .= "<form name='template' id='template' method='post'>\n<table width='100%' class='outer' cellspacing='1'>\n"; |
|
253 | - $ret .= implode("\n", $elements); |
|
254 | - $ret .= '<tr align="left" valign="top"><td class="head"></td><td class="even">'; |
|
255 | - $ret .= $tray->render(); |
|
256 | - $ret .= '</td></tr>'; |
|
257 | - $ret .= '</table></form>'; |
|
258 | - echo $ret; |
|
259 | - break; |
|
260 | - case 'template_save': |
|
261 | - $songlistpermHandler = Helper::getInstance()->getHandler('Permission'); |
|
262 | - $res = $songlistpermHandler->setTemplate($_POST['perms'], $groupid = 0); |
|
263 | - if ($res) { |
|
264 | - redirect_header('permissions.php?action=template', 2, _AM_SONGLIST_PERM_TEMPLATE_CREATED); |
|
265 | - } else { |
|
266 | - redirect_header('permissions.php?action=template', 2, _AM_SONGLIST_PERM_TEMPLATE_ERROR); |
|
267 | - } |
|
268 | - break; |
|
269 | - case 'apply': |
|
270 | - $songlistpermHandler = Helper::getInstance()->getHandler('Permission'); |
|
271 | - $perm_template = $songlistpermHandler->getTemplate(); |
|
272 | - if (null === $perm_template) { |
|
273 | - redirect_header('permissions.php?action=template', 2, _AM_SONGLIST_PERM_TEMPLATE); |
|
274 | - } |
|
218 | + /** @var \XoopsMemberHandler $memberHandler */ |
|
219 | + $memberHandler = xoops_getHandler('member'); |
|
220 | + $glist = $memberHandler->getGroupList(); |
|
221 | + $elements = []; |
|
222 | + $songlistpermHandler = Helper::getInstance()->getHandler('Permission'); |
|
223 | + $perm_template = $songlistpermHandler->getTemplate($groupid = 0); |
|
224 | + foreach (array_keys($glist) as $i) { |
|
225 | + $selected = !empty($perm_template[$i]) ? array_keys($perm_template[$i]) : []; |
|
226 | + $ret_ele = '<tr align="left" valign="top"><td class="head">' . $glist[$i] . '</td>'; |
|
227 | + $ret_ele .= '<td class="even">'; |
|
228 | + $ret_ele .= '<table class="outer"><tr><td class="odd"><table><tr>'; |
|
229 | + $ii = 0; |
|
230 | + $option_ids = []; |
|
231 | + foreach ($perms as $perm) { |
|
232 | + ++$ii; |
|
233 | + if (0 == $ii % 5) { |
|
234 | + $ret_ele .= '</tr><tr>'; |
|
235 | + } |
|
236 | + $checked = in_array('forum_' . $perm, $selected, true) ? ' checked' : ''; |
|
237 | + $option_id = $perm . '_' . $i; |
|
238 | + $option_ids[] = $option_id; |
|
239 | + $ret_ele .= '<td><input name="perms[' . $i . '][' . 'forum_' . $perm . ']" id="' . $option_id . '" onclick="" value="1" type="checkbox"' . $checked . '>' . constant('_AM_SONGLIST_CAN_' . \mb_strtoupper($perm)) . '<br></td>'; |
|
240 | + } |
|
241 | + $ret_ele .= '</tr></table></td><td class="even">'; |
|
242 | + $ret_ele .= _ALL . ' <input id="checkall[' . $i . ']" type="checkbox" value="" onclick="var optionids = new Array(' . implode(', ', $option_ids) . '); xoopsCheckAllElements(optionids, \'checkall[' . $i . ']\')">'; |
|
243 | + $ret_ele .= '</td></tr></table>'; |
|
244 | + $ret_ele .= '</td></tr>'; |
|
245 | + $elements[] = $ret_ele; |
|
246 | + } |
|
247 | + $tray = new \XoopsFormElementTray(''); |
|
248 | + $tray->addElement(new \XoopsFormHidden('action', 'template_save')); |
|
249 | + $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
250 | + $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
251 | + $ret = '<h4>' . _AM_SONGLIST_PERM_TEMPLATE . '</h4>' . _AM_SONGLIST_PERM_TEMPLATE_DESC . '<br><br><br>'; |
|
252 | + $ret .= "<form name='template' id='template' method='post'>\n<table width='100%' class='outer' cellspacing='1'>\n"; |
|
253 | + $ret .= implode("\n", $elements); |
|
254 | + $ret .= '<tr align="left" valign="top"><td class="head"></td><td class="even">'; |
|
255 | + $ret .= $tray->render(); |
|
256 | + $ret .= '</td></tr>'; |
|
257 | + $ret .= '</table></form>'; |
|
258 | + echo $ret; |
|
259 | + break; |
|
260 | + case 'template_save': |
|
261 | + $songlistpermHandler = Helper::getInstance()->getHandler('Permission'); |
|
262 | + $res = $songlistpermHandler->setTemplate($_POST['perms'], $groupid = 0); |
|
263 | + if ($res) { |
|
264 | + redirect_header('permissions.php?action=template', 2, _AM_SONGLIST_PERM_TEMPLATE_CREATED); |
|
265 | + } else { |
|
266 | + redirect_header('permissions.php?action=template', 2, _AM_SONGLIST_PERM_TEMPLATE_ERROR); |
|
267 | + } |
|
268 | + break; |
|
269 | + case 'apply': |
|
270 | + $songlistpermHandler = Helper::getInstance()->getHandler('Permission'); |
|
271 | + $perm_template = $songlistpermHandler->getTemplate(); |
|
272 | + if (null === $perm_template) { |
|
273 | + redirect_header('permissions.php?action=template', 2, _AM_SONGLIST_PERM_TEMPLATE); |
|
274 | + } |
|
275 | 275 | |
276 | - $opform = new \XoopsSimpleForm(_AM_SONGLIST_PERM_ACTION, 'actionform', 'permissions.php', 'get'); |
|
277 | - $op_select = new \XoopsFormSelect('', 'action'); |
|
278 | - $op_select->setExtra('onchange="document.forms.actionform.submit()"'); |
|
279 | - $op_select->addOptionArray(['no' => _SELECT, 'template' => _AM_SONGLIST_PERM_TEMPLATE, 'apply' => _AM_SONGLIST_PERM_TEMPLATEAPP]); |
|
280 | - $opform->addElement($op_select); |
|
281 | - $opform->display(); |
|
276 | + $opform = new \XoopsSimpleForm(_AM_SONGLIST_PERM_ACTION, 'actionform', 'permissions.php', 'get'); |
|
277 | + $op_select = new \XoopsFormSelect('', 'action'); |
|
278 | + $op_select->setExtra('onchange="document.forms.actionform.submit()"'); |
|
279 | + $op_select->addOptionArray(['no' => _SELECT, 'template' => _AM_SONGLIST_PERM_TEMPLATE, 'apply' => _AM_SONGLIST_PERM_TEMPLATEAPP]); |
|
280 | + $opform->addElement($op_select); |
|
281 | + $opform->display(); |
|
282 | 282 | |
283 | - $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
284 | - $categories = $categoryHandler->getAllCats('', true, false, true); |
|
283 | + $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
284 | + $categories = $categoryHandler->getAllCats('', true, false, true); |
|
285 | 285 | |
286 | - $GLOBALS['forumHandler'] = Helper::getInstance()->getHandler('Forum'); |
|
287 | - $songlists = $GLOBALS['forumHandler']->getForumsByCategory(0, '', false, false, true); |
|
288 | - $fm_options = []; |
|
289 | - foreach (array_keys($categories) as $c) { |
|
290 | - $fm_options[-1 * $c] = '[' . $categories[$c]->getVar('cat_title') . ']'; |
|
291 | - foreach (array_keys($songlists[$c]) as $f) { |
|
292 | - $fm_options[$f] = $songlists[$c][$f]['title']; |
|
293 | - if (!isset($songlists[$c][$f]['sub'])) { |
|
294 | - continue; |
|
295 | - } |
|
296 | - foreach (array_keys($songlists[$c][$f]['sub']) as $s) { |
|
297 | - $fm_options[$s] = '-- ' . $songlists[$c][$f]['sub'][$s]['title']; |
|
298 | - } |
|
299 | - } |
|
300 | - } |
|
301 | - unset($songlists, $categories); |
|
302 | - $fmform = new \XoopsThemeForm(_AM_SONGLIST_PERM_TEMPLATEAPP, 'fmform', 'permissions.php', 'post', true); |
|
303 | - $fm_select = new \XoopsFormSelect(_AM_SONGLIST_PERM_FORUMS, 'forums', null, 10, true); |
|
304 | - $fm_select->addOptionArray($fm_options); |
|
305 | - $fmform->addElement($fm_select); |
|
306 | - $tray = new \XoopsFormElementTray(''); |
|
307 | - $tray->addElement(new \XoopsFormHidden('action', 'apply_save')); |
|
308 | - $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
309 | - $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
310 | - $fmform->addElement($tray); |
|
311 | - $fmform->display(); |
|
312 | - break; |
|
313 | - case 'apply_save': |
|
314 | - if (empty($_POST['forums'])) { |
|
315 | - break; |
|
316 | - } |
|
317 | - $songlistpermHandler = Helper::getInstance()->getHandler('Permission'); |
|
318 | - foreach ($_POST['forums'] as $songlist) { |
|
319 | - if ($songlist < 1) { |
|
320 | - continue; |
|
321 | - } |
|
322 | - $songlistpermHandler->applyTemplate($songlist, $module_id); |
|
323 | - } |
|
324 | - redirect_header('permissions.php', 2, _AM_SONGLIST_PERM_TEMPLATE_APPLIED); |
|
325 | - break; |
|
326 | - default: |
|
327 | - $opform = new \XoopsSimpleForm(_AM_SONGLIST_PERM_ACTION, 'actionform', 'permissions.php', 'get'); |
|
328 | - $op_select = new \XoopsFormSelect('', 'action'); |
|
329 | - $op_select->setExtra('onchange="document.forms.actionform.submit()"'); |
|
330 | - $op_select->addOptionArray( |
|
331 | - [ |
|
332 | - 'no' => _SELECT, |
|
333 | - 'template' => _AM_SONGLIST_PERM_TEMPLATE, |
|
334 | - 'apply' => _AM_SONGLIST_PERM_TEMPLATEAPP, |
|
335 | - 'default' => _AM_SONGLIST_PERM_SETBYGROUP, |
|
336 | - ] |
|
337 | - ); |
|
338 | - $opform->addElement($op_select); |
|
339 | - $opform->display(); |
|
286 | + $GLOBALS['forumHandler'] = Helper::getInstance()->getHandler('Forum'); |
|
287 | + $songlists = $GLOBALS['forumHandler']->getForumsByCategory(0, '', false, false, true); |
|
288 | + $fm_options = []; |
|
289 | + foreach (array_keys($categories) as $c) { |
|
290 | + $fm_options[-1 * $c] = '[' . $categories[$c]->getVar('cat_title') . ']'; |
|
291 | + foreach (array_keys($songlists[$c]) as $f) { |
|
292 | + $fm_options[$f] = $songlists[$c][$f]['title']; |
|
293 | + if (!isset($songlists[$c][$f]['sub'])) { |
|
294 | + continue; |
|
295 | + } |
|
296 | + foreach (array_keys($songlists[$c][$f]['sub']) as $s) { |
|
297 | + $fm_options[$s] = '-- ' . $songlists[$c][$f]['sub'][$s]['title']; |
|
298 | + } |
|
299 | + } |
|
300 | + } |
|
301 | + unset($songlists, $categories); |
|
302 | + $fmform = new \XoopsThemeForm(_AM_SONGLIST_PERM_TEMPLATEAPP, 'fmform', 'permissions.php', 'post', true); |
|
303 | + $fm_select = new \XoopsFormSelect(_AM_SONGLIST_PERM_FORUMS, 'forums', null, 10, true); |
|
304 | + $fm_select->addOptionArray($fm_options); |
|
305 | + $fmform->addElement($fm_select); |
|
306 | + $tray = new \XoopsFormElementTray(''); |
|
307 | + $tray->addElement(new \XoopsFormHidden('action', 'apply_save')); |
|
308 | + $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
309 | + $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
|
310 | + $fmform->addElement($tray); |
|
311 | + $fmform->display(); |
|
312 | + break; |
|
313 | + case 'apply_save': |
|
314 | + if (empty($_POST['forums'])) { |
|
315 | + break; |
|
316 | + } |
|
317 | + $songlistpermHandler = Helper::getInstance()->getHandler('Permission'); |
|
318 | + foreach ($_POST['forums'] as $songlist) { |
|
319 | + if ($songlist < 1) { |
|
320 | + continue; |
|
321 | + } |
|
322 | + $songlistpermHandler->applyTemplate($songlist, $module_id); |
|
323 | + } |
|
324 | + redirect_header('permissions.php', 2, _AM_SONGLIST_PERM_TEMPLATE_APPLIED); |
|
325 | + break; |
|
326 | + default: |
|
327 | + $opform = new \XoopsSimpleForm(_AM_SONGLIST_PERM_ACTION, 'actionform', 'permissions.php', 'get'); |
|
328 | + $op_select = new \XoopsFormSelect('', 'action'); |
|
329 | + $op_select->setExtra('onchange="document.forms.actionform.submit()"'); |
|
330 | + $op_select->addOptionArray( |
|
331 | + [ |
|
332 | + 'no' => _SELECT, |
|
333 | + 'template' => _AM_SONGLIST_PERM_TEMPLATE, |
|
334 | + 'apply' => _AM_SONGLIST_PERM_TEMPLATEAPP, |
|
335 | + 'default' => _AM_SONGLIST_PERM_SETBYGROUP, |
|
336 | + ] |
|
337 | + ); |
|
338 | + $opform->addElement($op_select); |
|
339 | + $opform->display(); |
|
340 | 340 | |
341 | - $GLOBALS['forumHandler'] = Helper::getInstance()->getHandler('Forum'); |
|
342 | - $songlists = $GLOBALS['forumHandler']->getForumsByCategory(0, '', false, false, true); |
|
343 | - $op_options = ['category' => _AM_SONGLIST_CAT_ACCESS]; |
|
344 | - $fm_options = ['category' => ['title' => _AM_SONGLIST_CAT_ACCESS, 'item' => 'category_access', 'desc' => '', 'anonymous' => true]]; |
|
345 | - foreach ($perms as $perm) { |
|
346 | - $op_options[$perm] = constant('_AM_SONGLIST_CAN_' . \mb_strtoupper($perm)); |
|
347 | - $fm_options[$perm] = ['title' => constant('_AM_SONGLIST_CAN_' . \mb_strtoupper($perm)), 'item' => 'forum_' . $perm, 'desc' => '', 'anonymous' => true]; |
|
348 | - } |
|
341 | + $GLOBALS['forumHandler'] = Helper::getInstance()->getHandler('Forum'); |
|
342 | + $songlists = $GLOBALS['forumHandler']->getForumsByCategory(0, '', false, false, true); |
|
343 | + $op_options = ['category' => _AM_SONGLIST_CAT_ACCESS]; |
|
344 | + $fm_options = ['category' => ['title' => _AM_SONGLIST_CAT_ACCESS, 'item' => 'category_access', 'desc' => '', 'anonymous' => true]]; |
|
345 | + foreach ($perms as $perm) { |
|
346 | + $op_options[$perm] = constant('_AM_SONGLIST_CAN_' . \mb_strtoupper($perm)); |
|
347 | + $fm_options[$perm] = ['title' => constant('_AM_SONGLIST_CAN_' . \mb_strtoupper($perm)), 'item' => 'forum_' . $perm, 'desc' => '', 'anonymous' => true]; |
|
348 | + } |
|
349 | 349 | |
350 | - $op_keys = array_keys($op_options); |
|
351 | - $op = isset($_GET['op']) ? \mb_strtolower($_GET['op']) : (isset($_COOKIE['op']) ? \mb_strtolower($_COOKIE['op']) : ''); |
|
352 | - if (empty($op)) { |
|
353 | - $op = $op_keys[0]; |
|
354 | - setcookie('op', $op_keys[1] ?? ''); |
|
355 | - } else { |
|
356 | - for ($i = 0, $iMax = count($op_keys); $i < $iMax; ++$i) { |
|
357 | - if ($op_keys[$i] == $op) { |
|
358 | - break; |
|
359 | - } |
|
360 | - } |
|
361 | - setcookie('op', $op_keys[$i + 1] ?? ''); |
|
362 | - } |
|
350 | + $op_keys = array_keys($op_options); |
|
351 | + $op = isset($_GET['op']) ? \mb_strtolower($_GET['op']) : (isset($_COOKIE['op']) ? \mb_strtolower($_COOKIE['op']) : ''); |
|
352 | + if (empty($op)) { |
|
353 | + $op = $op_keys[0]; |
|
354 | + setcookie('op', $op_keys[1] ?? ''); |
|
355 | + } else { |
|
356 | + for ($i = 0, $iMax = count($op_keys); $i < $iMax; ++$i) { |
|
357 | + if ($op_keys[$i] == $op) { |
|
358 | + break; |
|
359 | + } |
|
360 | + } |
|
361 | + setcookie('op', $op_keys[$i + 1] ?? ''); |
|
362 | + } |
|
363 | 363 | |
364 | - $opform = new \XoopsSimpleForm('', 'opform', 'permissions.php', 'get'); |
|
365 | - $op_select = new \XoopsFormSelect('', 'op', $op); |
|
366 | - $op_select->setExtra('onchange="document.forms.opform.submit()"'); |
|
367 | - $op_select->addOptionArray($op_options); |
|
368 | - $opform->addElement($op_select); |
|
369 | - $opform->display(); |
|
364 | + $opform = new \XoopsSimpleForm('', 'opform', 'permissions.php', 'get'); |
|
365 | + $op_select = new \XoopsFormSelect('', 'op', $op); |
|
366 | + $op_select->setExtra('onchange="document.forms.opform.submit()"'); |
|
367 | + $op_select->addOptionArray($op_options); |
|
368 | + $opform->addElement($op_select); |
|
369 | + $opform->display(); |
|
370 | 370 | |
371 | - $perm_desc = ''; |
|
371 | + $perm_desc = ''; |
|
372 | 372 | |
373 | - $form = new forum_XoopsGroupPermForm($fm_options[$op]['title'], $module_id, $fm_options[$op]['item'], $fm_options[$op]['desc'], 'admin/permissions.php', $fm_options[$op]['anonymous']); |
|
373 | + $form = new forum_XoopsGroupPermForm($fm_options[$op]['title'], $module_id, $fm_options[$op]['item'], $fm_options[$op]['desc'], 'admin/permissions.php', $fm_options[$op]['anonymous']); |
|
374 | 374 | |
375 | - $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
376 | - $categories = $categoryHandler->getObjects(null, true); |
|
377 | - if ('category' === $op) { |
|
378 | - foreach (array_keys($categories) as $c) { |
|
379 | - $form->addItem($c, $categories[$c]->getVar('cat_title')); |
|
380 | - } |
|
381 | - unset($categories); |
|
382 | - } else { |
|
383 | - foreach (array_keys($categories) as $c) { |
|
384 | - $key_c = -1 * $c; |
|
385 | - $form->addItem($key_c, '<strong>[' . $categories[$c]->getVar('cat_title') . ']</strong>'); |
|
386 | - foreach (array_keys($songlists[$c]) as $f) { |
|
387 | - $form->addItem($f, $songlists[$c][$f]['title'], $key_c); |
|
388 | - if (!isset($songlists[$c][$f]['sub'])) { |
|
389 | - continue; |
|
390 | - } |
|
391 | - foreach (array_keys($songlists[$c][$f]['sub']) as $s) { |
|
392 | - $form->addItem($s, '→' . $songlists[$c][$f]['sub'][$s]['title'], $f); |
|
393 | - } |
|
394 | - } |
|
395 | - } |
|
396 | - unset($songlists, $categories); |
|
397 | - } |
|
398 | - $form->display(); |
|
375 | + $categoryHandler = Helper::getInstance()->getHandler('Category'); |
|
376 | + $categories = $categoryHandler->getObjects(null, true); |
|
377 | + if ('category' === $op) { |
|
378 | + foreach (array_keys($categories) as $c) { |
|
379 | + $form->addItem($c, $categories[$c]->getVar('cat_title')); |
|
380 | + } |
|
381 | + unset($categories); |
|
382 | + } else { |
|
383 | + foreach (array_keys($categories) as $c) { |
|
384 | + $key_c = -1 * $c; |
|
385 | + $form->addItem($key_c, '<strong>[' . $categories[$c]->getVar('cat_title') . ']</strong>'); |
|
386 | + foreach (array_keys($songlists[$c]) as $f) { |
|
387 | + $form->addItem($f, $songlists[$c][$f]['title'], $key_c); |
|
388 | + if (!isset($songlists[$c][$f]['sub'])) { |
|
389 | + continue; |
|
390 | + } |
|
391 | + foreach (array_keys($songlists[$c][$f]['sub']) as $s) { |
|
392 | + $form->addItem($s, '→' . $songlists[$c][$f]['sub'][$s]['title'], $f); |
|
393 | + } |
|
394 | + } |
|
395 | + } |
|
396 | + unset($songlists, $categories); |
|
397 | + } |
|
398 | + $form->display(); |
|
399 | 399 | |
400 | - break; |
|
400 | + break; |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | echo chronolabs_inline(false); |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | use Xmf\Module\Admin; |
19 | 19 | use XoopsModules\Songlist\Helper; |
20 | 20 | |
21 | -require_once __DIR__ . '/header.php'; |
|
22 | -require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['songlistModule']->getVar('dirname') . '/class/xoopsformloader.php'; |
|
23 | -require_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; |
|
21 | +require_once __DIR__.'/header.php'; |
|
22 | +require_once XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['songlistModule']->getVar('dirname').'/class/xoopsformloader.php'; |
|
23 | +require_once XOOPS_ROOT_PATH.'/class/xoopsform/grouppermform.php'; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Add category navigation to forum casscade structure |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | foreach (array_keys($glist) as $i) { |
65 | 65 | // get selected item id(s) for each group |
66 | 66 | $selected = $grouppermHandler->getItemIds($this->_permName, $i, $this->_modid); |
67 | - $ele = new forum_XoopsGroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected); |
|
67 | + $ele = new forum_XoopsGroupFormCheckBox($glist[$i], 'perms['.$this->_permName.']', $i, $selected); |
|
68 | 68 | $ele->setOptionTree($this->_itemTree); |
69 | 69 | $this->addElement($ele); |
70 | 70 | unset($ele); |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
74 | 74 | $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
75 | 75 | $this->addElement($tray); |
76 | - $ret = '<h4>' . $this->getTitle() . '</h4>' . $this->_permDesc . '<br>'; |
|
77 | - $ret .= "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n<table width='100%' class='outer' cellspacing='1' valign='top'>\n"; |
|
76 | + $ret = '<h4>'.$this->getTitle().'</h4>'.$this->_permDesc.'<br>'; |
|
77 | + $ret .= "<form name='".$this->getName()."' id='".$this->getName()."' action='".$this->getAction()."' method='".$this->getMethod()."'".$this->getExtra().">\n<table width='100%' class='outer' cellspacing='1' valign='top'>\n"; |
|
78 | 78 | $elements = $this->getElements(); |
79 | 79 | $hidden = ''; |
80 | 80 | foreach (array_keys($elements) as $i) { |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | } elseif ($elements[$i]->isHidden()) { |
84 | 84 | $hidden .= $elements[$i]->render(); |
85 | 85 | } else { |
86 | - $ret .= "<tr valign='top' align='left'><td class='head'>" . $elements[$i]->getCaption(); |
|
87 | - if ('' != $elements[$i]->getDescription()) { |
|
88 | - $ret .= '<br><br><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>'; |
|
86 | + $ret .= "<tr valign='top' align='left'><td class='head'>".$elements[$i]->getCaption(); |
|
87 | + if (''!=$elements[$i]->getDescription()) { |
|
88 | + $ret .= '<br><br><span style="font-weight: normal;">'.$elements[$i]->getDescription().'</span>'; |
|
89 | 89 | } |
90 | - $ret .= "</td>\n<td class='even'>\n" . $elements[$i]->render() . "\n</td></tr>\n"; |
|
90 | + $ret .= "</td>\n<td class='even'>\n".$elements[$i]->render()."\n</td></tr>\n"; |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | $ret .= "</table>$hidden</form>"; |
@@ -124,25 +124,25 @@ discard block |
||
124 | 124 | $ret = '<table class="outer"><tr><td class="odd"><table><tr>'; |
125 | 125 | $cols = 1; |
126 | 126 | foreach ($this->_optionTree[0]['children'] as $topitem) { |
127 | - if ($cols > 4) { |
|
128 | - $ret .= '</tr><tr>'; |
|
127 | + if ($cols>4) { |
|
128 | + $ret .= '</tr><tr>'; |
|
129 | 129 | $cols = 1; |
130 | 130 | } |
131 | 131 | $tree = '<td valign="top">'; |
132 | 132 | $prefix = ''; |
133 | 133 | $this->_renderOptionTree($tree, $this->_optionTree[$topitem], $prefix); |
134 | - $ret .= $tree . '</td>'; |
|
134 | + $ret .= $tree.'</td>'; |
|
135 | 135 | ++$cols; |
136 | 136 | } |
137 | 137 | $ret .= '</tr></table></td><td class="even">'; |
138 | 138 | foreach (array_keys($this->_optionTree) as $id) { |
139 | 139 | if (!empty($id)) { |
140 | - $option_ids[] = "'" . $this->getName() . '[groups][' . $this->_groupId . '][' . $id . ']' . "'"; |
|
140 | + $option_ids[] = "'".$this->getName().'[groups]['.$this->_groupId.']['.$id.']'."'"; |
|
141 | 141 | } |
142 | 142 | } |
143 | - $checkallbtn_id = $this->getName() . '[checkallbtn][' . $this->_groupId . ']'; |
|
143 | + $checkallbtn_id = $this->getName().'[checkallbtn]['.$this->_groupId.']'; |
|
144 | 144 | $option_ids_str = implode(', ', $option_ids); |
145 | - $ret .= _ALL . ' <input id="' . $checkallbtn_id . '" type="checkbox" value="" onclick="var optionids = new Array(' . $option_ids_str . "); xoopsCheckAllElements(optionids, '" . $checkallbtn_id . "');\">"; |
|
145 | + $ret .= _ALL.' <input id="'.$checkallbtn_id.'" type="checkbox" value="" onclick="var optionids = new Array('.$option_ids_str."); xoopsCheckAllElements(optionids, '".$checkallbtn_id."');\">"; |
|
146 | 146 | $ret .= '</td></tr></table>'; |
147 | 147 | |
148 | 148 | return $ret; |
@@ -156,36 +156,36 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = []): void |
158 | 158 | { |
159 | - if ($option['id'] > 0) : |
|
160 | - $tree .= $prefix . '<input type="checkbox" name="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" id="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" onclick="'; |
|
159 | + if ($option['id']>0) : |
|
160 | + $tree .= $prefix.'<input type="checkbox" name="'.$this->getName().'[groups]['.$this->_groupId.']['.$option['id'].']" id="'.$this->getName().'[groups]['.$this->_groupId.']['.$option['id'].']" onclick="'; |
|
161 | 161 | foreach ($parentIds as $pid) { |
162 | - if ($pid <= 0) { |
|
162 | + if ($pid<=0) { |
|
163 | 163 | continue; |
164 | 164 | } |
165 | - $parent_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $pid . ']'; |
|
166 | - $tree .= "var ele = xoopsGetElementById('" . $parent_ele . "'); if(ele.checked !== true) {ele.checked = this.checked;}"; |
|
165 | + $parent_ele = $this->getName().'[groups]['.$this->_groupId.']['.$pid.']'; |
|
166 | + $tree .= "var ele = xoopsGetElementById('".$parent_ele."'); if(ele.checked !== true) {ele.checked = this.checked;}"; |
|
167 | 167 | } |
168 | 168 | foreach ($option['allchild'] as $cid) { |
169 | - $child_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $cid . ']'; |
|
170 | - $tree .= "var ele = xoopsGetElementById('" . $child_ele . "'); if(this.checked !== true) {ele.checked = false;}"; |
|
169 | + $child_ele = $this->getName().'[groups]['.$this->_groupId.']['.$cid.']'; |
|
170 | + $tree .= "var ele = xoopsGetElementById('".$child_ele."'); if(this.checked !== true) {ele.checked = false;}"; |
|
171 | 171 | } |
172 | 172 | $tree .= '" value="1"'; |
173 | 173 | if (in_array($option['id'], $this->_value, true)) { |
174 | 174 | $tree .= ' checked'; |
175 | 175 | } |
176 | - $tree .= '>' . $option['name'] . '<input type="hidden" name="' . $this->getName() . '[parents][' . $option['id'] . ']" value="' . implode(':', $parentIds) . '"><input type="hidden" name="' . $this->getName() . '[itemname][' . $option['id'] . ']" value="' . htmlspecialchars( |
|
176 | + $tree .= '>'.$option['name'].'<input type="hidden" name="'.$this->getName().'[parents]['.$option['id'].']" value="'.implode(':', $parentIds).'"><input type="hidden" name="'.$this->getName().'[itemname]['.$option['id'].']" value="'.htmlspecialchars( |
|
177 | 177 | $option['name'], |
178 | 178 | ENT_QUOTES | ENT_HTML5 |
179 | - ) . "\"><br>\n"; |
|
179 | + )."\"><br>\n"; |
|
180 | 180 | else : |
181 | - $tree .= $prefix . $option['name'] . '<input type="hidden" id="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . "]\"><br>\n"; |
|
181 | + $tree .= $prefix.$option['name'].'<input type="hidden" id="'.$this->getName().'[groups]['.$this->_groupId.']['.$option['id']."]\"><br>\n"; |
|
182 | 182 | endif; |
183 | 183 | if (isset($option['children'])) { |
184 | 184 | foreach ($option['children'] as $child) { |
185 | - if ($option['id'] > 0) { |
|
185 | + if ($option['id']>0) { |
|
186 | 186 | $parentIds[] = $option['id']; |
187 | 187 | } |
188 | - $this->_renderOptionTree($tree, $this->_optionTree[$child], $prefix . ' -', $parentIds); |
|
188 | + $this->_renderOptionTree($tree, $this->_optionTree[$child], $prefix.' -', $parentIds); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
@@ -223,23 +223,23 @@ discard block |
||
223 | 223 | $perm_template = $songlistpermHandler->getTemplate($groupid = 0); |
224 | 224 | foreach (array_keys($glist) as $i) { |
225 | 225 | $selected = !empty($perm_template[$i]) ? array_keys($perm_template[$i]) : []; |
226 | - $ret_ele = '<tr align="left" valign="top"><td class="head">' . $glist[$i] . '</td>'; |
|
226 | + $ret_ele = '<tr align="left" valign="top"><td class="head">'.$glist[$i].'</td>'; |
|
227 | 227 | $ret_ele .= '<td class="even">'; |
228 | 228 | $ret_ele .= '<table class="outer"><tr><td class="odd"><table><tr>'; |
229 | 229 | $ii = 0; |
230 | 230 | $option_ids = []; |
231 | 231 | foreach ($perms as $perm) { |
232 | 232 | ++$ii; |
233 | - if (0 == $ii % 5) { |
|
233 | + if (0==$ii%5) { |
|
234 | 234 | $ret_ele .= '</tr><tr>'; |
235 | 235 | } |
236 | - $checked = in_array('forum_' . $perm, $selected, true) ? ' checked' : ''; |
|
237 | - $option_id = $perm . '_' . $i; |
|
236 | + $checked = in_array('forum_'.$perm, $selected, true) ? ' checked' : ''; |
|
237 | + $option_id = $perm.'_'.$i; |
|
238 | 238 | $option_ids[] = $option_id; |
239 | - $ret_ele .= '<td><input name="perms[' . $i . '][' . 'forum_' . $perm . ']" id="' . $option_id . '" onclick="" value="1" type="checkbox"' . $checked . '>' . constant('_AM_SONGLIST_CAN_' . \mb_strtoupper($perm)) . '<br></td>'; |
|
239 | + $ret_ele .= '<td><input name="perms['.$i.']['.'forum_'.$perm.']" id="'.$option_id.'" onclick="" value="1" type="checkbox"'.$checked.'>'.constant('_AM_SONGLIST_CAN_'.\mb_strtoupper($perm)).'<br></td>'; |
|
240 | 240 | } |
241 | 241 | $ret_ele .= '</tr></table></td><td class="even">'; |
242 | - $ret_ele .= _ALL . ' <input id="checkall[' . $i . ']" type="checkbox" value="" onclick="var optionids = new Array(' . implode(', ', $option_ids) . '); xoopsCheckAllElements(optionids, \'checkall[' . $i . ']\')">'; |
|
242 | + $ret_ele .= _ALL.' <input id="checkall['.$i.']" type="checkbox" value="" onclick="var optionids = new Array('.implode(', ', $option_ids).'); xoopsCheckAllElements(optionids, \'checkall['.$i.']\')">'; |
|
243 | 243 | $ret_ele .= '</td></tr></table>'; |
244 | 244 | $ret_ele .= '</td></tr>'; |
245 | 245 | $elements[] = $ret_ele; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | $tray->addElement(new \XoopsFormHidden('action', 'template_save')); |
249 | 249 | $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
250 | 250 | $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
251 | - $ret = '<h4>' . _AM_SONGLIST_PERM_TEMPLATE . '</h4>' . _AM_SONGLIST_PERM_TEMPLATE_DESC . '<br><br><br>'; |
|
251 | + $ret = '<h4>'._AM_SONGLIST_PERM_TEMPLATE.'</h4>'._AM_SONGLIST_PERM_TEMPLATE_DESC.'<br><br><br>'; |
|
252 | 252 | $ret .= "<form name='template' id='template' method='post'>\n<table width='100%' class='outer' cellspacing='1'>\n"; |
253 | 253 | $ret .= implode("\n", $elements); |
254 | 254 | $ret .= '<tr align="left" valign="top"><td class="head"></td><td class="even">'; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | case 'apply': |
270 | 270 | $songlistpermHandler = Helper::getInstance()->getHandler('Permission'); |
271 | 271 | $perm_template = $songlistpermHandler->getTemplate(); |
272 | - if (null === $perm_template) { |
|
272 | + if (null===$perm_template) { |
|
273 | 273 | redirect_header('permissions.php?action=template', 2, _AM_SONGLIST_PERM_TEMPLATE); |
274 | 274 | } |
275 | 275 | |
@@ -287,14 +287,14 @@ discard block |
||
287 | 287 | $songlists = $GLOBALS['forumHandler']->getForumsByCategory(0, '', false, false, true); |
288 | 288 | $fm_options = []; |
289 | 289 | foreach (array_keys($categories) as $c) { |
290 | - $fm_options[-1 * $c] = '[' . $categories[$c]->getVar('cat_title') . ']'; |
|
290 | + $fm_options[-1*$c] = '['.$categories[$c]->getVar('cat_title').']'; |
|
291 | 291 | foreach (array_keys($songlists[$c]) as $f) { |
292 | 292 | $fm_options[$f] = $songlists[$c][$f]['title']; |
293 | 293 | if (!isset($songlists[$c][$f]['sub'])) { |
294 | 294 | continue; |
295 | 295 | } |
296 | 296 | foreach (array_keys($songlists[$c][$f]['sub']) as $s) { |
297 | - $fm_options[$s] = '-- ' . $songlists[$c][$f]['sub'][$s]['title']; |
|
297 | + $fm_options[$s] = '-- '.$songlists[$c][$f]['sub'][$s]['title']; |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | } |
317 | 317 | $songlistpermHandler = Helper::getInstance()->getHandler('Permission'); |
318 | 318 | foreach ($_POST['forums'] as $songlist) { |
319 | - if ($songlist < 1) { |
|
319 | + if ($songlist<1) { |
|
320 | 320 | continue; |
321 | 321 | } |
322 | 322 | $songlistpermHandler->applyTemplate($songlist, $module_id); |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | $op_options = ['category' => _AM_SONGLIST_CAT_ACCESS]; |
344 | 344 | $fm_options = ['category' => ['title' => _AM_SONGLIST_CAT_ACCESS, 'item' => 'category_access', 'desc' => '', 'anonymous' => true]]; |
345 | 345 | foreach ($perms as $perm) { |
346 | - $op_options[$perm] = constant('_AM_SONGLIST_CAN_' . \mb_strtoupper($perm)); |
|
347 | - $fm_options[$perm] = ['title' => constant('_AM_SONGLIST_CAN_' . \mb_strtoupper($perm)), 'item' => 'forum_' . $perm, 'desc' => '', 'anonymous' => true]; |
|
346 | + $op_options[$perm] = constant('_AM_SONGLIST_CAN_'.\mb_strtoupper($perm)); |
|
347 | + $fm_options[$perm] = ['title' => constant('_AM_SONGLIST_CAN_'.\mb_strtoupper($perm)), 'item' => 'forum_'.$perm, 'desc' => '', 'anonymous' => true]; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | $op_keys = array_keys($op_options); |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | $op = $op_keys[0]; |
354 | 354 | setcookie('op', $op_keys[1] ?? ''); |
355 | 355 | } else { |
356 | - for ($i = 0, $iMax = count($op_keys); $i < $iMax; ++$i) { |
|
357 | - if ($op_keys[$i] == $op) { |
|
356 | + for ($i = 0, $iMax = count($op_keys); $i<$iMax; ++$i) { |
|
357 | + if ($op_keys[$i]==$op) { |
|
358 | 358 | break; |
359 | 359 | } |
360 | 360 | } |
361 | - setcookie('op', $op_keys[$i + 1] ?? ''); |
|
361 | + setcookie('op', $op_keys[$i+1] ?? ''); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | $opform = new \XoopsSimpleForm('', 'opform', 'permissions.php', 'get'); |
@@ -374,22 +374,22 @@ discard block |
||
374 | 374 | |
375 | 375 | $categoryHandler = Helper::getInstance()->getHandler('Category'); |
376 | 376 | $categories = $categoryHandler->getObjects(null, true); |
377 | - if ('category' === $op) { |
|
377 | + if ('category'===$op) { |
|
378 | 378 | foreach (array_keys($categories) as $c) { |
379 | 379 | $form->addItem($c, $categories[$c]->getVar('cat_title')); |
380 | 380 | } |
381 | 381 | unset($categories); |
382 | 382 | } else { |
383 | 383 | foreach (array_keys($categories) as $c) { |
384 | - $key_c = -1 * $c; |
|
385 | - $form->addItem($key_c, '<strong>[' . $categories[$c]->getVar('cat_title') . ']</strong>'); |
|
384 | + $key_c = -1*$c; |
|
385 | + $form->addItem($key_c, '<strong>['.$categories[$c]->getVar('cat_title').']</strong>'); |
|
386 | 386 | foreach (array_keys($songlists[$c]) as $f) { |
387 | 387 | $form->addItem($f, $songlists[$c][$f]['title'], $key_c); |
388 | 388 | if (!isset($songlists[$c][$f]['sub'])) { |
389 | 389 | continue; |
390 | 390 | } |
391 | 391 | foreach (array_keys($songlists[$c][$f]['sub']) as $s) { |
392 | - $form->addItem($s, '→' . $songlists[$c][$f]['sub'][$s]['title'], $f); |
|
392 | + $form->addItem($s, '→'.$songlists[$c][$f]['sub'][$s]['title'], $f); |
|
393 | 393 | } |
394 | 394 | } |
395 | 395 | } |
@@ -177,8 +177,10 @@ |
||
177 | 177 | $option['name'], |
178 | 178 | ENT_QUOTES | ENT_HTML5 |
179 | 179 | ) . "\"><br>\n"; |
180 | - else : |
|
180 | + else { |
|
181 | + : |
|
181 | 182 | $tree .= $prefix . $option['name'] . '<input type="hidden" id="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . "]\"><br>\n"; |
183 | + } |
|
182 | 184 | endif; |
183 | 185 | if (isset($option['children'])) { |
184 | 186 | foreach ($option['children'] as $child) { |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | $pathIcon32 = Admin::menuIconPath(''); |
16 | 16 | $pathModIcon32 = XOOPS_URL . '/modules/' . $moduleDirName . '/assets/images/icons/32/'; |
17 | 17 | if (is_object($helper->getModule()) && false !== $helper->getModule()->getInfo('modicons32')) { |
18 | - $pathModIcon32 = $helper->url($helper->getModule()->getInfo('modicons32')); |
|
18 | + $pathModIcon32 = $helper->url($helper->getModule()->getInfo('modicons32')); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** @var \XoopsModuleHandler $moduleHandler */ |
@@ -26,65 +26,65 @@ discard block |
||
26 | 26 | $GLOBALS['songlistModuleConfig'] = $configHandler->getConfigList($GLOBALS['songlistModule']->getVar('mid')); |
27 | 27 | |
28 | 28 | $adminmenu[] = [ |
29 | - 'title' => _MI_SONGLIST_ADMENU_DASHBOARD, |
|
30 | - 'icon' => $pathIcon32 . '/home.png', |
|
31 | - 'image' => $pathIcon32 . '/home.png', |
|
32 | - 'link' => 'admin/index.php', |
|
29 | + 'title' => _MI_SONGLIST_ADMENU_DASHBOARD, |
|
30 | + 'icon' => $pathIcon32 . '/home.png', |
|
31 | + 'image' => $pathIcon32 . '/home.png', |
|
32 | + 'link' => 'admin/index.php', |
|
33 | 33 | ]; |
34 | 34 | |
35 | 35 | $adminmenu[] = [ |
36 | - 'title' => _MI_SONGLIST_ADMENU_CATEGORY, |
|
37 | - 'icon' => 'assets/images/icons/32/songlist.category.png', |
|
38 | - 'image' => 'assets/images/icons/32/songlist.category.png', |
|
39 | - 'link' => 'admin/category.php', |
|
36 | + 'title' => _MI_SONGLIST_ADMENU_CATEGORY, |
|
37 | + 'icon' => 'assets/images/icons/32/songlist.category.png', |
|
38 | + 'image' => 'assets/images/icons/32/songlist.category.png', |
|
39 | + 'link' => 'admin/category.php', |
|
40 | 40 | ]; |
41 | 41 | |
42 | 42 | if ($GLOBALS['songlistModuleConfig']['voice']) { |
43 | - $adminmenu[] = [ |
|
44 | - 'title' => _MI_SONGLIST_ADMENU_VOICE, |
|
45 | - 'icon' => 'assets/images/icons/32/songlist.voice.png', |
|
46 | - 'image' => 'assets/images/icons/32/songlist.voice.png', |
|
47 | - 'link' => 'admin/voice.php', |
|
48 | - ]; |
|
43 | + $adminmenu[] = [ |
|
44 | + 'title' => _MI_SONGLIST_ADMENU_VOICE, |
|
45 | + 'icon' => 'assets/images/icons/32/songlist.voice.png', |
|
46 | + 'image' => 'assets/images/icons/32/songlist.voice.png', |
|
47 | + 'link' => 'admin/voice.php', |
|
48 | + ]; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | if ($GLOBALS['songlistModuleConfig']['album']) { |
52 | - $adminmenu[] = [ |
|
53 | - 'title' => _MI_SONGLIST_ADMENU_ALBUMS, |
|
54 | - 'icon' => 'assets/images/icons/32/songlist.albums.png', |
|
55 | - 'image' => 'assets/images/icons/32/songlist.albums.png', |
|
56 | - 'link' => 'admin/albums.php', |
|
57 | - ]; |
|
52 | + $adminmenu[] = [ |
|
53 | + 'title' => _MI_SONGLIST_ADMENU_ALBUMS, |
|
54 | + 'icon' => 'assets/images/icons/32/songlist.albums.png', |
|
55 | + 'image' => 'assets/images/icons/32/songlist.albums.png', |
|
56 | + 'link' => 'admin/albums.php', |
|
57 | + ]; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | if ($GLOBALS['songlistModuleConfig']['genre']) { |
61 | - $adminmenu[] = [ |
|
62 | - 'title' => _MI_SONGLIST_ADMENU_GENRE, |
|
63 | - 'icon' => 'assets/images/icons/32/songlist.genre.png', |
|
64 | - 'image' => 'assets/images/icons/32/songlist.genre.png', |
|
65 | - 'link' => 'admin/genre.php', |
|
66 | - ]; |
|
61 | + $adminmenu[] = [ |
|
62 | + 'title' => _MI_SONGLIST_ADMENU_GENRE, |
|
63 | + 'icon' => 'assets/images/icons/32/songlist.genre.png', |
|
64 | + 'image' => 'assets/images/icons/32/songlist.genre.png', |
|
65 | + 'link' => 'admin/genre.php', |
|
66 | + ]; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $adminmenu[] = [ |
70 | - 'title' => _MI_SONGLIST_ADMENU_ARTISTS, |
|
71 | - 'icon' => 'assets/images/icons/32/songlist.artists.png', |
|
72 | - 'image' => 'assets/images/icons/32/songlist.artists.png', |
|
73 | - 'link' => 'admin/artists.php', |
|
70 | + 'title' => _MI_SONGLIST_ADMENU_ARTISTS, |
|
71 | + 'icon' => 'assets/images/icons/32/songlist.artists.png', |
|
72 | + 'image' => 'assets/images/icons/32/songlist.artists.png', |
|
73 | + 'link' => 'admin/artists.php', |
|
74 | 74 | ]; |
75 | 75 | |
76 | 76 | $adminmenu[] = [ |
77 | - 'title' => _MI_SONGLIST_ADMENU_SONGS, |
|
78 | - 'icon' => 'assets/images/icons/32/songlist.songs.png', |
|
79 | - 'image' => 'assets/images/icons/32/songlist.songs.png', |
|
80 | - 'link' => 'admin/songs.php', |
|
77 | + 'title' => _MI_SONGLIST_ADMENU_SONGS, |
|
78 | + 'icon' => 'assets/images/icons/32/songlist.songs.png', |
|
79 | + 'image' => 'assets/images/icons/32/songlist.songs.png', |
|
80 | + 'link' => 'admin/songs.php', |
|
81 | 81 | ]; |
82 | 82 | |
83 | 83 | $adminmenu[] = [ |
84 | - 'title' => _MI_SONGLIST_ADMENU_VOTE, |
|
85 | - 'icon' => 'assets/images/icons/32/songlist.votes.png', |
|
86 | - 'image' => 'assets/images/icons/32/songlist.votes.png', |
|
87 | - 'link' => 'admin/votes.php', |
|
84 | + 'title' => _MI_SONGLIST_ADMENU_VOTE, |
|
85 | + 'icon' => 'assets/images/icons/32/songlist.votes.png', |
|
86 | + 'image' => 'assets/images/icons/32/songlist.votes.png', |
|
87 | + 'link' => 'admin/votes.php', |
|
88 | 88 | ]; |
89 | 89 | |
90 | 90 | //$adminmenu[] = [ |
@@ -95,57 +95,57 @@ discard block |
||
95 | 95 | //]; |
96 | 96 | |
97 | 97 | $adminmenu[] = [ |
98 | - 'title' => _MI_SONGLIST_ADMENU_REQUESTS, |
|
99 | - 'icon' => 'assets/images/icons/32/songlist.requests.png', |
|
100 | - 'image' => 'assets/images/icons/32/songlist.requests.png', |
|
101 | - 'link' => 'admin/requests.php', |
|
98 | + 'title' => _MI_SONGLIST_ADMENU_REQUESTS, |
|
99 | + 'icon' => 'assets/images/icons/32/songlist.requests.png', |
|
100 | + 'image' => 'assets/images/icons/32/songlist.requests.png', |
|
101 | + 'link' => 'admin/requests.php', |
|
102 | 102 | ]; |
103 | 103 | |
104 | 104 | $adminmenu[] = [ |
105 | - 'title' => _MI_SONGLIST_ADMENU_UTF8MAP, |
|
106 | - 'icon' => 'assets/images/icons/32/songlist.utf8map.png', |
|
107 | - 'image' => 'assets/images/icons/32/songlist.utf8map.png', |
|
108 | - 'link' => 'admin/utf8map.php', |
|
105 | + 'title' => _MI_SONGLIST_ADMENU_UTF8MAP, |
|
106 | + 'icon' => 'assets/images/icons/32/songlist.utf8map.png', |
|
107 | + 'image' => 'assets/images/icons/32/songlist.utf8map.png', |
|
108 | + 'link' => 'admin/utf8map.php', |
|
109 | 109 | ]; |
110 | 110 | |
111 | 111 | $adminmenu[] = [ |
112 | - 'title' => _MI_SONGLIST_ADMENU_IMPORT, |
|
113 | - 'icon' => 'assets/images/icons/32/songlist.import.png', |
|
114 | - 'image' => 'assets/images/icons/32/songlist.import.png', |
|
115 | - 'link' => 'admin/import.php', |
|
112 | + 'title' => _MI_SONGLIST_ADMENU_IMPORT, |
|
113 | + 'icon' => 'assets/images/icons/32/songlist.import.png', |
|
114 | + 'image' => 'assets/images/icons/32/songlist.import.png', |
|
115 | + 'link' => 'admin/import.php', |
|
116 | 116 | ]; |
117 | 117 | |
118 | 118 | $adminmenu[] = [ |
119 | - 'title' => _MI_SONGLIST_ADMENU_FIELDS, |
|
120 | - 'icon' => 'assets/images/icons/32/songlist.fields.png', |
|
121 | - 'image' => 'assets/images/icons/32/songlist.fields.png', |
|
122 | - 'link' => 'admin/field.php', |
|
119 | + 'title' => _MI_SONGLIST_ADMENU_FIELDS, |
|
120 | + 'icon' => 'assets/images/icons/32/songlist.fields.png', |
|
121 | + 'image' => 'assets/images/icons/32/songlist.fields.png', |
|
122 | + 'link' => 'admin/field.php', |
|
123 | 123 | ]; |
124 | 124 | |
125 | 125 | $adminmenu[] = [ |
126 | - 'title' => _MI_SONGLIST_ADMENU_FIELDSPERMS, |
|
127 | - 'icon' => 'assets/images/icons/32/songlist.field.permissions.png', |
|
128 | - 'image' => 'assets/images/icons/32/songlist.field.permissions.png', |
|
129 | - 'link' => 'admin/field_permissions.php', |
|
126 | + 'title' => _MI_SONGLIST_ADMENU_FIELDSPERMS, |
|
127 | + 'icon' => 'assets/images/icons/32/songlist.field.permissions.png', |
|
128 | + 'image' => 'assets/images/icons/32/songlist.field.permissions.png', |
|
129 | + 'link' => 'admin/field_permissions.php', |
|
130 | 130 | ]; |
131 | 131 | |
132 | 132 | // Blocks Admin |
133 | 133 | $adminmenu[] = [ |
134 | - 'title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS'), |
|
135 | - 'link' => 'admin/blocksadmin.php', |
|
136 | - 'icon' => $pathIcon32 . '/block.png', |
|
134 | + 'title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS'), |
|
135 | + 'link' => 'admin/blocksadmin.php', |
|
136 | + 'icon' => $pathIcon32 . '/block.png', |
|
137 | 137 | ]; |
138 | 138 | |
139 | 139 | //Clone |
140 | 140 | $adminmenu[] = [ |
141 | - 'title' => _CLONE, |
|
142 | - 'link' => 'admin/clone.php', |
|
143 | - 'icon' => $pathIcon32 . '/page_copy.png', |
|
141 | + 'title' => _CLONE, |
|
142 | + 'link' => 'admin/clone.php', |
|
143 | + 'icon' => $pathIcon32 . '/page_copy.png', |
|
144 | 144 | ]; |
145 | 145 | |
146 | 146 | $adminmenu[] = [ |
147 | - 'title' => _MI_SONGLIST_ADMENU_ABOUT, |
|
148 | - 'icon' => $pathIcon32 . '/about.png', |
|
149 | - 'image' => $pathIcon32 . '/about.png', |
|
150 | - 'link' => 'admin/about.php', |
|
147 | + 'title' => _MI_SONGLIST_ADMENU_ABOUT, |
|
148 | + 'icon' => $pathIcon32 . '/about.png', |
|
149 | + 'image' => $pathIcon32 . '/about.png', |
|
150 | + 'link' => 'admin/about.php', |
|
151 | 151 | ]; |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use Xmf\Module\Admin; |
4 | 4 | use XoopsModules\Songlist\Helper; |
5 | 5 | |
6 | -require \dirname(__DIR__) . '/preloads/autoloader.php'; |
|
6 | +require \dirname(__DIR__).'/preloads/autoloader.php'; |
|
7 | 7 | |
8 | 8 | $moduleDirName = \basename(\dirname(__DIR__)); |
9 | 9 | $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | $helper->loadLanguage('feedback'); |
14 | 14 | |
15 | 15 | $pathIcon32 = Admin::menuIconPath(''); |
16 | -$pathModIcon32 = XOOPS_URL . '/modules/' . $moduleDirName . '/assets/images/icons/32/'; |
|
17 | -if (is_object($helper->getModule()) && false !== $helper->getModule()->getInfo('modicons32')) { |
|
16 | +$pathModIcon32 = XOOPS_URL.'/modules/'.$moduleDirName.'/assets/images/icons/32/'; |
|
17 | +if (is_object($helper->getModule()) && false!==$helper->getModule()->getInfo('modicons32')) { |
|
18 | 18 | $pathModIcon32 = $helper->url($helper->getModule()->getInfo('modicons32')); |
19 | 19 | } |
20 | 20 | |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | |
28 | 28 | $adminmenu[] = [ |
29 | 29 | 'title' => _MI_SONGLIST_ADMENU_DASHBOARD, |
30 | - 'icon' => $pathIcon32 . '/home.png', |
|
31 | - 'image' => $pathIcon32 . '/home.png', |
|
30 | + 'icon' => $pathIcon32.'/home.png', |
|
31 | + 'image' => $pathIcon32.'/home.png', |
|
32 | 32 | 'link' => 'admin/index.php', |
33 | 33 | ]; |
34 | 34 | |
@@ -131,21 +131,21 @@ discard block |
||
131 | 131 | |
132 | 132 | // Blocks Admin |
133 | 133 | $adminmenu[] = [ |
134 | - 'title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS'), |
|
134 | + 'title' => constant('CO_'.$moduleDirNameUpper.'_'.'BLOCKS'), |
|
135 | 135 | 'link' => 'admin/blocksadmin.php', |
136 | - 'icon' => $pathIcon32 . '/block.png', |
|
136 | + 'icon' => $pathIcon32.'/block.png', |
|
137 | 137 | ]; |
138 | 138 | |
139 | 139 | //Clone |
140 | 140 | $adminmenu[] = [ |
141 | 141 | 'title' => _CLONE, |
142 | 142 | 'link' => 'admin/clone.php', |
143 | - 'icon' => $pathIcon32 . '/page_copy.png', |
|
143 | + 'icon' => $pathIcon32.'/page_copy.png', |
|
144 | 144 | ]; |
145 | 145 | |
146 | 146 | $adminmenu[] = [ |
147 | 147 | 'title' => _MI_SONGLIST_ADMENU_ABOUT, |
148 | - 'icon' => $pathIcon32 . '/about.png', |
|
149 | - 'image' => $pathIcon32 . '/about.png', |
|
148 | + 'icon' => $pathIcon32.'/about.png', |
|
149 | + 'image' => $pathIcon32.'/about.png', |
|
150 | 150 | 'link' => 'admin/about.php', |
151 | 151 | ]; |
@@ -29,22 +29,22 @@ discard block |
||
29 | 29 | $categoryHandler = Helper::getInstance()->getHandler('Category'); |
30 | 30 | |
31 | 31 | switch ($op) { |
32 | - case 'import': |
|
33 | - switch ($fct) { |
|
34 | - default: |
|
35 | - case 'actiona': |
|
36 | - if (Request::hasVar('xmlfile', 'SESSION')) { |
|
37 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?file=' . $_SESSION['xmlfile'] . '&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
38 | - } |
|
39 | - $adminObject = Admin::getInstance(); |
|
40 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
32 | + case 'import': |
|
33 | + switch ($fct) { |
|
34 | + default: |
|
35 | + case 'actiona': |
|
36 | + if (Request::hasVar('xmlfile', 'SESSION')) { |
|
37 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?file=' . $_SESSION['xmlfile'] . '&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
38 | + } |
|
39 | + $adminObject = Admin::getInstance(); |
|
40 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
41 | 41 | |
42 | - $GLOBALS['xoopsTpl']->assign('form', FormController::getFormImport(false)); |
|
43 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
44 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_import_actiona.tpl'); |
|
45 | - break; |
|
46 | - case 'upload': |
|
47 | - if (Request::hasVar('xmlfile', 'FILES') && !empty($_FILES['xmlfile']['title'])) { |
|
42 | + $GLOBALS['xoopsTpl']->assign('form', FormController::getFormImport(false)); |
|
43 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
44 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_import_actiona.tpl'); |
|
45 | + break; |
|
46 | + case 'upload': |
|
47 | + if (Request::hasVar('xmlfile', 'FILES') && !empty($_FILES['xmlfile']['title'])) { |
|
48 | 48 | // if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
49 | 49 | // foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) { |
50 | 50 | // foreach (explode('/', $folders) as $folder) { |
@@ -57,287 +57,287 @@ discard block |
||
57 | 57 | // } |
58 | 58 | |
59 | 59 | // require_once $GLOBALS['xoops']->path('modules/songlist/include/uploader.php'); |
60 | - $albums = $albumsHandler->get($id); |
|
61 | - $uploader = new Uploader( |
|
62 | - $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), |
|
63 | - ['application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity', 'text/xml xml xsl', 'text/xml-external-parsed-entity'], |
|
64 | - 1024 * 1024 * 32, |
|
65 | - 0, |
|
66 | - 0, |
|
67 | - ['xml'] |
|
68 | - ); |
|
69 | - try { |
|
70 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
71 | - } catch (Exception $e) { |
|
72 | - } |
|
60 | + $albums = $albumsHandler->get($id); |
|
61 | + $uploader = new Uploader( |
|
62 | + $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), |
|
63 | + ['application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity', 'text/xml xml xsl', 'text/xml-external-parsed-entity'], |
|
64 | + 1024 * 1024 * 32, |
|
65 | + 0, |
|
66 | + 0, |
|
67 | + ['xml'] |
|
68 | + ); |
|
69 | + try { |
|
70 | + $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
71 | + } catch (Exception $e) { |
|
72 | + } |
|
73 | 73 | |
74 | - if ($uploader->fetchMedia('xmlfile')) { |
|
75 | - if (!$uploader->upload()) { |
|
76 | - echo $uploader->getErrors(); |
|
77 | - require __DIR__ . '/admin_footer.php'; |
|
78 | - exit(0); |
|
79 | - } |
|
80 | - $_SESSION['xmlfile'] = $uploader->getSavedFileName(); |
|
81 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?file=' . $uploader->getSavedFileName() . '&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
82 | - } else { |
|
83 | - echo $uploader->getErrors(); |
|
84 | - require __DIR__ . '/admin_footer.php'; |
|
85 | - exit(0); |
|
86 | - } |
|
87 | - } |
|
88 | - break; |
|
89 | - case 'actionb': |
|
90 | - $adminObject = Admin::getInstance(); |
|
91 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
74 | + if ($uploader->fetchMedia('xmlfile')) { |
|
75 | + if (!$uploader->upload()) { |
|
76 | + echo $uploader->getErrors(); |
|
77 | + require __DIR__ . '/admin_footer.php'; |
|
78 | + exit(0); |
|
79 | + } |
|
80 | + $_SESSION['xmlfile'] = $uploader->getSavedFileName(); |
|
81 | + redirect_header($_SERVER['SCRIPT_NAME'] . '?file=' . $uploader->getSavedFileName() . '&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
82 | + } else { |
|
83 | + echo $uploader->getErrors(); |
|
84 | + require __DIR__ . '/admin_footer.php'; |
|
85 | + exit(0); |
|
86 | + } |
|
87 | + } |
|
88 | + break; |
|
89 | + case 'actionb': |
|
90 | + $adminObject = Admin::getInstance(); |
|
91 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
92 | 92 | |
93 | - $GLOBALS['xoopsTpl']->assign('form', FormController::getFormImportb($_SESSION['xmlfile'])); |
|
94 | - $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
95 | - $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_import_actionb.tpl'); |
|
96 | - break; |
|
97 | - case 'import': |
|
93 | + $GLOBALS['xoopsTpl']->assign('form', FormController::getFormImportb($_SESSION['xmlfile'])); |
|
94 | + $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
|
95 | + $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_import_actionb.tpl'); |
|
96 | + break; |
|
97 | + case 'import': |
|
98 | 98 | |
99 | - $filesize = filesize($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $_SESSION['xmlfile'])); |
|
100 | - $mb = floor($filesize / 1024 / 1024); |
|
101 | - if ($mb > 32) { |
|
102 | - set_ini('memory_limit', ($mb + 128) . 'M'); |
|
103 | - } |
|
104 | - set_time_limit(3600); |
|
99 | + $filesize = filesize($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $_SESSION['xmlfile'])); |
|
100 | + $mb = floor($filesize / 1024 / 1024); |
|
101 | + if ($mb > 32) { |
|
102 | + set_ini('memory_limit', ($mb + 128) . 'M'); |
|
103 | + } |
|
104 | + set_time_limit(3600); |
|
105 | 105 | |
106 | - $xmlarray = Utility::xml2array(file_get_contents($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $_SESSION['xmlfile'])), false, 'tag'); |
|
106 | + $xmlarray = Utility::xml2array(file_get_contents($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $_SESSION['xmlfile'])), false, 'tag'); |
|
107 | 107 | |
108 | - if (mb_strlen($_POST['collection']) > 0) { |
|
109 | - foreach ($xmlarray[$_POST['collection']] as $id => $record) { |
|
110 | - foreach ($record as $recid => $data) { |
|
111 | - $gid = 0; |
|
112 | - if (mb_strlen($_POST['genre']) > 0 && !empty($data[$_POST['genre']])) { |
|
113 | - $criteria = new \Criteria('name', $data[$_POST['genre']]); |
|
114 | - if ($genreHandler->getCount($criteria) > 0) { |
|
115 | - $objects = $genreHandler->getObjects($criteria, false); |
|
116 | - $gid = $objects[0]->getVar('gid'); |
|
117 | - } else { |
|
118 | - $object = $genreHandler->create(); |
|
119 | - $object->setVar('name', $data[$_POST['genre']]); |
|
120 | - $gid = $genreHandler->insert($object); |
|
121 | - } |
|
122 | - } |
|
108 | + if (mb_strlen($_POST['collection']) > 0) { |
|
109 | + foreach ($xmlarray[$_POST['collection']] as $id => $record) { |
|
110 | + foreach ($record as $recid => $data) { |
|
111 | + $gid = 0; |
|
112 | + if (mb_strlen($_POST['genre']) > 0 && !empty($data[$_POST['genre']])) { |
|
113 | + $criteria = new \Criteria('name', $data[$_POST['genre']]); |
|
114 | + if ($genreHandler->getCount($criteria) > 0) { |
|
115 | + $objects = $genreHandler->getObjects($criteria, false); |
|
116 | + $gid = $objects[0]->getVar('gid'); |
|
117 | + } else { |
|
118 | + $object = $genreHandler->create(); |
|
119 | + $object->setVar('name', $data[$_POST['genre']]); |
|
120 | + $gid = $genreHandler->insert($object); |
|
121 | + } |
|
122 | + } |
|
123 | 123 | |
124 | - $vid = 0; |
|
125 | - if (mb_strlen($_POST['voice']) > 0 && !empty($data[$_POST['voice']])) { |
|
126 | - $criteria = new \Criteria('name', $data[$_POST['voice']]); |
|
127 | - if ($voiceHandler->getCount($criteria) > 0) { |
|
128 | - $objects = $voiceHandler->getObjects($criteria, false); |
|
129 | - $gid = $objects[0]->getVar('vid'); |
|
130 | - } else { |
|
131 | - $object = $voiceHandler->create(); |
|
132 | - $object->setVar('name', $data[$_POST['voice']]); |
|
133 | - $gid = $voiceHandler->insert($object); |
|
134 | - } |
|
135 | - } |
|
124 | + $vid = 0; |
|
125 | + if (mb_strlen($_POST['voice']) > 0 && !empty($data[$_POST['voice']])) { |
|
126 | + $criteria = new \Criteria('name', $data[$_POST['voice']]); |
|
127 | + if ($voiceHandler->getCount($criteria) > 0) { |
|
128 | + $objects = $voiceHandler->getObjects($criteria, false); |
|
129 | + $gid = $objects[0]->getVar('vid'); |
|
130 | + } else { |
|
131 | + $object = $voiceHandler->create(); |
|
132 | + $object->setVar('name', $data[$_POST['voice']]); |
|
133 | + $gid = $voiceHandler->insert($object); |
|
134 | + } |
|
135 | + } |
|
136 | 136 | |
137 | - $cid = 0; |
|
138 | - if (mb_strlen($_POST['category']) > 0 && !empty($data[$_POST['category']])) { |
|
139 | - $criteria = new \Criteria('name', $data[$_POST['category']]); |
|
140 | - if ($categoryHandler->getCount($criteria) > 0) { |
|
141 | - $objects = $categoryHandler->getObjects($criteria, false); |
|
142 | - $cid = $objects[0]->getVar('cid'); |
|
143 | - } else { |
|
144 | - $object = $categoryHandler->create(); |
|
145 | - $object->setVar('name', $data[$_POST['category']]); |
|
146 | - $cid = $categoryHandler->insert($object); |
|
147 | - } |
|
148 | - } |
|
149 | - $aids = []; |
|
150 | - if (mb_strlen($_POST['artist']) > 0 && !empty($data[$_POST['artist']])) { |
|
151 | - foreach (explode(',', $data[$_POST['artist']]) as $artist) { |
|
152 | - $criteria = new \Criteria('name', $artist); |
|
153 | - if ($artistsHandler->getCount($criteria) > 0) { |
|
154 | - $objects = $artistsHandler->getObjects($criteria, false); |
|
155 | - $aids[$objects[0]->getVar('aid')] = $objects[0]->getVar('aid'); |
|
156 | - } else { |
|
157 | - $object = $artistsHandler->create(); |
|
158 | - $object->setVar('cid', $cid); |
|
159 | - switch ($data[$_POST['singer']]) { |
|
160 | - case $_POST['duet']: |
|
161 | - $object->setVar('singer', '_ENUM_SONGLIST_DUET'); |
|
162 | - break; |
|
163 | - case $_POST['solo']: |
|
164 | - $object->setVar('singer', '_ENUM_SONGLIST_SOLO'); |
|
165 | - break; |
|
166 | - } |
|
167 | - $object->setVar('name', $data[$_POST['artist']]); |
|
168 | - $aid = $artistsHandler->insert($object); |
|
169 | - $aids[$aid] = $aid; |
|
170 | - } |
|
171 | - } |
|
172 | - } |
|
173 | - $abid = 0; |
|
174 | - if (mb_strlen($_POST['album']) > 0 && !empty($data[$_POST['album']])) { |
|
175 | - $criteria = new \Criteria('name', $data[$_POST['album']]); |
|
176 | - if ($albumsHandler->getCount($criteria) > 0) { |
|
177 | - $objects = $albumsHandler->getObjects($criteria, false); |
|
178 | - $abid = $objects[0]->getVar('aid'); |
|
179 | - } else { |
|
180 | - $object = $albumsHandler->create(); |
|
181 | - $object->setVar('cid', $cid); |
|
182 | - $object->setVar('aids', $aids); |
|
183 | - $object->setVar('name', $data[$_POST['album']]); |
|
184 | - $abid = $albumsHandler->insert($object); |
|
185 | - } |
|
186 | - } |
|
187 | - $sid = 0; |
|
188 | - if (mb_strlen($_POST['songid']) > 0 && !empty($data[$_POST['songid']])) { |
|
189 | - $criteria = new \Criteria('songid', $data[$_POST['songid']]); |
|
190 | - if ($songsHandler->getCount($criteria) > 0) { |
|
191 | - $objects = $songsHandler->getObjects($criteria, false); |
|
192 | - $object = $objects[0]->getVar('sid'); |
|
193 | - } else { |
|
194 | - $object = $songsHandler->create(); |
|
195 | - } |
|
196 | - if ($object->getVar('cid') > 0 && $cid > 0) { |
|
197 | - $object->setVar('cid', $cid); |
|
198 | - } else { |
|
199 | - $object->setVar('cid', $cid); |
|
200 | - } |
|
201 | - if ($object->getVar('gid') > 0 && $gid > 0) { |
|
202 | - $object->setVar('gid', $gid); |
|
203 | - } else { |
|
204 | - $object->setVar('gid', $gid); |
|
205 | - } |
|
206 | - if (count($object->getVar('aids')) > 0 && count($aids) > 0) { |
|
207 | - $object->setVar('aids', $aids); |
|
208 | - } else { |
|
209 | - $object->setVar('aids', $aids); |
|
210 | - } |
|
211 | - if ($object->getVar('abid') > 0 && $abid > 0) { |
|
212 | - $object->setVar('abid', $abid); |
|
213 | - } else { |
|
214 | - $object->setVar('abid', $abid); |
|
215 | - } |
|
216 | - $object->setVar('songid', $data[$_POST['songid']]); |
|
217 | - $object->setVar('title', $data[$_POST['title']]); |
|
218 | - $object->setVar('lyrics', str_replace("\n", "<br>\n", $data[$_POST['lyrics']])); |
|
219 | - $sid = $songsHandler->insert($object); |
|
220 | - } |
|
221 | - } |
|
222 | - } |
|
223 | - } else { |
|
224 | - foreach ($xmlarray as $recid => $data) { |
|
225 | - $gid = 0; |
|
226 | - if (mb_strlen($_POST['genre']) > 0 && !empty($data[$_POST['genre']])) { |
|
227 | - $criteria = new \Criteria('name', $data[$_POST['genre']]); |
|
228 | - if ($genreHandler->getCount($criteria) > 0) { |
|
229 | - $objects = $genreHandler->getObjects($criteria, false); |
|
230 | - $gid = $objects[0]->getVar('gid'); |
|
231 | - } else { |
|
232 | - $object = $genreHandler->create(); |
|
233 | - $object->setVar('name', $data[$_POST['genre']]); |
|
234 | - $gid = $genreHandler->insert($object); |
|
235 | - } |
|
236 | - } |
|
237 | - $vid = 0; |
|
238 | - if (mb_strlen($_POST['voice']) > 0 && !empty($data[$_POST['voice']])) { |
|
239 | - $criteria = new \Criteria('name', $data[$_POST['voice']]); |
|
240 | - if ($voiceHandler->getCount($criteria) > 0) { |
|
241 | - $objects = $voiceHandler->getObjects($criteria, false); |
|
242 | - $gid = $objects[0]->getVar('vid'); |
|
243 | - } else { |
|
244 | - $object = $voiceHandler->create(); |
|
245 | - $object->setVar('name', $data[$_POST['voice']]); |
|
246 | - $gid = $voiceHandler->insert($object); |
|
247 | - } |
|
248 | - } |
|
249 | - $cid = 0; |
|
250 | - if (mb_strlen($_POST['category']) > 0 && !empty($data[$_POST['category']])) { |
|
251 | - $criteria = new \Criteria('name', $data[$_POST['category']]); |
|
252 | - if ($categoryHandler->getCount($criteria) > 0) { |
|
253 | - $objects = $categoryHandler->getObjects($criteria, false); |
|
254 | - $cid = $objects[0]->getVar('cid'); |
|
255 | - } else { |
|
256 | - $object = $categoryHandler->create(); |
|
257 | - $object->setVar('name', $data[$_POST['category']]); |
|
258 | - $cid = $categoryHandler->insert($object); |
|
259 | - } |
|
260 | - } |
|
261 | - $aids = []; |
|
262 | - if (mb_strlen($_POST['artist']) > 0 && !empty($data[$_POST['artist']])) { |
|
263 | - foreach (explode(',', $data[$_POST['artist']]) as $artist) { |
|
264 | - $criteria = new \Criteria('name', $artist); |
|
265 | - if ($artistsHandler->getCount($criteria) > 0) { |
|
266 | - $objects = $artistsHandler->getObjects($criteria, false); |
|
267 | - $aids[$objects[0]->getVar('aid')] = $objects[0]->getVar('aid'); |
|
268 | - } else { |
|
269 | - $object = $artistsHandler->create(); |
|
270 | - switch ($data[$_POST['singer']]) { |
|
271 | - case $_POST['duet']: |
|
272 | - $object->setVar('singer', '_ENUM_SONGLIST_DUET'); |
|
273 | - break; |
|
274 | - case $_POST['solo']: |
|
275 | - $object->setVar('singer', '_ENUM_SONGLIST_SOLO'); |
|
276 | - break; |
|
277 | - } |
|
278 | - $object->setVar('cid', $cid); |
|
279 | - $object->setVar('name', $data[$_POST['artist']]); |
|
280 | - $aid = $artistsHandler->insert($object); |
|
281 | - $aids[$aid] = $aid; |
|
282 | - } |
|
283 | - } |
|
284 | - } |
|
285 | - $abid = 0; |
|
286 | - if (mb_strlen($_POST['album']) > 0 && !empty($data[$_POST['album']])) { |
|
287 | - $criteria = new \Criteria('name', $data[$_POST['album']]); |
|
288 | - if ($albumsHandler->getCount($criteria) > 0) { |
|
289 | - $objects = $albumsHandler->getObjects($criteria, false); |
|
290 | - $abid = $objects[0]->getVar('aid'); |
|
291 | - } else { |
|
292 | - $object = $albumsHandler->create(); |
|
293 | - $object->setVar('cid', $cid); |
|
294 | - $object->setVar('aids', $aids); |
|
295 | - $object->setVar('name', $data[$_POST['album']]); |
|
296 | - $abid = $albumsHandler->insert($object); |
|
297 | - } |
|
298 | - } |
|
299 | - $sid = 0; |
|
300 | - if (mb_strlen($_POST['songid']) > 0 && !empty($data[$_POST['songid']])) { |
|
301 | - $criteria = new \Criteria('songid', $data[$_POST['songid']]); |
|
302 | - if ($songsHandler->getCount($criteria) > 0) { |
|
303 | - $objects = $songsHandler->getObjects($criteria, false); |
|
304 | - $object = $objects[0]->getVar('sid'); |
|
305 | - } else { |
|
306 | - $object = $songsHandler->create(); |
|
307 | - } |
|
308 | - if ($object->getVar('cid') > 0 && $cid > 0) { |
|
309 | - $object->setVar('cid', $cid); |
|
310 | - } else { |
|
311 | - $object->setVar('cid', $cid); |
|
312 | - } |
|
313 | - if ($object->getVar('gid') > 0 && $gid > 0) { |
|
314 | - $object->setVar('gid', $gid); |
|
315 | - } else { |
|
316 | - $object->setVar('gid', $gid); |
|
317 | - } |
|
318 | - if (count($object->getVar('aids')) > 0 && count($aids) > 0) { |
|
319 | - $object->setVar('aids', $aids); |
|
320 | - } else { |
|
321 | - $object->setVar('aids', $aids); |
|
322 | - } |
|
323 | - if ($object->getVar('abid') > 0 && $abid > 0) { |
|
324 | - $object->setVar('abid', $abid); |
|
325 | - } else { |
|
326 | - $object->setVar('abid', $abid); |
|
327 | - } |
|
328 | - $object->setVar('songid', $data[$_POST['songid']]); |
|
329 | - $object->setVar('title', $data[$_POST['title']]); |
|
330 | - $object->setVar('lyrics', str_replace("\n", "<br>\n", $data[$_POST['lyrics']])); |
|
331 | - $sid = $songsHandler->insert($object); |
|
332 | - } |
|
333 | - } |
|
334 | - } |
|
335 | - unlink($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $_SESSION['xmlfile'])); |
|
336 | - unset($_SESSION['xmlfile']); |
|
337 | - redirect_header($_SERVER['SCRIPT_NAME'] . '&op=import&fct=actiona', 10, _AM_SONGLIST_XMLFILE_COMPLETE); |
|
338 | - break; |
|
339 | - } |
|
340 | - break; |
|
137 | + $cid = 0; |
|
138 | + if (mb_strlen($_POST['category']) > 0 && !empty($data[$_POST['category']])) { |
|
139 | + $criteria = new \Criteria('name', $data[$_POST['category']]); |
|
140 | + if ($categoryHandler->getCount($criteria) > 0) { |
|
141 | + $objects = $categoryHandler->getObjects($criteria, false); |
|
142 | + $cid = $objects[0]->getVar('cid'); |
|
143 | + } else { |
|
144 | + $object = $categoryHandler->create(); |
|
145 | + $object->setVar('name', $data[$_POST['category']]); |
|
146 | + $cid = $categoryHandler->insert($object); |
|
147 | + } |
|
148 | + } |
|
149 | + $aids = []; |
|
150 | + if (mb_strlen($_POST['artist']) > 0 && !empty($data[$_POST['artist']])) { |
|
151 | + foreach (explode(',', $data[$_POST['artist']]) as $artist) { |
|
152 | + $criteria = new \Criteria('name', $artist); |
|
153 | + if ($artistsHandler->getCount($criteria) > 0) { |
|
154 | + $objects = $artistsHandler->getObjects($criteria, false); |
|
155 | + $aids[$objects[0]->getVar('aid')] = $objects[0]->getVar('aid'); |
|
156 | + } else { |
|
157 | + $object = $artistsHandler->create(); |
|
158 | + $object->setVar('cid', $cid); |
|
159 | + switch ($data[$_POST['singer']]) { |
|
160 | + case $_POST['duet']: |
|
161 | + $object->setVar('singer', '_ENUM_SONGLIST_DUET'); |
|
162 | + break; |
|
163 | + case $_POST['solo']: |
|
164 | + $object->setVar('singer', '_ENUM_SONGLIST_SOLO'); |
|
165 | + break; |
|
166 | + } |
|
167 | + $object->setVar('name', $data[$_POST['artist']]); |
|
168 | + $aid = $artistsHandler->insert($object); |
|
169 | + $aids[$aid] = $aid; |
|
170 | + } |
|
171 | + } |
|
172 | + } |
|
173 | + $abid = 0; |
|
174 | + if (mb_strlen($_POST['album']) > 0 && !empty($data[$_POST['album']])) { |
|
175 | + $criteria = new \Criteria('name', $data[$_POST['album']]); |
|
176 | + if ($albumsHandler->getCount($criteria) > 0) { |
|
177 | + $objects = $albumsHandler->getObjects($criteria, false); |
|
178 | + $abid = $objects[0]->getVar('aid'); |
|
179 | + } else { |
|
180 | + $object = $albumsHandler->create(); |
|
181 | + $object->setVar('cid', $cid); |
|
182 | + $object->setVar('aids', $aids); |
|
183 | + $object->setVar('name', $data[$_POST['album']]); |
|
184 | + $abid = $albumsHandler->insert($object); |
|
185 | + } |
|
186 | + } |
|
187 | + $sid = 0; |
|
188 | + if (mb_strlen($_POST['songid']) > 0 && !empty($data[$_POST['songid']])) { |
|
189 | + $criteria = new \Criteria('songid', $data[$_POST['songid']]); |
|
190 | + if ($songsHandler->getCount($criteria) > 0) { |
|
191 | + $objects = $songsHandler->getObjects($criteria, false); |
|
192 | + $object = $objects[0]->getVar('sid'); |
|
193 | + } else { |
|
194 | + $object = $songsHandler->create(); |
|
195 | + } |
|
196 | + if ($object->getVar('cid') > 0 && $cid > 0) { |
|
197 | + $object->setVar('cid', $cid); |
|
198 | + } else { |
|
199 | + $object->setVar('cid', $cid); |
|
200 | + } |
|
201 | + if ($object->getVar('gid') > 0 && $gid > 0) { |
|
202 | + $object->setVar('gid', $gid); |
|
203 | + } else { |
|
204 | + $object->setVar('gid', $gid); |
|
205 | + } |
|
206 | + if (count($object->getVar('aids')) > 0 && count($aids) > 0) { |
|
207 | + $object->setVar('aids', $aids); |
|
208 | + } else { |
|
209 | + $object->setVar('aids', $aids); |
|
210 | + } |
|
211 | + if ($object->getVar('abid') > 0 && $abid > 0) { |
|
212 | + $object->setVar('abid', $abid); |
|
213 | + } else { |
|
214 | + $object->setVar('abid', $abid); |
|
215 | + } |
|
216 | + $object->setVar('songid', $data[$_POST['songid']]); |
|
217 | + $object->setVar('title', $data[$_POST['title']]); |
|
218 | + $object->setVar('lyrics', str_replace("\n", "<br>\n", $data[$_POST['lyrics']])); |
|
219 | + $sid = $songsHandler->insert($object); |
|
220 | + } |
|
221 | + } |
|
222 | + } |
|
223 | + } else { |
|
224 | + foreach ($xmlarray as $recid => $data) { |
|
225 | + $gid = 0; |
|
226 | + if (mb_strlen($_POST['genre']) > 0 && !empty($data[$_POST['genre']])) { |
|
227 | + $criteria = new \Criteria('name', $data[$_POST['genre']]); |
|
228 | + if ($genreHandler->getCount($criteria) > 0) { |
|
229 | + $objects = $genreHandler->getObjects($criteria, false); |
|
230 | + $gid = $objects[0]->getVar('gid'); |
|
231 | + } else { |
|
232 | + $object = $genreHandler->create(); |
|
233 | + $object->setVar('name', $data[$_POST['genre']]); |
|
234 | + $gid = $genreHandler->insert($object); |
|
235 | + } |
|
236 | + } |
|
237 | + $vid = 0; |
|
238 | + if (mb_strlen($_POST['voice']) > 0 && !empty($data[$_POST['voice']])) { |
|
239 | + $criteria = new \Criteria('name', $data[$_POST['voice']]); |
|
240 | + if ($voiceHandler->getCount($criteria) > 0) { |
|
241 | + $objects = $voiceHandler->getObjects($criteria, false); |
|
242 | + $gid = $objects[0]->getVar('vid'); |
|
243 | + } else { |
|
244 | + $object = $voiceHandler->create(); |
|
245 | + $object->setVar('name', $data[$_POST['voice']]); |
|
246 | + $gid = $voiceHandler->insert($object); |
|
247 | + } |
|
248 | + } |
|
249 | + $cid = 0; |
|
250 | + if (mb_strlen($_POST['category']) > 0 && !empty($data[$_POST['category']])) { |
|
251 | + $criteria = new \Criteria('name', $data[$_POST['category']]); |
|
252 | + if ($categoryHandler->getCount($criteria) > 0) { |
|
253 | + $objects = $categoryHandler->getObjects($criteria, false); |
|
254 | + $cid = $objects[0]->getVar('cid'); |
|
255 | + } else { |
|
256 | + $object = $categoryHandler->create(); |
|
257 | + $object->setVar('name', $data[$_POST['category']]); |
|
258 | + $cid = $categoryHandler->insert($object); |
|
259 | + } |
|
260 | + } |
|
261 | + $aids = []; |
|
262 | + if (mb_strlen($_POST['artist']) > 0 && !empty($data[$_POST['artist']])) { |
|
263 | + foreach (explode(',', $data[$_POST['artist']]) as $artist) { |
|
264 | + $criteria = new \Criteria('name', $artist); |
|
265 | + if ($artistsHandler->getCount($criteria) > 0) { |
|
266 | + $objects = $artistsHandler->getObjects($criteria, false); |
|
267 | + $aids[$objects[0]->getVar('aid')] = $objects[0]->getVar('aid'); |
|
268 | + } else { |
|
269 | + $object = $artistsHandler->create(); |
|
270 | + switch ($data[$_POST['singer']]) { |
|
271 | + case $_POST['duet']: |
|
272 | + $object->setVar('singer', '_ENUM_SONGLIST_DUET'); |
|
273 | + break; |
|
274 | + case $_POST['solo']: |
|
275 | + $object->setVar('singer', '_ENUM_SONGLIST_SOLO'); |
|
276 | + break; |
|
277 | + } |
|
278 | + $object->setVar('cid', $cid); |
|
279 | + $object->setVar('name', $data[$_POST['artist']]); |
|
280 | + $aid = $artistsHandler->insert($object); |
|
281 | + $aids[$aid] = $aid; |
|
282 | + } |
|
283 | + } |
|
284 | + } |
|
285 | + $abid = 0; |
|
286 | + if (mb_strlen($_POST['album']) > 0 && !empty($data[$_POST['album']])) { |
|
287 | + $criteria = new \Criteria('name', $data[$_POST['album']]); |
|
288 | + if ($albumsHandler->getCount($criteria) > 0) { |
|
289 | + $objects = $albumsHandler->getObjects($criteria, false); |
|
290 | + $abid = $objects[0]->getVar('aid'); |
|
291 | + } else { |
|
292 | + $object = $albumsHandler->create(); |
|
293 | + $object->setVar('cid', $cid); |
|
294 | + $object->setVar('aids', $aids); |
|
295 | + $object->setVar('name', $data[$_POST['album']]); |
|
296 | + $abid = $albumsHandler->insert($object); |
|
297 | + } |
|
298 | + } |
|
299 | + $sid = 0; |
|
300 | + if (mb_strlen($_POST['songid']) > 0 && !empty($data[$_POST['songid']])) { |
|
301 | + $criteria = new \Criteria('songid', $data[$_POST['songid']]); |
|
302 | + if ($songsHandler->getCount($criteria) > 0) { |
|
303 | + $objects = $songsHandler->getObjects($criteria, false); |
|
304 | + $object = $objects[0]->getVar('sid'); |
|
305 | + } else { |
|
306 | + $object = $songsHandler->create(); |
|
307 | + } |
|
308 | + if ($object->getVar('cid') > 0 && $cid > 0) { |
|
309 | + $object->setVar('cid', $cid); |
|
310 | + } else { |
|
311 | + $object->setVar('cid', $cid); |
|
312 | + } |
|
313 | + if ($object->getVar('gid') > 0 && $gid > 0) { |
|
314 | + $object->setVar('gid', $gid); |
|
315 | + } else { |
|
316 | + $object->setVar('gid', $gid); |
|
317 | + } |
|
318 | + if (count($object->getVar('aids')) > 0 && count($aids) > 0) { |
|
319 | + $object->setVar('aids', $aids); |
|
320 | + } else { |
|
321 | + $object->setVar('aids', $aids); |
|
322 | + } |
|
323 | + if ($object->getVar('abid') > 0 && $abid > 0) { |
|
324 | + $object->setVar('abid', $abid); |
|
325 | + } else { |
|
326 | + $object->setVar('abid', $abid); |
|
327 | + } |
|
328 | + $object->setVar('songid', $data[$_POST['songid']]); |
|
329 | + $object->setVar('title', $data[$_POST['title']]); |
|
330 | + $object->setVar('lyrics', str_replace("\n", "<br>\n", $data[$_POST['lyrics']])); |
|
331 | + $sid = $songsHandler->insert($object); |
|
332 | + } |
|
333 | + } |
|
334 | + } |
|
335 | + unlink($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $_SESSION['xmlfile'])); |
|
336 | + unset($_SESSION['xmlfile']); |
|
337 | + redirect_header($_SERVER['SCRIPT_NAME'] . '&op=import&fct=actiona', 10, _AM_SONGLIST_XMLFILE_COMPLETE); |
|
338 | + break; |
|
339 | + } |
|
340 | + break; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | xoops_cp_footer(); |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use XoopsModules\Songlist\AlbumsHandler; |
8 | 8 | use XoopsModules\Songlist\Form\FormController; |
9 | 9 | |
10 | -require __DIR__ . '/header.php'; |
|
10 | +require __DIR__.'/header.php'; |
|
11 | 11 | |
12 | 12 | xoops_loadLanguage('admin', 'songlist'); |
13 | 13 | |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | $limit = Request::getInt('limit', 30, 'REQUEST'); |
19 | 19 | $start = Request::getInt('start', 0, 'REQUEST'); |
20 | 20 | $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
21 | -$sort = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
|
22 | -$filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
|
21 | +$sort = !empty($_REQUEST['sort']) ? ''.$_REQUEST['sort'].'' : 'created'; |
|
22 | +$filter = !empty($_REQUEST['filter']) ? ''.$_REQUEST['filter'].'' : '1,1'; |
|
23 | 23 | |
24 | 24 | $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
25 | 25 | $songsHandler = Helper::getInstance()->getHandler('Songs'); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | default: |
35 | 35 | case 'actiona': |
36 | 36 | if (Request::hasVar('xmlfile', 'SESSION')) { |
37 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?file=' . $_SESSION['xmlfile'] . '&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
37 | + redirect_header($_SERVER['SCRIPT_NAME'].'?file='.$_SESSION['xmlfile'].'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
38 | 38 | } |
39 | 39 | $adminObject = Admin::getInstance(); |
40 | 40 | $adminObject->displayNavigation(basename(__FILE__)); |
@@ -61,27 +61,27 @@ discard block |
||
61 | 61 | $uploader = new Uploader( |
62 | 62 | $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']), |
63 | 63 | ['application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity', 'text/xml xml xsl', 'text/xml-external-parsed-entity'], |
64 | - 1024 * 1024 * 32, |
|
64 | + 1024*1024*32, |
|
65 | 65 | 0, |
66 | 66 | 0, |
67 | 67 | ['xml'] |
68 | 68 | ); |
69 | 69 | try { |
70 | - $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
|
70 | + $uploader->setPrefix(mb_substr(md5((string) microtime(true)), random_int(0, 20), 13)); |
|
71 | 71 | } catch (Exception $e) { |
72 | 72 | } |
73 | 73 | |
74 | 74 | if ($uploader->fetchMedia('xmlfile')) { |
75 | 75 | if (!$uploader->upload()) { |
76 | 76 | echo $uploader->getErrors(); |
77 | - require __DIR__ . '/admin_footer.php'; |
|
77 | + require __DIR__.'/admin_footer.php'; |
|
78 | 78 | exit(0); |
79 | 79 | } |
80 | 80 | $_SESSION['xmlfile'] = $uploader->getSavedFileName(); |
81 | - redirect_header($_SERVER['SCRIPT_NAME'] . '?file=' . $uploader->getSavedFileName() . '&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
81 | + redirect_header($_SERVER['SCRIPT_NAME'].'?file='.$uploader->getSavedFileName().'&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED); |
|
82 | 82 | } else { |
83 | 83 | echo $uploader->getErrors(); |
84 | - require __DIR__ . '/admin_footer.php'; |
|
84 | + require __DIR__.'/admin_footer.php'; |
|
85 | 85 | exit(0); |
86 | 86 | } |
87 | 87 | } |
@@ -96,22 +96,22 @@ discard block |
||
96 | 96 | break; |
97 | 97 | case 'import': |
98 | 98 | |
99 | - $filesize = filesize($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $_SESSION['xmlfile'])); |
|
100 | - $mb = floor($filesize / 1024 / 1024); |
|
101 | - if ($mb > 32) { |
|
102 | - set_ini('memory_limit', ($mb + 128) . 'M'); |
|
99 | + $filesize = filesize($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'].$_SESSION['xmlfile'])); |
|
100 | + $mb = floor($filesize/1024/1024); |
|
101 | + if ($mb>32) { |
|
102 | + set_ini('memory_limit', ($mb+128).'M'); |
|
103 | 103 | } |
104 | 104 | set_time_limit(3600); |
105 | 105 | |
106 | - $xmlarray = Utility::xml2array(file_get_contents($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $_SESSION['xmlfile'])), false, 'tag'); |
|
106 | + $xmlarray = Utility::xml2array(file_get_contents($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'].$_SESSION['xmlfile'])), false, 'tag'); |
|
107 | 107 | |
108 | - if (mb_strlen($_POST['collection']) > 0) { |
|
108 | + if (mb_strlen($_POST['collection'])>0) { |
|
109 | 109 | foreach ($xmlarray[$_POST['collection']] as $id => $record) { |
110 | 110 | foreach ($record as $recid => $data) { |
111 | 111 | $gid = 0; |
112 | - if (mb_strlen($_POST['genre']) > 0 && !empty($data[$_POST['genre']])) { |
|
112 | + if (mb_strlen($_POST['genre'])>0 && !empty($data[$_POST['genre']])) { |
|
113 | 113 | $criteria = new \Criteria('name', $data[$_POST['genre']]); |
114 | - if ($genreHandler->getCount($criteria) > 0) { |
|
114 | + if ($genreHandler->getCount($criteria)>0) { |
|
115 | 115 | $objects = $genreHandler->getObjects($criteria, false); |
116 | 116 | $gid = $objects[0]->getVar('gid'); |
117 | 117 | } else { |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | $vid = 0; |
125 | - if (mb_strlen($_POST['voice']) > 0 && !empty($data[$_POST['voice']])) { |
|
125 | + if (mb_strlen($_POST['voice'])>0 && !empty($data[$_POST['voice']])) { |
|
126 | 126 | $criteria = new \Criteria('name', $data[$_POST['voice']]); |
127 | - if ($voiceHandler->getCount($criteria) > 0) { |
|
127 | + if ($voiceHandler->getCount($criteria)>0) { |
|
128 | 128 | $objects = $voiceHandler->getObjects($criteria, false); |
129 | 129 | $gid = $objects[0]->getVar('vid'); |
130 | 130 | } else { |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | $cid = 0; |
138 | - if (mb_strlen($_POST['category']) > 0 && !empty($data[$_POST['category']])) { |
|
138 | + if (mb_strlen($_POST['category'])>0 && !empty($data[$_POST['category']])) { |
|
139 | 139 | $criteria = new \Criteria('name', $data[$_POST['category']]); |
140 | - if ($categoryHandler->getCount($criteria) > 0) { |
|
140 | + if ($categoryHandler->getCount($criteria)>0) { |
|
141 | 141 | $objects = $categoryHandler->getObjects($criteria, false); |
142 | 142 | $cid = $objects[0]->getVar('cid'); |
143 | 143 | } else { |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | } |
148 | 148 | } |
149 | 149 | $aids = []; |
150 | - if (mb_strlen($_POST['artist']) > 0 && !empty($data[$_POST['artist']])) { |
|
150 | + if (mb_strlen($_POST['artist'])>0 && !empty($data[$_POST['artist']])) { |
|
151 | 151 | foreach (explode(',', $data[$_POST['artist']]) as $artist) { |
152 | 152 | $criteria = new \Criteria('name', $artist); |
153 | - if ($artistsHandler->getCount($criteria) > 0) { |
|
153 | + if ($artistsHandler->getCount($criteria)>0) { |
|
154 | 154 | $objects = $artistsHandler->getObjects($criteria, false); |
155 | 155 | $aids[$objects[0]->getVar('aid')] = $objects[0]->getVar('aid'); |
156 | 156 | } else { |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | } |
172 | 172 | } |
173 | 173 | $abid = 0; |
174 | - if (mb_strlen($_POST['album']) > 0 && !empty($data[$_POST['album']])) { |
|
174 | + if (mb_strlen($_POST['album'])>0 && !empty($data[$_POST['album']])) { |
|
175 | 175 | $criteria = new \Criteria('name', $data[$_POST['album']]); |
176 | - if ($albumsHandler->getCount($criteria) > 0) { |
|
176 | + if ($albumsHandler->getCount($criteria)>0) { |
|
177 | 177 | $objects = $albumsHandler->getObjects($criteria, false); |
178 | 178 | $abid = $objects[0]->getVar('aid'); |
179 | 179 | } else { |
@@ -185,30 +185,30 @@ discard block |
||
185 | 185 | } |
186 | 186 | } |
187 | 187 | $sid = 0; |
188 | - if (mb_strlen($_POST['songid']) > 0 && !empty($data[$_POST['songid']])) { |
|
188 | + if (mb_strlen($_POST['songid'])>0 && !empty($data[$_POST['songid']])) { |
|
189 | 189 | $criteria = new \Criteria('songid', $data[$_POST['songid']]); |
190 | - if ($songsHandler->getCount($criteria) > 0) { |
|
190 | + if ($songsHandler->getCount($criteria)>0) { |
|
191 | 191 | $objects = $songsHandler->getObjects($criteria, false); |
192 | 192 | $object = $objects[0]->getVar('sid'); |
193 | 193 | } else { |
194 | 194 | $object = $songsHandler->create(); |
195 | 195 | } |
196 | - if ($object->getVar('cid') > 0 && $cid > 0) { |
|
196 | + if ($object->getVar('cid')>0 && $cid>0) { |
|
197 | 197 | $object->setVar('cid', $cid); |
198 | 198 | } else { |
199 | 199 | $object->setVar('cid', $cid); |
200 | 200 | } |
201 | - if ($object->getVar('gid') > 0 && $gid > 0) { |
|
201 | + if ($object->getVar('gid')>0 && $gid>0) { |
|
202 | 202 | $object->setVar('gid', $gid); |
203 | 203 | } else { |
204 | 204 | $object->setVar('gid', $gid); |
205 | 205 | } |
206 | - if (count($object->getVar('aids')) > 0 && count($aids) > 0) { |
|
206 | + if (count($object->getVar('aids'))>0 && count($aids)>0) { |
|
207 | 207 | $object->setVar('aids', $aids); |
208 | 208 | } else { |
209 | 209 | $object->setVar('aids', $aids); |
210 | 210 | } |
211 | - if ($object->getVar('abid') > 0 && $abid > 0) { |
|
211 | + if ($object->getVar('abid')>0 && $abid>0) { |
|
212 | 212 | $object->setVar('abid', $abid); |
213 | 213 | } else { |
214 | 214 | $object->setVar('abid', $abid); |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | } else { |
224 | 224 | foreach ($xmlarray as $recid => $data) { |
225 | 225 | $gid = 0; |
226 | - if (mb_strlen($_POST['genre']) > 0 && !empty($data[$_POST['genre']])) { |
|
226 | + if (mb_strlen($_POST['genre'])>0 && !empty($data[$_POST['genre']])) { |
|
227 | 227 | $criteria = new \Criteria('name', $data[$_POST['genre']]); |
228 | - if ($genreHandler->getCount($criteria) > 0) { |
|
228 | + if ($genreHandler->getCount($criteria)>0) { |
|
229 | 229 | $objects = $genreHandler->getObjects($criteria, false); |
230 | 230 | $gid = $objects[0]->getVar('gid'); |
231 | 231 | } else { |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | } |
236 | 236 | } |
237 | 237 | $vid = 0; |
238 | - if (mb_strlen($_POST['voice']) > 0 && !empty($data[$_POST['voice']])) { |
|
238 | + if (mb_strlen($_POST['voice'])>0 && !empty($data[$_POST['voice']])) { |
|
239 | 239 | $criteria = new \Criteria('name', $data[$_POST['voice']]); |
240 | - if ($voiceHandler->getCount($criteria) > 0) { |
|
240 | + if ($voiceHandler->getCount($criteria)>0) { |
|
241 | 241 | $objects = $voiceHandler->getObjects($criteria, false); |
242 | 242 | $gid = $objects[0]->getVar('vid'); |
243 | 243 | } else { |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | } |
248 | 248 | } |
249 | 249 | $cid = 0; |
250 | - if (mb_strlen($_POST['category']) > 0 && !empty($data[$_POST['category']])) { |
|
250 | + if (mb_strlen($_POST['category'])>0 && !empty($data[$_POST['category']])) { |
|
251 | 251 | $criteria = new \Criteria('name', $data[$_POST['category']]); |
252 | - if ($categoryHandler->getCount($criteria) > 0) { |
|
252 | + if ($categoryHandler->getCount($criteria)>0) { |
|
253 | 253 | $objects = $categoryHandler->getObjects($criteria, false); |
254 | 254 | $cid = $objects[0]->getVar('cid'); |
255 | 255 | } else { |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | } |
260 | 260 | } |
261 | 261 | $aids = []; |
262 | - if (mb_strlen($_POST['artist']) > 0 && !empty($data[$_POST['artist']])) { |
|
262 | + if (mb_strlen($_POST['artist'])>0 && !empty($data[$_POST['artist']])) { |
|
263 | 263 | foreach (explode(',', $data[$_POST['artist']]) as $artist) { |
264 | 264 | $criteria = new \Criteria('name', $artist); |
265 | - if ($artistsHandler->getCount($criteria) > 0) { |
|
265 | + if ($artistsHandler->getCount($criteria)>0) { |
|
266 | 266 | $objects = $artistsHandler->getObjects($criteria, false); |
267 | 267 | $aids[$objects[0]->getVar('aid')] = $objects[0]->getVar('aid'); |
268 | 268 | } else { |
@@ -283,9 +283,9 @@ discard block |
||
283 | 283 | } |
284 | 284 | } |
285 | 285 | $abid = 0; |
286 | - if (mb_strlen($_POST['album']) > 0 && !empty($data[$_POST['album']])) { |
|
286 | + if (mb_strlen($_POST['album'])>0 && !empty($data[$_POST['album']])) { |
|
287 | 287 | $criteria = new \Criteria('name', $data[$_POST['album']]); |
288 | - if ($albumsHandler->getCount($criteria) > 0) { |
|
288 | + if ($albumsHandler->getCount($criteria)>0) { |
|
289 | 289 | $objects = $albumsHandler->getObjects($criteria, false); |
290 | 290 | $abid = $objects[0]->getVar('aid'); |
291 | 291 | } else { |
@@ -297,30 +297,30 @@ discard block |
||
297 | 297 | } |
298 | 298 | } |
299 | 299 | $sid = 0; |
300 | - if (mb_strlen($_POST['songid']) > 0 && !empty($data[$_POST['songid']])) { |
|
300 | + if (mb_strlen($_POST['songid'])>0 && !empty($data[$_POST['songid']])) { |
|
301 | 301 | $criteria = new \Criteria('songid', $data[$_POST['songid']]); |
302 | - if ($songsHandler->getCount($criteria) > 0) { |
|
302 | + if ($songsHandler->getCount($criteria)>0) { |
|
303 | 303 | $objects = $songsHandler->getObjects($criteria, false); |
304 | 304 | $object = $objects[0]->getVar('sid'); |
305 | 305 | } else { |
306 | 306 | $object = $songsHandler->create(); |
307 | 307 | } |
308 | - if ($object->getVar('cid') > 0 && $cid > 0) { |
|
308 | + if ($object->getVar('cid')>0 && $cid>0) { |
|
309 | 309 | $object->setVar('cid', $cid); |
310 | 310 | } else { |
311 | 311 | $object->setVar('cid', $cid); |
312 | 312 | } |
313 | - if ($object->getVar('gid') > 0 && $gid > 0) { |
|
313 | + if ($object->getVar('gid')>0 && $gid>0) { |
|
314 | 314 | $object->setVar('gid', $gid); |
315 | 315 | } else { |
316 | 316 | $object->setVar('gid', $gid); |
317 | 317 | } |
318 | - if (count($object->getVar('aids')) > 0 && count($aids) > 0) { |
|
318 | + if (count($object->getVar('aids'))>0 && count($aids)>0) { |
|
319 | 319 | $object->setVar('aids', $aids); |
320 | 320 | } else { |
321 | 321 | $object->setVar('aids', $aids); |
322 | 322 | } |
323 | - if ($object->getVar('abid') > 0 && $abid > 0) { |
|
323 | + if ($object->getVar('abid')>0 && $abid>0) { |
|
324 | 324 | $object->setVar('abid', $abid); |
325 | 325 | } else { |
326 | 326 | $object->setVar('abid', $abid); |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | } |
333 | 333 | } |
334 | 334 | } |
335 | - unlink($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'] . $_SESSION['xmlfile'])); |
|
335 | + unlink($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'].$_SESSION['xmlfile'])); |
|
336 | 336 | unset($_SESSION['xmlfile']); |
337 | - redirect_header($_SERVER['SCRIPT_NAME'] . '&op=import&fct=actiona', 10, _AM_SONGLIST_XMLFILE_COMPLETE); |
|
337 | + redirect_header($_SERVER['SCRIPT_NAME'].'&op=import&fct=actiona', 10, _AM_SONGLIST_XMLFILE_COMPLETE); |
|
338 | 338 | break; |
339 | 339 | } |
340 | 340 | break; |
@@ -19,11 +19,11 @@ |
||
19 | 19 | use Xmf\Module\Admin; |
20 | 20 | use XoopsModules\Songlist\Helper; |
21 | 21 | |
22 | -require \dirname(__DIR__) . '/preloads/autoloader.php'; |
|
22 | +require \dirname(__DIR__).'/preloads/autoloader.php'; |
|
23 | 23 | |
24 | -require \dirname(__DIR__, 3) . '/include/cp_header.php'; |
|
24 | +require \dirname(__DIR__, 3).'/include/cp_header.php'; |
|
25 | 25 | //require $GLOBALS['xoops']->path('www/class/xoopsformloader.php'); |
26 | -require \dirname(__DIR__) . '/include/common.php'; |
|
26 | +require \dirname(__DIR__).'/include/common.php'; |
|
27 | 27 | |
28 | 28 | $moduleDirName = \basename(\dirname(__DIR__)); |
29 | 29 |