Passed
Push — master ( 757841...94ec22 )
by Goffy
06:13 queued 02:50
created
admin/manage.php 2 patches
Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
 
16 16
 // Verify if the table is up to date
17 17
 if (!myiframe_FieldExists('frame_frameid', $GLOBALS['xoopsDB']->prefix('myiframe'))) {
18
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `frameid` `frame_frameid` INT( 8 ) NOT NULL AUTO_INCREMENT');
19
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `created` `frame_created` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'");
20
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `uid` `frame_uid` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'");
21
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `longdesc` `frame_description` VARCHAR( 255 ) NOT NULL');
22
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `width` `frame_width` VARCHAR( 15 ) NOT NULL');
23
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `height` `frame_height` VARCHAR( 15 ) NOT NULL');
24
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `align` `frame_align` SMALLINT( 2 ) NOT NULL DEFAULT '0'");
25
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `frameborder` `frame_frameborder` SMALLINT( 3 ) NOT NULL DEFAULT '0'");
26
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `marginwidth` `frame_marginwidth` SMALLINT( 3 ) NOT NULL DEFAULT '0'");
27
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `marginheight` `frame_marginheight` SMALLINT( 3 ) NOT NULL DEFAULT '0'");
28
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `scrolling` `frame_scrolling` SMALLINT( 1 ) NOT NULL DEFAULT '0'");
29
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `hits` `frame_hits` INT( 8 ) UNSIGNED NOT NULL DEFAULT '0'");
30
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `url` `frame_url` VARCHAR( 255 ) NOT NULL');
31
-    header('Location : ' . XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=update&module=myiframe');
18
+	$result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `frameid` `frame_frameid` INT( 8 ) NOT NULL AUTO_INCREMENT');
19
+	$result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `created` `frame_created` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'");
20
+	$result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `uid` `frame_uid` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'");
21
+	$result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `longdesc` `frame_description` VARCHAR( 255 ) NOT NULL');
22
+	$result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `width` `frame_width` VARCHAR( 15 ) NOT NULL');
23
+	$result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `height` `frame_height` VARCHAR( 15 ) NOT NULL');
24
+	$result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `align` `frame_align` SMALLINT( 2 ) NOT NULL DEFAULT '0'");
25
+	$result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `frameborder` `frame_frameborder` SMALLINT( 3 ) NOT NULL DEFAULT '0'");
26
+	$result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `marginwidth` `frame_marginwidth` SMALLINT( 3 ) NOT NULL DEFAULT '0'");
27
+	$result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `marginheight` `frame_marginheight` SMALLINT( 3 ) NOT NULL DEFAULT '0'");
28
+	$result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `scrolling` `frame_scrolling` SMALLINT( 1 ) NOT NULL DEFAULT '0'");
29
+	$result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `hits` `frame_hits` INT( 8 ) UNSIGNED NOT NULL DEFAULT '0'");
30
+	$result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `url` `frame_url` VARCHAR( 255 ) NOT NULL');
31
+	header('Location : ' . XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=update&module=myiframe');
32 32
 }
33 33
 
34 34
 $module_id = $xoopsModule->getVar('mid');
@@ -53,48 +53,48 @@  discard block
 block discarded – undo
53 53
  */
54 54
 function addEditForm($frameid, $Action, $FormTitle, $longdesc, $width, $height, $align, $frameborder, $marginwidth, $marginheight, $scrolling, $url, $LabelSubmitButton): void
55 55
 {
56
-    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
57
-    global $xoopsModule;
56
+	require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
57
+	global $xoopsModule;
58 58
 
59
-    $sform = new \XoopsThemeForm($FormTitle, 'indexform', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/manage.php');
60
-    $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_DESC, 'longdesc', 50, 255, $longdesc), false);
61
-    $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_WIDTH, 'width', 10, 15, $width), false);
62
-    $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_HEIGHT, 'height', 10, 15, $height), false);
59
+	$sform = new \XoopsThemeForm($FormTitle, 'indexform', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/manage.php');
60
+	$sform->addElement(new \XoopsFormText(_AM_MYIFRAME_DESC, 'longdesc', 50, 255, $longdesc), false);
61
+	$sform->addElement(new \XoopsFormText(_AM_MYIFRAME_WIDTH, 'width', 10, 15, $width), false);
62
+	$sform->addElement(new \XoopsFormText(_AM_MYIFRAME_HEIGHT, 'height', 10, 15, $height), false);
63 63
 
64
-    $selalign = new \XoopsFormSelect(_AM_MYIFRAME_ALIGN, 'align', $align);
65
-    $selalign->addOption(1, _AM_MYIFRAME_ALIGN_TOP);
66
-    $selalign->addOption(2, _AM_MYIFRAME_ALIGN_MIDDLE);
67
-    $selalign->addOption(3, _AM_MYIFRAME_ALIGN_BOTTOM);
68
-    $selalign->addOption(4, _AM_MYIFRAME_ALIGN_LEFT);
69
-    $selalign->addOption(5, _AM_MYIFRAME_ALIGN_RIGHT);
70
-    $selalign->setValue($align);
71
-    $sform->addElement($selalign);
64
+	$selalign = new \XoopsFormSelect(_AM_MYIFRAME_ALIGN, 'align', $align);
65
+	$selalign->addOption(1, _AM_MYIFRAME_ALIGN_TOP);
66
+	$selalign->addOption(2, _AM_MYIFRAME_ALIGN_MIDDLE);
67
+	$selalign->addOption(3, _AM_MYIFRAME_ALIGN_BOTTOM);
68
+	$selalign->addOption(4, _AM_MYIFRAME_ALIGN_LEFT);
69
+	$selalign->addOption(5, _AM_MYIFRAME_ALIGN_RIGHT);
70
+	$selalign->setValue($align);
71
+	$sform->addElement($selalign);
72 72
 
73
-    $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_FRAMEBORDER, 'frameborder', 3, 3, $frameborder), false);
74
-    $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_MARGINWIDTH, 'marginwidth', 3, 3, $marginwidth), false);
75
-    $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_MARGINHEIGHT, 'marginheight', 3, 3, $marginheight), false);
73
+	$sform->addElement(new \XoopsFormText(_AM_MYIFRAME_FRAMEBORDER, 'frameborder', 3, 3, $frameborder), false);
74
+	$sform->addElement(new \XoopsFormText(_AM_MYIFRAME_MARGINWIDTH, 'marginwidth', 3, 3, $marginwidth), false);
75
+	$sform->addElement(new \XoopsFormText(_AM_MYIFRAME_MARGINHEIGHT, 'marginheight', 3, 3, $marginheight), false);
76 76
 
77
-    $selscroll = new \XoopsFormSelect(_AM_MYIFRAME_SCROLLING, 'scrolling', $scrolling);
78
-    $selscroll->addOption(1, _YES);
79
-    $selscroll->addOption(2, _NO);
80
-    $selscroll->addOption(3, _AM_MYIFRAME_AUTO);
81
-    $selscroll->setValue($scrolling);
82
-    $sform->addElement($selscroll);
77
+	$selscroll = new \XoopsFormSelect(_AM_MYIFRAME_SCROLLING, 'scrolling', $scrolling);
78
+	$selscroll->addOption(1, _YES);
79
+	$selscroll->addOption(2, _NO);
80
+	$selscroll->addOption(3, _AM_MYIFRAME_AUTO);
81
+	$selscroll->setValue($scrolling);
82
+	$sform->addElement($selscroll);
83 83
 
84
-    $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_URL, 'url', 50, 255, $url), true);
85
-    $sform->addElement(new \XoopsFormHidden('op', $Action), false);
86
-    if (!empty($frameid)) {
87
-        $sform->addElement(new \XoopsFormHidden('frameid', $frameid), false);
88
-    }
84
+	$sform->addElement(new \XoopsFormText(_AM_MYIFRAME_URL, 'url', 50, 255, $url), true);
85
+	$sform->addElement(new \XoopsFormHidden('op', $Action), false);
86
+	if (!empty($frameid)) {
87
+		$sform->addElement(new \XoopsFormHidden('frameid', $frameid), false);
88
+	}
89 89
 
90
-    $buttonTray = new \XoopsFormElementTray('', '');
91
-    $submit_btn = new \XoopsFormButton('', 'submit', $LabelSubmitButton, 'submit');
92
-    $buttonTray->addElement($submit_btn);
93
-    $cancel_btn = new \XoopsFormButton('', 'reset', _AM_MYIFRAME_RESETBUTTON, 'reset');
94
-    $buttonTray->addElement($cancel_btn);
95
-    $sform->addElement($buttonTray);
96
-    $sform->display();
97
-    require_once __DIR__ . '/admin_footer.php';
90
+	$buttonTray = new \XoopsFormElementTray('', '');
91
+	$submit_btn = new \XoopsFormButton('', 'submit', $LabelSubmitButton, 'submit');
92
+	$buttonTray->addElement($submit_btn);
93
+	$cancel_btn = new \XoopsFormButton('', 'reset', _AM_MYIFRAME_RESETBUTTON, 'reset');
94
+	$buttonTray->addElement($cancel_btn);
95
+	$sform->addElement($buttonTray);
96
+	$sform->display();
97
+	require_once __DIR__ . '/admin_footer.php';
98 98
 }
99 99
 
100 100
 // ******************************************************************************************************************************************
@@ -104,191 +104,191 @@  discard block
 block discarded – undo
104 104
 $op = Request::getCmd('op', '');
105 105
 
106 106
 switch ($op) {
107
-    case 'verifybeforeedit':
108
-        if (Request::hasVar('submit', 'POST') && '' !== $_POST['submit']) {
109
-            if ('' === $_POST['longdesc']) {
110
-                xoops_cp_header();
111
-                $adminObject = Admin::getInstance();
112
-                $adminObject->displayNavigation(basename(__FILE__));
113
-                echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n";
114
-                echo '<tr><td class="odd">';
115
-                echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>';
116
-                echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 1';
117
-                echo '</td></tr></table>';
118
-                require_once __DIR__ . '/admin_footer.php';
119
-                xoops_cp_footer();
120
-                exit();
121
-            }
107
+	case 'verifybeforeedit':
108
+		if (Request::hasVar('submit', 'POST') && '' !== $_POST['submit']) {
109
+			if ('' === $_POST['longdesc']) {
110
+				xoops_cp_header();
111
+				$adminObject = Admin::getInstance();
112
+				$adminObject->displayNavigation(basename(__FILE__));
113
+				echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n";
114
+				echo '<tr><td class="odd">';
115
+				echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>';
116
+				echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 1';
117
+				echo '</td></tr></table>';
118
+				require_once __DIR__ . '/admin_footer.php';
119
+				xoops_cp_footer();
120
+				exit();
121
+			}
122 122
 
123
-            $frameid = $_POST['frameid'];
124
-            $frame   = $iframeHandler->get($frameid);
125
-            $frame->unsetNew();
126
-            $frame->setVar('frame_description', $_POST['longdesc']);
127
-            $frame->setVar('frame_width', $_POST['width']);
128
-            $frame->setVar('frame_height', $_POST['height']);
129
-            $frame->setVar('frame_align', $_POST['align']);
130
-            $frame->setVar('frame_frameborder', $_POST['frameborder']);
131
-            $frame->setVar('frame_marginwidth', $_POST['marginwidth']);
132
-            $frame->setVar('frame_marginheight', $_POST['marginheight']);
133
-            $frame->setVar('frame_scrolling', $_POST['scrolling']);
134
-            $frame->setVar('frame_url', $_POST['url']);
135
-            $frame->setVar('frame_uid', $xoopsUser->getVar('uid'));
136
-            $res = $iframeHandler->insert($frame);
137
-            if (!$res) {
138
-                redirect_header('manage.php', 1, _AM_MYIFRAME_ERROR_MODIFY_DB);
139
-            }
140
-            redirect_header('manage.php', 1, _AM_MYIFRAME_DBUPDATED);
141
-        }
142
-        break;
143
-    case 'edit':
144
-        xoops_cp_header();
145
-        $adminObject = Admin::getInstance();
146
-        $adminObject->displayNavigation(basename(__FILE__));
147
-        if (Request::hasVar('frameid', 'GET')) {
148
-            $frameid = Request::getInt('frameid', 0, 'GET');
149
-            $frame   = $iframeHandler->get($frameid);
150
-            addEditForm(
151
-                $frameid,
152
-                'verifybeforeedit',
153
-                _AM_MYIFRAME_CONFIG,
154
-                $frame->getVar('frame_description', 'e'),
155
-                $frame->getVar('frame_width', 'e'),
156
-                $frame->getVar('frame_height', 'e'),
157
-                $frame->getVar('frame_align', 'e'),
158
-                $frame->getVar('frame_frameborder', 'e'),
159
-                $frame->getVar('frame_marginwidth', 'e'),
160
-                $frame->getVar('frame_marginheight', 'e'),
161
-                $frame->getVar('frame_scrolling', 'e'),
162
-                $frame->getVar('frame_url', 'e'),
163
-                _AM_MYIFRAME_UPDATE
164
-            );
165
-        } else {
166
-            xoops_cp_header();
167
-            $adminObject = Admin::getInstance();
168
-            $adminObject->displayNavigation(basename(__FILE__));
169
-            echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n";
170
-            echo '<tr><td class="odd">';
171
-            echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>';
172
-            echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 2';
173
-            echo "</td></tr></table>\n";
174
-            require_once __DIR__ . '/admin_footer.php';
175
-            xoops_cp_footer();
176
-            exit();
177
-        }
178
-        break;
179
-    case 'delete':
180
-        if (!isset($_POST['ok'])) {
181
-            xoops_cp_header();
182
-            $adminObject = Admin::getInstance();
183
-            $adminObject->displayNavigation(basename(__FILE__));
184
-            echo '<h4>' . _AM_MYIFRAME_CONFIG . '</h4>';
185
-            xoops_confirm(
186
-                [
187
-                    'op'      => 'delete',
188
-                    'frameid' => Request::getInt('frameid', 0, 'GET'),
189
-                    'ok'      => 1,
190
-                ],
191
-                'manage.php',
192
-                _AM_MYIFRAME_RUSUREDEL
193
-            );
194
-            require_once __DIR__ . '/admin_footer.php';
195
-        } else {
196
-            if (empty($_POST['frameid'])) {
197
-                redirect_header('manage.php', 2, _AM_MYIFRAME_ERROR_ADD_INDEX . ' 3');
198
-            }
199
-            $frameid = Request::getInt('frameid', 0, 'POST');
200
-            $critere = new \Criteria('frame_frameid', $frameid, '=');
201
-            $iframeHandler->deleteAll($critere);
202
-            redirect_header('manage.php', 1, _AM_MYIFRAME_DBUPDATED);
203
-        }
204
-        break;
205
-    case 'verifytoadd':
206
-        if (Request::hasVar('submit', 'POST') && '' !== $_POST['submit']) {
207
-            if ('' === $_POST['url']) {
208
-                xoops_cp_header();
209
-                $adminObject = Admin::getInstance();
210
-                $adminObject->displayNavigation(basename(__FILE__));
211
-                echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n";
212
-                echo '<tr><td class="odd">';
213
-                echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>';
214
-                echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 4';
215
-                echo "</td></tr></table>\n";
216
-                require_once __DIR__ . '/admin_footer.php';
217
-                xoops_cp_footer();
218
-                $adminObject = Admin::getInstance();
219
-                $adminObject->displayNavigation(basename(__FILE__));
220
-                exit();
221
-            }
222
-            $frame = $iframeHandler->create(true);
223
-            $frame->setVar('frame_description', $_POST['longdesc']);
224
-            $frame->setVar('frame_width', $_POST['width']);
225
-            $frame->setVar('frame_height', $_POST['height']);
226
-            $frame->setVar('frame_align', $_POST['align']);
227
-            $frame->setVar('frame_frameborder', $_POST['frameborder']);
228
-            $frame->setVar('frame_marginwidth', $_POST['marginwidth']);
229
-            $frame->setVar('frame_marginheight', $_POST['marginheight']);
230
-            $frame->setVar('frame_scrolling', $_POST['scrolling']);
231
-            $frame->setVar('frame_url', $_POST['url']);
232
-            $frame->setVar('frame_created', time());
233
-            $frame->setVar('frame_uid', $xoopsUser->getVar('uid'));
234
-            $res = $iframeHandler->insert($frame);
235
-            if (!$res) {
236
-                redirect_header('manage.php', 1, _AM_MYIFRAME_ERROR_ADD_INDEX . ' 5');
237
-            }
238
-            redirect_header('manage.php', 1, _AM_MYIFRAME_ADDED_OK);
239
-        }
240
-        break;
241
-    case 'addframe':
242
-        xoops_cp_header();
243
-        $adminObject = Admin::getInstance();
244
-        $adminObject->displayNavigation(basename(__FILE__));
245
-        addEditForm(0, 'verifytoadd', _AM_MYIFRAME_CONFIG, '', '100%', '', '', '0', '0', '0', 1, '', _AM_MYIFRAME_ADDBUTTON);
246
-        break;
247
-    case 'default':
248
-    default:
249
-        xoops_cp_header();
250
-        $adminObject = Admin::getInstance();
251
-        $adminObject->displayNavigation(basename(__FILE__));
252
-        echo '<h4>' . _AM_MYIFRAME_CONFIG . "</h4><br>\n";
253
-        echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n";
254
-        echo "<tr><th align='center'>" . _AM_MYIFRAME_ID . "</th><th align='center'>" . _AM_MYIFRAME_DESC . "</th><th align='center'>" . _AM_MYIFRAME_CREATED . "</th><th align='center'>" . _AM_MYIFRAME_HITS . "</th><th align='center'>" . _AM_MYIFRAME_ACTION . "</th></tr>\n";
255
-        $critere = new \Criteria('1', '1', '=');
256
-        $critere->setSort('frame_description');
257
-        $frarray = $iframeHandler->getObjects($critere);
258
-        $class   = 'even';
259
-        $baseurl = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/manage.php';
260
-        if (count($frarray) > 0) {
261
-            /** @var Myiframe $frame */
262
-            foreach ($frarray as $frame) {
263
-                $action_edit   = "<a href='" . $baseurl . '?op=edit&frameid=' . $frame->getVar('frame_frameid') . "'><img src='../assets/images/edit.png' alt='" . _AM_MYIFRAME_EDIT . "'></a>";
264
-                $action_delete = "<a href='" . $baseurl . '?op=delete&frameid=' . $frame->getVar('frame_frameid') . "'><img src='../assets/images/delete.png' alt='" . _AM_MYIFRAME_DELETE . "'></a>";
265
-                if ('' === xoops_trim($frame->getVar('frame_description'))) {
266
-                    $liendesc = $frame->getVar('frame_url');
267
-                } else {
268
-                    $liendesc = "<a href='" . XOOPS_URL . '/modules/myiframe/index.php?iframeid=' . $frame->getVar('frame_frameid') . "'>" . $frame->getVar('frame_description') . '</a>';
269
-                }
270
-                echo "<tr class='"
271
-                     . $class
272
-                     . "'><td align='center'>"
273
-                     . $frame->getVar('frame_frameid')
274
-                     . "</td><td align='center'>"
275
-                     . $liendesc
276
-                     . "</td><td align='center'>"
277
-                     . formatTimestamp($frame->getVar('frame_created'))
278
-                     . "</td><td align='center'>"
279
-                     . $frame->getVar('frame_hits')
280
-                     . "</td><td align='center'>"
281
-                     . $action_edit
282
-                     . '&nbsp;-&nbsp;'
283
-                     . $action_delete
284
-                     . "</td></tr>\n";
285
-                $class = ('even' === $class) ? 'odd' : 'even';
286
-            }
287
-        }
288
-        echo "<tr class='" . $class . "'><td colspan='5' align='center'><form name='faddframe' method='post' action='manage.php'><input type='hidden' name='op' value='addframe'><input type='submit' name='submit' value='" . _AM_MYIFRAME_ADD . "'></td></tr>";
289
-        echo '</table>';
290
-        require_once __DIR__ . '/admin_footer.php';
291
-        break;
123
+			$frameid = $_POST['frameid'];
124
+			$frame   = $iframeHandler->get($frameid);
125
+			$frame->unsetNew();
126
+			$frame->setVar('frame_description', $_POST['longdesc']);
127
+			$frame->setVar('frame_width', $_POST['width']);
128
+			$frame->setVar('frame_height', $_POST['height']);
129
+			$frame->setVar('frame_align', $_POST['align']);
130
+			$frame->setVar('frame_frameborder', $_POST['frameborder']);
131
+			$frame->setVar('frame_marginwidth', $_POST['marginwidth']);
132
+			$frame->setVar('frame_marginheight', $_POST['marginheight']);
133
+			$frame->setVar('frame_scrolling', $_POST['scrolling']);
134
+			$frame->setVar('frame_url', $_POST['url']);
135
+			$frame->setVar('frame_uid', $xoopsUser->getVar('uid'));
136
+			$res = $iframeHandler->insert($frame);
137
+			if (!$res) {
138
+				redirect_header('manage.php', 1, _AM_MYIFRAME_ERROR_MODIFY_DB);
139
+			}
140
+			redirect_header('manage.php', 1, _AM_MYIFRAME_DBUPDATED);
141
+		}
142
+		break;
143
+	case 'edit':
144
+		xoops_cp_header();
145
+		$adminObject = Admin::getInstance();
146
+		$adminObject->displayNavigation(basename(__FILE__));
147
+		if (Request::hasVar('frameid', 'GET')) {
148
+			$frameid = Request::getInt('frameid', 0, 'GET');
149
+			$frame   = $iframeHandler->get($frameid);
150
+			addEditForm(
151
+				$frameid,
152
+				'verifybeforeedit',
153
+				_AM_MYIFRAME_CONFIG,
154
+				$frame->getVar('frame_description', 'e'),
155
+				$frame->getVar('frame_width', 'e'),
156
+				$frame->getVar('frame_height', 'e'),
157
+				$frame->getVar('frame_align', 'e'),
158
+				$frame->getVar('frame_frameborder', 'e'),
159
+				$frame->getVar('frame_marginwidth', 'e'),
160
+				$frame->getVar('frame_marginheight', 'e'),
161
+				$frame->getVar('frame_scrolling', 'e'),
162
+				$frame->getVar('frame_url', 'e'),
163
+				_AM_MYIFRAME_UPDATE
164
+			);
165
+		} else {
166
+			xoops_cp_header();
167
+			$adminObject = Admin::getInstance();
168
+			$adminObject->displayNavigation(basename(__FILE__));
169
+			echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n";
170
+			echo '<tr><td class="odd">';
171
+			echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>';
172
+			echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 2';
173
+			echo "</td></tr></table>\n";
174
+			require_once __DIR__ . '/admin_footer.php';
175
+			xoops_cp_footer();
176
+			exit();
177
+		}
178
+		break;
179
+	case 'delete':
180
+		if (!isset($_POST['ok'])) {
181
+			xoops_cp_header();
182
+			$adminObject = Admin::getInstance();
183
+			$adminObject->displayNavigation(basename(__FILE__));
184
+			echo '<h4>' . _AM_MYIFRAME_CONFIG . '</h4>';
185
+			xoops_confirm(
186
+				[
187
+					'op'      => 'delete',
188
+					'frameid' => Request::getInt('frameid', 0, 'GET'),
189
+					'ok'      => 1,
190
+				],
191
+				'manage.php',
192
+				_AM_MYIFRAME_RUSUREDEL
193
+			);
194
+			require_once __DIR__ . '/admin_footer.php';
195
+		} else {
196
+			if (empty($_POST['frameid'])) {
197
+				redirect_header('manage.php', 2, _AM_MYIFRAME_ERROR_ADD_INDEX . ' 3');
198
+			}
199
+			$frameid = Request::getInt('frameid', 0, 'POST');
200
+			$critere = new \Criteria('frame_frameid', $frameid, '=');
201
+			$iframeHandler->deleteAll($critere);
202
+			redirect_header('manage.php', 1, _AM_MYIFRAME_DBUPDATED);
203
+		}
204
+		break;
205
+	case 'verifytoadd':
206
+		if (Request::hasVar('submit', 'POST') && '' !== $_POST['submit']) {
207
+			if ('' === $_POST['url']) {
208
+				xoops_cp_header();
209
+				$adminObject = Admin::getInstance();
210
+				$adminObject->displayNavigation(basename(__FILE__));
211
+				echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n";
212
+				echo '<tr><td class="odd">';
213
+				echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>';
214
+				echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 4';
215
+				echo "</td></tr></table>\n";
216
+				require_once __DIR__ . '/admin_footer.php';
217
+				xoops_cp_footer();
218
+				$adminObject = Admin::getInstance();
219
+				$adminObject->displayNavigation(basename(__FILE__));
220
+				exit();
221
+			}
222
+			$frame = $iframeHandler->create(true);
223
+			$frame->setVar('frame_description', $_POST['longdesc']);
224
+			$frame->setVar('frame_width', $_POST['width']);
225
+			$frame->setVar('frame_height', $_POST['height']);
226
+			$frame->setVar('frame_align', $_POST['align']);
227
+			$frame->setVar('frame_frameborder', $_POST['frameborder']);
228
+			$frame->setVar('frame_marginwidth', $_POST['marginwidth']);
229
+			$frame->setVar('frame_marginheight', $_POST['marginheight']);
230
+			$frame->setVar('frame_scrolling', $_POST['scrolling']);
231
+			$frame->setVar('frame_url', $_POST['url']);
232
+			$frame->setVar('frame_created', time());
233
+			$frame->setVar('frame_uid', $xoopsUser->getVar('uid'));
234
+			$res = $iframeHandler->insert($frame);
235
+			if (!$res) {
236
+				redirect_header('manage.php', 1, _AM_MYIFRAME_ERROR_ADD_INDEX . ' 5');
237
+			}
238
+			redirect_header('manage.php', 1, _AM_MYIFRAME_ADDED_OK);
239
+		}
240
+		break;
241
+	case 'addframe':
242
+		xoops_cp_header();
243
+		$adminObject = Admin::getInstance();
244
+		$adminObject->displayNavigation(basename(__FILE__));
245
+		addEditForm(0, 'verifytoadd', _AM_MYIFRAME_CONFIG, '', '100%', '', '', '0', '0', '0', 1, '', _AM_MYIFRAME_ADDBUTTON);
246
+		break;
247
+	case 'default':
248
+	default:
249
+		xoops_cp_header();
250
+		$adminObject = Admin::getInstance();
251
+		$adminObject->displayNavigation(basename(__FILE__));
252
+		echo '<h4>' . _AM_MYIFRAME_CONFIG . "</h4><br>\n";
253
+		echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n";
254
+		echo "<tr><th align='center'>" . _AM_MYIFRAME_ID . "</th><th align='center'>" . _AM_MYIFRAME_DESC . "</th><th align='center'>" . _AM_MYIFRAME_CREATED . "</th><th align='center'>" . _AM_MYIFRAME_HITS . "</th><th align='center'>" . _AM_MYIFRAME_ACTION . "</th></tr>\n";
255
+		$critere = new \Criteria('1', '1', '=');
256
+		$critere->setSort('frame_description');
257
+		$frarray = $iframeHandler->getObjects($critere);
258
+		$class   = 'even';
259
+		$baseurl = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/manage.php';
260
+		if (count($frarray) > 0) {
261
+			/** @var Myiframe $frame */
262
+			foreach ($frarray as $frame) {
263
+				$action_edit   = "<a href='" . $baseurl . '?op=edit&frameid=' . $frame->getVar('frame_frameid') . "'><img src='../assets/images/edit.png' alt='" . _AM_MYIFRAME_EDIT . "'></a>";
264
+				$action_delete = "<a href='" . $baseurl . '?op=delete&frameid=' . $frame->getVar('frame_frameid') . "'><img src='../assets/images/delete.png' alt='" . _AM_MYIFRAME_DELETE . "'></a>";
265
+				if ('' === xoops_trim($frame->getVar('frame_description'))) {
266
+					$liendesc = $frame->getVar('frame_url');
267
+				} else {
268
+					$liendesc = "<a href='" . XOOPS_URL . '/modules/myiframe/index.php?iframeid=' . $frame->getVar('frame_frameid') . "'>" . $frame->getVar('frame_description') . '</a>';
269
+				}
270
+				echo "<tr class='"
271
+					 . $class
272
+					 . "'><td align='center'>"
273
+					 . $frame->getVar('frame_frameid')
274
+					 . "</td><td align='center'>"
275
+					 . $liendesc
276
+					 . "</td><td align='center'>"
277
+					 . formatTimestamp($frame->getVar('frame_created'))
278
+					 . "</td><td align='center'>"
279
+					 . $frame->getVar('frame_hits')
280
+					 . "</td><td align='center'>"
281
+					 . $action_edit
282
+					 . '&nbsp;-&nbsp;'
283
+					 . $action_delete
284
+					 . "</td></tr>\n";
285
+				$class = ('even' === $class) ? 'odd' : 'even';
286
+			}
287
+		}
288
+		echo "<tr class='" . $class . "'><td colspan='5' align='center'><form name='faddframe' method='post' action='manage.php'><input type='hidden' name='op' value='addframe'><input type='submit' name='submit' value='" . _AM_MYIFRAME_ADD . "'></td></tr>";
289
+		echo '</table>';
290
+		require_once __DIR__ . '/admin_footer.php';
291
+		break;
292 292
 }
293 293
 
294 294
 xoops_cp_footer();
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -10,25 +10,25 @@  discard block
 block discarded – undo
10 10
 use Xmf\Module\Admin;
11 11
 use Xmf\Request;
12 12
 
13
-require_once __DIR__ . '/admin_header.php';
14
-require_once XOOPS_ROOT_PATH . '/modules/myiframe/include/functions.php';
13
+require_once __DIR__.'/admin_header.php';
14
+require_once XOOPS_ROOT_PATH.'/modules/myiframe/include/functions.php';
15 15
 
16 16
 // Verify if the table is up to date
17 17
 if (!myiframe_FieldExists('frame_frameid', $GLOBALS['xoopsDB']->prefix('myiframe'))) {
18
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `frameid` `frame_frameid` INT( 8 ) NOT NULL AUTO_INCREMENT');
19
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `created` `frame_created` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'");
20
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `uid` `frame_uid` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'");
21
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `longdesc` `frame_description` VARCHAR( 255 ) NOT NULL');
22
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `width` `frame_width` VARCHAR( 15 ) NOT NULL');
23
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `height` `frame_height` VARCHAR( 15 ) NOT NULL');
24
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `align` `frame_align` SMALLINT( 2 ) NOT NULL DEFAULT '0'");
25
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `frameborder` `frame_frameborder` SMALLINT( 3 ) NOT NULL DEFAULT '0'");
26
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `marginwidth` `frame_marginwidth` SMALLINT( 3 ) NOT NULL DEFAULT '0'");
27
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `marginheight` `frame_marginheight` SMALLINT( 3 ) NOT NULL DEFAULT '0'");
28
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `scrolling` `frame_scrolling` SMALLINT( 1 ) NOT NULL DEFAULT '0'");
29
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . " CHANGE `hits` `frame_hits` INT( 8 ) UNSIGNED NOT NULL DEFAULT '0'");
30
-    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('myiframe') . ' CHANGE `url` `frame_url` VARCHAR( 255 ) NOT NULL');
31
-    header('Location : ' . XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=update&module=myiframe');
18
+    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE '.$GLOBALS['xoopsDB']->prefix('myiframe').' CHANGE `frameid` `frame_frameid` INT( 8 ) NOT NULL AUTO_INCREMENT');
19
+    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE '.$GLOBALS['xoopsDB']->prefix('myiframe')." CHANGE `created` `frame_created` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'");
20
+    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE '.$GLOBALS['xoopsDB']->prefix('myiframe')." CHANGE `uid` `frame_uid` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'");
21
+    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE '.$GLOBALS['xoopsDB']->prefix('myiframe').' CHANGE `longdesc` `frame_description` VARCHAR( 255 ) NOT NULL');
22
+    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE '.$GLOBALS['xoopsDB']->prefix('myiframe').' CHANGE `width` `frame_width` VARCHAR( 15 ) NOT NULL');
23
+    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE '.$GLOBALS['xoopsDB']->prefix('myiframe').' CHANGE `height` `frame_height` VARCHAR( 15 ) NOT NULL');
24
+    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE '.$GLOBALS['xoopsDB']->prefix('myiframe')." CHANGE `align` `frame_align` SMALLINT( 2 ) NOT NULL DEFAULT '0'");
25
+    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE '.$GLOBALS['xoopsDB']->prefix('myiframe')." CHANGE `frameborder` `frame_frameborder` SMALLINT( 3 ) NOT NULL DEFAULT '0'");
26
+    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE '.$GLOBALS['xoopsDB']->prefix('myiframe')." CHANGE `marginwidth` `frame_marginwidth` SMALLINT( 3 ) NOT NULL DEFAULT '0'");
27
+    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE '.$GLOBALS['xoopsDB']->prefix('myiframe')." CHANGE `marginheight` `frame_marginheight` SMALLINT( 3 ) NOT NULL DEFAULT '0'");
28
+    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE '.$GLOBALS['xoopsDB']->prefix('myiframe')." CHANGE `scrolling` `frame_scrolling` SMALLINT( 1 ) NOT NULL DEFAULT '0'");
29
+    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE '.$GLOBALS['xoopsDB']->prefix('myiframe')." CHANGE `hits` `frame_hits` INT( 8 ) UNSIGNED NOT NULL DEFAULT '0'");
30
+    $result = $GLOBALS['xoopsDB']->queryF('ALTER TABLE '.$GLOBALS['xoopsDB']->prefix('myiframe').' CHANGE `url` `frame_url` VARCHAR( 255 ) NOT NULL');
31
+    header('Location : '.XOOPS_URL.'/modules/system/admin.php?fct=modulesadmin&op=update&module=myiframe');
32 32
 }
33 33
 
34 34
 $module_id = $xoopsModule->getVar('mid');
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
  */
54 54
 function addEditForm($frameid, $Action, $FormTitle, $longdesc, $width, $height, $align, $frameborder, $marginwidth, $marginheight, $scrolling, $url, $LabelSubmitButton): void
55 55
 {
56
-    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
56
+    require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
57 57
     global $xoopsModule;
58 58
 
59
-    $sform = new \XoopsThemeForm($FormTitle, 'indexform', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/manage.php');
59
+    $sform = new \XoopsThemeForm($FormTitle, 'indexform', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/admin/manage.php');
60 60
     $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_DESC, 'longdesc', 50, 255, $longdesc), false);
61 61
     $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_WIDTH, 'width', 10, 15, $width), false);
62 62
     $sform->addElement(new \XoopsFormText(_AM_MYIFRAME_HEIGHT, 'height', 10, 15, $height), false);
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     $buttonTray->addElement($cancel_btn);
95 95
     $sform->addElement($buttonTray);
96 96
     $sform->display();
97
-    require_once __DIR__ . '/admin_footer.php';
97
+    require_once __DIR__.'/admin_footer.php';
98 98
 }
99 99
 
100 100
 // ******************************************************************************************************************************************
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
                 $adminObject->displayNavigation(basename(__FILE__));
113 113
                 echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n";
114 114
                 echo '<tr><td class="odd">';
115
-                echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>';
116
-                echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 1';
115
+                echo "<a href='manage.php'><h4>"._AM_MYIFRAME_CONFIG.'</h4></a>';
116
+                echo _AM_MYIFRAME_ERROR_ADD_INDEX.' 1';
117 117
                 echo '</td></tr></table>';
118
-                require_once __DIR__ . '/admin_footer.php';
118
+                require_once __DIR__.'/admin_footer.php';
119 119
                 xoops_cp_footer();
120 120
                 exit();
121 121
             }
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
             $adminObject->displayNavigation(basename(__FILE__));
169 169
             echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n";
170 170
             echo '<tr><td class="odd">';
171
-            echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>';
172
-            echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 2';
171
+            echo "<a href='manage.php'><h4>"._AM_MYIFRAME_CONFIG.'</h4></a>';
172
+            echo _AM_MYIFRAME_ERROR_ADD_INDEX.' 2';
173 173
             echo "</td></tr></table>\n";
174
-            require_once __DIR__ . '/admin_footer.php';
174
+            require_once __DIR__.'/admin_footer.php';
175 175
             xoops_cp_footer();
176 176
             exit();
177 177
         }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             xoops_cp_header();
182 182
             $adminObject = Admin::getInstance();
183 183
             $adminObject->displayNavigation(basename(__FILE__));
184
-            echo '<h4>' . _AM_MYIFRAME_CONFIG . '</h4>';
184
+            echo '<h4>'._AM_MYIFRAME_CONFIG.'</h4>';
185 185
             xoops_confirm(
186 186
                 [
187 187
                     'op'      => 'delete',
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
                 'manage.php',
192 192
                 _AM_MYIFRAME_RUSUREDEL
193 193
             );
194
-            require_once __DIR__ . '/admin_footer.php';
194
+            require_once __DIR__.'/admin_footer.php';
195 195
         } else {
196 196
             if (empty($_POST['frameid'])) {
197
-                redirect_header('manage.php', 2, _AM_MYIFRAME_ERROR_ADD_INDEX . ' 3');
197
+                redirect_header('manage.php', 2, _AM_MYIFRAME_ERROR_ADD_INDEX.' 3');
198 198
             }
199 199
             $frameid = Request::getInt('frameid', 0, 'POST');
200 200
             $critere = new \Criteria('frame_frameid', $frameid, '=');
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
                 $adminObject->displayNavigation(basename(__FILE__));
211 211
                 echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n";
212 212
                 echo '<tr><td class="odd">';
213
-                echo "<a href='manage.php'><h4>" . _AM_MYIFRAME_CONFIG . '</h4></a>';
214
-                echo _AM_MYIFRAME_ERROR_ADD_INDEX . ' 4';
213
+                echo "<a href='manage.php'><h4>"._AM_MYIFRAME_CONFIG.'</h4></a>';
214
+                echo _AM_MYIFRAME_ERROR_ADD_INDEX.' 4';
215 215
                 echo "</td></tr></table>\n";
216
-                require_once __DIR__ . '/admin_footer.php';
216
+                require_once __DIR__.'/admin_footer.php';
217 217
                 xoops_cp_footer();
218 218
                 $adminObject = Admin::getInstance();
219 219
                 $adminObject->displayNavigation(basename(__FILE__));
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
             $frame->setVar('frame_uid', $xoopsUser->getVar('uid'));
234 234
             $res = $iframeHandler->insert($frame);
235 235
             if (!$res) {
236
-                redirect_header('manage.php', 1, _AM_MYIFRAME_ERROR_ADD_INDEX . ' 5');
236
+                redirect_header('manage.php', 1, _AM_MYIFRAME_ERROR_ADD_INDEX.' 5');
237 237
             }
238 238
             redirect_header('manage.php', 1, _AM_MYIFRAME_ADDED_OK);
239 239
         }
@@ -249,23 +249,23 @@  discard block
 block discarded – undo
249 249
         xoops_cp_header();
250 250
         $adminObject = Admin::getInstance();
251 251
         $adminObject->displayNavigation(basename(__FILE__));
252
-        echo '<h4>' . _AM_MYIFRAME_CONFIG . "</h4><br>\n";
252
+        echo '<h4>'._AM_MYIFRAME_CONFIG."</h4><br>\n";
253 253
         echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n";
254
-        echo "<tr><th align='center'>" . _AM_MYIFRAME_ID . "</th><th align='center'>" . _AM_MYIFRAME_DESC . "</th><th align='center'>" . _AM_MYIFRAME_CREATED . "</th><th align='center'>" . _AM_MYIFRAME_HITS . "</th><th align='center'>" . _AM_MYIFRAME_ACTION . "</th></tr>\n";
254
+        echo "<tr><th align='center'>"._AM_MYIFRAME_ID."</th><th align='center'>"._AM_MYIFRAME_DESC."</th><th align='center'>"._AM_MYIFRAME_CREATED."</th><th align='center'>"._AM_MYIFRAME_HITS."</th><th align='center'>"._AM_MYIFRAME_ACTION."</th></tr>\n";
255 255
         $critere = new \Criteria('1', '1', '=');
256 256
         $critere->setSort('frame_description');
257 257
         $frarray = $iframeHandler->getObjects($critere);
258 258
         $class   = 'even';
259
-        $baseurl = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/manage.php';
259
+        $baseurl = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/admin/manage.php';
260 260
         if (count($frarray) > 0) {
261 261
             /** @var Myiframe $frame */
262 262
             foreach ($frarray as $frame) {
263
-                $action_edit   = "<a href='" . $baseurl . '?op=edit&frameid=' . $frame->getVar('frame_frameid') . "'><img src='../assets/images/edit.png' alt='" . _AM_MYIFRAME_EDIT . "'></a>";
264
-                $action_delete = "<a href='" . $baseurl . '?op=delete&frameid=' . $frame->getVar('frame_frameid') . "'><img src='../assets/images/delete.png' alt='" . _AM_MYIFRAME_DELETE . "'></a>";
263
+                $action_edit   = "<a href='".$baseurl.'?op=edit&frameid='.$frame->getVar('frame_frameid')."'><img src='../assets/images/edit.png' alt='"._AM_MYIFRAME_EDIT."'></a>";
264
+                $action_delete = "<a href='".$baseurl.'?op=delete&frameid='.$frame->getVar('frame_frameid')."'><img src='../assets/images/delete.png' alt='"._AM_MYIFRAME_DELETE."'></a>";
265 265
                 if ('' === xoops_trim($frame->getVar('frame_description'))) {
266 266
                     $liendesc = $frame->getVar('frame_url');
267 267
                 } else {
268
-                    $liendesc = "<a href='" . XOOPS_URL . '/modules/myiframe/index.php?iframeid=' . $frame->getVar('frame_frameid') . "'>" . $frame->getVar('frame_description') . '</a>';
268
+                    $liendesc = "<a href='".XOOPS_URL.'/modules/myiframe/index.php?iframeid='.$frame->getVar('frame_frameid')."'>".$frame->getVar('frame_description').'</a>';
269 269
                 }
270 270
                 echo "<tr class='"
271 271
                      . $class
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
                 $class = ('even' === $class) ? 'odd' : 'even';
286 286
             }
287 287
         }
288
-        echo "<tr class='" . $class . "'><td colspan='5' align='center'><form name='faddframe' method='post' action='manage.php'><input type='hidden' name='op' value='addframe'><input type='submit' name='submit' value='" . _AM_MYIFRAME_ADD . "'></td></tr>";
288
+        echo "<tr class='".$class."'><td colspan='5' align='center'><form name='faddframe' method='post' action='manage.php'><input type='hidden' name='op' value='addframe'><input type='submit' name='submit' value='"._AM_MYIFRAME_ADD."'></td></tr>";
289 289
         echo '</table>';
290
-        require_once __DIR__ . '/admin_footer.php';
290
+        require_once __DIR__.'/admin_footer.php';
291 291
         break;
292 292
 }
293 293
 
Please login to merge, or discard this patch.
include/common.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
 //$downloadHandler     = new Myiframe\DownloadHandler($db);
39 39
 
40 40
 if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) {
41
-    define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__)));
42
-    define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
43
-    define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
44
-    define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/');
45
-    define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/');
46
-    define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images');
47
-    define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/');
48
-    define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/');
49
-    define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php');
50
-    define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png');
51
-    define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash
52
-    define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash
53
-    define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1);
41
+	define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__)));
42
+	define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
43
+	define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
44
+	define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/');
45
+	define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/');
46
+	define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images');
47
+	define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/');
48
+	define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/');
49
+	define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php');
50
+	define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png');
51
+	define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash
52
+	define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash
53
+	define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1);
54 54
 }
55 55
 
56 56
 $pathIcon16 = Admin::iconUrl('', '16');
@@ -59,15 +59,15 @@  discard block
 block discarded – undo
59 59
 //$pathModIcon32 = $helper->getModule()->getInfo('modicons32');
60 60
 
61 61
 $icons = [
62
-    'edit'    => "<img src='" . $pathIcon16 . "/edit.png'  alt=" . _EDIT . "' align='middle'>",
63
-    'delete'  => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>",
64
-    'clone'   => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>",
65
-    'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>",
66
-    'print'   => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>",
67
-    'pdf'     => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>",
68
-    'add'     => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>",
69
-    '0'       => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>",
70
-    '1'       => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>",
62
+	'edit'    => "<img src='" . $pathIcon16 . "/edit.png'  alt=" . _EDIT . "' align='middle'>",
63
+	'delete'  => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>",
64
+	'clone'   => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>",
65
+	'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>",
66
+	'print'   => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>",
67
+	'pdf'     => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>",
68
+	'add'     => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>",
69
+	'0'       => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>",
70
+	'1'       => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>",
71 71
 ];
72 72
 
73 73
 $debug = false;
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
 $myts = \MyTextSanitizer::getInstance();
77 77
 
78 78
 if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) {
79
-    require_once $GLOBALS['xoops']->path('class/template.php');
80
-    $GLOBALS['xoopsTpl'] = new \XoopsTpl();
79
+	require_once $GLOBALS['xoops']->path('class/template.php');
80
+	$GLOBALS['xoopsTpl'] = new \XoopsTpl();
81 81
 }
82 82
 
83 83
 $GLOBALS['xoopsTpl']->assign('mod_url', $helper->url());
84 84
 // Local icons path
85 85
 if (is_object($helper->getModule())) {
86
-    $pathModIcon16 = $helper->getModule()
87
-                            ->getInfo('modicons16');
88
-    $pathModIcon32 = $helper->getModule()
89
-                            ->getInfo('modicons32');
86
+	$pathModIcon16 = $helper->getModule()
87
+							->getInfo('modicons16');
88
+	$pathModIcon32 = $helper->getModule()
89
+							->getInfo('modicons32');
90 90
 
91
-    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16);
92
-    $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32);
91
+	$GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16);
92
+	$GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32);
93 93
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use Xmf\Module\Admin;
19 19
 use XoopsModules\Myiframe;
20 20
 
21
-require_once \dirname(__DIR__) . '/preloads/autoloader.php';
21
+require_once \dirname(__DIR__).'/preloads/autoloader.php';
22 22
 
23 23
 $moduleDirName      = \basename(\dirname(__DIR__));
24 24
 $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
@@ -37,20 +37,20 @@  discard block
 block discarded – undo
37 37
 //$categoryHandler     = new Myiframe\CategoryHandler($db);
38 38
 //$downloadHandler     = new Myiframe\DownloadHandler($db);
39 39
 
40
-if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) {
41
-    define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__)));
42
-    define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
43
-    define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
44
-    define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/');
45
-    define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/');
46
-    define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images');
47
-    define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/');
48
-    define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/');
49
-    define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php');
50
-    define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png');
51
-    define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash
52
-    define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash
53
-    define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1);
40
+if (!defined($moduleDirNameUpper.'_CONSTANTS_DEFINED')) {
41
+    define($moduleDirNameUpper.'_DIRNAME', basename(dirname(__DIR__)));
42
+    define($moduleDirNameUpper.'_ROOT_PATH', XOOPS_ROOT_PATH.'/modules/'.$moduleDirName.'/');
43
+    define($moduleDirNameUpper.'_PATH', XOOPS_ROOT_PATH.'/modules/'.$moduleDirName.'/');
44
+    define($moduleDirNameUpper.'_URL', XOOPS_URL.'/modules/'.$moduleDirName.'/');
45
+    define($moduleDirNameUpper.'_IMAGE_URL', constant($moduleDirNameUpper.'_URL').'/assets/images/');
46
+    define($moduleDirNameUpper.'_IMAGE_PATH', constant($moduleDirNameUpper.'_ROOT_PATH').'/assets/images');
47
+    define($moduleDirNameUpper.'_ADMIN_URL', constant($moduleDirNameUpper.'_URL').'/admin/');
48
+    define($moduleDirNameUpper.'_ADMIN_PATH', constant($moduleDirNameUpper.'_ROOT_PATH').'/admin/');
49
+    define($moduleDirNameUpper.'_ADMIN', constant($moduleDirNameUpper.'_URL').'/admin/index.php');
50
+    define($moduleDirNameUpper.'_AUTHOR_LOGOIMG', constant($moduleDirNameUpper.'_URL').'/assets/images/logoModule.png');
51
+    define($moduleDirNameUpper.'_UPLOAD_URL', XOOPS_UPLOAD_URL.'/'.$moduleDirName); // WITHOUT Trailing slash
52
+    define($moduleDirNameUpper.'_UPLOAD_PATH', XOOPS_UPLOAD_PATH.'/'.$moduleDirName); // WITHOUT Trailing slash
53
+    define($moduleDirNameUpper.'_CONSTANTS_DEFINED', 1);
54 54
 }
55 55
 
56 56
 $pathIcon16 = Admin::iconUrl('', '16');
@@ -59,15 +59,15 @@  discard block
 block discarded – undo
59 59
 //$pathModIcon32 = $helper->getModule()->getInfo('modicons32');
60 60
 
61 61
 $icons = [
62
-    'edit'    => "<img src='" . $pathIcon16 . "/edit.png'  alt=" . _EDIT . "' align='middle'>",
63
-    'delete'  => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>",
64
-    'clone'   => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>",
65
-    'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>",
66
-    'print'   => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>",
67
-    'pdf'     => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>",
68
-    'add'     => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>",
69
-    '0'       => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>",
70
-    '1'       => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>",
62
+    'edit'    => "<img src='".$pathIcon16."/edit.png'  alt="._EDIT."' align='middle'>",
63
+    'delete'  => "<img src='".$pathIcon16."/delete.png' alt='"._DELETE."' align='middle'>",
64
+    'clone'   => "<img src='".$pathIcon16."/editcopy.png' alt='"._CLONE."' align='middle'>",
65
+    'preview' => "<img src='".$pathIcon16."/view.png' alt='"._PREVIEW."' align='middle'>",
66
+    'print'   => "<img src='".$pathIcon16."/printer.png' alt='"._CLONE."' align='middle'>",
67
+    'pdf'     => "<img src='".$pathIcon16."/pdf.png' alt='"._CLONE."' align='middle'>",
68
+    'add'     => "<img src='".$pathIcon16."/add.png' alt='"._ADD."' align='middle'>",
69
+    '0'       => "<img src='".$pathIcon16."/0.png' alt='".0."' align='middle'>",
70
+    '1'       => "<img src='".$pathIcon16."/1.png' alt='".1."' align='middle'>",
71 71
 ];
72 72
 
73 73
 $debug = false;
@@ -88,6 +88,6 @@  discard block
 block discarded – undo
88 88
     $pathModIcon32 = $helper->getModule()
89 89
                             ->getInfo('modicons32');
90 90
 
91
-    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16);
91
+    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL.'/modules/'.$moduleDirName.'/'.$pathModIcon16);
92 92
     $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32);
93 93
 }
Please login to merge, or discard this patch.
blocks/myiframe_iframe.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
 
10 10
 use XoopsModules\Newbb;
11 11
 use XoopsModules\Myiframe\{
12
-    Constants,
13
-    Helper
12
+	Constants,
13
+	Helper
14 14
 };
15 15
 
16 16
 /** @var Helper $helper */
@@ -23,40 +23,40 @@  discard block
 block discarded – undo
23 23
  */
24 24
 function b_myiframe_iframe_show($options)
25 25
 {
26
-    if (!class_exists(Helper::class)) {
27
-        return false;
28
-    }
29
-    $frame         = null;
30
-    $helper        = Helper::getInstance();
31
-    $block         = [];
32
-    $tblalign      = [
33
-        'top',
34
-        'middle',
35
-        'bottom',
36
-        'left',
37
-        'rigth',
38
-    ];
39
-    $tblscrolling  = [
40
-        'yes',
41
-        'no',
42
-        'auto',
43
-    ];
44
-    $iframeHandler = $helper->getHandler('MyiframeBase');
45
-    $frame         = $iframeHandler->get($options[0]);
26
+	if (!class_exists(Helper::class)) {
27
+		return false;
28
+	}
29
+	$frame         = null;
30
+	$helper        = Helper::getInstance();
31
+	$block         = [];
32
+	$tblalign      = [
33
+		'top',
34
+		'middle',
35
+		'bottom',
36
+		'left',
37
+		'rigth',
38
+	];
39
+	$tblscrolling  = [
40
+		'yes',
41
+		'no',
42
+		'auto',
43
+	];
44
+	$iframeHandler = $helper->getHandler('MyiframeBase');
45
+	$frame         = $iframeHandler->get($options[0]);
46 46
 
47
-    if (is_object($frame)) {
48
-        $block['longdesc']     = $frame->getVar('frame_description');
49
-        $block['width']        = $frame->getVar('frame_width');
50
-        $block['height']       = $frame->getVar('frame_height');
51
-        $block['align']        = $tblalign[$frame->getVar('frame_align') - 1];
52
-        $block['frameborder']  = $frame->getVar('frame_frameborder');
53
-        $block['marginwidth']  = $frame->getVar('frame_marginwidth');
54
-        $block['marginheight'] = $frame->getVar('frame_marginheight');
55
-        $block['scrolling']    = $tblscrolling[$frame->getVar('frame_scrolling') - 1];
56
-        $block['url']          = $frame->getVar('frame_url');
57
-    }
47
+	if (is_object($frame)) {
48
+		$block['longdesc']     = $frame->getVar('frame_description');
49
+		$block['width']        = $frame->getVar('frame_width');
50
+		$block['height']       = $frame->getVar('frame_height');
51
+		$block['align']        = $tblalign[$frame->getVar('frame_align') - 1];
52
+		$block['frameborder']  = $frame->getVar('frame_frameborder');
53
+		$block['marginwidth']  = $frame->getVar('frame_marginwidth');
54
+		$block['marginheight'] = $frame->getVar('frame_marginheight');
55
+		$block['scrolling']    = $tblscrolling[$frame->getVar('frame_scrolling') - 1];
56
+		$block['url']          = $frame->getVar('frame_url');
57
+	}
58 58
 
59
-    return $block;
59
+	return $block;
60 60
 }
61 61
 
62 62
 /**
@@ -65,30 +65,30 @@  discard block
 block discarded – undo
65 65
  */
66 66
 function b_myiframe_iframe_edit($options)
67 67
 {
68
-    if (!class_exists(Helper::class)) {
69
-        return false;
70
-    }
71
-    $helper = Helper::getInstance();
68
+	if (!class_exists(Helper::class)) {
69
+		return false;
70
+	}
71
+	$helper = Helper::getInstance();
72 72
 
73
-    /** @var \MyiframeBaseHandler $iframeHandler */
74
-    $iframeHandler = $helper->getHandler('MyiframeBase');
75
-    $frarray       = [];
76
-    $critere       = new \Criteria('1', '1', '=');
77
-    $critere->setSort('frame_description');
78
-    $frarray = $iframeHandler->getObjects($critere);
73
+	/** @var \MyiframeBaseHandler $iframeHandler */
74
+	$iframeHandler = $helper->getHandler('MyiframeBase');
75
+	$frarray       = [];
76
+	$critere       = new \Criteria('1', '1', '=');
77
+	$critere->setSort('frame_description');
78
+	$frarray = $iframeHandler->getObjects($critere);
79 79
 
80
-    $form = '' . _MB_MYIFRAME_IFRAME . "&nbsp;<select name='options[0]'>";
81
-    /** @var Myiframe $oneframe */
82
-    foreach ($frarray as $oneframe) {
83
-        $form .= "<option value='" . $oneframe->getVar('frame_frameid') . "'";
84
-        if ($options[0] == $oneframe->getVar('frame_frameid')) {
85
-            $form .= " selected='selected'";
86
-        }
87
-        $form .= '>' . $oneframe->getVar('frame_description') . '</option>';
88
-    }
89
-    $form .= "</select>\n";
80
+	$form = '' . _MB_MYIFRAME_IFRAME . "&nbsp;<select name='options[0]'>";
81
+	/** @var Myiframe $oneframe */
82
+	foreach ($frarray as $oneframe) {
83
+		$form .= "<option value='" . $oneframe->getVar('frame_frameid') . "'";
84
+		if ($options[0] == $oneframe->getVar('frame_frameid')) {
85
+			$form .= " selected='selected'";
86
+		}
87
+		$form .= '>' . $oneframe->getVar('frame_description') . '</option>';
88
+	}
89
+	$form .= "</select>\n";
90 90
 
91
-    return $form;
91
+	return $form;
92 92
 }
93 93
 
94 94
 /**
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
  */
97 97
 function b_myiframe_iframe_onthefly($options): void
98 98
 {
99
-    $options = explode('|', $options);
100
-    $block   = b_myiframe_iframe_show($options);
99
+	$options = explode('|', $options);
100
+	$block   = b_myiframe_iframe_show($options);
101 101
 
102
-    $tpl = new \XoopsTpl();
103
-    $tpl->assign('block', $block);
104
-    $tpl->display('db:myiframe_block_show.tpl');
102
+	$tpl = new \XoopsTpl();
103
+	$tpl->assign('block', $block);
104
+	$tpl->display('db:myiframe_block_show.tpl');
105 105
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 /** @var Helper $helper */
17 17
 
18
-require_once XOOPS_ROOT_PATH . '/modules/myiframe/include/functions.php';
18
+require_once XOOPS_ROOT_PATH.'/modules/myiframe/include/functions.php';
19 19
 
20 20
 /**
21 21
  * @param $options
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         'left',
37 37
         'rigth',
38 38
     ];
39
-    $tblscrolling  = [
39
+    $tblscrolling = [
40 40
         'yes',
41 41
         'no',
42 42
         'auto',
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
         $block['longdesc']     = $frame->getVar('frame_description');
49 49
         $block['width']        = $frame->getVar('frame_width');
50 50
         $block['height']       = $frame->getVar('frame_height');
51
-        $block['align']        = $tblalign[$frame->getVar('frame_align') - 1];
51
+        $block['align']        = $tblalign[$frame->getVar('frame_align')-1];
52 52
         $block['frameborder']  = $frame->getVar('frame_frameborder');
53 53
         $block['marginwidth']  = $frame->getVar('frame_marginwidth');
54 54
         $block['marginheight'] = $frame->getVar('frame_marginheight');
55
-        $block['scrolling']    = $tblscrolling[$frame->getVar('frame_scrolling') - 1];
55
+        $block['scrolling']    = $tblscrolling[$frame->getVar('frame_scrolling')-1];
56 56
         $block['url']          = $frame->getVar('frame_url');
57 57
     }
58 58
 
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
     $critere->setSort('frame_description');
78 78
     $frarray = $iframeHandler->getObjects($critere);
79 79
 
80
-    $form = '' . _MB_MYIFRAME_IFRAME . "&nbsp;<select name='options[0]'>";
80
+    $form = ''._MB_MYIFRAME_IFRAME."&nbsp;<select name='options[0]'>";
81 81
     /** @var Myiframe $oneframe */
82 82
     foreach ($frarray as $oneframe) {
83
-        $form .= "<option value='" . $oneframe->getVar('frame_frameid') . "'";
83
+        $form .= "<option value='".$oneframe->getVar('frame_frameid')."'";
84 84
         if ($options[0] == $oneframe->getVar('frame_frameid')) {
85 85
             $form .= " selected='selected'";
86 86
         }
87
-        $form .= '>' . $oneframe->getVar('frame_description') . '</option>';
87
+        $form .= '>'.$oneframe->getVar('frame_description').'</option>';
88 88
     }
89 89
     $form .= "</select>\n";
90 90
 
Please login to merge, or discard this patch.
class/MyiframeBaseHandler.php 2 patches
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -15,215 +15,215 @@
 block discarded – undo
15 15
  */
16 16
 class MyiframeBaseHandler extends \XoopsObjectHandler
17 17
 {
18
-    /**
19
-     * @param bool $isNew
20
-     * @return \XoopsModules\Myiframe\MyiframeBase
21
-     */
22
-    public function create($isNew = true)
23
-    {
24
-        $object = new MyiframeBase();
25
-        if ($isNew) {
26
-            $object->setNew();
27
-        }
28
-
29
-        return $object;
30
-    }
31
-
32
-    /**
33
-     * @param int $id
34
-     * @return \XoopsModules\Myiframe\MyiframeBase|null
35
-     */
36
-    public function get($id)
37
-    {
38
-        $ret = null;
39
-        $sql = 'SELECT * FROM ' . $this->db->prefix('myiframe') . '  WHERE frame_frameid=' . (int)$id;
40
-        if (!$result = $this->db->query($sql)) {
41
-            return $ret;
42
-        }
43
-        $numrows = $this->db->getRowsNum($result);
44
-        if (1 == $numrows) {
45
-            $object = new MyiframeBase();
46
-            $object->assignVars($this->db->fetchArray($result));
47
-
48
-            return $object;
49
-        }
50
-
51
-        return $ret;
52
-    }
53
-
54
-    /**
55
-     * @param bool $force
56
-     * @return bool
57
-     */
58
-    public function insert(\XoopsObject $object, $force = false)
59
-    {
60
-        if (!$object instanceof MyiframeBase) {
61
-            return false;
62
-        }
63
-        if (!$object->isDirty()) {
64
-            return true;
65
-        }
66
-        if (!$object->cleanVars()) {
67
-            foreach ($object->getErrors() as $oneerror) {
68
-                \trigger_error($oneerror);
69
-            }
70
-
71
-            return false;
72
-        }
73
-        foreach ($object->cleanVars as $k => $v) {
74
-            ${$k} = $v;
75
-        }
76
-
77
-        if ($object->isNew()) {
78
-            $format = 'INSERT INTO %s (frame_created, frame_uid, frame_description, frame_width, frame_height, frame_align, frame_frameborder, frame_marginwidth, frame_marginheight, frame_scrolling, frame_hits, frame_url) VALUES (%u, %u, %s, %s, %s, %d, %d, %d, %d, %d, %u, %s)';
79
-            $sql    = \sprintf(
80
-                $format,
81
-                $this->db->prefix('myiframe'),
82
-                $frame_created,
83
-                $frame_uid,
84
-                $this->db->quoteString($frame_description),
85
-                $this->db->quoteString($frame_width),
86
-                $this->db->quoteString($frame_height),
87
-                $frame_align,
88
-                $frame_frameborder,
89
-                $frame_marginwidth,
90
-                $frame_marginheight,
91
-                $frame_scrolling,
92
-                $frame_hits,
93
-                $this->db->quoteString($frame_url)
94
-            );
95
-            $force  = true;
96
-        } else {
97
-            $format = 'UPDATE %s SET frame_description=%s, frame_width=%s, frame_height=%s, frame_align="%d", frame_frameborder="%d", frame_marginwidth="%d", frame_marginheight="%d", frame_scrolling="%d", frame_hits="%u", frame_url=%s WHERE frame_frameid=%u';
98
-            $sql    = \sprintf(
99
-                $format,
100
-                $this->db->prefix('myiframe'),
101
-                $this->db->quoteString($frame_description),
102
-                $this->db->quoteString($frame_width),
103
-                $this->db->quoteString($frame_height),
104
-                $frame_align,
105
-                $frame_frameborder,
106
-                $frame_marginwidth,
107
-                $frame_marginheight,
108
-                $frame_scrolling,
109
-                $frame_hits,
110
-                $this->db->quoteString($frame_url),
111
-                $frame_frameid
112
-            );
113
-        }
114
-        if (false !== $force) {
115
-            $result = $this->db->queryF($sql);
116
-        } else {
117
-            $result = $this->db->query($sql);
118
-        }
119
-        if (!$result) {
120
-            return false;
121
-        }
122
-        if (empty($frame_frameid)) {
123
-            $frame_frameid = $this->db->getInsertId();
124
-        }
125
-        $object->assignVar('frame_frameid', $frame_frameid);
126
-
127
-        return $frame_frameid;
128
-    }
129
-
130
-    /**
131
-     * @param bool $force
132
-     * @return bool
133
-     */
134
-    public function delete(\XoopsObject $object, $force = false)
135
-    {
136
-        if (!$object instanceof MyiframeBase) {
137
-            return false;
138
-        }
139
-        $sql = \sprintf('DELETE FROM %s WHERE frame_frameid = "%u"', $this->db->prefix('myiframe'), $object->getVar('frame_frameid'));
140
-        if (false !== $force) {
141
-            $result = $this->db->queryF($sql);
142
-        } else {
143
-            $result = $this->db->query($sql);
144
-        }
145
-        if (!$result) {
146
-            return false;
147
-        }
148
-
149
-        return true;
150
-    }
151
-
152
-    /**
153
-     * @param \Criteria|null $criteria
154
-     * @param bool           $id_as_key
155
-     * @return array
156
-     */
157
-    public function &getObjects(\Criteria $criteria = null, $id_as_key = false): array
158
-    {
159
-        $ret   = [];
160
-        $limit = $start = 0;
161
-        $sql   = 'SELECT * FROM ' . $this->db->prefix('myiframe');
162
-        if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
163
-            $sql .= ' ' . $criteria->renderWhere();
164
-            if ('' !== $criteria->getSort()) {
165
-                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
166
-            }
167
-            $limit = $criteria->getLimit();
168
-            $start = $criteria->getStart();
169
-        }
170
-        $result = $this->db->query($sql, $limit, $start);
171
-        /** @var array $myrow */
172
-        if ($result instanceof \mysqli_result) {
173
-            while (false !== ($myrow = $this->db->fetchArray($result))) {
174
-                if (!$id_as_key) {
175
-                    $ret[] = new MyiframeBase($myrow);
176
-                } else {
177
-                    $ret[$myrow['frame_frameid']] = new MyiframeBase($myrow);
178
-                }
179
-            }
180
-        }
181
-
182
-        return $ret;
183
-    }
184
-
185
-    /**
186
-     * @param \CriteriaCompo|null $criteria
187
-     * @return int
188
-     */
189
-    public function getCount(\CriteriaCompo $criteria = null): int
190
-    {
191
-        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('myiframe');
192
-        if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
193
-            $sql .= ' ' . $criteria->renderWhere();
194
-        }
195
-        $result = $this->db->query($sql);
196
-        if (!$result) {
197
-            return 0;
198
-        }
199
-        [$count] = $this->db->fetchRow($result);
200
-
201
-        return $count;
202
-    }
203
-
204
-    /**
205
-     * @param \CriteriaCompo|null $criteria
206
-     * @return bool
207
-     */
208
-    public function deleteAll(\CriteriaCompo $criteria = null): bool
209
-    {
210
-        $sql = 'DELETE FROM ' . $this->db->prefix('myiframe');
211
-        if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
212
-            $sql .= ' ' . $criteria->renderWhere();
213
-        }
214
-        if (!$result = $this->db->query($sql)) {
215
-            return false;
216
-        }
217
-
218
-        return true;
219
-    }
220
-
221
-    /**
222
-     * @param $frame_id
223
-     */
224
-    public function updatehits($frame_id): void
225
-    {
226
-        $sql = \sprintf('UPDATE %s SET frame_hits = frame_hits+1 WHERE frame_frameid="%u"', $this->db->prefix('myiframe'), (int)$frame_id);
227
-        $this->db->queryF($sql);
228
-    }
18
+	/**
19
+	 * @param bool $isNew
20
+	 * @return \XoopsModules\Myiframe\MyiframeBase
21
+	 */
22
+	public function create($isNew = true)
23
+	{
24
+		$object = new MyiframeBase();
25
+		if ($isNew) {
26
+			$object->setNew();
27
+		}
28
+
29
+		return $object;
30
+	}
31
+
32
+	/**
33
+	 * @param int $id
34
+	 * @return \XoopsModules\Myiframe\MyiframeBase|null
35
+	 */
36
+	public function get($id)
37
+	{
38
+		$ret = null;
39
+		$sql = 'SELECT * FROM ' . $this->db->prefix('myiframe') . '  WHERE frame_frameid=' . (int)$id;
40
+		if (!$result = $this->db->query($sql)) {
41
+			return $ret;
42
+		}
43
+		$numrows = $this->db->getRowsNum($result);
44
+		if (1 == $numrows) {
45
+			$object = new MyiframeBase();
46
+			$object->assignVars($this->db->fetchArray($result));
47
+
48
+			return $object;
49
+		}
50
+
51
+		return $ret;
52
+	}
53
+
54
+	/**
55
+	 * @param bool $force
56
+	 * @return bool
57
+	 */
58
+	public function insert(\XoopsObject $object, $force = false)
59
+	{
60
+		if (!$object instanceof MyiframeBase) {
61
+			return false;
62
+		}
63
+		if (!$object->isDirty()) {
64
+			return true;
65
+		}
66
+		if (!$object->cleanVars()) {
67
+			foreach ($object->getErrors() as $oneerror) {
68
+				\trigger_error($oneerror);
69
+			}
70
+
71
+			return false;
72
+		}
73
+		foreach ($object->cleanVars as $k => $v) {
74
+			${$k} = $v;
75
+		}
76
+
77
+		if ($object->isNew()) {
78
+			$format = 'INSERT INTO %s (frame_created, frame_uid, frame_description, frame_width, frame_height, frame_align, frame_frameborder, frame_marginwidth, frame_marginheight, frame_scrolling, frame_hits, frame_url) VALUES (%u, %u, %s, %s, %s, %d, %d, %d, %d, %d, %u, %s)';
79
+			$sql    = \sprintf(
80
+				$format,
81
+				$this->db->prefix('myiframe'),
82
+				$frame_created,
83
+				$frame_uid,
84
+				$this->db->quoteString($frame_description),
85
+				$this->db->quoteString($frame_width),
86
+				$this->db->quoteString($frame_height),
87
+				$frame_align,
88
+				$frame_frameborder,
89
+				$frame_marginwidth,
90
+				$frame_marginheight,
91
+				$frame_scrolling,
92
+				$frame_hits,
93
+				$this->db->quoteString($frame_url)
94
+			);
95
+			$force  = true;
96
+		} else {
97
+			$format = 'UPDATE %s SET frame_description=%s, frame_width=%s, frame_height=%s, frame_align="%d", frame_frameborder="%d", frame_marginwidth="%d", frame_marginheight="%d", frame_scrolling="%d", frame_hits="%u", frame_url=%s WHERE frame_frameid=%u';
98
+			$sql    = \sprintf(
99
+				$format,
100
+				$this->db->prefix('myiframe'),
101
+				$this->db->quoteString($frame_description),
102
+				$this->db->quoteString($frame_width),
103
+				$this->db->quoteString($frame_height),
104
+				$frame_align,
105
+				$frame_frameborder,
106
+				$frame_marginwidth,
107
+				$frame_marginheight,
108
+				$frame_scrolling,
109
+				$frame_hits,
110
+				$this->db->quoteString($frame_url),
111
+				$frame_frameid
112
+			);
113
+		}
114
+		if (false !== $force) {
115
+			$result = $this->db->queryF($sql);
116
+		} else {
117
+			$result = $this->db->query($sql);
118
+		}
119
+		if (!$result) {
120
+			return false;
121
+		}
122
+		if (empty($frame_frameid)) {
123
+			$frame_frameid = $this->db->getInsertId();
124
+		}
125
+		$object->assignVar('frame_frameid', $frame_frameid);
126
+
127
+		return $frame_frameid;
128
+	}
129
+
130
+	/**
131
+	 * @param bool $force
132
+	 * @return bool
133
+	 */
134
+	public function delete(\XoopsObject $object, $force = false)
135
+	{
136
+		if (!$object instanceof MyiframeBase) {
137
+			return false;
138
+		}
139
+		$sql = \sprintf('DELETE FROM %s WHERE frame_frameid = "%u"', $this->db->prefix('myiframe'), $object->getVar('frame_frameid'));
140
+		if (false !== $force) {
141
+			$result = $this->db->queryF($sql);
142
+		} else {
143
+			$result = $this->db->query($sql);
144
+		}
145
+		if (!$result) {
146
+			return false;
147
+		}
148
+
149
+		return true;
150
+	}
151
+
152
+	/**
153
+	 * @param \Criteria|null $criteria
154
+	 * @param bool           $id_as_key
155
+	 * @return array
156
+	 */
157
+	public function &getObjects(\Criteria $criteria = null, $id_as_key = false): array
158
+	{
159
+		$ret   = [];
160
+		$limit = $start = 0;
161
+		$sql   = 'SELECT * FROM ' . $this->db->prefix('myiframe');
162
+		if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
163
+			$sql .= ' ' . $criteria->renderWhere();
164
+			if ('' !== $criteria->getSort()) {
165
+				$sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
166
+			}
167
+			$limit = $criteria->getLimit();
168
+			$start = $criteria->getStart();
169
+		}
170
+		$result = $this->db->query($sql, $limit, $start);
171
+		/** @var array $myrow */
172
+		if ($result instanceof \mysqli_result) {
173
+			while (false !== ($myrow = $this->db->fetchArray($result))) {
174
+				if (!$id_as_key) {
175
+					$ret[] = new MyiframeBase($myrow);
176
+				} else {
177
+					$ret[$myrow['frame_frameid']] = new MyiframeBase($myrow);
178
+				}
179
+			}
180
+		}
181
+
182
+		return $ret;
183
+	}
184
+
185
+	/**
186
+	 * @param \CriteriaCompo|null $criteria
187
+	 * @return int
188
+	 */
189
+	public function getCount(\CriteriaCompo $criteria = null): int
190
+	{
191
+		$sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('myiframe');
192
+		if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
193
+			$sql .= ' ' . $criteria->renderWhere();
194
+		}
195
+		$result = $this->db->query($sql);
196
+		if (!$result) {
197
+			return 0;
198
+		}
199
+		[$count] = $this->db->fetchRow($result);
200
+
201
+		return $count;
202
+	}
203
+
204
+	/**
205
+	 * @param \CriteriaCompo|null $criteria
206
+	 * @return bool
207
+	 */
208
+	public function deleteAll(\CriteriaCompo $criteria = null): bool
209
+	{
210
+		$sql = 'DELETE FROM ' . $this->db->prefix('myiframe');
211
+		if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
212
+			$sql .= ' ' . $criteria->renderWhere();
213
+		}
214
+		if (!$result = $this->db->query($sql)) {
215
+			return false;
216
+		}
217
+
218
+		return true;
219
+	}
220
+
221
+	/**
222
+	 * @param $frame_id
223
+	 */
224
+	public function updatehits($frame_id): void
225
+	{
226
+		$sql = \sprintf('UPDATE %s SET frame_hits = frame_hits+1 WHERE frame_frameid="%u"', $this->db->prefix('myiframe'), (int)$frame_id);
227
+		$this->db->queryF($sql);
228
+	}
229 229
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * Copyright (c) Hervé Thouzard of Instant Zero (https://www.instant-zero.com)
9 9
  * ****************************************************************************
10 10
  */
11
-require_once XOOPS_ROOT_PATH . '/kernel/object.php';
11
+require_once XOOPS_ROOT_PATH.'/kernel/object.php';
12 12
 
13 13
 /**
14 14
  * Class MyiframeBaseHandler
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     public function get($id)
37 37
     {
38 38
         $ret = null;
39
-        $sql = 'SELECT * FROM ' . $this->db->prefix('myiframe') . '  WHERE frame_frameid=' . (int)$id;
39
+        $sql = 'SELECT * FROM '.$this->db->prefix('myiframe').'  WHERE frame_frameid='.(int) $id;
40 40
         if (!$result = $this->db->query($sql)) {
41 41
             return $ret;
42 42
         }
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
     {
159 159
         $ret   = [];
160 160
         $limit = $start = 0;
161
-        $sql   = 'SELECT * FROM ' . $this->db->prefix('myiframe');
161
+        $sql   = 'SELECT * FROM '.$this->db->prefix('myiframe');
162 162
         if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
163
-            $sql .= ' ' . $criteria->renderWhere();
163
+            $sql .= ' '.$criteria->renderWhere();
164 164
             if ('' !== $criteria->getSort()) {
165
-                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
165
+                $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
166 166
             }
167 167
             $limit = $criteria->getLimit();
168 168
             $start = $criteria->getStart();
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
      */
189 189
     public function getCount(\CriteriaCompo $criteria = null): int
190 190
     {
191
-        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('myiframe');
191
+        $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('myiframe');
192 192
         if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
193
-            $sql .= ' ' . $criteria->renderWhere();
193
+            $sql .= ' '.$criteria->renderWhere();
194 194
         }
195 195
         $result = $this->db->query($sql);
196 196
         if (!$result) {
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
      */
208 208
     public function deleteAll(\CriteriaCompo $criteria = null): bool
209 209
     {
210
-        $sql = 'DELETE FROM ' . $this->db->prefix('myiframe');
210
+        $sql = 'DELETE FROM '.$this->db->prefix('myiframe');
211 211
         if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
212
-            $sql .= ' ' . $criteria->renderWhere();
212
+            $sql .= ' '.$criteria->renderWhere();
213 213
         }
214 214
         if (!$result = $this->db->query($sql)) {
215 215
             return false;
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     public function updatehits($frame_id): void
225 225
     {
226
-        $sql = \sprintf('UPDATE %s SET frame_hits = frame_hits+1 WHERE frame_frameid="%u"', $this->db->prefix('myiframe'), (int)$frame_id);
226
+        $sql = \sprintf('UPDATE %s SET frame_hits = frame_hits+1 WHERE frame_frameid="%u"', $this->db->prefix('myiframe'), (int) $frame_id);
227 227
         $this->db->queryF($sql);
228 228
     }
229 229
 }
Please login to merge, or discard this patch.
class/Constants.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -27,26 +27,26 @@
 block discarded – undo
27 27
  */
28 28
 final class Constants
29 29
 {
30
-    /**#@+
30
+	/**#@+
31 31
      * Constant definition
32 32
      */
33 33
 
34
-    public const DISALLOW = 0;
35
-    /**
36
-     * no delay XOOPS redirect delay (in seconds)
37
-     */
38
-    public const REDIRECT_DELAY_NONE = 0;
39
-    /**
40
-     * short XOOPS redirect delay (in seconds)
41
-     */
42
-    public const REDIRECT_DELAY_SHORT = 1;
43
-    /**
44
-     * medium XOOPS redirect delay (in seconds)
45
-     */
46
-    public const REDIRECT_DELAY_MEDIUM = 3;
47
-    /**
48
-     * long XOOPS redirect delay (in seconds)
49
-     */
50
-    public const REDIRECT_DELAY_LONG = 7;
51
-    /**#@-*/
34
+	public const DISALLOW = 0;
35
+	/**
36
+	 * no delay XOOPS redirect delay (in seconds)
37
+	 */
38
+	public const REDIRECT_DELAY_NONE = 0;
39
+	/**
40
+	 * short XOOPS redirect delay (in seconds)
41
+	 */
42
+	public const REDIRECT_DELAY_SHORT = 1;
43
+	/**
44
+	 * medium XOOPS redirect delay (in seconds)
45
+	 */
46
+	public const REDIRECT_DELAY_MEDIUM = 3;
47
+	/**
48
+	 * long XOOPS redirect delay (in seconds)
49
+	 */
50
+	public const REDIRECT_DELAY_LONG = 7;
51
+	/**#@-*/
52 52
 }
Please login to merge, or discard this patch.
class/Common/Blocksadmin.php 2 patches
Indentation   +623 added lines, -623 removed lines patch added patch discarded remove patch
@@ -26,72 +26,72 @@  discard block
 block discarded – undo
26 26
  */
27 27
 class Blocksadmin
28 28
 {
29
-    /**
30
-     * @var \XoopsMySQLDatabase|null
31
-     */
32
-    public $db;
33
-    /**
34
-     * @var \Xmf\Module\Helper
35
-     */
36
-    public $helper;
37
-    /**
38
-     * @var string
39
-     */
40
-    public $moduleDirName;
41
-    /**
42
-     * @var string
43
-     */
44
-    public $moduleDirNameUpper;
45
-
46
-    /**
47
-     * Blocksadmin constructor.
48
-     */
49
-    public function __construct(?\XoopsDatabase $db, \Xmf\Module\Helper $helper)
50
-    {
51
-        if (null === $db) {
52
-            $db = \XoopsDatabaseFactory::getDatabaseConnection();
53
-        }
54
-        $this->db                 = $db;
55
-        $this->helper             = $helper;
56
-        $this->moduleDirName      = \basename(\dirname(__DIR__, 2));
57
-        $this->moduleDirNameUpper = \mb_strtoupper($this->moduleDirName);
58
-        \xoops_loadLanguage('admin', 'system');
59
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
60
-        \xoops_loadLanguage('admin/groups', 'system');
61
-        \xoops_loadLanguage('common', $this->moduleDirName);
62
-        //        \xoops_loadLanguage('blocksadmin', $this->moduleDirName);
63
-    }
64
-
65
-    /**
66
-     * @return void
67
-     */
68
-    public function listBlocks(): void
69
-    {
70
-        global $xoopsModule, $pathIcon16;
71
-        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
72
-        //        xoops_loadLanguage('admin', 'system');
73
-        //        xoops_loadLanguage('admin/blocksadmin', 'system');
74
-        //        xoops_loadLanguage('admin/groups', 'system');
75
-        //        xoops_loadLanguage('common', $moduleDirName);
76
-        //        xoops_loadLanguage('blocks', $moduleDirName);
77
-
78
-        /** @var \XoopsModuleHandler $moduleHandler */
79
-        $moduleHandler = \xoops_getHandler('module');
80
-        /** @var \XoopsMemberHandler $memberHandler */
81
-        $memberHandler = \xoops_getHandler('member');
82
-        /** @var \XoopsGroupPermHandler $grouppermHandler */
83
-        $grouppermHandler = \xoops_getHandler('groupperm');
84
-        $groups           = $memberHandler->getGroups();
85
-        $criteria         = new \CriteriaCompo(new \Criteria('hasmain', '1'));
86
-        $criteria->add(new \Criteria('isactive', '1'));
87
-        $moduleList     = $moduleHandler->getList($criteria);
88
-        $moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
89
-        $moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
90
-        \ksort($moduleList);
91
-        echo "<h4 style='text-align:left;'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
92
-        echo "<form action='" . $_SERVER['SCRIPT_NAME'] . "' name='blockadmin' method='post'>";
93
-        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
94
-        echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
29
+	/**
30
+	 * @var \XoopsMySQLDatabase|null
31
+	 */
32
+	public $db;
33
+	/**
34
+	 * @var \Xmf\Module\Helper
35
+	 */
36
+	public $helper;
37
+	/**
38
+	 * @var string
39
+	 */
40
+	public $moduleDirName;
41
+	/**
42
+	 * @var string
43
+	 */
44
+	public $moduleDirNameUpper;
45
+
46
+	/**
47
+	 * Blocksadmin constructor.
48
+	 */
49
+	public function __construct(?\XoopsDatabase $db, \Xmf\Module\Helper $helper)
50
+	{
51
+		if (null === $db) {
52
+			$db = \XoopsDatabaseFactory::getDatabaseConnection();
53
+		}
54
+		$this->db                 = $db;
55
+		$this->helper             = $helper;
56
+		$this->moduleDirName      = \basename(\dirname(__DIR__, 2));
57
+		$this->moduleDirNameUpper = \mb_strtoupper($this->moduleDirName);
58
+		\xoops_loadLanguage('admin', 'system');
59
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
60
+		\xoops_loadLanguage('admin/groups', 'system');
61
+		\xoops_loadLanguage('common', $this->moduleDirName);
62
+		//        \xoops_loadLanguage('blocksadmin', $this->moduleDirName);
63
+	}
64
+
65
+	/**
66
+	 * @return void
67
+	 */
68
+	public function listBlocks(): void
69
+	{
70
+		global $xoopsModule, $pathIcon16;
71
+		require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
72
+		//        xoops_loadLanguage('admin', 'system');
73
+		//        xoops_loadLanguage('admin/blocksadmin', 'system');
74
+		//        xoops_loadLanguage('admin/groups', 'system');
75
+		//        xoops_loadLanguage('common', $moduleDirName);
76
+		//        xoops_loadLanguage('blocks', $moduleDirName);
77
+
78
+		/** @var \XoopsModuleHandler $moduleHandler */
79
+		$moduleHandler = \xoops_getHandler('module');
80
+		/** @var \XoopsMemberHandler $memberHandler */
81
+		$memberHandler = \xoops_getHandler('member');
82
+		/** @var \XoopsGroupPermHandler $grouppermHandler */
83
+		$grouppermHandler = \xoops_getHandler('groupperm');
84
+		$groups           = $memberHandler->getGroups();
85
+		$criteria         = new \CriteriaCompo(new \Criteria('hasmain', '1'));
86
+		$criteria->add(new \Criteria('isactive', '1'));
87
+		$moduleList     = $moduleHandler->getList($criteria);
88
+		$moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
89
+		$moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
90
+		\ksort($moduleList);
91
+		echo "<h4 style='text-align:left;'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
92
+		echo "<form action='" . $_SERVER['SCRIPT_NAME'] . "' name='blockadmin' method='post'>";
93
+		echo $GLOBALS['xoopsSecurity']->getTokenHTML();
94
+		echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
95 95
         <tr valign='middle'><th align='center'>" . \_AM_SYSTEM_BLOCKS_TITLE . "</th><th align='center' nowrap='nowrap'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'SIDE') . '<br>' . \_LEFT . '-' . \_CENTER . '-' . \_RIGHT . "</th>
96 96
         <th align='center'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT') . "</th>
97 97
         <th align='center'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE') . "</th><th align='center'>" . \_AM_SYSTEM_BLOCKS_VISIBLEIN . "</th>
@@ -99,82 +99,82 @@  discard block
 block discarded – undo
99 99
         <th align='center'>" . \_AM_SYSTEM_BLOCKS_BCACHETIME . "</th>
100 100
         <th align='center'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'ACTION') . '</th>
101 101
         </tr>';
102
-        $blockArray = \XoopsBlock::getByModule($xoopsModule->mid());
103
-        $blockCount = \count($blockArray);
104
-        $class      = 'even';
105
-        $cachetimes = [
106
-            0       => \_NOCACHE,
107
-            30      => \sprintf(\_SECONDS, 30),
108
-            60      => \_MINUTE,
109
-            300     => \sprintf(\_MINUTES, 5),
110
-            1800    => \sprintf(\_MINUTES, 30),
111
-            3600    => \_HOUR,
112
-            18000   => \sprintf(\_HOURS, 5),
113
-            86400   => \_DAY,
114
-            259200  => \sprintf(\_DAYS, 3),
115
-            604800  => \_WEEK,
116
-            2592000 => \_MONTH,
117
-        ];
118
-        foreach ($blockArray as $i) {
119
-            $groupsPermissions = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
120
-            $sql               = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
121
-            $result            = $this->db->query($sql);
122
-            $modules           = [];
123
-            if (!$result instanceof \mysqli_result) {
124
-                \trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR);
125
-            }
126
-            while (false !== ($row = $this->db->fetchArray($result))) {
127
-                $modules[] = (int)$row['module_id'];
128
-            }
129
-
130
-            $cachetimeOptions = '';
131
-            foreach ($cachetimes as $cachetime => $cachetimeName) {
132
-                if ($i->getVar('bcachetime') == $cachetime) {
133
-                    $cachetimeOptions .= "<option value='$cachetime' selected='selected'>$cachetimeName</option>\n";
134
-                } else {
135
-                    $cachetimeOptions .= "<option value='$cachetime'>$cachetimeName</option>\n";
136
-                }
137
-            }
138
-
139
-            $ssel7 = '';
140
-            $ssel6 = $ssel7;
141
-            $ssel5 = $ssel6;
142
-            $ssel4 = $ssel5;
143
-            $ssel3 = $ssel4;
144
-            $ssel2 = $ssel3;
145
-            $ssel1 = $ssel2;
146
-            $ssel0 = $ssel1;
147
-            $sel1  = $ssel0;
148
-            $sel0  = $sel1;
149
-            if (1 === $i->getVar('visible')) {
150
-                $sel1 = ' checked';
151
-            } else {
152
-                $sel0 = ' checked';
153
-            }
154
-            if (\XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) {
155
-                $ssel0 = ' checked';
156
-            } elseif (\XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) {
157
-                $ssel1 = ' checked';
158
-            } elseif (\XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) {
159
-                $ssel2 = ' checked';
160
-            } elseif (\XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) {
161
-                $ssel4 = ' checked';
162
-            } elseif (\XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) {
163
-                $ssel3 = ' checked';
164
-            } elseif (\XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) {
165
-                $ssel5 = ' checked';
166
-            } elseif (\XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) {
167
-                $ssel6 = ' checked';
168
-            } elseif (\XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) {
169
-                $ssel7 = ' checked';
170
-            }
171
-            if ('' === $i->getVar('title')) {
172
-                $title = '&nbsp;';
173
-            } else {
174
-                $title = $i->getVar('title');
175
-            }
176
-            $name = $i->getVar('name');
177
-            echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title[" . $i->getVar('bid') . "]' value='" . $title . "'></td>
102
+		$blockArray = \XoopsBlock::getByModule($xoopsModule->mid());
103
+		$blockCount = \count($blockArray);
104
+		$class      = 'even';
105
+		$cachetimes = [
106
+			0       => \_NOCACHE,
107
+			30      => \sprintf(\_SECONDS, 30),
108
+			60      => \_MINUTE,
109
+			300     => \sprintf(\_MINUTES, 5),
110
+			1800    => \sprintf(\_MINUTES, 30),
111
+			3600    => \_HOUR,
112
+			18000   => \sprintf(\_HOURS, 5),
113
+			86400   => \_DAY,
114
+			259200  => \sprintf(\_DAYS, 3),
115
+			604800  => \_WEEK,
116
+			2592000 => \_MONTH,
117
+		];
118
+		foreach ($blockArray as $i) {
119
+			$groupsPermissions = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
120
+			$sql               = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
121
+			$result            = $this->db->query($sql);
122
+			$modules           = [];
123
+			if (!$result instanceof \mysqli_result) {
124
+				\trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR);
125
+			}
126
+			while (false !== ($row = $this->db->fetchArray($result))) {
127
+				$modules[] = (int)$row['module_id'];
128
+			}
129
+
130
+			$cachetimeOptions = '';
131
+			foreach ($cachetimes as $cachetime => $cachetimeName) {
132
+				if ($i->getVar('bcachetime') == $cachetime) {
133
+					$cachetimeOptions .= "<option value='$cachetime' selected='selected'>$cachetimeName</option>\n";
134
+				} else {
135
+					$cachetimeOptions .= "<option value='$cachetime'>$cachetimeName</option>\n";
136
+				}
137
+			}
138
+
139
+			$ssel7 = '';
140
+			$ssel6 = $ssel7;
141
+			$ssel5 = $ssel6;
142
+			$ssel4 = $ssel5;
143
+			$ssel3 = $ssel4;
144
+			$ssel2 = $ssel3;
145
+			$ssel1 = $ssel2;
146
+			$ssel0 = $ssel1;
147
+			$sel1  = $ssel0;
148
+			$sel0  = $sel1;
149
+			if (1 === $i->getVar('visible')) {
150
+				$sel1 = ' checked';
151
+			} else {
152
+				$sel0 = ' checked';
153
+			}
154
+			if (\XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) {
155
+				$ssel0 = ' checked';
156
+			} elseif (\XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) {
157
+				$ssel1 = ' checked';
158
+			} elseif (\XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) {
159
+				$ssel2 = ' checked';
160
+			} elseif (\XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) {
161
+				$ssel4 = ' checked';
162
+			} elseif (\XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) {
163
+				$ssel3 = ' checked';
164
+			} elseif (\XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) {
165
+				$ssel5 = ' checked';
166
+			} elseif (\XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) {
167
+				$ssel6 = ' checked';
168
+			} elseif (\XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) {
169
+				$ssel7 = ' checked';
170
+			}
171
+			if ('' === $i->getVar('title')) {
172
+				$title = '&nbsp;';
173
+			} else {
174
+				$title = $i->getVar('title');
175
+			}
176
+			$name = $i->getVar('name');
177
+			echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title[" . $i->getVar('bid') . "]' value='" . $title . "'></td>
178 178
             <td class='$class' align='center' nowrap='nowrap'><div align='center' >
179 179
                     <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_LEFT . "'$ssel2>
180 180
                     <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_CENTER . "'$ssel3>
@@ -193,39 +193,39 @@  discard block
 block discarded – undo
193 193
                 <td class='$class' align='center'><input type='text' name='weight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "' size='5' maxlength='5'></td>
194 194
                 <td class='$class' align='center' nowrap><input type='radio' name='visible[" . $i->getVar('bid') . "]' value='1'$sel1>" . \_YES . "&nbsp;<input type='radio' name='visible[" . $i->getVar('bid') . "]' value='0'$sel0>" . \_NO . '</td>';
195 195
 
196
-            echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>";
197
-            foreach ($moduleList as $k => $v) {
198
-                echo "<option value='$k'" . (\in_array($k, $modules) ? " selected='selected'" : '') . ">$v</option>";
199
-            }
200
-            echo '</select></td>';
196
+			echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>";
197
+			foreach ($moduleList as $k => $v) {
198
+				echo "<option value='$k'" . (\in_array($k, $modules) ? " selected='selected'" : '') . ">$v</option>";
199
+			}
200
+			echo '</select></td>';
201 201
 
202
-            echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>";
203
-            foreach ($groups as $grp) {
204
-                echo "<option value='" . $grp->getVar('groupid') . "' " . (\in_array($grp->getVar('groupid'), $groupsPermissions) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>';
205
-            }
206
-            echo '</select></td>';
202
+			echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>";
203
+			foreach ($groups as $grp) {
204
+				echo "<option value='" . $grp->getVar('groupid') . "' " . (\in_array($grp->getVar('groupid'), $groupsPermissions) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>';
205
+			}
206
+			echo '</select></td>';
207 207
 
208
-            // Cache lifetime
209
-            echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetimeOptions . '</select>
208
+			// Cache lifetime
209
+			echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetimeOptions . '</select>
210 210
                                     </td>';
211 211
 
212
-            // Actions
212
+			// Actions
213 213
 
214
-            echo "<td class='$class' align='center'>
214
+			echo "<td class='$class' align='center'>
215 215
                 <a href='blocksadmin.php?op=edit&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . \_EDIT . "' title='" . \_EDIT . "'></a> 
216 216
                 <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . \_CLONE . "' title='" . \_CLONE . "'></a>";
217
-            //            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
218
-            //                echo "&nbsp;<a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&amp;op=delete&amp;bid=' . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>
219
-            //                     </a>";
220
-            //            }
221
-
222
-            //            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
223
-            if (!\in_array($i->getVar('block_type'), ['M', 'S'])) {
224
-                echo "&nbsp;
217
+			//            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
218
+			//                echo "&nbsp;<a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&amp;op=delete&amp;bid=' . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>
219
+			//                     </a>";
220
+			//            }
221
+
222
+			//            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
223
+			if (!\in_array($i->getVar('block_type'), ['M', 'S'])) {
224
+				echo "&nbsp;
225 225
                 <a href='blocksadmin.php?op=delete&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . \_DELETE . "' title='" . \_DELETE . "'>
226 226
                      </a>";
227
-            }
228
-            echo "
227
+			}
228
+			echo "
229 229
             <input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "'>
230 230
             <input type='hidden' name='oldside[" . $i->getVar('bid') . "]' value='" . $i->getVar('side') . "'>
231 231
             <input type='hidden' name='oldweight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "'>
@@ -235,461 +235,461 @@  discard block
 block discarded – undo
235 235
             <input type='hidden' name='bid[" . $i->getVar('bid') . "]' value='" . $i->getVar('bid') . "'>
236 236
             </td></tr>
237 237
             ";
238
-            $class = ('even' === $class) ? 'odd' : 'even';
239
-        }
240
-        echo "<tr><td class='foot' align='center' colspan='8'> <input type='hidden' name='op' value='order'>" . $GLOBALS['xoopsSecurity']->getTokenHTML() . "<input type='submit' name='submit' value='" . \_SUBMIT . "'></td></tr></table></form><br><br>";
241
-    }
242
-
243
-    /**
244
-     * @param int $bid
245
-     * @return void
246
-     */
247
-    public function deleteBlock(int $bid): void
248
-    {
249
-        //        \xoops_cp_header();
250
-
251
-        \xoops_loadLanguage('admin', 'system');
252
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
253
-        \xoops_loadLanguage('admin/groups', 'system');
254
-
255
-        $myblock = new \XoopsBlock($bid);
256
-
257
-        $sql = \sprintf('DELETE FROM %s WHERE bid = %u', $this->db->prefix('newblocks'), $bid);
258
-        $this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error());
259
-        $sql = \sprintf('DELETE FROM %s WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid);
260
-        $this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error());
261
-
262
-        $this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
263
-    }
264
-
265
-    /**
266
-     * @param int $bid
267
-     * @return void
268
-     */
269
-    public function cloneBlock(int $bid): void
270
-    {
271
-        //require __DIR__ . '/admin_header.php';
272
-        //        \xoops_cp_header();
273
-
274
-        \xoops_loadLanguage('admin', 'system');
275
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
276
-        \xoops_loadLanguage('admin/groups', 'system');
277
-
278
-        $myblock = new \XoopsBlock($bid);
279
-        $sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
280
-        $result  = $this->db->query($sql);
281
-        $modules = [];
282
-        if ($result instanceof \mysqli_result) {
283
-            while (false !== ($row = $this->db->fetchArray($result))) {
284
-                $modules[] = (int)$row['module_id'];
285
-            }
286
-        }
287
-        $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']);
288
-        $block    = [
289
-            'title'      => $myblock->getVar('title') . ' Clone',
290
-            'form_title' => \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'),
291
-            'name'       => $myblock->getVar('name'),
292
-            'side'       => $myblock->getVar('side'),
293
-            'weight'     => $myblock->getVar('weight'),
294
-            'visible'    => $myblock->getVar('visible'),
295
-            'content'    => $myblock->getVar('content', 'N'),
296
-            'modules'    => $modules,
297
-            'is_custom'  => $isCustom,
298
-            'ctype'      => $myblock->getVar('c_type'),
299
-            'bcachetime' => $myblock->getVar('bcachetime'),
300
-            'op'         => 'clone_ok',
301
-            'bid'        => $myblock->getVar('bid'),
302
-            'edit_form'  => $myblock->getOptions(),
303
-            'template'   => $myblock->getVar('template'),
304
-            'options'    => $myblock->getVar('options'),
305
-        ];
306
-        echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . \_AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>';
307
-        //        $form = new Blockform();
308
-        //        $form->render();
309
-
310
-        echo $this->render($block);
311
-        //        xoops_cp_footer();
312
-        //        require_once __DIR__ . '/admin_footer.php';
313
-        //        exit();
314
-    }
315
-
316
-    /**
317
-     * @param int        $bid
318
-     * @param string     $bside
319
-     * @param string     $bweight
320
-     * @param string     $bvisible
321
-     * @param string     $bcachetime
322
-     * @param array|null $bmodule
323
-     * @param array|null $options
324
-     * @param array|null $groups
325
-     * @return void
326
-     */
327
-    public function isBlockCloned(int $bid, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
328
-    {
329
-        \xoops_loadLanguage('admin', 'system');
330
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
331
-        \xoops_loadLanguage('admin/groups', 'system');
332
-
333
-        $block = new \XoopsBlock($bid);
334
-        $clone = $block->xoopsClone();
335
-        if (empty($bmodule)) {
336
-            //            \xoops_cp_header();
337
-            \xoops_error(\sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
338
-            \xoops_cp_footer();
339
-            exit();
340
-        }
341
-        $clone->setVar('side', $bside);
342
-        $clone->setVar('weight', $bweight);
343
-        $clone->setVar('visible', $bvisible);
344
-        //$clone->setVar('content', $_POST['bcontent']);
345
-        $clone->setVar('title', Request::getString('btitle', '', 'POST'));
346
-        $clone->setVar('bcachetime', $bcachetime);
347
-        if (\is_array($options) && (\count($options) > 0)) {
348
-            $options = \implode('|', $options);
349
-            $clone->setVar('options', $options);
350
-        }
351
-        $clone->setVar('bid', 0);
352
-        if (\in_array($block->getVar('block_type'), ['C', 'E'])) {
353
-            $clone->setVar('block_type', 'E');
354
-        } else {
355
-            $clone->setVar('block_type', 'D');
356
-        }
357
-        //        $newid = $clone->store(); //see https://github.com/XOOPS/XoopsCore25/issues/1105
358
-        if ($clone->store()) {
359
-            $newid = $clone->id();  //get the id of the cloned block
360
-        }
361
-        if (!$newid) {
362
-            //            \xoops_cp_header();
363
-            $clone->getHtmlErrors();
364
-            \xoops_cp_footer();
365
-            exit();
366
-        }
367
-        if ('' !== $clone->getVar('template')) {
368
-            /** @var \XoopsTplfileHandler $tplfileHandler */
369
-            $tplfileHandler = \xoops_getHandler('tplfile');
370
-            $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', (string)$bid);
371
-            if (\count($btemplate) > 0) {
372
-                $tplclone = $btemplate[0]->xoopsClone();
373
-                $tplclone->setVar('tpl_id', 0);
374
-                $tplclone->setVar('tpl_refid', $newid);
375
-                $tplfileHandler->insert($tplclone);
376
-            }
377
-        }
378
-
379
-        foreach ($bmodule as $bmid) {
380
-            $sql = 'INSERT INTO ' . $this->db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
381
-            $this->db->query($sql);
382
-        }
383
-        //$groups = &$GLOBALS['xoopsUser']->getGroups();
384
-        foreach ($groups as $iValue) {
385
-            $sql = 'INSERT INTO ' . $this->db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $iValue . ', ' . $newid . ", 1, 'block_read')";
386
-            $this->db->query($sql);
387
-        }
388
-        $this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
389
-    }
390
-
391
-    /**
392
-     * @param string     $bid
393
-     * @param string     $title
394
-     * @param string     $weight
395
-     * @param string     $visible
396
-     * @param string     $side
397
-     * @param string     $bcachetime
398
-     * @param array|null $bmodule
399
-     * @return void
400
-     */
401
-    public function setOrder(string $bid, string $title, string $weight, string $visible, string $side, string $bcachetime, ?array $bmodule = null): void
402
-    {
403
-        $myblock = new \XoopsBlock($bid);
404
-        $myblock->setVar('title', $title);
405
-        $myblock->setVar('weight', $weight);
406
-        $myblock->setVar('visible', $visible);
407
-        $myblock->setVar('side', $side);
408
-        $myblock->setVar('bcachetime', $bcachetime);
409
-        $myblock->store();
410
-        //        /** @var \XoopsBlockHandler $blockHandler */
411
-        //        $blockHandler = \xoops_getHandler('block');
412
-        //        return $blockHandler->insert($myblock);
413
-    }
414
-
415
-    /**
416
-     * @param int $bid
417
-     * @return void
418
-     */
419
-    public function editBlock(int $bid): void
420
-    {
421
-        //        require_once \dirname(__DIR__,2) . '/admin/admin_header.php';
422
-        //        \xoops_cp_header();
423
-        \xoops_loadLanguage('admin', 'system');
424
-        \xoops_loadLanguage('admin/blocksadmin', 'system');
425
-        \xoops_loadLanguage('admin/groups', 'system');
426
-        //        mpu_adm_menu();
427
-        $myblock = new \XoopsBlock($bid);
428
-        $sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
429
-        $result  = $this->db->query($sql);
430
-        $modules = [];
431
-        if ($result instanceof \mysqli_result) {
432
-            while (false !== ($row = $this->db->fetchArray($result))) {
433
-                $modules[] = (int)$row['module_id'];
434
-            }
435
-        }
436
-        $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']);
437
-        $block    = [
438
-            'title'      => $myblock->getVar('title'),
439
-            'form_title' => \_AM_SYSTEM_BLOCKS_EDITBLOCK,
440
-            //        'name'       => $myblock->getVar('name'),
441
-            'side'       => $myblock->getVar('side'),
442
-            'weight'     => $myblock->getVar('weight'),
443
-            'visible'    => $myblock->getVar('visible'),
444
-            'content'    => $myblock->getVar('content', 'N'),
445
-            'modules'    => $modules,
446
-            'is_custom'  => $isCustom,
447
-            'ctype'      => $myblock->getVar('c_type'),
448
-            'bcachetime' => $myblock->getVar('bcachetime'),
449
-            'op'         => 'edit_ok',
450
-            'bid'        => $myblock->getVar('bid'),
451
-            'edit_form'  => $myblock->getOptions(),
452
-            'template'   => $myblock->getVar('template'),
453
-            'options'    => $myblock->getVar('options'),
454
-        ];
455
-        echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . \_AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>';
456
-
457
-        echo $this->render($block);
458
-    }
459
-
460
-    /**
461
-     * @param int        $bid
462
-     * @param string     $btitle
463
-     * @param string     $bside
464
-     * @param string     $bweight
465
-     * @param string     $bvisible
466
-     * @param string     $bcachetime
467
-     * @param array|null $bmodule
468
-     * @param array|null $options
469
-     * @param array|null $groups
470
-     * @return void
471
-     */
472
-    public function updateBlock(int $bid, string $btitle, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
473
-    {
474
-        $myblock = new \XoopsBlock($bid);
475
-        $myblock->setVar('title', $btitle);
476
-        $myblock->setVar('weight', $bweight);
477
-        $myblock->setVar('visible', $bvisible);
478
-        $myblock->setVar('side', $bside);
479
-        $myblock->setVar('bcachetime', $bcachetime);
480
-        //update block options
481
-        if (isset($options)) {
482
-            $optionsCount = \count($options);
483
-            if ($optionsCount > 0) {
484
-                //Convert array values to comma-separated
485
-                foreach ($options as $i => $iValue) {
486
-                    if (\is_array($iValue)) {
487
-                        $options[$i] = \implode(',', $iValue);
488
-                    }
489
-                }
490
-                $options = \implode('|', $options);
491
-                $myblock->setVar('options', $options);
492
-            }
493
-        }
494
-        $myblock->store();
495
-        //        /** @var \XoopsBlockHandler $blockHandler */
496
-        //        $blockHandler = \xoops_getHandler('block');
497
-        //        $blockHandler->insert($myblock);
498
-
499
-        if (!empty($bmodule) && \count($bmodule) > 0) {
500
-            $sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid);
501
-            $this->db->query($sql);
502
-            if (\in_array(0, $bmodule)) {
503
-                $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, 0);
504
-                $this->db->query($sql);
505
-            } else {
506
-                foreach ($bmodule as $bmid) {
507
-                    $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, (int)$bmid);
508
-                    $this->db->query($sql);
509
-                }
510
-            }
511
-        }
512
-        $sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid);
513
-        $this->db->query($sql);
514
-        if (!empty($groups)) {
515
-            foreach ($groups as $grp) {
516
-                $sql = \sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $this->db->prefix('group_permission'), $grp, $bid);
517
-                $this->db->query($sql);
518
-            }
519
-        }
520
-        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
521
-    }
522
-
523
-    /**
524
-     * @param array $bid
525
-     * @param array $oldtitle
526
-     * @param array $oldside
527
-     * @param array $oldweight
528
-     * @param array $oldvisible
529
-     * @param array $oldgroups
530
-     * @param array $oldbcachetime
531
-     * @param array $oldbmodule
532
-     * @param array $title
533
-     * @param array $weight
534
-     * @param array $visible
535
-     * @param array $side
536
-     * @param array $bcachetime
537
-     * @param array $groups
538
-     * @param array $bmodule
539
-     * @return void
540
-     */
541
-    public function orderBlock(
542
-        array $bid, array $oldtitle, array $oldside, array $oldweight, array $oldvisible, array $oldgroups, array $oldbcachetime, array $oldbmodule, array $title, array $weight, array $visible, array $side, array $bcachetime, array $groups, array $bmodule
543
-    ): void {
544
-        if (!$GLOBALS['xoopsSecurity']->check()) {
545
-            \redirect_header($_SERVER['SCRIPT_NAME'], 3, \implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
546
-        }
547
-        foreach (\array_keys($bid) as $i) {
548
-            if ($oldtitle[$i] !== $title[$i]
549
-                || $oldweight[$i] !== $weight[$i]
550
-                || $oldvisible[$i] !== $visible[$i]
551
-                || $oldside[$i] !== $side[$i]
552
-                || $oldbcachetime[$i] !== $bcachetime[$i]
553
-                || $oldbmodule[$i] !== $bmodule[$i]) {
554
-                $this->setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]);
555
-            }
556
-            if (!empty($bmodule[$i]) && \count($bmodule[$i]) > 0) {
557
-                $sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid[$i]);
558
-                $this->db->query($sql);
559
-                if (\in_array(0, $bmodule[$i], true)) {
560
-                    $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], 0);
561
-                    $this->db->query($sql);
562
-                } else {
563
-                    foreach ($bmodule[$i] as $bmid) {
564
-                        $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int)$bmid);
565
-                        $this->db->query($sql);
566
-                    }
567
-                }
568
-            }
569
-            $sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid[$i]);
570
-            $this->db->query($sql);
571
-            if (!empty($groups[$i])) {
572
-                foreach ($groups[$i] as $grp) {
573
-                    $sql = \sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $this->db->prefix('group_permission'), $grp, $bid[$i]);
574
-                    $this->db->query($sql);
575
-                }
576
-            }
577
-        }
578
-
579
-        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
580
-    }
581
-
582
-    /**
583
-     * @param array|null $block
584
-     * @return void
585
-     */
586
-    public function render(?array $block = null): void
587
-    {
588
-        \xoops_load('XoopsFormLoader');
589
-        \xoops_loadLanguage('common', $this->moduleDirNameUpper);
590
-
591
-        $form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true);
592
-        if (isset($block['name'])) {
593
-            $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_NAME, $block['name']));
594
-        }
595
-        $sideSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_TYPE, 'bside', $block['side']);
596
-        $sideSelect->addOptionArray([
597
-                                        0 => \_AM_SYSTEM_BLOCKS_SBLEFT,
598
-                                        1 => \_AM_SYSTEM_BLOCKS_SBRIGHT,
599
-                                        3 => \_AM_SYSTEM_BLOCKS_CBLEFT,
600
-                                        4 => \_AM_SYSTEM_BLOCKS_CBRIGHT,
601
-                                        5 => \_AM_SYSTEM_BLOCKS_CBCENTER,
602
-                                        7 => \_AM_SYSTEM_BLOCKS_CBBOTTOMLEFT,
603
-                                        8 => \_AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT,
604
-                                        9 => \_AM_SYSTEM_BLOCKS_CBBOTTOM,
605
-                                    ]);
606
-        $form->addElement($sideSelect);
607
-        $form->addElement(new \XoopsFormText(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight']));
608
-        $form->addElement(new \XoopsFormRadioYN(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible']));
609
-        $modSelect = new \XoopsFormSelect(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true);
610
-        /** @var \XoopsModuleHandler $moduleHandler */
611
-        $moduleHandler = \xoops_getHandler('module');
612
-        $criteria      = new \CriteriaCompo(new \Criteria('hasmain', '1'));
613
-        $criteria->add(new \Criteria('isactive', '1'));
614
-        $moduleList     = $moduleHandler->getList($criteria);
615
-        $moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
616
-        $moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
617
-        \ksort($moduleList);
618
-        $modSelect->addOptionArray($moduleList);
619
-        $form->addElement($modSelect);
620
-        $form->addElement(new \XoopsFormText(\_AM_SYSTEM_BLOCKS_TITLE, 'btitle', 50, 255, $block['title']), false);
621
-        if ($block['is_custom']) {
622
-            $textarea = new \XoopsFormDhtmlTextArea(\_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70);
623
-            $textarea->setDescription('<span style="font-size:x-small;font-weight:bold;">' . \_AM_SYSTEM_BLOCKS_USEFULTAGS . '</span><br><span style="font-size:x-small;font-weight:normal;">' . \sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . '</span>');
624
-            $form->addElement($textarea, true);
625
-            $ctypeSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']);
626
-            $ctypeSelect->addOptionArray([
627
-                                             'H' => \_AM_SYSTEM_BLOCKS_HTML,
628
-                                             'P' => \_AM_SYSTEM_BLOCKS_PHP,
629
-                                             'S' => \_AM_SYSTEM_BLOCKS_AFWSMILE,
630
-                                             'T' => \_AM_SYSTEM_BLOCKS_AFNOSMILE,
631
-                                         ]);
632
-            $form->addElement($ctypeSelect);
633
-        } else {
634
-            if ('' !== $block['template']) {
635
-                /** @var \XoopsTplfileHandler $tplfileHandler */
636
-                $tplfileHandler = \xoops_getHandler('tplfile');
637
-                $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
638
-                if (\count($btemplate) > 0) {
639
-                    $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate[0]->getVar('tpl_id') . '">' . \_AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
640
-                } else {
641
-                    $btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']);
642
-                    if (\count($btemplate2) > 0) {
643
-                        $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate2[0]->getVar('tpl_id') . '" target="_blank">' . \_AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
644
-                    }
645
-                }
646
-            }
647
-            if (false !== $block['edit_form']) {
648
-                $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_OPTIONS, $block['edit_form']));
649
-            }
650
-        }
651
-        $cache_select = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']);
652
-        $cache_select->addOptionArray([
653
-                                          0       => \_NOCACHE,
654
-                                          30      => \sprintf(\_SECONDS, 30),
655
-                                          60      => \_MINUTE,
656
-                                          300     => \sprintf(\_MINUTES, 5),
657
-                                          1800    => \sprintf(\_MINUTES, 30),
658
-                                          3600    => \_HOUR,
659
-                                          18000   => \sprintf(\_HOURS, 5),
660
-                                          86400   => \_DAY,
661
-                                          259200  => \sprintf(\_DAYS, 3),
662
-                                          604800  => \_WEEK,
663
-                                          2592000 => \_MONTH,
664
-                                      ]);
665
-        $form->addElement($cache_select);
666
-
667
-        /** @var \XoopsGroupPermHandler $grouppermHandler */
668
-        $grouppermHandler = \xoops_getHandler('groupperm');
669
-        $groups           = $grouppermHandler->getGroupIds('block_read', $block['bid']);
670
-
671
-        $form->addElement(new \XoopsFormSelectGroup(\_AM_SYSTEM_BLOCKS_GROUP, 'groups', true, $groups, 5, true));
672
-
673
-        if (isset($block['bid'])) {
674
-            $form->addElement(new \XoopsFormHidden('bid', $block['bid']));
675
-        }
676
-        $form->addElement(new \XoopsFormHidden('op', $block['op']));
677
-        $form->addElement(new \XoopsFormHidden('fct', 'blocksadmin'));
678
-        $buttonTray = new \XoopsFormElementTray('', '&nbsp;');
679
-        if ($block['is_custom']) {
680
-            $buttonTray->addElement(new \XoopsFormButton('', 'previewblock', \_PREVIEW, 'submit'));
681
-        }
682
-
683
-        //Submit buttons
684
-        $buttonTray   = new \XoopsFormElementTray('', '');
685
-        $submitButton = new \XoopsFormButton('', 'submitblock', \_SUBMIT, 'submit');
686
-        $buttonTray->addElement($submitButton);
687
-
688
-        $cancelButton = new \XoopsFormButton('', '', \_CANCEL, 'button');
689
-        $cancelButton->setExtra('onclick="history.go(-1)"');
690
-        $buttonTray->addElement($cancelButton);
691
-
692
-        $form->addElement($buttonTray);
693
-        $form->display();
694
-    }
238
+			$class = ('even' === $class) ? 'odd' : 'even';
239
+		}
240
+		echo "<tr><td class='foot' align='center' colspan='8'> <input type='hidden' name='op' value='order'>" . $GLOBALS['xoopsSecurity']->getTokenHTML() . "<input type='submit' name='submit' value='" . \_SUBMIT . "'></td></tr></table></form><br><br>";
241
+	}
242
+
243
+	/**
244
+	 * @param int $bid
245
+	 * @return void
246
+	 */
247
+	public function deleteBlock(int $bid): void
248
+	{
249
+		//        \xoops_cp_header();
250
+
251
+		\xoops_loadLanguage('admin', 'system');
252
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
253
+		\xoops_loadLanguage('admin/groups', 'system');
254
+
255
+		$myblock = new \XoopsBlock($bid);
256
+
257
+		$sql = \sprintf('DELETE FROM %s WHERE bid = %u', $this->db->prefix('newblocks'), $bid);
258
+		$this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error());
259
+		$sql = \sprintf('DELETE FROM %s WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid);
260
+		$this->db->queryF($sql) or \trigger_error($GLOBALS['xoopsDB']->error());
261
+
262
+		$this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
263
+	}
264
+
265
+	/**
266
+	 * @param int $bid
267
+	 * @return void
268
+	 */
269
+	public function cloneBlock(int $bid): void
270
+	{
271
+		//require __DIR__ . '/admin_header.php';
272
+		//        \xoops_cp_header();
273
+
274
+		\xoops_loadLanguage('admin', 'system');
275
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
276
+		\xoops_loadLanguage('admin/groups', 'system');
277
+
278
+		$myblock = new \XoopsBlock($bid);
279
+		$sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
280
+		$result  = $this->db->query($sql);
281
+		$modules = [];
282
+		if ($result instanceof \mysqli_result) {
283
+			while (false !== ($row = $this->db->fetchArray($result))) {
284
+				$modules[] = (int)$row['module_id'];
285
+			}
286
+		}
287
+		$isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']);
288
+		$block    = [
289
+			'title'      => $myblock->getVar('title') . ' Clone',
290
+			'form_title' => \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'),
291
+			'name'       => $myblock->getVar('name'),
292
+			'side'       => $myblock->getVar('side'),
293
+			'weight'     => $myblock->getVar('weight'),
294
+			'visible'    => $myblock->getVar('visible'),
295
+			'content'    => $myblock->getVar('content', 'N'),
296
+			'modules'    => $modules,
297
+			'is_custom'  => $isCustom,
298
+			'ctype'      => $myblock->getVar('c_type'),
299
+			'bcachetime' => $myblock->getVar('bcachetime'),
300
+			'op'         => 'clone_ok',
301
+			'bid'        => $myblock->getVar('bid'),
302
+			'edit_form'  => $myblock->getOptions(),
303
+			'template'   => $myblock->getVar('template'),
304
+			'options'    => $myblock->getVar('options'),
305
+		];
306
+		echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . \_AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>';
307
+		//        $form = new Blockform();
308
+		//        $form->render();
309
+
310
+		echo $this->render($block);
311
+		//        xoops_cp_footer();
312
+		//        require_once __DIR__ . '/admin_footer.php';
313
+		//        exit();
314
+	}
315
+
316
+	/**
317
+	 * @param int        $bid
318
+	 * @param string     $bside
319
+	 * @param string     $bweight
320
+	 * @param string     $bvisible
321
+	 * @param string     $bcachetime
322
+	 * @param array|null $bmodule
323
+	 * @param array|null $options
324
+	 * @param array|null $groups
325
+	 * @return void
326
+	 */
327
+	public function isBlockCloned(int $bid, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
328
+	{
329
+		\xoops_loadLanguage('admin', 'system');
330
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
331
+		\xoops_loadLanguage('admin/groups', 'system');
332
+
333
+		$block = new \XoopsBlock($bid);
334
+		$clone = $block->xoopsClone();
335
+		if (empty($bmodule)) {
336
+			//            \xoops_cp_header();
337
+			\xoops_error(\sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
338
+			\xoops_cp_footer();
339
+			exit();
340
+		}
341
+		$clone->setVar('side', $bside);
342
+		$clone->setVar('weight', $bweight);
343
+		$clone->setVar('visible', $bvisible);
344
+		//$clone->setVar('content', $_POST['bcontent']);
345
+		$clone->setVar('title', Request::getString('btitle', '', 'POST'));
346
+		$clone->setVar('bcachetime', $bcachetime);
347
+		if (\is_array($options) && (\count($options) > 0)) {
348
+			$options = \implode('|', $options);
349
+			$clone->setVar('options', $options);
350
+		}
351
+		$clone->setVar('bid', 0);
352
+		if (\in_array($block->getVar('block_type'), ['C', 'E'])) {
353
+			$clone->setVar('block_type', 'E');
354
+		} else {
355
+			$clone->setVar('block_type', 'D');
356
+		}
357
+		//        $newid = $clone->store(); //see https://github.com/XOOPS/XoopsCore25/issues/1105
358
+		if ($clone->store()) {
359
+			$newid = $clone->id();  //get the id of the cloned block
360
+		}
361
+		if (!$newid) {
362
+			//            \xoops_cp_header();
363
+			$clone->getHtmlErrors();
364
+			\xoops_cp_footer();
365
+			exit();
366
+		}
367
+		if ('' !== $clone->getVar('template')) {
368
+			/** @var \XoopsTplfileHandler $tplfileHandler */
369
+			$tplfileHandler = \xoops_getHandler('tplfile');
370
+			$btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', (string)$bid);
371
+			if (\count($btemplate) > 0) {
372
+				$tplclone = $btemplate[0]->xoopsClone();
373
+				$tplclone->setVar('tpl_id', 0);
374
+				$tplclone->setVar('tpl_refid', $newid);
375
+				$tplfileHandler->insert($tplclone);
376
+			}
377
+		}
378
+
379
+		foreach ($bmodule as $bmid) {
380
+			$sql = 'INSERT INTO ' . $this->db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
381
+			$this->db->query($sql);
382
+		}
383
+		//$groups = &$GLOBALS['xoopsUser']->getGroups();
384
+		foreach ($groups as $iValue) {
385
+			$sql = 'INSERT INTO ' . $this->db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $iValue . ', ' . $newid . ", 1, 'block_read')";
386
+			$this->db->query($sql);
387
+		}
388
+		$this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
389
+	}
390
+
391
+	/**
392
+	 * @param string     $bid
393
+	 * @param string     $title
394
+	 * @param string     $weight
395
+	 * @param string     $visible
396
+	 * @param string     $side
397
+	 * @param string     $bcachetime
398
+	 * @param array|null $bmodule
399
+	 * @return void
400
+	 */
401
+	public function setOrder(string $bid, string $title, string $weight, string $visible, string $side, string $bcachetime, ?array $bmodule = null): void
402
+	{
403
+		$myblock = new \XoopsBlock($bid);
404
+		$myblock->setVar('title', $title);
405
+		$myblock->setVar('weight', $weight);
406
+		$myblock->setVar('visible', $visible);
407
+		$myblock->setVar('side', $side);
408
+		$myblock->setVar('bcachetime', $bcachetime);
409
+		$myblock->store();
410
+		//        /** @var \XoopsBlockHandler $blockHandler */
411
+		//        $blockHandler = \xoops_getHandler('block');
412
+		//        return $blockHandler->insert($myblock);
413
+	}
414
+
415
+	/**
416
+	 * @param int $bid
417
+	 * @return void
418
+	 */
419
+	public function editBlock(int $bid): void
420
+	{
421
+		//        require_once \dirname(__DIR__,2) . '/admin/admin_header.php';
422
+		//        \xoops_cp_header();
423
+		\xoops_loadLanguage('admin', 'system');
424
+		\xoops_loadLanguage('admin/blocksadmin', 'system');
425
+		\xoops_loadLanguage('admin/groups', 'system');
426
+		//        mpu_adm_menu();
427
+		$myblock = new \XoopsBlock($bid);
428
+		$sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
429
+		$result  = $this->db->query($sql);
430
+		$modules = [];
431
+		if ($result instanceof \mysqli_result) {
432
+			while (false !== ($row = $this->db->fetchArray($result))) {
433
+				$modules[] = (int)$row['module_id'];
434
+			}
435
+		}
436
+		$isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']);
437
+		$block    = [
438
+			'title'      => $myblock->getVar('title'),
439
+			'form_title' => \_AM_SYSTEM_BLOCKS_EDITBLOCK,
440
+			//        'name'       => $myblock->getVar('name'),
441
+			'side'       => $myblock->getVar('side'),
442
+			'weight'     => $myblock->getVar('weight'),
443
+			'visible'    => $myblock->getVar('visible'),
444
+			'content'    => $myblock->getVar('content', 'N'),
445
+			'modules'    => $modules,
446
+			'is_custom'  => $isCustom,
447
+			'ctype'      => $myblock->getVar('c_type'),
448
+			'bcachetime' => $myblock->getVar('bcachetime'),
449
+			'op'         => 'edit_ok',
450
+			'bid'        => $myblock->getVar('bid'),
451
+			'edit_form'  => $myblock->getOptions(),
452
+			'template'   => $myblock->getVar('template'),
453
+			'options'    => $myblock->getVar('options'),
454
+		];
455
+		echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . \_AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>';
456
+
457
+		echo $this->render($block);
458
+	}
459
+
460
+	/**
461
+	 * @param int        $bid
462
+	 * @param string     $btitle
463
+	 * @param string     $bside
464
+	 * @param string     $bweight
465
+	 * @param string     $bvisible
466
+	 * @param string     $bcachetime
467
+	 * @param array|null $bmodule
468
+	 * @param array|null $options
469
+	 * @param array|null $groups
470
+	 * @return void
471
+	 */
472
+	public function updateBlock(int $bid, string $btitle, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void
473
+	{
474
+		$myblock = new \XoopsBlock($bid);
475
+		$myblock->setVar('title', $btitle);
476
+		$myblock->setVar('weight', $bweight);
477
+		$myblock->setVar('visible', $bvisible);
478
+		$myblock->setVar('side', $bside);
479
+		$myblock->setVar('bcachetime', $bcachetime);
480
+		//update block options
481
+		if (isset($options)) {
482
+			$optionsCount = \count($options);
483
+			if ($optionsCount > 0) {
484
+				//Convert array values to comma-separated
485
+				foreach ($options as $i => $iValue) {
486
+					if (\is_array($iValue)) {
487
+						$options[$i] = \implode(',', $iValue);
488
+					}
489
+				}
490
+				$options = \implode('|', $options);
491
+				$myblock->setVar('options', $options);
492
+			}
493
+		}
494
+		$myblock->store();
495
+		//        /** @var \XoopsBlockHandler $blockHandler */
496
+		//        $blockHandler = \xoops_getHandler('block');
497
+		//        $blockHandler->insert($myblock);
498
+
499
+		if (!empty($bmodule) && \count($bmodule) > 0) {
500
+			$sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid);
501
+			$this->db->query($sql);
502
+			if (\in_array(0, $bmodule)) {
503
+				$sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, 0);
504
+				$this->db->query($sql);
505
+			} else {
506
+				foreach ($bmodule as $bmid) {
507
+					$sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, (int)$bmid);
508
+					$this->db->query($sql);
509
+				}
510
+			}
511
+		}
512
+		$sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid);
513
+		$this->db->query($sql);
514
+		if (!empty($groups)) {
515
+			foreach ($groups as $grp) {
516
+				$sql = \sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $this->db->prefix('group_permission'), $grp, $bid);
517
+				$this->db->query($sql);
518
+			}
519
+		}
520
+		$this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
521
+	}
522
+
523
+	/**
524
+	 * @param array $bid
525
+	 * @param array $oldtitle
526
+	 * @param array $oldside
527
+	 * @param array $oldweight
528
+	 * @param array $oldvisible
529
+	 * @param array $oldgroups
530
+	 * @param array $oldbcachetime
531
+	 * @param array $oldbmodule
532
+	 * @param array $title
533
+	 * @param array $weight
534
+	 * @param array $visible
535
+	 * @param array $side
536
+	 * @param array $bcachetime
537
+	 * @param array $groups
538
+	 * @param array $bmodule
539
+	 * @return void
540
+	 */
541
+	public function orderBlock(
542
+		array $bid, array $oldtitle, array $oldside, array $oldweight, array $oldvisible, array $oldgroups, array $oldbcachetime, array $oldbmodule, array $title, array $weight, array $visible, array $side, array $bcachetime, array $groups, array $bmodule
543
+	): void {
544
+		if (!$GLOBALS['xoopsSecurity']->check()) {
545
+			\redirect_header($_SERVER['SCRIPT_NAME'], 3, \implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
546
+		}
547
+		foreach (\array_keys($bid) as $i) {
548
+			if ($oldtitle[$i] !== $title[$i]
549
+				|| $oldweight[$i] !== $weight[$i]
550
+				|| $oldvisible[$i] !== $visible[$i]
551
+				|| $oldside[$i] !== $side[$i]
552
+				|| $oldbcachetime[$i] !== $bcachetime[$i]
553
+				|| $oldbmodule[$i] !== $bmodule[$i]) {
554
+				$this->setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]);
555
+			}
556
+			if (!empty($bmodule[$i]) && \count($bmodule[$i]) > 0) {
557
+				$sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid[$i]);
558
+				$this->db->query($sql);
559
+				if (\in_array(0, $bmodule[$i], true)) {
560
+					$sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], 0);
561
+					$this->db->query($sql);
562
+				} else {
563
+					foreach ($bmodule[$i] as $bmid) {
564
+						$sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int)$bmid);
565
+						$this->db->query($sql);
566
+					}
567
+				}
568
+			}
569
+			$sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid[$i]);
570
+			$this->db->query($sql);
571
+			if (!empty($groups[$i])) {
572
+				foreach ($groups[$i] as $grp) {
573
+					$sql = \sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $this->db->prefix('group_permission'), $grp, $bid[$i]);
574
+					$this->db->query($sql);
575
+				}
576
+			}
577
+		}
578
+
579
+		$this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
580
+	}
581
+
582
+	/**
583
+	 * @param array|null $block
584
+	 * @return void
585
+	 */
586
+	public function render(?array $block = null): void
587
+	{
588
+		\xoops_load('XoopsFormLoader');
589
+		\xoops_loadLanguage('common', $this->moduleDirNameUpper);
590
+
591
+		$form = new \XoopsThemeForm($block['form_title'], 'blockform', 'blocksadmin.php', 'post', true);
592
+		if (isset($block['name'])) {
593
+			$form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_NAME, $block['name']));
594
+		}
595
+		$sideSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_TYPE, 'bside', $block['side']);
596
+		$sideSelect->addOptionArray([
597
+										0 => \_AM_SYSTEM_BLOCKS_SBLEFT,
598
+										1 => \_AM_SYSTEM_BLOCKS_SBRIGHT,
599
+										3 => \_AM_SYSTEM_BLOCKS_CBLEFT,
600
+										4 => \_AM_SYSTEM_BLOCKS_CBRIGHT,
601
+										5 => \_AM_SYSTEM_BLOCKS_CBCENTER,
602
+										7 => \_AM_SYSTEM_BLOCKS_CBBOTTOMLEFT,
603
+										8 => \_AM_SYSTEM_BLOCKS_CBBOTTOMRIGHT,
604
+										9 => \_AM_SYSTEM_BLOCKS_CBBOTTOM,
605
+									]);
606
+		$form->addElement($sideSelect);
607
+		$form->addElement(new \XoopsFormText(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight']));
608
+		$form->addElement(new \XoopsFormRadioYN(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible']));
609
+		$modSelect = new \XoopsFormSelect(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true);
610
+		/** @var \XoopsModuleHandler $moduleHandler */
611
+		$moduleHandler = \xoops_getHandler('module');
612
+		$criteria      = new \CriteriaCompo(new \Criteria('hasmain', '1'));
613
+		$criteria->add(new \Criteria('isactive', '1'));
614
+		$moduleList     = $moduleHandler->getList($criteria);
615
+		$moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
616
+		$moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
617
+		\ksort($moduleList);
618
+		$modSelect->addOptionArray($moduleList);
619
+		$form->addElement($modSelect);
620
+		$form->addElement(new \XoopsFormText(\_AM_SYSTEM_BLOCKS_TITLE, 'btitle', 50, 255, $block['title']), false);
621
+		if ($block['is_custom']) {
622
+			$textarea = new \XoopsFormDhtmlTextArea(\_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70);
623
+			$textarea->setDescription('<span style="font-size:x-small;font-weight:bold;">' . \_AM_SYSTEM_BLOCKS_USEFULTAGS . '</span><br><span style="font-size:x-small;font-weight:normal;">' . \sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . '</span>');
624
+			$form->addElement($textarea, true);
625
+			$ctypeSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']);
626
+			$ctypeSelect->addOptionArray([
627
+											 'H' => \_AM_SYSTEM_BLOCKS_HTML,
628
+											 'P' => \_AM_SYSTEM_BLOCKS_PHP,
629
+											 'S' => \_AM_SYSTEM_BLOCKS_AFWSMILE,
630
+											 'T' => \_AM_SYSTEM_BLOCKS_AFNOSMILE,
631
+										 ]);
632
+			$form->addElement($ctypeSelect);
633
+		} else {
634
+			if ('' !== $block['template']) {
635
+				/** @var \XoopsTplfileHandler $tplfileHandler */
636
+				$tplfileHandler = \xoops_getHandler('tplfile');
637
+				$btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
638
+				if (\count($btemplate) > 0) {
639
+					$form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate[0]->getVar('tpl_id') . '">' . \_AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
640
+				} else {
641
+					$btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']);
642
+					if (\count($btemplate2) > 0) {
643
+						$form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate2[0]->getVar('tpl_id') . '" target="_blank">' . \_AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
644
+					}
645
+				}
646
+			}
647
+			if (false !== $block['edit_form']) {
648
+				$form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_OPTIONS, $block['edit_form']));
649
+			}
650
+		}
651
+		$cache_select = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_BCACHETIME, 'bcachetime', $block['bcachetime']);
652
+		$cache_select->addOptionArray([
653
+										  0       => \_NOCACHE,
654
+										  30      => \sprintf(\_SECONDS, 30),
655
+										  60      => \_MINUTE,
656
+										  300     => \sprintf(\_MINUTES, 5),
657
+										  1800    => \sprintf(\_MINUTES, 30),
658
+										  3600    => \_HOUR,
659
+										  18000   => \sprintf(\_HOURS, 5),
660
+										  86400   => \_DAY,
661
+										  259200  => \sprintf(\_DAYS, 3),
662
+										  604800  => \_WEEK,
663
+										  2592000 => \_MONTH,
664
+									  ]);
665
+		$form->addElement($cache_select);
666
+
667
+		/** @var \XoopsGroupPermHandler $grouppermHandler */
668
+		$grouppermHandler = \xoops_getHandler('groupperm');
669
+		$groups           = $grouppermHandler->getGroupIds('block_read', $block['bid']);
670
+
671
+		$form->addElement(new \XoopsFormSelectGroup(\_AM_SYSTEM_BLOCKS_GROUP, 'groups', true, $groups, 5, true));
672
+
673
+		if (isset($block['bid'])) {
674
+			$form->addElement(new \XoopsFormHidden('bid', $block['bid']));
675
+		}
676
+		$form->addElement(new \XoopsFormHidden('op', $block['op']));
677
+		$form->addElement(new \XoopsFormHidden('fct', 'blocksadmin'));
678
+		$buttonTray = new \XoopsFormElementTray('', '&nbsp;');
679
+		if ($block['is_custom']) {
680
+			$buttonTray->addElement(new \XoopsFormButton('', 'previewblock', \_PREVIEW, 'submit'));
681
+		}
682
+
683
+		//Submit buttons
684
+		$buttonTray   = new \XoopsFormElementTray('', '');
685
+		$submitButton = new \XoopsFormButton('', 'submitblock', \_SUBMIT, 'submit');
686
+		$buttonTray->addElement($submitButton);
687
+
688
+		$cancelButton = new \XoopsFormButton('', '', \_CANCEL, 'button');
689
+		$cancelButton->setExtra('onclick="history.go(-1)"');
690
+		$buttonTray->addElement($cancelButton);
691
+
692
+		$form->addElement($buttonTray);
693
+		$form->display();
694
+	}
695 695
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     public function listBlocks(): void
69 69
     {
70 70
         global $xoopsModule, $pathIcon16;
71
-        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
71
+        require_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
72 72
         //        xoops_loadLanguage('admin', 'system');
73 73
         //        xoops_loadLanguage('admin/blocksadmin', 'system');
74 74
         //        xoops_loadLanguage('admin/groups', 'system');
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
         $moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE;
89 89
         $moduleList[0]  = \_AM_SYSTEM_BLOCKS_ALLPAGES;
90 90
         \ksort($moduleList);
91
-        echo "<h4 style='text-align:left;'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
92
-        echo "<form action='" . $_SERVER['SCRIPT_NAME'] . "' name='blockadmin' method='post'>";
91
+        echo "<h4 style='text-align:left;'>".\constant('CO_'.$this->moduleDirNameUpper.'_'.'BADMIN').'</h4>';
92
+        echo "<form action='".$_SERVER['SCRIPT_NAME']."' name='blockadmin' method='post'>";
93 93
         echo $GLOBALS['xoopsSecurity']->getTokenHTML();
94 94
         echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
95
-        <tr valign='middle'><th align='center'>" . \_AM_SYSTEM_BLOCKS_TITLE . "</th><th align='center' nowrap='nowrap'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'SIDE') . '<br>' . \_LEFT . '-' . \_CENTER . '-' . \_RIGHT . "</th>
96
-        <th align='center'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT') . "</th>
97
-        <th align='center'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE') . "</th><th align='center'>" . \_AM_SYSTEM_BLOCKS_VISIBLEIN . "</th>
98
-        <th align='center'>" . \_AM_SYSTEM_ADGS . "</th>
99
-        <th align='center'>" . \_AM_SYSTEM_BLOCKS_BCACHETIME . "</th>
100
-        <th align='center'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'ACTION') . '</th>
95
+        <tr valign='middle'><th align='center'>" . \_AM_SYSTEM_BLOCKS_TITLE."</th><th align='center' nowrap='nowrap'>".\constant('CO_'.$this->moduleDirNameUpper.'_'.'SIDE').'<br>'.\_LEFT.'-'.\_CENTER.'-'.\_RIGHT."</th>
96
+        <th align='center'>" . \constant('CO_'.$this->moduleDirNameUpper.'_'.'WEIGHT')."</th>
97
+        <th align='center'>" . \constant('CO_'.$this->moduleDirNameUpper.'_'.'VISIBLE')."</th><th align='center'>".\_AM_SYSTEM_BLOCKS_VISIBLEIN."</th>
98
+        <th align='center'>" . \_AM_SYSTEM_ADGS."</th>
99
+        <th align='center'>" . \_AM_SYSTEM_BLOCKS_BCACHETIME."</th>
100
+        <th align='center'>" . \constant('CO_'.$this->moduleDirNameUpper.'_'.'ACTION').'</th>
101 101
         </tr>';
102 102
         $blockArray = \XoopsBlock::getByModule($xoopsModule->mid());
103 103
         $blockCount = \count($blockArray);
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
         ];
118 118
         foreach ($blockArray as $i) {
119 119
             $groupsPermissions = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
120
-            $sql               = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
120
+            $sql               = 'SELECT module_id FROM '.$this->db->prefix('block_module_link').' WHERE block_id='.$i->getVar('bid');
121 121
             $result            = $this->db->query($sql);
122 122
             $modules           = [];
123 123
             if (!$result instanceof \mysqli_result) {
124
-                \trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR);
124
+                \trigger_error("Query Failed! SQL: $sql Error: ".$this->db->error(), \E_USER_ERROR);
125 125
             }
126 126
             while (false !== ($row = $this->db->fetchArray($result))) {
127
-                $modules[] = (int)$row['module_id'];
127
+                $modules[] = (int) $row['module_id'];
128 128
             }
129 129
 
130 130
             $cachetimeOptions = '';
@@ -174,46 +174,46 @@  discard block
 block discarded – undo
174 174
                 $title = $i->getVar('title');
175 175
             }
176 176
             $name = $i->getVar('name');
177
-            echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title[" . $i->getVar('bid') . "]' value='" . $title . "'></td>
177
+            echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title[".$i->getVar('bid')."]' value='".$title."'></td>
178 178
             <td class='$class' align='center' nowrap='nowrap'><div align='center' >
179
-                    <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_LEFT . "'$ssel2>
180
-                    <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_CENTER . "'$ssel3>
181
-                    <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_RIGHT . "'$ssel4>
179
+                    <input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_CENTERBLOCK_LEFT."'$ssel2>
180
+                    <input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_CENTERBLOCK_CENTER."'$ssel3>
181
+                    <input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_CENTERBLOCK_RIGHT."'$ssel4>
182 182
                     </div>
183 183
                     <div>
184
-                        <span style='float:right;'><input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_SIDEBLOCK_RIGHT . "'$ssel1></span>
185
-                    <div align='left'><input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_SIDEBLOCK_LEFT . "'$ssel0></div>
184
+                        <span style='float:right;'><input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_SIDEBLOCK_RIGHT."'$ssel1></span>
185
+                    <div align='left'><input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_SIDEBLOCK_LEFT."'$ssel0></div>
186 186
                     </div>
187 187
                     <div align='center'>
188
-                    <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_BOTTOMLEFT . "'$ssel5>
189
-                        <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_BOTTOM . "'$ssel7>
190
-                    <input type='radio' name='side[" . $i->getVar('bid') . "]' value='" . \XOOPS_CENTERBLOCK_BOTTOMRIGHT . "'$ssel6>
188
+                    <input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_CENTERBLOCK_BOTTOMLEFT."'$ssel5>
189
+                        <input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_CENTERBLOCK_BOTTOM."'$ssel7>
190
+                    <input type='radio' name='side[".$i->getVar('bid')."]' value='".\XOOPS_CENTERBLOCK_BOTTOMRIGHT."'$ssel6>
191 191
                     </div>
192 192
                 </td>
193
-                <td class='$class' align='center'><input type='text' name='weight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "' size='5' maxlength='5'></td>
194
-                <td class='$class' align='center' nowrap><input type='radio' name='visible[" . $i->getVar('bid') . "]' value='1'$sel1>" . \_YES . "&nbsp;<input type='radio' name='visible[" . $i->getVar('bid') . "]' value='0'$sel0>" . \_NO . '</td>';
193
+                <td class='$class' align='center'><input type='text' name='weight[".$i->getVar('bid')."]' value='".$i->getVar('weight')."' size='5' maxlength='5'></td>
194
+                <td class='$class' align='center' nowrap><input type='radio' name='visible[".$i->getVar('bid')."]' value='1'$sel1>".\_YES."&nbsp;<input type='radio' name='visible[".$i->getVar('bid')."]' value='0'$sel0>".\_NO.'</td>';
195 195
 
196
-            echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>";
196
+            echo "<td class='$class' align='center'><select size='5' name='bmodule[".$i->getVar('bid')."][]' id='bmodule[".$i->getVar('bid')."][]' multiple='multiple'>";
197 197
             foreach ($moduleList as $k => $v) {
198
-                echo "<option value='$k'" . (\in_array($k, $modules) ? " selected='selected'" : '') . ">$v</option>";
198
+                echo "<option value='$k'".(\in_array($k, $modules) ? " selected='selected'" : '').">$v</option>";
199 199
             }
200 200
             echo '</select></td>';
201 201
 
202
-            echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>";
202
+            echo "<td class='$class' align='center'><select size='5' name='groups[".$i->getVar('bid')."][]' id='groups[".$i->getVar('bid')."][]' multiple='multiple'>";
203 203
             foreach ($groups as $grp) {
204
-                echo "<option value='" . $grp->getVar('groupid') . "' " . (\in_array($grp->getVar('groupid'), $groupsPermissions) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>';
204
+                echo "<option value='".$grp->getVar('groupid')."' ".(\in_array($grp->getVar('groupid'), $groupsPermissions) ? " selected='selected'" : '').'>'.$grp->getVar('name').'</option>';
205 205
             }
206 206
             echo '</select></td>';
207 207
 
208 208
             // Cache lifetime
209
-            echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetimeOptions . '</select>
209
+            echo '<td class="'.$class.'" align="center"> <select name="bcachetime['.$i->getVar('bid').']" size="1">'.$cachetimeOptions.'</select>
210 210
                                     </td>';
211 211
 
212 212
             // Actions
213 213
 
214 214
             echo "<td class='$class' align='center'>
215
-                <a href='blocksadmin.php?op=edit&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . \_EDIT . "' title='" . \_EDIT . "'></a> 
216
-                <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . \_CLONE . "' title='" . \_CLONE . "'></a>";
215
+                <a href='blocksadmin.php?op=edit&amp;bid=".$i->getVar('bid')."'><img src=".$pathIcon16.'/edit.png'." alt='".\_EDIT."' title='".\_EDIT."'></a> 
216
+                <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid')."'><img src=".$pathIcon16.'/editcopy.png'." alt='".\_CLONE."' title='".\_CLONE."'></a>";
217 217
             //            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
218 218
             //                echo "&nbsp;<a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&amp;op=delete&amp;bid=' . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>
219 219
             //                     </a>";
@@ -222,22 +222,22 @@  discard block
 block discarded – undo
222 222
             //            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
223 223
             if (!\in_array($i->getVar('block_type'), ['M', 'S'])) {
224 224
                 echo "&nbsp;
225
-                <a href='blocksadmin.php?op=delete&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . \_DELETE . "' title='" . \_DELETE . "'>
225
+                <a href='blocksadmin.php?op=delete&amp;bid=" . $i->getVar('bid')."'><img src=".$pathIcon16.'/delete.png'." alt='".\_DELETE."' title='".\_DELETE."'>
226 226
                      </a>";
227 227
             }
228 228
             echo "
229
-            <input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "'>
230
-            <input type='hidden' name='oldside[" . $i->getVar('bid') . "]' value='" . $i->getVar('side') . "'>
231
-            <input type='hidden' name='oldweight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "'>
232
-            <input type='hidden' name='oldvisible[" . $i->getVar('bid') . "]' value='" . $i->getVar('visible') . "'>
233
-            <input type='hidden' name='oldgroups[" . $i->getVar('groups') . "]' value='" . $i->getVar('groups') . "'>
234
-            <input type='hidden' name='oldbcachetime[" . $i->getVar('bid') . "]' value='" . $i->getVar('bcachetime') . "'>
235
-            <input type='hidden' name='bid[" . $i->getVar('bid') . "]' value='" . $i->getVar('bid') . "'>
229
+            <input type='hidden' name='oldtitle[" . $i->getVar('bid')."]' value='".$i->getVar('title')."'>
230
+            <input type='hidden' name='oldside[" . $i->getVar('bid')."]' value='".$i->getVar('side')."'>
231
+            <input type='hidden' name='oldweight[" . $i->getVar('bid')."]' value='".$i->getVar('weight')."'>
232
+            <input type='hidden' name='oldvisible[" . $i->getVar('bid')."]' value='".$i->getVar('visible')."'>
233
+            <input type='hidden' name='oldgroups[" . $i->getVar('groups')."]' value='".$i->getVar('groups')."'>
234
+            <input type='hidden' name='oldbcachetime[" . $i->getVar('bid')."]' value='".$i->getVar('bcachetime')."'>
235
+            <input type='hidden' name='bid[" . $i->getVar('bid')."]' value='".$i->getVar('bid')."'>
236 236
             </td></tr>
237 237
             ";
238 238
             $class = ('even' === $class) ? 'odd' : 'even';
239 239
         }
240
-        echo "<tr><td class='foot' align='center' colspan='8'> <input type='hidden' name='op' value='order'>" . $GLOBALS['xoopsSecurity']->getTokenHTML() . "<input type='submit' name='submit' value='" . \_SUBMIT . "'></td></tr></table></form><br><br>";
240
+        echo "<tr><td class='foot' align='center' colspan='8'> <input type='hidden' name='op' value='order'>".$GLOBALS['xoopsSecurity']->getTokenHTML()."<input type='submit' name='submit' value='".\_SUBMIT."'></td></tr></table></form><br><br>";
241 241
     }
242 242
 
243 243
     /**
@@ -276,18 +276,18 @@  discard block
 block discarded – undo
276 276
         \xoops_loadLanguage('admin/groups', 'system');
277 277
 
278 278
         $myblock = new \XoopsBlock($bid);
279
-        $sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
279
+        $sql     = 'SELECT module_id FROM '.$this->db->prefix('block_module_link').' WHERE block_id='.$bid;
280 280
         $result  = $this->db->query($sql);
281 281
         $modules = [];
282 282
         if ($result instanceof \mysqli_result) {
283 283
             while (false !== ($row = $this->db->fetchArray($result))) {
284
-                $modules[] = (int)$row['module_id'];
284
+                $modules[] = (int) $row['module_id'];
285 285
             }
286 286
         }
287 287
         $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']);
288 288
         $block    = [
289
-            'title'      => $myblock->getVar('title') . ' Clone',
290
-            'form_title' => \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'),
289
+            'title'      => $myblock->getVar('title').' Clone',
290
+            'form_title' => \constant('CO_'.$this->moduleDirNameUpper.'_'.'BLOCKS_CLONEBLOCK'),
291 291
             'name'       => $myblock->getVar('name'),
292 292
             'side'       => $myblock->getVar('side'),
293 293
             'weight'     => $myblock->getVar('weight'),
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
             'template'   => $myblock->getVar('template'),
304 304
             'options'    => $myblock->getVar('options'),
305 305
         ];
306
-        echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . \_AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>';
306
+        echo '<a href="blocksadmin.php">'.\constant('CO_'.$this->moduleDirNameUpper.'_'.'BADMIN').'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'.\_AM_SYSTEM_BLOCKS_CLONEBLOCK.'<br><br>';
307 307
         //        $form = new Blockform();
308 308
         //        $form->render();
309 309
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
         }
357 357
         //        $newid = $clone->store(); //see https://github.com/XOOPS/XoopsCore25/issues/1105
358 358
         if ($clone->store()) {
359
-            $newid = $clone->id();  //get the id of the cloned block
359
+            $newid = $clone->id(); //get the id of the cloned block
360 360
         }
361 361
         if (!$newid) {
362 362
             //            \xoops_cp_header();
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
         if ('' !== $clone->getVar('template')) {
368 368
             /** @var \XoopsTplfileHandler $tplfileHandler */
369 369
             $tplfileHandler = \xoops_getHandler('tplfile');
370
-            $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', (string)$bid);
370
+            $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', (string) $bid);
371 371
             if (\count($btemplate) > 0) {
372 372
                 $tplclone = $btemplate[0]->xoopsClone();
373 373
                 $tplclone->setVar('tpl_id', 0);
@@ -377,12 +377,12 @@  discard block
 block discarded – undo
377 377
         }
378 378
 
379 379
         foreach ($bmodule as $bmid) {
380
-            $sql = 'INSERT INTO ' . $this->db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
380
+            $sql = 'INSERT INTO '.$this->db->prefix('block_module_link').' (block_id, module_id) VALUES ('.$newid.', '.$bmid.')';
381 381
             $this->db->query($sql);
382 382
         }
383 383
         //$groups = &$GLOBALS['xoopsUser']->getGroups();
384 384
         foreach ($groups as $iValue) {
385
-            $sql = 'INSERT INTO ' . $this->db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $iValue . ', ' . $newid . ", 1, 'block_read')";
385
+            $sql = 'INSERT INTO '.$this->db->prefix('group_permission').' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES ('.$iValue.', '.$newid.", 1, 'block_read')";
386 386
             $this->db->query($sql);
387 387
         }
388 388
         $this->helper->redirect('admin/blocksadmin.php?op=list', 1, _AM_DBUPDATED);
@@ -425,12 +425,12 @@  discard block
 block discarded – undo
425 425
         \xoops_loadLanguage('admin/groups', 'system');
426 426
         //        mpu_adm_menu();
427 427
         $myblock = new \XoopsBlock($bid);
428
-        $sql     = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid;
428
+        $sql     = 'SELECT module_id FROM '.$this->db->prefix('block_module_link').' WHERE block_id='.$bid;
429 429
         $result  = $this->db->query($sql);
430 430
         $modules = [];
431 431
         if ($result instanceof \mysqli_result) {
432 432
             while (false !== ($row = $this->db->fetchArray($result))) {
433
-                $modules[] = (int)$row['module_id'];
433
+                $modules[] = (int) $row['module_id'];
434 434
             }
435 435
         }
436 436
         $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']);
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
             'template'   => $myblock->getVar('template'),
453 453
             'options'    => $myblock->getVar('options'),
454 454
         ];
455
-        echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . \_AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>';
455
+        echo '<a href="blocksadmin.php">'.\constant('CO_'.$this->moduleDirNameUpper.'_'.'BADMIN').'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'.\_AM_SYSTEM_BLOCKS_EDITBLOCK.'<br><br>';
456 456
 
457 457
         echo $this->render($block);
458 458
     }
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
                 $this->db->query($sql);
505 505
             } else {
506 506
                 foreach ($bmodule as $bmid) {
507
-                    $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, (int)$bmid);
507
+                    $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid, (int) $bmid);
508 508
                     $this->db->query($sql);
509 509
                 }
510 510
             }
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
                 $this->db->query($sql);
518 518
             }
519 519
         }
520
-        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
520
+        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_'.$this->moduleDirNameUpper.'_'.'UPDATE_SUCCESS'));
521 521
     }
522 522
 
523 523
     /**
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
                     $this->db->query($sql);
562 562
                 } else {
563 563
                     foreach ($bmodule[$i] as $bmid) {
564
-                        $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int)$bmid);
564
+                        $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int) $bmid);
565 565
                         $this->db->query($sql);
566 566
                     }
567 567
                 }
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
             }
577 577
         }
578 578
 
579
-        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
579
+        $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_'.$this->moduleDirNameUpper.'_'.'UPDATE_SUCCESS'));
580 580
     }
581 581
 
582 582
     /**
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
                                         9 => \_AM_SYSTEM_BLOCKS_CBBOTTOM,
605 605
                                     ]);
606 606
         $form->addElement($sideSelect);
607
-        $form->addElement(new \XoopsFormText(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT'), 'bweight', 2, 5, $block['weight']));
608
-        $form->addElement(new \XoopsFormRadioYN(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE'), 'bvisible', $block['visible']));
609
-        $modSelect = new \XoopsFormSelect(\constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLEIN'), 'bmodule', $block['modules'], 5, true);
607
+        $form->addElement(new \XoopsFormText(\constant('CO_'.$this->moduleDirNameUpper.'_'.'WEIGHT'), 'bweight', 2, 5, $block['weight']));
608
+        $form->addElement(new \XoopsFormRadioYN(\constant('CO_'.$this->moduleDirNameUpper.'_'.'VISIBLE'), 'bvisible', $block['visible']));
609
+        $modSelect = new \XoopsFormSelect(\constant('CO_'.$this->moduleDirNameUpper.'_'.'VISIBLEIN'), 'bmodule', $block['modules'], 5, true);
610 610
         /** @var \XoopsModuleHandler $moduleHandler */
611 611
         $moduleHandler = \xoops_getHandler('module');
612 612
         $criteria      = new \CriteriaCompo(new \Criteria('hasmain', '1'));
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
         $form->addElement(new \XoopsFormText(\_AM_SYSTEM_BLOCKS_TITLE, 'btitle', 50, 255, $block['title']), false);
621 621
         if ($block['is_custom']) {
622 622
             $textarea = new \XoopsFormDhtmlTextArea(\_AM_SYSTEM_BLOCKS_CONTENT, 'bcontent', $block['content'], 15, 70);
623
-            $textarea->setDescription('<span style="font-size:x-small;font-weight:bold;">' . \_AM_SYSTEM_BLOCKS_USEFULTAGS . '</span><br><span style="font-size:x-small;font-weight:normal;">' . \sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL . '/') . '</span>');
623
+            $textarea->setDescription('<span style="font-size:x-small;font-weight:bold;">'.\_AM_SYSTEM_BLOCKS_USEFULTAGS.'</span><br><span style="font-size:x-small;font-weight:normal;">'.\sprintf(_AM_BLOCKTAG1, '{X_SITEURL}', XOOPS_URL.'/').'</span>');
624 624
             $form->addElement($textarea, true);
625 625
             $ctypeSelect = new \XoopsFormSelect(\_AM_SYSTEM_BLOCKS_CTYPE, 'bctype', $block['ctype']);
626 626
             $ctypeSelect->addOptionArray([
@@ -636,11 +636,11 @@  discard block
 block discarded – undo
636 636
                 $tplfileHandler = \xoops_getHandler('tplfile');
637 637
                 $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
638 638
                 if (\count($btemplate) > 0) {
639
-                    $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate[0]->getVar('tpl_id') . '">' . \_AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
639
+                    $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="'.XOOPS_URL.'/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id='.$btemplate[0]->getVar('tpl_id').'">'.\_AM_SYSTEM_BLOCKS_EDITTPL.'</a>'));
640 640
                 } else {
641 641
                     $btemplate2 = $tplfileHandler->find('default', 'block', $block['bid']);
642 642
                     if (\count($btemplate2) > 0) {
643
-                        $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id=' . $btemplate2[0]->getVar('tpl_id') . '" target="_blank">' . \_AM_SYSTEM_BLOCKS_EDITTPL . '</a>'));
643
+                        $form->addElement(new \XoopsFormLabel(\_AM_SYSTEM_BLOCKS_CONTENT, '<a href="'.XOOPS_URL.'/modules/system/admin.php?fct=tplsets&amp;op=edittpl&amp;id='.$btemplate2[0]->getVar('tpl_id').'" target="_blank">'.\_AM_SYSTEM_BLOCKS_EDITTPL.'</a>'));
644 644
                     }
645 645
                 }
646 646
             }
Please login to merge, or discard this patch.
class/Common/VersionChecks.php 2 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -19,129 +19,129 @@
 block discarded – undo
19 19
  */
20 20
 trait VersionChecks
21 21
 {
22
-    /**
23
-     * Verifies XOOPS version meets minimum requirements for this module
24
-     * @static
25
-     * @param \XoopsModule|null $module
26
-     *
27
-     * @param null|string       $requiredVer
28
-     * @return bool true if meets requirements, false if not
29
-     */
30
-    public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null): bool
31
-    {
32
-        $moduleDirName      = \basename(\dirname(__DIR__, 2));
33
-        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
34
-        if (null === $module) {
35
-            $module = \XoopsModule::getByDirname($moduleDirName);
36
-        }
37
-        \xoops_loadLanguage('admin', $moduleDirName);
38
-        \xoops_loadLanguage('common', $moduleDirName);
22
+	/**
23
+	 * Verifies XOOPS version meets minimum requirements for this module
24
+	 * @static
25
+	 * @param \XoopsModule|null $module
26
+	 *
27
+	 * @param null|string       $requiredVer
28
+	 * @return bool true if meets requirements, false if not
29
+	 */
30
+	public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null): bool
31
+	{
32
+		$moduleDirName      = \basename(\dirname(__DIR__, 2));
33
+		$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
34
+		if (null === $module) {
35
+			$module = \XoopsModule::getByDirname($moduleDirName);
36
+		}
37
+		\xoops_loadLanguage('admin', $moduleDirName);
38
+		\xoops_loadLanguage('common', $moduleDirName);
39 39
 
40
-        //check for minimum XOOPS version
41
-        $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string
42
-        if (null === $requiredVer) {
43
-            $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
44
-        }
45
-        $success = true;
40
+		//check for minimum XOOPS version
41
+		$currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string
42
+		if (null === $requiredVer) {
43
+			$requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
44
+		}
45
+		$success = true;
46 46
 
47
-        if (\version_compare($currentVer, $requiredVer, '<')) {
48
-            $success = false;
49
-            $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
50
-        }
47
+		if (\version_compare($currentVer, $requiredVer, '<')) {
48
+			$success = false;
49
+			$module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
50
+		}
51 51
 
52
-        return $success;
53
-    }
52
+		return $success;
53
+	}
54 54
 
55
-    /**
56
-     * Verifies PHP version meets minimum requirements for this module
57
-     * @static
58
-     * @param \XoopsModule|bool|null $module
59
-     *
60
-     * @return bool true if meets requirements, false if not
61
-     */
62
-    public static function checkVerPhp(\XoopsModule $module = null): bool
63
-    {
64
-        $moduleDirName      = \basename(\dirname(__DIR__, 2));
65
-        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
66
-        if (null === $module) {
67
-            $module = \XoopsModule::getByDirname($moduleDirName);
68
-        }
69
-        \xoops_loadLanguage('admin', $moduleDirName);
70
-        \xoops_loadLanguage('common', $moduleDirName);
55
+	/**
56
+	 * Verifies PHP version meets minimum requirements for this module
57
+	 * @static
58
+	 * @param \XoopsModule|bool|null $module
59
+	 *
60
+	 * @return bool true if meets requirements, false if not
61
+	 */
62
+	public static function checkVerPhp(\XoopsModule $module = null): bool
63
+	{
64
+		$moduleDirName      = \basename(\dirname(__DIR__, 2));
65
+		$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
66
+		if (null === $module) {
67
+			$module = \XoopsModule::getByDirname($moduleDirName);
68
+		}
69
+		\xoops_loadLanguage('admin', $moduleDirName);
70
+		\xoops_loadLanguage('common', $moduleDirName);
71 71
 
72
-        // check for minimum PHP version
73
-        $success = true;
72
+		// check for minimum PHP version
73
+		$success = true;
74 74
 
75
-        $verNum = \PHP_VERSION;
76
-        $reqVer = &$module->getInfo('min_php');
75
+		$verNum = \PHP_VERSION;
76
+		$reqVer = &$module->getInfo('min_php');
77 77
 
78
-        if (false !== $reqVer && '' !== $reqVer) {
79
-            if (\version_compare($verNum, $reqVer, '<')) {
80
-                $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
81
-                $success = false;
82
-            }
83
-        }
78
+		if (false !== $reqVer && '' !== $reqVer) {
79
+			if (\version_compare($verNum, $reqVer, '<')) {
80
+				$module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
81
+				$success = false;
82
+			}
83
+		}
84 84
 
85
-        return $success;
86
-    }
85
+		return $success;
86
+	}
87 87
 
88
-    /**
89
-     * compares current module version with the latest GitHub release
90
-     * @static
91
-     *
92
-     * @return string|array info about the latest module version, if newer
93
-     */
94
-    public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array
95
-    {
96
-        $moduleDirName      = \basename(\dirname(__DIR__, 2));
97
-        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
98
-        $update             = '';
99
-        $repository         = 'XoopsModules25x/' . $moduleDirName;
100
-        //        $repository         = 'XoopsModules25x/publisher'; //for testing only
101
-        $ret             = null;
102
-        $infoReleasesUrl = "https://api.github.com/repos/$repository/releases";
103
-        if ('github' === $source) {
104
-            if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) {
105
-                \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl);
106
-                \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true);
107
-                \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized'
108
-                \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]);
109
-                $curlReturn = \curl_exec($curlHandle);
110
-                if (false === $curlReturn) {
111
-                    \trigger_error(\curl_error($curlHandle));
112
-                } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) {
113
-                    \trigger_error('Repository Not Found: ' . $infoReleasesUrl);
114
-                } else {
115
-                    $file              = json_decode($curlReturn, false);
116
-                    $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default);
117
-                    $latestVersion     = $file[0]->tag_name;
118
-                    $prerelease        = $file[0]->prerelease;
119
-                    if ('master' !== $latestVersionLink) {
120
-                        $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion;
121
-                    }
122
-                    //"PHP-standardized" version
123
-                    $latestVersion = \mb_strtolower($latestVersion);
124
-                    if (false !== mb_strpos($latestVersion, 'final')) {
125
-                        $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion));
126
-                        $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion));
127
-                    }
128
-                    $moduleVersion = ($helper->getModule()
129
-                                             ->getInfo('version') . '_' . $helper->getModule()
130
-                                                                                 ->getInfo('module_status'));
131
-                    //"PHP-standardized" version
132
-                    $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion));
133
-                    //                    $moduleVersion = '1.0'; //for testing only
134
-                    //                    $moduleDirName = 'publisher'; //for testing only
135
-                    if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) {
136
-                        $ret   = [];
137
-                        $ret[] = $update;
138
-                        $ret[] = $latestVersionLink;
139
-                    }
140
-                }
141
-                \curl_close($curlHandle);
142
-            }
143
-        }
88
+	/**
89
+	 * compares current module version with the latest GitHub release
90
+	 * @static
91
+	 *
92
+	 * @return string|array info about the latest module version, if newer
93
+	 */
94
+	public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array
95
+	{
96
+		$moduleDirName      = \basename(\dirname(__DIR__, 2));
97
+		$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
98
+		$update             = '';
99
+		$repository         = 'XoopsModules25x/' . $moduleDirName;
100
+		//        $repository         = 'XoopsModules25x/publisher'; //for testing only
101
+		$ret             = null;
102
+		$infoReleasesUrl = "https://api.github.com/repos/$repository/releases";
103
+		if ('github' === $source) {
104
+			if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) {
105
+				\curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl);
106
+				\curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true);
107
+				\curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized'
108
+				\curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]);
109
+				$curlReturn = \curl_exec($curlHandle);
110
+				if (false === $curlReturn) {
111
+					\trigger_error(\curl_error($curlHandle));
112
+				} elseif (false !== \mb_strpos($curlReturn, 'Not Found')) {
113
+					\trigger_error('Repository Not Found: ' . $infoReleasesUrl);
114
+				} else {
115
+					$file              = json_decode($curlReturn, false);
116
+					$latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default);
117
+					$latestVersion     = $file[0]->tag_name;
118
+					$prerelease        = $file[0]->prerelease;
119
+					if ('master' !== $latestVersionLink) {
120
+						$update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion;
121
+					}
122
+					//"PHP-standardized" version
123
+					$latestVersion = \mb_strtolower($latestVersion);
124
+					if (false !== mb_strpos($latestVersion, 'final')) {
125
+						$latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion));
126
+						$latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion));
127
+					}
128
+					$moduleVersion = ($helper->getModule()
129
+											 ->getInfo('version') . '_' . $helper->getModule()
130
+																				 ->getInfo('module_status'));
131
+					//"PHP-standardized" version
132
+					$moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion));
133
+					//                    $moduleVersion = '1.0'; //for testing only
134
+					//                    $moduleDirName = 'publisher'; //for testing only
135
+					if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) {
136
+						$ret   = [];
137
+						$ret[] = $update;
138
+						$ret[] = $latestVersionLink;
139
+					}
140
+				}
141
+				\curl_close($curlHandle);
142
+			}
143
+		}
144 144
 
145
-        return $ret;
146
-    }
145
+		return $ret;
146
+	}
147 147
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
         //check for minimum XOOPS version
41 41
         $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string
42 42
         if (null === $requiredVer) {
43
-            $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
43
+            $requiredVer = ''.$module->getInfo('min_xoops'); //making sure it's a string
44 44
         }
45 45
         $success = true;
46 46
 
47 47
         if (\version_compare($currentVer, $requiredVer, '<')) {
48 48
             $success = false;
49
-            $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
49
+            $module->setErrors(\sprintf(\constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
50 50
         }
51 51
 
52 52
         return $success;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
         if (false !== $reqVer && '' !== $reqVer) {
79 79
             if (\version_compare($verNum, $reqVer, '<')) {
80
-                $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
80
+                $module->setErrors(\sprintf(\constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_PHP'), $reqVer, $verNum));
81 81
                 $success = false;
82 82
             }
83 83
         }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         $moduleDirName      = \basename(\dirname(__DIR__, 2));
97 97
         $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
98 98
         $update             = '';
99
-        $repository         = 'XoopsModules25x/' . $moduleDirName;
99
+        $repository         = 'XoopsModules25x/'.$moduleDirName;
100 100
         //        $repository         = 'XoopsModules25x/publisher'; //for testing only
101 101
         $ret             = null;
102 102
         $infoReleasesUrl = "https://api.github.com/repos/$repository/releases";
@@ -110,14 +110,14 @@  discard block
 block discarded – undo
110 110
                 if (false === $curlReturn) {
111 111
                     \trigger_error(\curl_error($curlHandle));
112 112
                 } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) {
113
-                    \trigger_error('Repository Not Found: ' . $infoReleasesUrl);
113
+                    \trigger_error('Repository Not Found: '.$infoReleasesUrl);
114 114
                 } else {
115 115
                     $file              = json_decode($curlReturn, false);
116 116
                     $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default);
117 117
                     $latestVersion     = $file[0]->tag_name;
118 118
                     $prerelease        = $file[0]->prerelease;
119 119
                     if ('master' !== $latestVersionLink) {
120
-                        $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion;
120
+                        $update = \constant('CO_'.$moduleDirNameUpper.'_'.'NEW_VERSION').$latestVersion;
121 121
                     }
122 122
                     //"PHP-standardized" version
123 123
                     $latestVersion = \mb_strtolower($latestVersion);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                         $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion));
127 127
                     }
128 128
                     $moduleVersion = ($helper->getModule()
129
-                                             ->getInfo('version') . '_' . $helper->getModule()
129
+                                             ->getInfo('version').'_'.$helper->getModule()
130 130
                                                                                  ->getInfo('module_status'));
131 131
                     //"PHP-standardized" version
132 132
                     $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion));
Please login to merge, or discard this patch.
class/Common/SysUtility.php 2 patches
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -30,217 +30,217 @@
 block discarded – undo
30 30
  */
31 31
 class SysUtility
32 32
 {
33
-    use VersionChecks;
34
-
35
-    //checkVerXoops, checkVerPhp Traits
36
-
37
-    use ServerStats;
38
-
39
-    // getServerStats Trait
40
-
41
-    use FilesManagement;
42
-
43
-    // Files Management Trait
44
-
45
-    /**
46
-     * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags
47
-     * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags
48
-     * www.cakephp.org
49
-     *
50
-     * @param string $text         String to truncate.
51
-     * @param int    $length       Length of returned string, including ellipsis.
52
-     * @param string $ending       Ending to be appended to the trimmed string.
53
-     * @param bool   $exact        If false, $text will not be cut mid-word
54
-     * @param bool   $considerHtml If true, HTML tags would be handled correctly
55
-     *
56
-     * @return string Trimmed string.
57
-     */
58
-    public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true): string
59
-    {
60
-        if ($considerHtml) {
61
-            // if the plain text is shorter than the maximum length, return the whole text
62
-            if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
63
-                return $text;
64
-            }
65
-            // splits all html-tags to scanable lines
66
-            \preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER);
67
-            $total_length = mb_strlen($ending);
68
-            $open_tags    = [];
69
-            $truncate     = '';
70
-            foreach ($lines as $line_matchings) {
71
-                // if there is any html-tag in this line, handle it and add it (uncounted) to the output
72
-                if (!empty($line_matchings[1])) {
73
-                    // if it's an "empty element" with or without xhtml-conform closing slash
74
-                    if (\preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) {
75
-                        // do nothing
76
-                        // if tag is a closing tag
77
-                    } elseif (\preg_match('/^<\s*\/(\S+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
78
-                        // delete tag from $open_tags list
79
-                        $pos = \array_search($tag_matchings[1], $open_tags, true);
80
-                        if (false !== $pos) {
81
-                            unset($open_tags[$pos]);
82
-                        }
83
-                        // if tag is an opening tag
84
-                    } elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) {
85
-                        // add tag to the beginning of $open_tags list
86
-                        \array_unshift($open_tags, \mb_strtolower($tag_matchings[1]));
87
-                    }
88
-                    // add html-tag to $truncate'd text
89
-                    $truncate .= $line_matchings[1];
90
-                }
91
-                // calculate the length of the plain text part of the line; handle entities as one character
92
-                $content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
93
-                if ($total_length + $content_length > $length) {
94
-                    // the number of characters which are left
95
-                    $left            = $length - $total_length;
96
-                    $entities_length = 0;
97
-                    // search for html entities
98
-                    if (\preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) {
99
-                        // calculate the real length of all entities in the legal range
100
-                        foreach ($entities[0] as $entity) {
101
-                            if ($left >= $entity[1] + 1 - $entities_length) {
102
-                                $left--;
103
-                                $entities_length += mb_strlen($entity[0]);
104
-                            } else {
105
-                                // no more characters left
106
-                                break;
107
-                            }
108
-                        }
109
-                    }
110
-                    $truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length);
111
-                    // maximum lenght is reached, so get off the loop
112
-                    break;
113
-                }
114
-                $truncate     .= $line_matchings[2];
115
-                $total_length += $content_length;
116
-
117
-                // if the maximum length is reached, get off the loop
118
-                if ($total_length >= $length) {
119
-                    break;
120
-                }
121
-            }
122
-        } else {
123
-            if (mb_strlen($text) <= $length) {
124
-                return $text;
125
-            }
126
-            $truncate = mb_substr($text, 0, $length - mb_strlen($ending));
127
-        }
128
-        // if the words shouldn't be cut in the middle...
129
-        if (!$exact) {
130
-            // ...search the last occurance of a space...
131
-            $spacepos = mb_strrpos($truncate, ' ');
132
-            if (isset($spacepos)) {
133
-                // ...and cut the text in this position
134
-                $truncate = mb_substr($truncate, 0, $spacepos);
135
-            }
136
-        }
137
-        // add the defined ending to the text
138
-        $truncate .= $ending;
139
-        if ($considerHtml) {
140
-            // close all unclosed html-tags
141
-            foreach ($open_tags as $tag) {
142
-                $truncate .= '</' . $tag . '>';
143
-            }
144
-        }
145
-
146
-        return $truncate;
147
-    }
148
-
149
-    /**
150
-     * @param \Xmf\Module\Helper $helper
151
-     * @param array|null         $options
152
-     * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor
153
-     */
154
-    public static function getEditor($helper = null, $options = null)
155
-    {
156
-        /** @var Helper $helper */
157
-        if (null === $options) {
158
-            $options           = [];
159
-            $options['name']   = 'Editor';
160
-            $options['value']  = 'Editor';
161
-            $options['rows']   = 10;
162
-            $options['cols']   = '100%';
163
-            $options['width']  = '100%';
164
-            $options['height'] = '400px';
165
-        }
166
-
167
-        if (null === $helper) {
168
-            $helper = Helper::getInstance();
169
-        }
170
-
171
-        $isAdmin = $helper->isUserAdmin();
172
-
173
-        if (\class_exists('XoopsFormEditor')) {
174
-            if ($isAdmin) {
175
-                $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea');
176
-            } else {
177
-                $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea');
178
-            }
179
-        } else {
180
-            $descEditor = new \XoopsFormDhtmlTextArea(\ucfirst($options['name']), $options['name'], $options['value'], '100%', '100%');
181
-        }
182
-
183
-        //        $form->addElement($descEditor);
184
-
185
-        return $descEditor;
186
-    }
187
-
188
-    /**
189
-     * @param string $fieldname
190
-     * @param string $table
191
-     * @return bool
192
-     */
193
-    public static function fieldExists(string $fieldname, string $table): bool
194
-    {
195
-        global $xoopsDB;
196
-        $result = $xoopsDB->queryF("SHOW COLUMNS FROM   $table LIKE '$fieldname'");
197
-
198
-        return ($xoopsDB->getRowsNum($result) > 0);
199
-    }
200
-
201
-    /**
202
-     * @param array|string $tableName
203
-     * @param int          $id_field
204
-     * @param int          $id
205
-     *
206
-     * @return mixed
207
-     */
208
-    public static function cloneRecord($tableName, $id_field, $id)
209
-    {
210
-        $new_id = false;
211
-        $table  = $GLOBALS['xoopsDB']->prefix($tableName);
212
-        // copy content of the record you wish to clone
213
-        $sql    = "SELECT * FROM $table WHERE $idField='" . $id . "' ";
214
-        $result = $GLOBALS['xoopsDB']->query($sql);
215
-        if ($result instanceof \mysqli_result) {
216
-            $tempTable = $GLOBALS['xoopsDB']->fetchArray($result, \MYSQLI_ASSOC);
217
-        }
218
-        if (!$tempTable) {
219
-            \trigger_error($GLOBALS['xoopsDB']->error());
220
-        }
221
-        // set the auto-incremented id's value to blank.
222
-        unset($tempTable[$id_field]);
223
-        // insert cloned copy of the original  record
224
-        $sql    = "INSERT INTO $table (" . \implode(', ', \array_keys($tempTable)) . ") VALUES ('" . \implode("', '", $tempTable) . "')";
225
-        $result = $GLOBALS['xoopsDB']->queryF($sql);
226
-        if (!$result) {
227
-            \trigger_error($GLOBALS['xoopsDB']->error());
228
-        }
229
-        // Return the new id
230
-        $new_id = $GLOBALS['xoopsDB']->getInsertId();
231
-
232
-        return $new_id;
233
-    }
234
-
235
-    /**
236
-     * @param string $tablename
237
-     *
238
-     * @return bool
239
-     */
240
-    public static function tableExists($tablename): bool
241
-    {
242
-        $result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'");
243
-
244
-        return $GLOBALS['xoopsDB']->getRowsNum($result) > 0;
245
-    }
33
+	use VersionChecks;
34
+
35
+	//checkVerXoops, checkVerPhp Traits
36
+
37
+	use ServerStats;
38
+
39
+	// getServerStats Trait
40
+
41
+	use FilesManagement;
42
+
43
+	// Files Management Trait
44
+
45
+	/**
46
+	 * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags
47
+	 * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags
48
+	 * www.cakephp.org
49
+	 *
50
+	 * @param string $text         String to truncate.
51
+	 * @param int    $length       Length of returned string, including ellipsis.
52
+	 * @param string $ending       Ending to be appended to the trimmed string.
53
+	 * @param bool   $exact        If false, $text will not be cut mid-word
54
+	 * @param bool   $considerHtml If true, HTML tags would be handled correctly
55
+	 *
56
+	 * @return string Trimmed string.
57
+	 */
58
+	public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true): string
59
+	{
60
+		if ($considerHtml) {
61
+			// if the plain text is shorter than the maximum length, return the whole text
62
+			if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
63
+				return $text;
64
+			}
65
+			// splits all html-tags to scanable lines
66
+			\preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER);
67
+			$total_length = mb_strlen($ending);
68
+			$open_tags    = [];
69
+			$truncate     = '';
70
+			foreach ($lines as $line_matchings) {
71
+				// if there is any html-tag in this line, handle it and add it (uncounted) to the output
72
+				if (!empty($line_matchings[1])) {
73
+					// if it's an "empty element" with or without xhtml-conform closing slash
74
+					if (\preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) {
75
+						// do nothing
76
+						// if tag is a closing tag
77
+					} elseif (\preg_match('/^<\s*\/(\S+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
78
+						// delete tag from $open_tags list
79
+						$pos = \array_search($tag_matchings[1], $open_tags, true);
80
+						if (false !== $pos) {
81
+							unset($open_tags[$pos]);
82
+						}
83
+						// if tag is an opening tag
84
+					} elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) {
85
+						// add tag to the beginning of $open_tags list
86
+						\array_unshift($open_tags, \mb_strtolower($tag_matchings[1]));
87
+					}
88
+					// add html-tag to $truncate'd text
89
+					$truncate .= $line_matchings[1];
90
+				}
91
+				// calculate the length of the plain text part of the line; handle entities as one character
92
+				$content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
93
+				if ($total_length + $content_length > $length) {
94
+					// the number of characters which are left
95
+					$left            = $length - $total_length;
96
+					$entities_length = 0;
97
+					// search for html entities
98
+					if (\preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) {
99
+						// calculate the real length of all entities in the legal range
100
+						foreach ($entities[0] as $entity) {
101
+							if ($left >= $entity[1] + 1 - $entities_length) {
102
+								$left--;
103
+								$entities_length += mb_strlen($entity[0]);
104
+							} else {
105
+								// no more characters left
106
+								break;
107
+							}
108
+						}
109
+					}
110
+					$truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length);
111
+					// maximum lenght is reached, so get off the loop
112
+					break;
113
+				}
114
+				$truncate     .= $line_matchings[2];
115
+				$total_length += $content_length;
116
+
117
+				// if the maximum length is reached, get off the loop
118
+				if ($total_length >= $length) {
119
+					break;
120
+				}
121
+			}
122
+		} else {
123
+			if (mb_strlen($text) <= $length) {
124
+				return $text;
125
+			}
126
+			$truncate = mb_substr($text, 0, $length - mb_strlen($ending));
127
+		}
128
+		// if the words shouldn't be cut in the middle...
129
+		if (!$exact) {
130
+			// ...search the last occurance of a space...
131
+			$spacepos = mb_strrpos($truncate, ' ');
132
+			if (isset($spacepos)) {
133
+				// ...and cut the text in this position
134
+				$truncate = mb_substr($truncate, 0, $spacepos);
135
+			}
136
+		}
137
+		// add the defined ending to the text
138
+		$truncate .= $ending;
139
+		if ($considerHtml) {
140
+			// close all unclosed html-tags
141
+			foreach ($open_tags as $tag) {
142
+				$truncate .= '</' . $tag . '>';
143
+			}
144
+		}
145
+
146
+		return $truncate;
147
+	}
148
+
149
+	/**
150
+	 * @param \Xmf\Module\Helper $helper
151
+	 * @param array|null         $options
152
+	 * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor
153
+	 */
154
+	public static function getEditor($helper = null, $options = null)
155
+	{
156
+		/** @var Helper $helper */
157
+		if (null === $options) {
158
+			$options           = [];
159
+			$options['name']   = 'Editor';
160
+			$options['value']  = 'Editor';
161
+			$options['rows']   = 10;
162
+			$options['cols']   = '100%';
163
+			$options['width']  = '100%';
164
+			$options['height'] = '400px';
165
+		}
166
+
167
+		if (null === $helper) {
168
+			$helper = Helper::getInstance();
169
+		}
170
+
171
+		$isAdmin = $helper->isUserAdmin();
172
+
173
+		if (\class_exists('XoopsFormEditor')) {
174
+			if ($isAdmin) {
175
+				$descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea');
176
+			} else {
177
+				$descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea');
178
+			}
179
+		} else {
180
+			$descEditor = new \XoopsFormDhtmlTextArea(\ucfirst($options['name']), $options['name'], $options['value'], '100%', '100%');
181
+		}
182
+
183
+		//        $form->addElement($descEditor);
184
+
185
+		return $descEditor;
186
+	}
187
+
188
+	/**
189
+	 * @param string $fieldname
190
+	 * @param string $table
191
+	 * @return bool
192
+	 */
193
+	public static function fieldExists(string $fieldname, string $table): bool
194
+	{
195
+		global $xoopsDB;
196
+		$result = $xoopsDB->queryF("SHOW COLUMNS FROM   $table LIKE '$fieldname'");
197
+
198
+		return ($xoopsDB->getRowsNum($result) > 0);
199
+	}
200
+
201
+	/**
202
+	 * @param array|string $tableName
203
+	 * @param int          $id_field
204
+	 * @param int          $id
205
+	 *
206
+	 * @return mixed
207
+	 */
208
+	public static function cloneRecord($tableName, $id_field, $id)
209
+	{
210
+		$new_id = false;
211
+		$table  = $GLOBALS['xoopsDB']->prefix($tableName);
212
+		// copy content of the record you wish to clone
213
+		$sql    = "SELECT * FROM $table WHERE $idField='" . $id . "' ";
214
+		$result = $GLOBALS['xoopsDB']->query($sql);
215
+		if ($result instanceof \mysqli_result) {
216
+			$tempTable = $GLOBALS['xoopsDB']->fetchArray($result, \MYSQLI_ASSOC);
217
+		}
218
+		if (!$tempTable) {
219
+			\trigger_error($GLOBALS['xoopsDB']->error());
220
+		}
221
+		// set the auto-incremented id's value to blank.
222
+		unset($tempTable[$id_field]);
223
+		// insert cloned copy of the original  record
224
+		$sql    = "INSERT INTO $table (" . \implode(', ', \array_keys($tempTable)) . ") VALUES ('" . \implode("', '", $tempTable) . "')";
225
+		$result = $GLOBALS['xoopsDB']->queryF($sql);
226
+		if (!$result) {
227
+			\trigger_error($GLOBALS['xoopsDB']->error());
228
+		}
229
+		// Return the new id
230
+		$new_id = $GLOBALS['xoopsDB']->getInsertId();
231
+
232
+		return $new_id;
233
+	}
234
+
235
+	/**
236
+	 * @param string $tablename
237
+	 *
238
+	 * @return bool
239
+	 */
240
+	public static function tableExists($tablename): bool
241
+	{
242
+		$result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'");
243
+
244
+		return $GLOBALS['xoopsDB']->getRowsNum($result) > 0;
245
+	}
246 246
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
     {
60 60
         if ($considerHtml) {
61 61
             // if the plain text is shorter than the maximum length, return the whole text
62
-            if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
62
+            if (mb_strlen(\preg_replace('/<.*?'.'>/', '', $text)) <= $length) {
63 63
                 return $text;
64 64
             }
65 65
             // splits all html-tags to scanable lines
66
-            \preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER);
66
+            \preg_match_all('/(<.+?'.'>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER);
67 67
             $total_length = mb_strlen($ending);
68 68
             $open_tags    = [];
69 69
             $truncate     = '';
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
                             unset($open_tags[$pos]);
82 82
                         }
83 83
                         // if tag is an opening tag
84
-                    } elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) {
84
+                    } elseif (\preg_match('/^<\s*([^\s>!]+).*?'.'>$/s', $line_matchings[1], $tag_matchings)) {
85 85
                         // add tag to the beginning of $open_tags list
86 86
                         \array_unshift($open_tags, \mb_strtolower($tag_matchings[1]));
87 87
                     }
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
                 }
91 91
                 // calculate the length of the plain text part of the line; handle entities as one character
92 92
                 $content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
93
-                if ($total_length + $content_length > $length) {
93
+                if ($total_length+$content_length > $length) {
94 94
                     // the number of characters which are left
95
-                    $left            = $length - $total_length;
95
+                    $left            = $length-$total_length;
96 96
                     $entities_length = 0;
97 97
                     // search for html entities
98 98
                     if (\preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) {
99 99
                         // calculate the real length of all entities in the legal range
100 100
                         foreach ($entities[0] as $entity) {
101
-                            if ($left >= $entity[1] + 1 - $entities_length) {
101
+                            if ($left >= $entity[1]+1-$entities_length) {
102 102
                                 $left--;
103 103
                                 $entities_length += mb_strlen($entity[0]);
104 104
                             } else {
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                             }
108 108
                         }
109 109
                     }
110
-                    $truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length);
110
+                    $truncate .= mb_substr($line_matchings[2], 0, $left+$entities_length);
111 111
                     // maximum lenght is reached, so get off the loop
112 112
                     break;
113 113
                 }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             if (mb_strlen($text) <= $length) {
124 124
                 return $text;
125 125
             }
126
-            $truncate = mb_substr($text, 0, $length - mb_strlen($ending));
126
+            $truncate = mb_substr($text, 0, $length-mb_strlen($ending));
127 127
         }
128 128
         // if the words shouldn't be cut in the middle...
129 129
         if (!$exact) {
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         if ($considerHtml) {
140 140
             // close all unclosed html-tags
141 141
             foreach ($open_tags as $tag) {
142
-                $truncate .= '</' . $tag . '>';
142
+                $truncate .= '</'.$tag.'>';
143 143
             }
144 144
         }
145 145
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         $new_id = false;
211 211
         $table  = $GLOBALS['xoopsDB']->prefix($tableName);
212 212
         // copy content of the record you wish to clone
213
-        $sql    = "SELECT * FROM $table WHERE $idField='" . $id . "' ";
213
+        $sql    = "SELECT * FROM $table WHERE $idField='".$id."' ";
214 214
         $result = $GLOBALS['xoopsDB']->query($sql);
215 215
         if ($result instanceof \mysqli_result) {
216 216
             $tempTable = $GLOBALS['xoopsDB']->fetchArray($result, \MYSQLI_ASSOC);
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
         // set the auto-incremented id's value to blank.
222 222
         unset($tempTable[$id_field]);
223 223
         // insert cloned copy of the original  record
224
-        $sql    = "INSERT INTO $table (" . \implode(', ', \array_keys($tempTable)) . ") VALUES ('" . \implode("', '", $tempTable) . "')";
224
+        $sql    = "INSERT INTO $table (".\implode(', ', \array_keys($tempTable)).") VALUES ('".\implode("', '", $tempTable)."')";
225 225
         $result = $GLOBALS['xoopsDB']->queryF($sql);
226 226
         if (!$result) {
227 227
             \trigger_error($GLOBALS['xoopsDB']->error());
Please login to merge, or discard this patch.
testdata/index.php 2 patches
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 use Xmf\Request;
22 22
 use Xmf\Yaml;
23 23
 use XoopsModules\Myiframe\{
24
-    Helper,
25
-    Common\Configurator,
26
-    Utility
24
+	Helper,
25
+	Common\Configurator,
26
+	Utility
27 27
 };
28 28
 
29 29
 /** @var Helper $helper */
@@ -43,33 +43,33 @@  discard block
 block discarded – undo
43 43
 $helper->loadLanguage('common');
44 44
 
45 45
 switch ($op) {
46
-    case 'load':
47
-        if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0)) {
48
-            if (!$GLOBALS['xoopsSecurity']->check()) {
49
-                \redirect_header($helper->url('admin/index.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
50
-            }
51
-            loadSampleData();
52
-        } else {
53
-            xoops_cp_header();
54
-            xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_CONFIRM')), \constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true);
55
-            xoops_cp_footer();
56
-        }
57
-        break;
58
-    case 'save':
59
-        saveSampleData();
60
-        break;
61
-    case 'clear':
62
-        if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0)) {
63
-            if (!$GLOBALS['xoopsSecurity']->check()) {
64
-                redirect_header($helper->url('admin/index.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
65
-            }
66
-            clearSampleData();
67
-        } else {
68
-            xoops_cp_header();
69
-            xoops_confirm(['ok' => 1, 'op' => 'clear'], 'index.php', sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA')), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true);
70
-            xoops_cp_footer();
71
-        }
72
-        break;
46
+	case 'load':
47
+		if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0)) {
48
+			if (!$GLOBALS['xoopsSecurity']->check()) {
49
+				\redirect_header($helper->url('admin/index.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
50
+			}
51
+			loadSampleData();
52
+		} else {
53
+			xoops_cp_header();
54
+			xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_CONFIRM')), \constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true);
55
+			xoops_cp_footer();
56
+		}
57
+		break;
58
+	case 'save':
59
+		saveSampleData();
60
+		break;
61
+	case 'clear':
62
+		if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0)) {
63
+			if (!$GLOBALS['xoopsSecurity']->check()) {
64
+				redirect_header($helper->url('admin/index.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
65
+			}
66
+			clearSampleData();
67
+		} else {
68
+			xoops_cp_header();
69
+			xoops_confirm(['ok' => 1, 'op' => 'clear'], 'index.php', sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA')), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true);
70
+			xoops_cp_footer();
71
+		}
72
+		break;
73 73
 }
74 74
 
75 75
 // XMF TableLoad for SAMPLE data
@@ -79,47 +79,47 @@  discard block
 block discarded – undo
79 79
  */
80 80
 function loadSampleData()
81 81
 {
82
-    global $xoopsConfig;
83
-    $moduleDirName      = \basename(\dirname(__DIR__));
84
-    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
85
-
86
-    $utility      = new Utility();
87
-    $configurator = new Configurator();
88
-
89
-    $tables = \Xmf\Module\Helper::getHelper($moduleDirName)
90
-                                ->getModule()
91
-                                ->getInfo('tables');
92
-
93
-    $language = 'english/';
94
-    if (\is_dir(__DIR__ . '/' . $xoopsConfig['language'])) {
95
-        $language = $xoopsConfig['language'] . '/';
96
-    }
97
-
98
-    // load module tables
99
-    foreach ($tables as $table) {
100
-        $tabledata = Yaml::readWrapped($language . $table . '.yml');
101
-        TableLoad::truncateTable($table);
102
-        TableLoad::loadTableFromArray($table, $tabledata);
103
-    }
104
-
105
-    // load permissions
106
-    $table     = 'group_permission';
107
-    $tabledata = Yaml::readWrapped($language . $table . '.yml');
108
-    $mid       = \Xmf\Module\Helper::getHelper($moduleDirName)
109
-                                   ->getModule()
110
-                                   ->getVar('mid');
111
-    loadTableFromArrayWithReplace($table, $tabledata, 'gperm_modid', $mid);
112
-
113
-    //  ---  COPY test folder files ---------------
114
-    if (\is_array($configurator->copyTestFolders) && \count($configurator->copyTestFolders) > 0) {
115
-        //        $file =  dirname(__DIR__) . '/testdata/images/';
116
-        foreach (\array_keys($configurator->copyTestFolders) as $i) {
117
-            $src  = $configurator->copyTestFolders[$i][0];
118
-            $dest = $configurator->copyTestFolders[$i][1];
119
-            $utility::rcopy($src, $dest);
120
-        }
121
-    }
122
-    \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_SUCCESS'));
82
+	global $xoopsConfig;
83
+	$moduleDirName      = \basename(\dirname(__DIR__));
84
+	$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
85
+
86
+	$utility      = new Utility();
87
+	$configurator = new Configurator();
88
+
89
+	$tables = \Xmf\Module\Helper::getHelper($moduleDirName)
90
+								->getModule()
91
+								->getInfo('tables');
92
+
93
+	$language = 'english/';
94
+	if (\is_dir(__DIR__ . '/' . $xoopsConfig['language'])) {
95
+		$language = $xoopsConfig['language'] . '/';
96
+	}
97
+
98
+	// load module tables
99
+	foreach ($tables as $table) {
100
+		$tabledata = Yaml::readWrapped($language . $table . '.yml');
101
+		TableLoad::truncateTable($table);
102
+		TableLoad::loadTableFromArray($table, $tabledata);
103
+	}
104
+
105
+	// load permissions
106
+	$table     = 'group_permission';
107
+	$tabledata = Yaml::readWrapped($language . $table . '.yml');
108
+	$mid       = \Xmf\Module\Helper::getHelper($moduleDirName)
109
+								   ->getModule()
110
+								   ->getVar('mid');
111
+	loadTableFromArrayWithReplace($table, $tabledata, 'gperm_modid', $mid);
112
+
113
+	//  ---  COPY test folder files ---------------
114
+	if (\is_array($configurator->copyTestFolders) && \count($configurator->copyTestFolders) > 0) {
115
+		//        $file =  dirname(__DIR__) . '/testdata/images/';
116
+		foreach (\array_keys($configurator->copyTestFolders) as $i) {
117
+			$src  = $configurator->copyTestFolders[$i][0];
118
+			$dest = $configurator->copyTestFolders[$i][1];
119
+			$utility::rcopy($src, $dest);
120
+		}
121
+	}
122
+	\redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_SUCCESS'));
123 123
 }
124 124
 
125 125
 /**
@@ -127,38 +127,38 @@  discard block
 block discarded – undo
127 127
  */
128 128
 function saveSampleData()
129 129
 {
130
-    global $xoopsConfig;
131
-    $moduleDirName      = \basename(\dirname(__DIR__));
132
-    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
133
-    $helper             = Helper::getInstance();
134
-    $tables             = $helper->getModule()
135
-                                 ->getInfo('tables');
136
-
137
-    $languageFolder = __DIR__ . '/' . $xoopsConfig['language'];
138
-    if (!\file_exists($languageFolder . '/')) {
139
-        Utility::createFolder($languageFolder . '/');
140
-    }
141
-    $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/';
142
-    Utility::createFolder($exportFolder);
143
-
144
-    // save module tables
145
-    foreach ($tables as $table) {
146
-        TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml');
147
-    }
148
-
149
-    // save permissions
150
-    $criteria = new \CriteriaCompo();
151
-    $criteria->add(
152
-        new \Criteria(
153
-            'gperm_modid', $helper->getModule()
154
-                                  ->getVar('mid')
155
-        )
156
-    );
157
-    $skipColumns[] = 'gperm_id';
158
-    TableLoad::saveTableToYamlFile('group_permission', $exportFolder . 'group_permission.yml', $criteria, $skipColumns);
159
-    unset($criteria);
160
-
161
-    \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS'));
130
+	global $xoopsConfig;
131
+	$moduleDirName      = \basename(\dirname(__DIR__));
132
+	$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
133
+	$helper             = Helper::getInstance();
134
+	$tables             = $helper->getModule()
135
+								 ->getInfo('tables');
136
+
137
+	$languageFolder = __DIR__ . '/' . $xoopsConfig['language'];
138
+	if (!\file_exists($languageFolder . '/')) {
139
+		Utility::createFolder($languageFolder . '/');
140
+	}
141
+	$exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/';
142
+	Utility::createFolder($exportFolder);
143
+
144
+	// save module tables
145
+	foreach ($tables as $table) {
146
+		TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml');
147
+	}
148
+
149
+	// save permissions
150
+	$criteria = new \CriteriaCompo();
151
+	$criteria->add(
152
+		new \Criteria(
153
+			'gperm_modid', $helper->getModule()
154
+								  ->getVar('mid')
155
+		)
156
+	);
157
+	$skipColumns[] = 'gperm_id';
158
+	TableLoad::saveTableToYamlFile('group_permission', $exportFolder . 'group_permission.yml', $criteria, $skipColumns);
159
+	unset($criteria);
160
+
161
+	\redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS'));
162 162
 }
163 163
 
164 164
 /**
@@ -166,18 +166,18 @@  discard block
 block discarded – undo
166 166
  */
167 167
 function exportSchema()
168 168
 {
169
-    $moduleDirName      = \basename(\dirname(__DIR__));
170
-    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
171
-
172
-    try {
173
-        // TODO set exportSchema
174
-        //        $migrate = new Migrate($moduleDirName);
175
-        //        $migrate->saveCurrentSchema();
176
-        //
177
-        //        redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS'));
178
-    } catch (\Throwable $e) {
179
-        exit(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR'));
180
-    }
169
+	$moduleDirName      = \basename(\dirname(__DIR__));
170
+	$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
171
+
172
+	try {
173
+		// TODO set exportSchema
174
+		//        $migrate = new Migrate($moduleDirName);
175
+		//        $migrate->saveCurrentSchema();
176
+		//
177
+		//        redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS'));
178
+	} catch (\Throwable $e) {
179
+		exit(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR'));
180
+	}
181 181
 }
182 182
 
183 183
 /**
@@ -194,46 +194,46 @@  discard block
 block discarded – undo
194 194
  */
195 195
 function loadTableFromArrayWithReplace($table, $data, $search, $replace)
196 196
 {
197
-    /** @var \XoopsMySQLDatabase $db */
198
-    $db = \XoopsDatabaseFactory::getDatabaseConnection();
199
-
200
-    $prefixedTable = $db->prefix($table);
201
-    $count         = 0;
202
-
203
-    $sql = 'DELETE FROM ' . $prefixedTable . ' WHERE `' . $search . '`=' . $db->quote($replace);
204
-
205
-    $result = $db->queryF($sql);
206
-
207
-    if ($result) {
208
-        foreach ($data as $row) {
209
-            $insertInto  = 'INSERT INTO ' . $prefixedTable . ' (';
210
-            $valueClause = ' VALUES (';
211
-            $first       = true;
212
-            foreach ($row as $column => $value) {
213
-                if ($first) {
214
-                    $first = false;
215
-                } else {
216
-                    $insertInto  .= ', ';
217
-                    $valueClause .= ', ';
218
-                }
219
-
220
-                $insertInto .= $column;
221
-                if ($search === $column) {
222
-                    $valueClause .= $db->quote($replace);
223
-                } else {
224
-                    $valueClause .= $db->quote($value);
225
-                }
226
-            }
227
-
228
-            $sql = $insertInto . ') ' . $valueClause . ')';
229
-
230
-            $result = $db->queryF($sql);
231
-            if (false !== $result) {
232
-                ++$count;
233
-            }
234
-        }
235
-    }
236
-    return $count;
197
+	/** @var \XoopsMySQLDatabase $db */
198
+	$db = \XoopsDatabaseFactory::getDatabaseConnection();
199
+
200
+	$prefixedTable = $db->prefix($table);
201
+	$count         = 0;
202
+
203
+	$sql = 'DELETE FROM ' . $prefixedTable . ' WHERE `' . $search . '`=' . $db->quote($replace);
204
+
205
+	$result = $db->queryF($sql);
206
+
207
+	if ($result) {
208
+		foreach ($data as $row) {
209
+			$insertInto  = 'INSERT INTO ' . $prefixedTable . ' (';
210
+			$valueClause = ' VALUES (';
211
+			$first       = true;
212
+			foreach ($row as $column => $value) {
213
+				if ($first) {
214
+					$first = false;
215
+				} else {
216
+					$insertInto  .= ', ';
217
+					$valueClause .= ', ';
218
+				}
219
+
220
+				$insertInto .= $column;
221
+				if ($search === $column) {
222
+					$valueClause .= $db->quote($replace);
223
+				} else {
224
+					$valueClause .= $db->quote($value);
225
+				}
226
+			}
227
+
228
+			$sql = $insertInto . ') ' . $valueClause . ')';
229
+
230
+			$result = $db->queryF($sql);
231
+			if (false !== $result) {
232
+				++$count;
233
+			}
234
+		}
235
+	}
236
+	return $count;
237 237
 }
238 238
 
239 239
 /**
@@ -241,16 +241,16 @@  discard block
 block discarded – undo
241 241
  */
242 242
 function clearSampleData()
243 243
 {
244
-    $moduleDirName      = \basename(\dirname(__DIR__));
245
-    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
246
-    $helper             = Helper::getInstance();
247
-    // Load language files
248
-    $helper->loadLanguage('common');
249
-    $tables = $helper->getModule()
250
-                     ->getInfo('tables');
251
-    // truncate module tables
252
-    foreach ($tables as $table) {
253
-        \Xmf\Database\TableLoad::truncateTable($table);
254
-    }
255
-    redirect_header($helper->url('admin/index.php'), 1, constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_OK'));
244
+	$moduleDirName      = \basename(\dirname(__DIR__));
245
+	$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
246
+	$helper             = Helper::getInstance();
247
+	// Load language files
248
+	$helper->loadLanguage('common');
249
+	$tables = $helper->getModule()
250
+					 ->getInfo('tables');
251
+	// truncate module tables
252
+	foreach ($tables as $table) {
253
+		\Xmf\Database\TableLoad::truncateTable($table);
254
+	}
255
+	redirect_header($helper->url('admin/index.php'), 1, constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_OK'));
256 256
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 /** @var Utility $utility */
31 31
 /** @var Configurator $configurator */
32 32
 
33
-require_once dirname(__DIR__, 3) . '/include/cp_header.php';
34
-require \dirname(__DIR__) . '/preloads/autoloader.php';
33
+require_once dirname(__DIR__, 3).'/include/cp_header.php';
34
+require \dirname(__DIR__).'/preloads/autoloader.php';
35 35
 
36 36
 $op = Request::getCmd('op', '');
37 37
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             loadSampleData();
52 52
         } else {
53 53
             xoops_cp_header();
54
-            xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_CONFIRM')), \constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true);
54
+            xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', \sprintf(\constant('CO_'.$moduleDirNameUpper.'_'.'LOAD_SAMPLEDATA_CONFIRM')), \constant('CO_'.$moduleDirNameUpper.'_'.'CONFIRM'), true);
55 55
             xoops_cp_footer();
56 56
         }
57 57
         break;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             clearSampleData();
67 67
         } else {
68 68
             xoops_cp_header();
69
-            xoops_confirm(['ok' => 1, 'op' => 'clear'], 'index.php', sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA')), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true);
69
+            xoops_confirm(['ok' => 1, 'op' => 'clear'], 'index.php', sprintf(constant('CO_'.$moduleDirNameUpper.'_'.'CLEAR_SAMPLEDATA')), constant('CO_'.$moduleDirNameUpper.'_'.'CONFIRM'), true);
70 70
             xoops_cp_footer();
71 71
         }
72 72
         break;
@@ -91,20 +91,20 @@  discard block
 block discarded – undo
91 91
                                 ->getInfo('tables');
92 92
 
93 93
     $language = 'english/';
94
-    if (\is_dir(__DIR__ . '/' . $xoopsConfig['language'])) {
95
-        $language = $xoopsConfig['language'] . '/';
94
+    if (\is_dir(__DIR__.'/'.$xoopsConfig['language'])) {
95
+        $language = $xoopsConfig['language'].'/';
96 96
     }
97 97
 
98 98
     // load module tables
99 99
     foreach ($tables as $table) {
100
-        $tabledata = Yaml::readWrapped($language . $table . '.yml');
100
+        $tabledata = Yaml::readWrapped($language.$table.'.yml');
101 101
         TableLoad::truncateTable($table);
102 102
         TableLoad::loadTableFromArray($table, $tabledata);
103 103
     }
104 104
 
105 105
     // load permissions
106 106
     $table     = 'group_permission';
107
-    $tabledata = Yaml::readWrapped($language . $table . '.yml');
107
+    $tabledata = Yaml::readWrapped($language.$table.'.yml');
108 108
     $mid       = \Xmf\Module\Helper::getHelper($moduleDirName)
109 109
                                    ->getModule()
110 110
                                    ->getVar('mid');
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
             $utility::rcopy($src, $dest);
120 120
         }
121 121
     }
122
-    \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_SUCCESS'));
122
+    \redirect_header('../admin/index.php', 1, \constant('CO_'.$moduleDirNameUpper.'_'.'LOAD_SAMPLEDATA_SUCCESS'));
123 123
 }
124 124
 
125 125
 /**
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
     $tables             = $helper->getModule()
135 135
                                  ->getInfo('tables');
136 136
 
137
-    $languageFolder = __DIR__ . '/' . $xoopsConfig['language'];
138
-    if (!\file_exists($languageFolder . '/')) {
139
-        Utility::createFolder($languageFolder . '/');
137
+    $languageFolder = __DIR__.'/'.$xoopsConfig['language'];
138
+    if (!\file_exists($languageFolder.'/')) {
139
+        Utility::createFolder($languageFolder.'/');
140 140
     }
141
-    $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/';
141
+    $exportFolder = $languageFolder.'/Exports-'.date('Y-m-d-H-i-s').'/';
142 142
     Utility::createFolder($exportFolder);
143 143
 
144 144
     // save module tables
145 145
     foreach ($tables as $table) {
146
-        TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml');
146
+        TableLoad::saveTableToYamlFile($table, $exportFolder.$table.'.yml');
147 147
     }
148 148
 
149 149
     // save permissions
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
         )
156 156
     );
157 157
     $skipColumns[] = 'gperm_id';
158
-    TableLoad::saveTableToYamlFile('group_permission', $exportFolder . 'group_permission.yml', $criteria, $skipColumns);
158
+    TableLoad::saveTableToYamlFile('group_permission', $exportFolder.'group_permission.yml', $criteria, $skipColumns);
159 159
     unset($criteria);
160 160
 
161
-    \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS'));
161
+    \redirect_header('../admin/index.php', 1, \constant('CO_'.$moduleDirNameUpper.'_'.'SAVE_SAMPLEDATA_SUCCESS'));
162 162
 }
163 163
 
164 164
 /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         //
177 177
         //        redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS'));
178 178
     } catch (\Throwable $e) {
179
-        exit(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR'));
179
+        exit(constant('CO_'.$moduleDirNameUpper.'_'.'EXPORT_SCHEMA_ERROR'));
180 180
     }
181 181
 }
182 182
 
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
     $prefixedTable = $db->prefix($table);
201 201
     $count         = 0;
202 202
 
203
-    $sql = 'DELETE FROM ' . $prefixedTable . ' WHERE `' . $search . '`=' . $db->quote($replace);
203
+    $sql = 'DELETE FROM '.$prefixedTable.' WHERE `'.$search.'`='.$db->quote($replace);
204 204
 
205 205
     $result = $db->queryF($sql);
206 206
 
207 207
     if ($result) {
208 208
         foreach ($data as $row) {
209
-            $insertInto  = 'INSERT INTO ' . $prefixedTable . ' (';
209
+            $insertInto  = 'INSERT INTO '.$prefixedTable.' (';
210 210
             $valueClause = ' VALUES (';
211 211
             $first       = true;
212 212
             foreach ($row as $column => $value) {
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
                 }
226 226
             }
227 227
 
228
-            $sql = $insertInto . ') ' . $valueClause . ')';
228
+            $sql = $insertInto.') '.$valueClause.')';
229 229
 
230 230
             $result = $db->queryF($sql);
231 231
             if (false !== $result) {
@@ -252,5 +252,5 @@  discard block
 block discarded – undo
252 252
     foreach ($tables as $table) {
253 253
         \Xmf\Database\TableLoad::truncateTable($table);
254 254
     }
255
-    redirect_header($helper->url('admin/index.php'), 1, constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA_OK'));
255
+    redirect_header($helper->url('admin/index.php'), 1, constant('CO_'.$moduleDirNameUpper.'_'.'CLEAR_SAMPLEDATA_OK'));
256 256
 }
Please login to merge, or discard this patch.