Completed
Push — master ( d19713...8239ac )
by Michael
05:12
created
comment_new.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@
 block discarded – undo
7 7
 
8 8
 $com_itemid = Request::getInt('com_itemid', 0, 'GET');
9 9
 if ($com_itemid > 0) {
10
-    $itemObj       = $publisher->getHandler('item')->get($com_itemid);
11
-    $com_replytext = _POSTEDBY . '&nbsp;<strong>' . $itemObj->getLinkedPosterName() . '</strong>&nbsp;' . _DATE . '&nbsp;<strong>' . $itemObj->dateSub() . '</strong><br><br>' . $itemObj->summary();
12
-    $bodytext      = $itemObj->body();
13
-    if ('' != $bodytext) {
14
-        $com_replytext .= '<br><br>' . $bodytext . '';
15
-    }
16
-    $com_replytitle = $itemObj->getTitle();
17
-    include_once $GLOBALS['xoops']->path('include/comment_new.php');
10
+	$itemObj       = $publisher->getHandler('item')->get($com_itemid);
11
+	$com_replytext = _POSTEDBY . '&nbsp;<strong>' . $itemObj->getLinkedPosterName() . '</strong>&nbsp;' . _DATE . '&nbsp;<strong>' . $itemObj->dateSub() . '</strong><br><br>' . $itemObj->summary();
12
+	$bodytext      = $itemObj->body();
13
+	if ('' != $bodytext) {
14
+		$com_replytext .= '<br><br>' . $bodytext . '';
15
+	}
16
+	$com_replytitle = $itemObj->getTitle();
17
+	include_once $GLOBALS['xoops']->path('include/comment_new.php');
18 18
 }
Please login to merge, or discard this patch.
admin/admin_header.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -8,27 +8,27 @@
 block discarded – undo
8 8
 $myts = MyTextSanitizer::getInstance();
9 9
 
10 10
 if ($xoopsUser) {
11
-    $modulepermHandler = xoops_getHandler('groupperm');
12
-    if (!$modulepermHandler->checkRight('module_admin', $xoopsModule->getVar('mid'), $xoopsUser->getGroups())) {
13
-        redirect_header(XOOPS_URL, 1, _NOPERM);
14
-        exit();
15
-    }
11
+	$modulepermHandler = xoops_getHandler('groupperm');
12
+	if (!$modulepermHandler->checkRight('module_admin', $xoopsModule->getVar('mid'), $xoopsUser->getGroups())) {
13
+		redirect_header(XOOPS_URL, 1, _NOPERM);
14
+		exit();
15
+	}
16 16
 } else {
17
-    redirect_header(XOOPS_URL . '/user.php', 1, _NOPERM);
18
-    exit();
17
+	redirect_header(XOOPS_URL . '/user.php', 1, _NOPERM);
18
+	exit();
19 19
 }
20 20
 
21 21
 /** @var Xmf\Module\Helper $moduleHelper */
22 22
 if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) {
23 23
 } else {
24
-    $moduleHelper = Xmf\Module\Helper::getHelper('system');
24
+	$moduleHelper = Xmf\Module\Helper::getHelper('system');
25 25
 }
26 26
 /** @var Xmf\Module\Admin $adminObject */
27 27
 $adminObject = \Xmf\Module\Admin::getInstance();
28 28
 
29 29
 if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) {
30
-    require_once $GLOBALS['xoops']->path('class/template.php');
31
-    $xoopsTpl = new XoopsTpl();
30
+	require_once $GLOBALS['xoops']->path('class/template.php');
31
+	$xoopsTpl = new XoopsTpl();
32 32
 }
33 33
 
34 34
 $pathIcon16    = Xmf\Module\Admin::iconUrl('', 16);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 if ($xoopsUser) {
11 11
     $modulepermHandler = xoops_getHandler('groupperm');
12
-    if (!$modulepermHandler->checkRight('module_admin', $xoopsModule->getVar('mid'), $xoopsUser->getGroups())) {
12
+    if ( ! $modulepermHandler->checkRight('module_admin', $xoopsModule->getVar('mid'), $xoopsUser->getGroups())) {
13 13
         redirect_header(XOOPS_URL, 1, _NOPERM);
14 14
         exit();
15 15
     }
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 /** @var Xmf\Module\Admin $adminObject */
27 27
 $adminObject = \Xmf\Module\Admin::getInstance();
28 28
 
29
-if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) {
29
+if ( ! isset($GLOBALS['xoopsTpl']) || ! ($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) {
30 30
     require_once $GLOBALS['xoops']->path('class/template.php');
31 31
     $xoopsTpl = new XoopsTpl();
32 32
 }
Please login to merge, or discard this patch.
admin/cat.php 2 patches
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -27,272 +27,272 @@
 block discarded – undo
27 27
 // Выбор
28 28
 switch ($op) {
29 29
 
30
-    case 'main':
31
-
32
-        // Подключаем трей
33
-        $moduleDirName = dirname(__DIR__);
34
-        include_once $moduleDirName . '/class/tree.php';
35
-        //include_once $GLOBALS['xoops']->path('modules/instruction/class/tree.php');
36
-
37
-        // Заголовок админки
38
-        xoops_cp_header();
39
-        // Навигация
40
-        $adminObject->displayNavigation(basename(__FILE__));
41
-
42
-        // Находим ID-категории => Число страниц
43
-        $cidinstrids = [];
44
-        $sql         = "SELECT `cid`, COUNT( `instrid` ) FROM {$insinstrHandler->table} GROUP BY `cid`";
45
-        $result      = $GLOBALS['xoopsDB']->query($sql);
46
-        while (list($cid, $count) = $GLOBALS['xoopsDB']->fetchRow($result)) {
47
-            // Заполняем массив
48
-            $cidinstrids[$cid] = $count;
49
-        }
50
-
51
-        // Выбираем категории из БД
52
-        $criteria = new CriteriaCompo();
53
-        $criteria->setSort('weight ASC, title');
54
-        $criteria->setOrder('ASC');
55
-        $ins_cat = $instructioncatHandler->getall($criteria);
56
-        unset($criteria);
57
-
58
-        // Инициализируем
59
-        $cattree = new InstructionTree($ins_cat, 'cid', 'pid');
60
-        // Выводим списко категорий в шаблон
61
-        $GLOBALS['xoopsTpl']->assign('insListCat', $cattree->makeCatsAdmin('--', $cidinstrids));
62
-
63
-        // Создание новой категории
64
-        $objInstructioncat = $instructioncatHandler->create();
65
-        $form              = $objInstructioncat->getForm('cat.php');
66
-        // Форма
67
-        $GLOBALS['xoopsTpl']->assign('insFormCat', $form->render());
68
-        // Выводим шаблон
69
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_cat.tpl');
70
-
71
-        // Текст внизу админки
72
-        include __DIR__ . '/admin_footer.php';
73
-        // Подвал админки
74
-        xoops_cp_footer();
75
-
76
-        break;
77
-
78
-    // Редактирование категории
79
-    case 'editcat':
80
-
81
-        // Заголовок админки
82
-        xoops_cp_header();
83
-        // Навигация
84
-        $adminObject->displayNavigation(basename(__FILE__));
85
-
86
-        $objInstructioncat = $instructioncatHandler->get($cid);
87
-        $form              = $objInstructioncat->getForm('cat.php');
88
-        // Форма
89
-        //$GLOBALS['xoopsTpl']->assign( 'insFormCat', $form->render() );
90
-        echo $form->render();
91
-        // Выводим шаблон
92
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editcat.tpl');
93
-
94
-        // Текст внизу админки
95
-        include __DIR__ . '/admin_footer.php';
96
-        // Подвал админки
97
-        xoops_cp_footer();
98
-
99
-        break;
100
-
101
-    // Сохранение категорий
102
-    case 'savecat':
103
-
104
-        // Проверка
105
-        if (!$GLOBALS['xoopsSecurity']->check()) {
106
-            redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
107
-        }
108
-        // Если мы редактируем
109
-        if ($cid) {
110
-            $objInstructioncat = $instructioncatHandler->get($cid);
111
-        } else {
112
-            $objInstructioncat = $instructioncatHandler->create();
113
-            // Указываем дату создания
114
-            $objInstructioncat->setVar('datecreated', $time);
115
-        }
116
-
117
-        $err         = false;
118
-        $message_err = '';
119
-
120
-        // Дата обновления
121
-        $objInstructioncat->setVar('dateupdated', $time);
122
-        $objInstructioncat->setVar('pid', $pid);
123
-        $objInstructioncat->setVar('title', $_POST['title']);
124
-        $objInstructioncat->setVar('description', $_POST['description']);
125
-        $objInstructioncat->setVar('weight', $weight);
126
-        $objInstructioncat->setVar('metakeywords', $_POST['metakeywords']);
127
-        $objInstructioncat->setVar('metadescription', $_POST['metadescription']);
128
-
129
-        // Проверка веса
130
-        if (0 == $weight) {
131
-            $err         = true;
132
-            $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>';
133
-        }
134
-        // Проверка категорий
135
-        if ($cid && ($cid == $pid)) {
136
-            $err         = true;
137
-            $message_err .= _AM_INSTRUCTION_ERR_PCAT . '<br>';
138
-        }
139
-        // Если были ошибки
140
-        if (true === $err) {
141
-            xoops_cp_header();
142
-            // Навигация
143
-            $adminObject->displayNavigation(basename(__FILE__));
144
-
145
-            $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
146
-            // Выводим ошибки в шаблон
147
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
148
-            // Если небыло ошибок
149
-        } else {
150
-            // Вставляем данные в БД
151
-            if ($instructioncatHandler->insert($objInstructioncat)) {
152
-
153
-                // ID категории. Если редактируем - то не изменяется. Если создаём новую - то получаем ID созданной записи.
154
-                $new_cid = $cid ?: $objInstructioncat->get_new_enreg();
155
-
156
-                // ===============
157
-                // ==== Права ====
158
-                // ===============
159
-
160
-                $gpermHandler = xoops_getHandler('groupperm');
161
-
162
-                // Если мы редактируем категорию, то старые права нужно удалить
163
-                if ($cid) {
164
-                    // Права на просмотр
165
-                    $criteria = new CriteriaCompo();
166
-                    $criteria->add(new Criteria('gperm_itemid', $new_cid, '='));
167
-                    $criteria->add(new Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '='));
168
-                    $criteria->add(new Criteria('gperm_name', 'instruction_view', '='));
169
-                    $gpermHandler->deleteAll($criteria);
170
-                    // Права на добавление
171
-                    $criteria = new CriteriaCompo();
172
-                    $criteria->add(new Criteria('gperm_itemid', $new_cid, '='));
173
-                    $criteria->add(new Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '='));
174
-                    $criteria->add(new Criteria('gperm_name', 'instruction_submit', '='));
175
-                    $gpermHandler->deleteAll($criteria);
176
-                    // Права на редактирование
177
-                    $criteria = new CriteriaCompo();
178
-                    $criteria->add(new Criteria('gperm_itemid', $new_cid, '='));
179
-                    $criteria->add(new Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '='));
180
-                    $criteria->add(new Criteria('gperm_name', 'instruction_edit', '='));
181
-                    $gpermHandler->deleteAll($criteria);
182
-                }
183
-
184
-                // Добавляем права
185
-                // Права на просмотр
186
-                if (isset($_POST['groups_instr_view'])) {
187
-                    foreach ($_POST['groups_instr_view'] as $onegroup_id) {
188
-                        $gpermHandler->addRight('instruction_view', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid'));
189
-                    }
190
-                }
191
-                // Права на добавление
192
-                if (isset($_POST['groups_instr_submit'])) {
193
-                    foreach ($_POST['groups_instr_submit'] as $onegroup_id) {
194
-                        $gpermHandler->addRight('instruction_submit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid'));
195
-                    }
196
-                }
197
-                // Права на редактирование
198
-                if (isset($_POST['groups_instr_edit'])) {
199
-                    foreach ($_POST['groups_instr_edit'] as $onegroup_id) {
200
-                        $gpermHandler->addRight('instruction_edit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid'));
201
-                    }
202
-                }
203
-
204
-                //
205
-                redirect_header('cat.php', 3, _AM_INSTRUCTION_NEWCATADDED);
206
-            }
207
-            xoops_cp_header();
208
-            // Навигация
209
-            $adminObject->displayNavigation(basename(__FILE__));
210
-            // Выводим ошибки в шаблон
211
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors());
212
-        }
213
-        // Выводим шаблон
214
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savecat.tpl');
215
-        // Выводим форму
216
-        $form = $objInstructioncat->getForm();
217
-        // Форма
218
-        echo $form->render();
219
-        // Текст внизу админки
220
-        include __DIR__ . '/admin_footer.php';
221
-        // Подвал админки
222
-        xoops_cp_footer();
223
-
224
-        break;
225
-
226
-    // Удаление категории
227
-    case 'delcat':
228
-
229
-        // Находим число инструкций в данной категории
230
-        // Критерий выборки
231
-        $criteria = new CriteriaCompo();
232
-        // Все инструкции в данной категории
233
-        $criteria->add(new Criteria('cid', $cid, '='));
234
-        $numrows = $insinstrHandler->getCount($criteria);
235
-        //
236
-        unset($criteria);
237
-        // Если есть хоть одна инструкция
238
-        if ($numrows) {
239
-            redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTEMPTY);
240
-        }
241
-
242
-        $objInscat = $instructioncatHandler->get($cid);
243
-        // Если нет такой категории
244
-        if (!is_object($objInscat)) {
245
-            redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT);
246
-        }
247
-
248
-        // Нельзя удалять пока есть доченрии категории
249
-        // Подключаем трей
250
-        include_once $GLOBALS['xoops']->path('class/tree.php');
251
-        $inscat_arr   = $instructioncatHandler->getall();
252
-        $mytree       = new XoopsObjectTree($inscat_arr, 'cid', 'pid');
253
-        $ins_childcat = $mytree->getAllChild($cid);
254
-        // Если есть дочернии категории
255
-        if (count($ins_childcat)) {
256
-            redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATCHILDREN);
257
-        }
258
-
259
-        // Нажали ли мы на кнопку OK
260
-        $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
261
-        // Если мы нажали на кнопку
262
-        if ($ok) {
263
-
264
-            // Проверка
265
-            if (!$GLOBALS['xoopsSecurity']->check()) {
266
-                redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
267
-            }
268
-            // Пытаемся удалить категорию
269
-            if ($instructioncatHandler->delete($objInscat)) {
270
-
271
-                // Удалить права доступа к категории
272
-                // =================================
273
-
274
-                // Редирект
275
-                redirect_header('cat.php', 3, _AM_INSTRUCTION_CATDELETED);
276
-                // Если не смогли удалить категорию
277
-            } else {
278
-                // Редирект
279
-                redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_DELCAT);
280
-            }
281
-        } else {
282
-
283
-            // Заголовок админки
284
-            xoops_cp_header();
285
-            // Навигация
286
-            $adminObject->displayNavigation(basename(__FILE__));
287
-
288
-            xoops_confirm(['ok' => 1, 'cid' => $cid, 'op' => 'delcat'], 'cat.php', sprintf(_AM_INSTRUCTION_FORMDELCAT, $objInscat->getVar('title')));
289
-
290
-            // Текст внизу админки
291
-            include __DIR__ . '/admin_footer.php';
292
-            // Подвал админки
293
-            xoops_cp_footer();
294
-        }
295
-
296
-        break;
30
+	case 'main':
31
+
32
+		// Подключаем трей
33
+		$moduleDirName = dirname(__DIR__);
34
+		include_once $moduleDirName . '/class/tree.php';
35
+		//include_once $GLOBALS['xoops']->path('modules/instruction/class/tree.php');
36
+
37
+		// Заголовок админки
38
+		xoops_cp_header();
39
+		// Навигация
40
+		$adminObject->displayNavigation(basename(__FILE__));
41
+
42
+		// Находим ID-категории => Число страниц
43
+		$cidinstrids = [];
44
+		$sql         = "SELECT `cid`, COUNT( `instrid` ) FROM {$insinstrHandler->table} GROUP BY `cid`";
45
+		$result      = $GLOBALS['xoopsDB']->query($sql);
46
+		while (list($cid, $count) = $GLOBALS['xoopsDB']->fetchRow($result)) {
47
+			// Заполняем массив
48
+			$cidinstrids[$cid] = $count;
49
+		}
50
+
51
+		// Выбираем категории из БД
52
+		$criteria = new CriteriaCompo();
53
+		$criteria->setSort('weight ASC, title');
54
+		$criteria->setOrder('ASC');
55
+		$ins_cat = $instructioncatHandler->getall($criteria);
56
+		unset($criteria);
57
+
58
+		// Инициализируем
59
+		$cattree = new InstructionTree($ins_cat, 'cid', 'pid');
60
+		// Выводим списко категорий в шаблон
61
+		$GLOBALS['xoopsTpl']->assign('insListCat', $cattree->makeCatsAdmin('--', $cidinstrids));
62
+
63
+		// Создание новой категории
64
+		$objInstructioncat = $instructioncatHandler->create();
65
+		$form              = $objInstructioncat->getForm('cat.php');
66
+		// Форма
67
+		$GLOBALS['xoopsTpl']->assign('insFormCat', $form->render());
68
+		// Выводим шаблон
69
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_cat.tpl');
70
+
71
+		// Текст внизу админки
72
+		include __DIR__ . '/admin_footer.php';
73
+		// Подвал админки
74
+		xoops_cp_footer();
75
+
76
+		break;
77
+
78
+	// Редактирование категории
79
+	case 'editcat':
80
+
81
+		// Заголовок админки
82
+		xoops_cp_header();
83
+		// Навигация
84
+		$adminObject->displayNavigation(basename(__FILE__));
85
+
86
+		$objInstructioncat = $instructioncatHandler->get($cid);
87
+		$form              = $objInstructioncat->getForm('cat.php');
88
+		// Форма
89
+		//$GLOBALS['xoopsTpl']->assign( 'insFormCat', $form->render() );
90
+		echo $form->render();
91
+		// Выводим шаблон
92
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editcat.tpl');
93
+
94
+		// Текст внизу админки
95
+		include __DIR__ . '/admin_footer.php';
96
+		// Подвал админки
97
+		xoops_cp_footer();
98
+
99
+		break;
100
+
101
+	// Сохранение категорий
102
+	case 'savecat':
103
+
104
+		// Проверка
105
+		if (!$GLOBALS['xoopsSecurity']->check()) {
106
+			redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
107
+		}
108
+		// Если мы редактируем
109
+		if ($cid) {
110
+			$objInstructioncat = $instructioncatHandler->get($cid);
111
+		} else {
112
+			$objInstructioncat = $instructioncatHandler->create();
113
+			// Указываем дату создания
114
+			$objInstructioncat->setVar('datecreated', $time);
115
+		}
116
+
117
+		$err         = false;
118
+		$message_err = '';
119
+
120
+		// Дата обновления
121
+		$objInstructioncat->setVar('dateupdated', $time);
122
+		$objInstructioncat->setVar('pid', $pid);
123
+		$objInstructioncat->setVar('title', $_POST['title']);
124
+		$objInstructioncat->setVar('description', $_POST['description']);
125
+		$objInstructioncat->setVar('weight', $weight);
126
+		$objInstructioncat->setVar('metakeywords', $_POST['metakeywords']);
127
+		$objInstructioncat->setVar('metadescription', $_POST['metadescription']);
128
+
129
+		// Проверка веса
130
+		if (0 == $weight) {
131
+			$err         = true;
132
+			$message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>';
133
+		}
134
+		// Проверка категорий
135
+		if ($cid && ($cid == $pid)) {
136
+			$err         = true;
137
+			$message_err .= _AM_INSTRUCTION_ERR_PCAT . '<br>';
138
+		}
139
+		// Если были ошибки
140
+		if (true === $err) {
141
+			xoops_cp_header();
142
+			// Навигация
143
+			$adminObject->displayNavigation(basename(__FILE__));
144
+
145
+			$message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
146
+			// Выводим ошибки в шаблон
147
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
148
+			// Если небыло ошибок
149
+		} else {
150
+			// Вставляем данные в БД
151
+			if ($instructioncatHandler->insert($objInstructioncat)) {
152
+
153
+				// ID категории. Если редактируем - то не изменяется. Если создаём новую - то получаем ID созданной записи.
154
+				$new_cid = $cid ?: $objInstructioncat->get_new_enreg();
155
+
156
+				// ===============
157
+				// ==== Права ====
158
+				// ===============
159
+
160
+				$gpermHandler = xoops_getHandler('groupperm');
161
+
162
+				// Если мы редактируем категорию, то старые права нужно удалить
163
+				if ($cid) {
164
+					// Права на просмотр
165
+					$criteria = new CriteriaCompo();
166
+					$criteria->add(new Criteria('gperm_itemid', $new_cid, '='));
167
+					$criteria->add(new Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '='));
168
+					$criteria->add(new Criteria('gperm_name', 'instruction_view', '='));
169
+					$gpermHandler->deleteAll($criteria);
170
+					// Права на добавление
171
+					$criteria = new CriteriaCompo();
172
+					$criteria->add(new Criteria('gperm_itemid', $new_cid, '='));
173
+					$criteria->add(new Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '='));
174
+					$criteria->add(new Criteria('gperm_name', 'instruction_submit', '='));
175
+					$gpermHandler->deleteAll($criteria);
176
+					// Права на редактирование
177
+					$criteria = new CriteriaCompo();
178
+					$criteria->add(new Criteria('gperm_itemid', $new_cid, '='));
179
+					$criteria->add(new Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '='));
180
+					$criteria->add(new Criteria('gperm_name', 'instruction_edit', '='));
181
+					$gpermHandler->deleteAll($criteria);
182
+				}
183
+
184
+				// Добавляем права
185
+				// Права на просмотр
186
+				if (isset($_POST['groups_instr_view'])) {
187
+					foreach ($_POST['groups_instr_view'] as $onegroup_id) {
188
+						$gpermHandler->addRight('instruction_view', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid'));
189
+					}
190
+				}
191
+				// Права на добавление
192
+				if (isset($_POST['groups_instr_submit'])) {
193
+					foreach ($_POST['groups_instr_submit'] as $onegroup_id) {
194
+						$gpermHandler->addRight('instruction_submit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid'));
195
+					}
196
+				}
197
+				// Права на редактирование
198
+				if (isset($_POST['groups_instr_edit'])) {
199
+					foreach ($_POST['groups_instr_edit'] as $onegroup_id) {
200
+						$gpermHandler->addRight('instruction_edit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid'));
201
+					}
202
+				}
203
+
204
+				//
205
+				redirect_header('cat.php', 3, _AM_INSTRUCTION_NEWCATADDED);
206
+			}
207
+			xoops_cp_header();
208
+			// Навигация
209
+			$adminObject->displayNavigation(basename(__FILE__));
210
+			// Выводим ошибки в шаблон
211
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors());
212
+		}
213
+		// Выводим шаблон
214
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savecat.tpl');
215
+		// Выводим форму
216
+		$form = $objInstructioncat->getForm();
217
+		// Форма
218
+		echo $form->render();
219
+		// Текст внизу админки
220
+		include __DIR__ . '/admin_footer.php';
221
+		// Подвал админки
222
+		xoops_cp_footer();
223
+
224
+		break;
225
+
226
+	// Удаление категории
227
+	case 'delcat':
228
+
229
+		// Находим число инструкций в данной категории
230
+		// Критерий выборки
231
+		$criteria = new CriteriaCompo();
232
+		// Все инструкции в данной категории
233
+		$criteria->add(new Criteria('cid', $cid, '='));
234
+		$numrows = $insinstrHandler->getCount($criteria);
235
+		//
236
+		unset($criteria);
237
+		// Если есть хоть одна инструкция
238
+		if ($numrows) {
239
+			redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTEMPTY);
240
+		}
241
+
242
+		$objInscat = $instructioncatHandler->get($cid);
243
+		// Если нет такой категории
244
+		if (!is_object($objInscat)) {
245
+			redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT);
246
+		}
247
+
248
+		// Нельзя удалять пока есть доченрии категории
249
+		// Подключаем трей
250
+		include_once $GLOBALS['xoops']->path('class/tree.php');
251
+		$inscat_arr   = $instructioncatHandler->getall();
252
+		$mytree       = new XoopsObjectTree($inscat_arr, 'cid', 'pid');
253
+		$ins_childcat = $mytree->getAllChild($cid);
254
+		// Если есть дочернии категории
255
+		if (count($ins_childcat)) {
256
+			redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATCHILDREN);
257
+		}
258
+
259
+		// Нажали ли мы на кнопку OK
260
+		$ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
261
+		// Если мы нажали на кнопку
262
+		if ($ok) {
263
+
264
+			// Проверка
265
+			if (!$GLOBALS['xoopsSecurity']->check()) {
266
+				redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
267
+			}
268
+			// Пытаемся удалить категорию
269
+			if ($instructioncatHandler->delete($objInscat)) {
270
+
271
+				// Удалить права доступа к категории
272
+				// =================================
273
+
274
+				// Редирект
275
+				redirect_header('cat.php', 3, _AM_INSTRUCTION_CATDELETED);
276
+				// Если не смогли удалить категорию
277
+			} else {
278
+				// Редирект
279
+				redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_DELCAT);
280
+			}
281
+		} else {
282
+
283
+			// Заголовок админки
284
+			xoops_cp_header();
285
+			// Навигация
286
+			$adminObject->displayNavigation(basename(__FILE__));
287
+
288
+			xoops_confirm(['ok' => 1, 'cid' => $cid, 'op' => 'delcat'], 'cat.php', sprintf(_AM_INSTRUCTION_FORMDELCAT, $objInscat->getVar('title')));
289
+
290
+			// Текст внизу админки
291
+			include __DIR__ . '/admin_footer.php';
292
+			// Подвал админки
293
+			xoops_cp_footer();
294
+		}
295
+
296
+		break;
297 297
 
298 298
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     case 'savecat':
103 103
 
104 104
         // Проверка
105
-        if (!$GLOBALS['xoopsSecurity']->check()) {
105
+        if ( ! $GLOBALS['xoopsSecurity']->check()) {
106 106
             redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
107 107
         }
108 108
         // Если мы редактируем
@@ -128,12 +128,12 @@  discard block
 block discarded – undo
128 128
 
129 129
         // Проверка веса
130 130
         if (0 == $weight) {
131
-            $err         = true;
131
+            $err = true;
132 132
             $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>';
133 133
         }
134 134
         // Проверка категорий
135 135
         if ($cid && ($cid == $pid)) {
136
-            $err         = true;
136
+            $err = true;
137 137
             $message_err .= _AM_INSTRUCTION_ERR_PCAT . '<br>';
138 138
         }
139 139
         // Если были ошибки
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
         $objInscat = $instructioncatHandler->get($cid);
243 243
         // Если нет такой категории
244
-        if (!is_object($objInscat)) {
244
+        if ( ! is_object($objInscat)) {
245 245
             redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT);
246 246
         }
247 247
 
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
         }
258 258
 
259 259
         // Нажали ли мы на кнопку OK
260
-        $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
260
+        $ok = isset($_POST['ok']) ? (int) $_POST['ok'] : 0;
261 261
         // Если мы нажали на кнопку
262 262
         if ($ok) {
263 263
 
264 264
             // Проверка
265
-            if (!$GLOBALS['xoopsSecurity']->check()) {
265
+            if ( ! $GLOBALS['xoopsSecurity']->check()) {
266 266
                 redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
267 267
             }
268 268
             // Пытаемся удалить категорию
Please login to merge, or discard this patch.
admin/menu.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (!isset($moduleDirName)) {
4
-    $moduleDirName = basename(dirname(__DIR__));
4
+	$moduleDirName = basename(dirname(__DIR__));
5 5
 }
6 6
 
7 7
 if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) {
8 8
 } else {
9
-    $moduleHelper = Xmf\Module\Helper::getHelper('system');
9
+	$moduleHelper = Xmf\Module\Helper::getHelper('system');
10 10
 }
11 11
 
12 12
 $pathIcon32    = \Xmf\Module\Admin::menuIconPath('');
@@ -17,34 +17,34 @@  discard block
 block discarded – undo
17 17
 
18 18
 // Административное меню
19 19
 $adminmenu = [
20
-    [
21
-        'title' => _MI_INSTRUCTION_ADMIN_HOME,
22
-        'link'  => 'admin/index.php',
23
-        'desc'  => _MI_INSTRUCTION_ADMIN_HOME_DESC,
24
-        'icon'  => $pathIcon32 . '/home.png'
25
-    ],
26
-    [
27
-        'title' => _MI_INSTRUCTION_ADMIN_CAT,
28
-        'link'  => 'admin/cat.php',
29
-        'desc'  => _MI_INSTRUCTION_ADMIN_CAT_DESC,
30
-        'icon'  => $pathIcon32 . '/category.png'
31
-    ],
32
-    [
33
-        'title' => _MI_INSTRUCTION_ADMIN_INSTR,
34
-        'link'  => 'admin/instr.php',
35
-        'desc'  => _MI_INSTRUCTION_ADMIN_INSTR_DESC,
36
-        'icon'  => $pathModIcon32 . '/nav_book.png'
37
-    ],
38
-    [
39
-        'title' => _MI_INSTRUCTION_ADMIN_PERM,
40
-        'link'  => 'admin/perm.php',
41
-        'desc'  => _MI_INSTRUCTION_ADMIN_PERM_DESC,
42
-        'icon'  => $pathIcon32 . '/permissions.png'
43
-    ],
44
-    [
45
-        'title' => _MI_INSTRUCTION_ADMIN_ABOUT,
46
-        'link'  => 'admin/about.php',
47
-        'desc'  => _MI_INSTRUCTION_ADMIN_ABOUT_DESC,
48
-        'icon'  => $pathIcon32 . '/about.png'
49
-    ]
20
+	[
21
+		'title' => _MI_INSTRUCTION_ADMIN_HOME,
22
+		'link'  => 'admin/index.php',
23
+		'desc'  => _MI_INSTRUCTION_ADMIN_HOME_DESC,
24
+		'icon'  => $pathIcon32 . '/home.png'
25
+	],
26
+	[
27
+		'title' => _MI_INSTRUCTION_ADMIN_CAT,
28
+		'link'  => 'admin/cat.php',
29
+		'desc'  => _MI_INSTRUCTION_ADMIN_CAT_DESC,
30
+		'icon'  => $pathIcon32 . '/category.png'
31
+	],
32
+	[
33
+		'title' => _MI_INSTRUCTION_ADMIN_INSTR,
34
+		'link'  => 'admin/instr.php',
35
+		'desc'  => _MI_INSTRUCTION_ADMIN_INSTR_DESC,
36
+		'icon'  => $pathModIcon32 . '/nav_book.png'
37
+	],
38
+	[
39
+		'title' => _MI_INSTRUCTION_ADMIN_PERM,
40
+		'link'  => 'admin/perm.php',
41
+		'desc'  => _MI_INSTRUCTION_ADMIN_PERM_DESC,
42
+		'icon'  => $pathIcon32 . '/permissions.png'
43
+	],
44
+	[
45
+		'title' => _MI_INSTRUCTION_ADMIN_ABOUT,
46
+		'link'  => 'admin/about.php',
47
+		'desc'  => _MI_INSTRUCTION_ADMIN_ABOUT_DESC,
48
+		'icon'  => $pathIcon32 . '/about.png'
49
+	]
50 50
 ];
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!isset($moduleDirName)) {
3
+if ( ! isset($moduleDirName)) {
4 4
     $moduleDirName = basename(dirname(__DIR__));
5 5
 }
6 6
 
Please login to merge, or discard this patch.
admin/perm.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -36,24 +36,24 @@  discard block
 block discarded – undo
36 36
 $moduleId = $GLOBALS['xoopsModule']->getVar('mid');
37 37
 
38 38
 switch ($permission) {
39
-    // Права на просмотр
40
-    case 1:
41
-        $formTitle             = _AM_INSTRUCTION_PERM_VIEW;
42
-        $permissionName        = 'instruction_view';
43
-        $permissionDescription = _AM_INSTRUCTION_PERM_VIEW_DSC;
44
-        break;
45
-    // Права на добавление
46
-    case 2:
47
-        $formTitle             = _AM_INSTRUCTION_PERM_SUBMIT;
48
-        $permissionName        = 'instruction_submit';
49
-        $permissionDescription = _AM_INSTRUCTION_PERM_SUBMIT_DSC;
50
-        break;
51
-    // Права на редактирование
52
-    case 3:
53
-        $formTitle             = _AM_INSTRUCTION_PERM_EDIT;
54
-        $permissionName        = 'instruction_edit';
55
-        $permissionDescription = _AM_INSTRUCTION_PERM_EDIT_DSC;
56
-        break;
39
+	// Права на просмотр
40
+	case 1:
41
+		$formTitle             = _AM_INSTRUCTION_PERM_VIEW;
42
+		$permissionName        = 'instruction_view';
43
+		$permissionDescription = _AM_INSTRUCTION_PERM_VIEW_DSC;
44
+		break;
45
+	// Права на добавление
46
+	case 2:
47
+		$formTitle             = _AM_INSTRUCTION_PERM_SUBMIT;
48
+		$permissionName        = 'instruction_submit';
49
+		$permissionDescription = _AM_INSTRUCTION_PERM_SUBMIT_DSC;
50
+		break;
51
+	// Права на редактирование
52
+	case 3:
53
+		$formTitle             = _AM_INSTRUCTION_PERM_EDIT;
54
+		$permissionName        = 'instruction_edit';
55
+		$permissionDescription = _AM_INSTRUCTION_PERM_EDIT_DSC;
56
+		break;
57 57
 }
58 58
 
59 59
 // Права
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
 $sql    = 'SELECT cid, pid, title FROM ' . $xoopsDB->prefix('instruction_cat') . ' ORDER BY title';
63 63
 $result = $xoopsDB->query($sql);
64 64
 if ($result) {
65
-    while ($row = $xoopsDB->fetchArray($result)) {
66
-        $permissionsForm->addItem($row['cid'], $row['title'], $row['pid']);
67
-    }
65
+	while ($row = $xoopsDB->fetchArray($result)) {
66
+		$permissionsForm->addItem($row['cid'], $row['title'], $row['pid']);
67
+	}
68 68
 }
69 69
 
70 70
 echo $permissionsForm->render();
Please login to merge, or discard this patch.
admin/ajax.php 2 patches
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -19,178 +19,178 @@
 block discarded – undo
19 19
 
20 20
 // Выбор
21 21
 switch ($op) {
22
-    // Сохранение страницы
23
-    case 'savepage':
24
-        // Выходной массив
25
-        $ret = [];
22
+	// Сохранение страницы
23
+	case 'savepage':
24
+		// Выходной массив
25
+		$ret = [];
26 26
 
27
-        // Ошибки
28
-        $err         = false;
29
-        $message_err = '';
27
+		// Ошибки
28
+		$err         = false;
29
+		$message_err = '';
30 30
 
31
-        //
32
-        $title       = InstructionUtility::cleanVars($_POST, 'title', '', 'string');
33
-        $pid         = InstructionUtility::cleanVars($_POST, 'pid', 0, 'int');
34
-        $weight      = InstructionUtility::cleanVars($_POST, 'weight', 0, 'int');
35
-        $hometext    = InstructionUtility::cleanVars($_POST, 'hometext', '', 'string');
36
-        $footnote    = InstructionUtility::cleanVars($_POST, 'footnote', '', 'string');
37
-        $status      = InstructionUtility::cleanVars($_POST, 'status', 0, 'int');
38
-        $type        = InstructionUtility::cleanVars($_POST, 'type', 0, 'int');
39
-        $keywords    = InstructionUtility::cleanVars($_POST, 'keywords', '', 'string');
40
-        $description = InstructionUtility::cleanVars($_POST, 'description', '', 'string');
41
-        $dosmiley    = (isset($_POST['dosmiley']) && (int)$_POST['dosmiley'] > 0) ? 1 : 0;
42
-        $doxcode     = (isset($_POST['doxcode']) && (int)$_POST['doxcode'] > 0) ? 1 : 0;
43
-        $dobr        = (isset($_POST['dobr']) && (int)$_POST['dobr'] > 0) ? 1 : 0;
44
-        $dohtml      = (isset($_POST['dohtml']) && (int)$_POST['dohtml'] > 0) ? 1 : 0;
45
-        //$dohtml      = InstructionUtility::cleanVars( $_POST, 'dohtml', 0, 'int' );
46
-        //$dosmiley    = InstructionUtility::cleanVars( $_POST, 'dosmiley', 0, 'int' );
47
-        //$doxcode     = InstructionUtility::cleanVars( $_POST, 'doxcode', 0, 'int' );
48
-        //$dobr        = InstructionUtility::cleanVars( $_POST, 'dobr', 0, 'int' );
49
-        $pageid  = InstructionUtility::cleanVars($_POST, 'pageid', 0, 'int');
50
-        $instrid = InstructionUtility::cleanVars($_POST, 'instrid', 0, 'int');
31
+		//
32
+		$title       = InstructionUtility::cleanVars($_POST, 'title', '', 'string');
33
+		$pid         = InstructionUtility::cleanVars($_POST, 'pid', 0, 'int');
34
+		$weight      = InstructionUtility::cleanVars($_POST, 'weight', 0, 'int');
35
+		$hometext    = InstructionUtility::cleanVars($_POST, 'hometext', '', 'string');
36
+		$footnote    = InstructionUtility::cleanVars($_POST, 'footnote', '', 'string');
37
+		$status      = InstructionUtility::cleanVars($_POST, 'status', 0, 'int');
38
+		$type        = InstructionUtility::cleanVars($_POST, 'type', 0, 'int');
39
+		$keywords    = InstructionUtility::cleanVars($_POST, 'keywords', '', 'string');
40
+		$description = InstructionUtility::cleanVars($_POST, 'description', '', 'string');
41
+		$dosmiley    = (isset($_POST['dosmiley']) && (int)$_POST['dosmiley'] > 0) ? 1 : 0;
42
+		$doxcode     = (isset($_POST['doxcode']) && (int)$_POST['doxcode'] > 0) ? 1 : 0;
43
+		$dobr        = (isset($_POST['dobr']) && (int)$_POST['dobr'] > 0) ? 1 : 0;
44
+		$dohtml      = (isset($_POST['dohtml']) && (int)$_POST['dohtml'] > 0) ? 1 : 0;
45
+		//$dohtml      = InstructionUtility::cleanVars( $_POST, 'dohtml', 0, 'int' );
46
+		//$dosmiley    = InstructionUtility::cleanVars( $_POST, 'dosmiley', 0, 'int' );
47
+		//$doxcode     = InstructionUtility::cleanVars( $_POST, 'doxcode', 0, 'int' );
48
+		//$dobr        = InstructionUtility::cleanVars( $_POST, 'dobr', 0, 'int' );
49
+		$pageid  = InstructionUtility::cleanVars($_POST, 'pageid', 0, 'int');
50
+		$instrid = InstructionUtility::cleanVars($_POST, 'instrid', 0, 'int');
51 51
 
52
-        // Проверка
53
-        if (!$GLOBALS['xoopsSecurity']->check()) {
54
-            $err         = true;
55
-            $err_txt     = implode(', ', $GLOBALS['xoopsSecurity']->getErrors());
56
-            $message_err .= $err_txt . '<br>' . _AM_INSTR_TRY_AGAIN . '<br>';
57
-        }
58
-        // =========================
59
-        // Устанавливаем новый token
60
-        $token_name    = 'XOOPS_TOKEN';
61
-        $token_timeout = 0;
62
-        // $token_name . '_REQUEST' - название элемента формы
63
-        $ret['toket'] = $GLOBALS['xoopsSecurity']->createToken($token_timeout, $token_name);
64
-        // =========================
52
+		// Проверка
53
+		if (!$GLOBALS['xoopsSecurity']->check()) {
54
+			$err         = true;
55
+			$err_txt     = implode(', ', $GLOBALS['xoopsSecurity']->getErrors());
56
+			$message_err .= $err_txt . '<br>' . _AM_INSTR_TRY_AGAIN . '<br>';
57
+		}
58
+		// =========================
59
+		// Устанавливаем новый token
60
+		$token_name    = 'XOOPS_TOKEN';
61
+		$token_timeout = 0;
62
+		// $token_name . '_REQUEST' - название элемента формы
63
+		$ret['toket'] = $GLOBALS['xoopsSecurity']->createToken($token_timeout, $token_name);
64
+		// =========================
65 65
 
66
-        // Если мы редактируем
67
-        if ($pageid) {
68
-            $objInspage = $inspageHandler->get($pageid);
69
-        } elseif ($instrid) {
70
-            $objInspage = $inspageHandler->create();
71
-            // Если мы создаём страницу необходимо указать к какой инструкции
72
-            $objInspage->setVar('instrid', $instrid);
73
-            // Указываем дату создания
74
-            $objInspage->setVar('datecreated', $time);
75
-            // Указываем пользователя
76
-            $objInspage->setVar('uid', $uid);
77
-        } else {
78
-            // Устанавливаем сообщение
79
-            $ret['message'] = _AM_INSTRUCTION_BADREQUEST;
80
-            // Возвращаем ответ скрипту через JSON
81
-            echo json_encode($ret);
82
-            // Прерываем выполнение
83
-            exit();
84
-        }
66
+		// Если мы редактируем
67
+		if ($pageid) {
68
+			$objInspage = $inspageHandler->get($pageid);
69
+		} elseif ($instrid) {
70
+			$objInspage = $inspageHandler->create();
71
+			// Если мы создаём страницу необходимо указать к какой инструкции
72
+			$objInspage->setVar('instrid', $instrid);
73
+			// Указываем дату создания
74
+			$objInspage->setVar('datecreated', $time);
75
+			// Указываем пользователя
76
+			$objInspage->setVar('uid', $uid);
77
+		} else {
78
+			// Устанавливаем сообщение
79
+			$ret['message'] = _AM_INSTRUCTION_BADREQUEST;
80
+			// Возвращаем ответ скрипту через JSON
81
+			echo json_encode($ret);
82
+			// Прерываем выполнение
83
+			exit();
84
+		}
85 85
 
86
-        // Родительская страница
87
-        $objInspage->setVar('pid', $pid);
88
-        // Дата обновления
89
-        $objInspage->setVar('dateupdated', $time);
90
-        // Название
91
-        $objInspage->setVar('title', $title);
92
-        // Вес
93
-        $objInspage->setVar('weight', $weight);
94
-        // Текст
95
-        $objInspage->setVar('hometext', $hometext);
96
-        // Сноска
97
-        $objInspage->setVar('footnote', $footnote);
98
-        // Статус
99
-        $objInspage->setVar('status', $status);
100
-        // Тип
101
-        $objInspage->setVar('type', $type);
102
-        // Мета-теги ключевых слов
103
-        $objInspage->setVar('keywords', $keywords);
104
-        // Мета-теги описания
105
-        $objInspage->setVar('description', $description);
106
-        //
107
-        $objInspage->setVar('dohtml', $dohtml);
108
-        $objInspage->setVar('dosmiley', $dosmiley);
109
-        $objInspage->setVar('doxcode', $doxcode);
110
-        $objInspage->setVar('dobr', $dobr);
86
+		// Родительская страница
87
+		$objInspage->setVar('pid', $pid);
88
+		// Дата обновления
89
+		$objInspage->setVar('dateupdated', $time);
90
+		// Название
91
+		$objInspage->setVar('title', $title);
92
+		// Вес
93
+		$objInspage->setVar('weight', $weight);
94
+		// Текст
95
+		$objInspage->setVar('hometext', $hometext);
96
+		// Сноска
97
+		$objInspage->setVar('footnote', $footnote);
98
+		// Статус
99
+		$objInspage->setVar('status', $status);
100
+		// Тип
101
+		$objInspage->setVar('type', $type);
102
+		// Мета-теги ключевых слов
103
+		$objInspage->setVar('keywords', $keywords);
104
+		// Мета-теги описания
105
+		$objInspage->setVar('description', $description);
106
+		//
107
+		$objInspage->setVar('dohtml', $dohtml);
108
+		$objInspage->setVar('dosmiley', $dosmiley);
109
+		$objInspage->setVar('doxcode', $doxcode);
110
+		$objInspage->setVar('dobr', $dobr);
111 111
 
112
-        // Проверка категорий
113
-        if (!$pageid && !$instrid) {
114
-            $err         = true;
115
-            $message_err .= _AM_INSTRUCTION_ERR_INSTR . '<br>';
116
-        }
117
-        // Проверка веса
118
-        if (0 == $weight) {
119
-            $err         = true;
120
-            $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>';
121
-        }
122
-        // Проверка родительской страницы
123
-        if ($pageid && ($pageid == $pid)) {
124
-            $err         = true;
125
-            $message_err .= _AM_INSTRUCTION_ERR_PPAGE . '<br>';
126
-        }
127
-        // Проверка названия
128
-        if (!$title) {
129
-            $err         = true;
130
-            $message_err .= _AM_INSTR_ERR_TITLE . '<br>';
131
-        }
132
-        // Проверка основного текста
133
-        if (!$hometext) {
134
-            $err         = true;
135
-            $message_err .= _AM_INSTR_ERR_HOMETEXT . '<br>';
136
-        }
112
+		// Проверка категорий
113
+		if (!$pageid && !$instrid) {
114
+			$err         = true;
115
+			$message_err .= _AM_INSTRUCTION_ERR_INSTR . '<br>';
116
+		}
117
+		// Проверка веса
118
+		if (0 == $weight) {
119
+			$err         = true;
120
+			$message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>';
121
+		}
122
+		// Проверка родительской страницы
123
+		if ($pageid && ($pageid == $pid)) {
124
+			$err         = true;
125
+			$message_err .= _AM_INSTRUCTION_ERR_PPAGE . '<br>';
126
+		}
127
+		// Проверка названия
128
+		if (!$title) {
129
+			$err         = true;
130
+			$message_err .= _AM_INSTR_ERR_TITLE . '<br>';
131
+		}
132
+		// Проверка основного текста
133
+		if (!$hometext) {
134
+			$err         = true;
135
+			$message_err .= _AM_INSTR_ERR_HOMETEXT . '<br>';
136
+		}
137 137
 
138
-        // Если были ошибки
139
-        if (true === $err) {
140
-            //
141
-            $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
142
-            // Устанавливаем сообщение
143
-            $ret['message'] = $message_err;
144
-            // Возвращаем ответ скрипту через JSON
145
-            echo json_encode($ret);
146
-            // Прерываем выполнение
147
-            exit();
148
-            // Если небыло ошибок
149
-        } else {
150
-            // Вставляем данные в БД
151
-            if ($inspageHandler->insert($objInspage)) {
152
-                // Находим ID созданной записи
153
-                $pageid_new = $pageid ?: $objInspage->get_new_enreg();
154
-                //
155
-                $ret['pageid'] = $pageid_new;
156
-                // Получаем ID инструкции
157
-                $instrid = $objInspage->getInstrid();
158
-                // Обновляем в инструкции число страниц и дату
159
-                $insinstrHandler->updatePages($instrid);
160
-                // Если мы редактируем
161
-                if ($pageid) {
162
-                    // Устанавливаем сообщение
163
-                    $ret['message'] = '<div class="successMsg" style="text-align: left;">' . _AM_INSTRUCTION_PAGEMODIFY . '</div>';
164
-                    // Возвращаем ответ скрипту через JSON
165
-                    echo json_encode($ret);
166
-                    // Прерываем выполнение
167
-                    exit();
138
+		// Если были ошибки
139
+		if (true === $err) {
140
+			//
141
+			$message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
142
+			// Устанавливаем сообщение
143
+			$ret['message'] = $message_err;
144
+			// Возвращаем ответ скрипту через JSON
145
+			echo json_encode($ret);
146
+			// Прерываем выполнение
147
+			exit();
148
+			// Если небыло ошибок
149
+		} else {
150
+			// Вставляем данные в БД
151
+			if ($inspageHandler->insert($objInspage)) {
152
+				// Находим ID созданной записи
153
+				$pageid_new = $pageid ?: $objInspage->get_new_enreg();
154
+				//
155
+				$ret['pageid'] = $pageid_new;
156
+				// Получаем ID инструкции
157
+				$instrid = $objInspage->getInstrid();
158
+				// Обновляем в инструкции число страниц и дату
159
+				$insinstrHandler->updatePages($instrid);
160
+				// Если мы редактируем
161
+				if ($pageid) {
162
+					// Устанавливаем сообщение
163
+					$ret['message'] = '<div class="successMsg" style="text-align: left;">' . _AM_INSTRUCTION_PAGEMODIFY . '</div>';
164
+					// Возвращаем ответ скрипту через JSON
165
+					echo json_encode($ret);
166
+					// Прерываем выполнение
167
+					exit();
168 168
 
169
-                    // Если мы добавляем
170
-                } else {
171
-                    // Инкримент комментов
172
-                    $inspageHandler->updateposts($uid, $status, 'add');
169
+					// Если мы добавляем
170
+				} else {
171
+					// Инкримент комментов
172
+					$inspageHandler->updateposts($uid, $status, 'add');
173 173
 
174
-                    // Устанавливаем сообщение
175
-                    $ret['message'] = '<div class="successMsg" style="text-align: left;">' . _AM_INSTRUCTION_PAGEADDED . '</div>';
176
-                    // Возвращаем ответ скрипту через JSON
177
-                    echo json_encode($ret);
178
-                    // Прерываем выполнение
179
-                    exit();
180
-                }
181
-                // Если не получилось вставить данные
182
-            } else {
174
+					// Устанавливаем сообщение
175
+					$ret['message'] = '<div class="successMsg" style="text-align: left;">' . _AM_INSTRUCTION_PAGEADDED . '</div>';
176
+					// Возвращаем ответ скрипту через JSON
177
+					echo json_encode($ret);
178
+					// Прерываем выполнение
179
+					exit();
180
+				}
181
+				// Если не получилось вставить данные
182
+			} else {
183 183
 
184
-                //
185
-                $message_err = '<div class="errorMsg" style="text-align: left;">' . $objInspage->getHtmlErrors() . '</div>';
186
-                // Устанавливаем сообщение
187
-                $ret['message'] = $message_err;
188
-                // Возвращаем ответ скрипту через JSON
189
-                echo json_encode($ret);
190
-                // Прерываем выполнение
191
-                exit();
192
-            }
193
-        }
184
+				//
185
+				$message_err = '<div class="errorMsg" style="text-align: left;">' . $objInspage->getHtmlErrors() . '</div>';
186
+				// Устанавливаем сообщение
187
+				$ret['message'] = $message_err;
188
+				// Возвращаем ответ скрипту через JSON
189
+				echo json_encode($ret);
190
+				// Прерываем выполнение
191
+				exit();
192
+			}
193
+		}
194 194
 
195
-        break;
195
+		break;
196 196
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
         $type        = InstructionUtility::cleanVars($_POST, 'type', 0, 'int');
39 39
         $keywords    = InstructionUtility::cleanVars($_POST, 'keywords', '', 'string');
40 40
         $description = InstructionUtility::cleanVars($_POST, 'description', '', 'string');
41
-        $dosmiley    = (isset($_POST['dosmiley']) && (int)$_POST['dosmiley'] > 0) ? 1 : 0;
42
-        $doxcode     = (isset($_POST['doxcode']) && (int)$_POST['doxcode'] > 0) ? 1 : 0;
43
-        $dobr        = (isset($_POST['dobr']) && (int)$_POST['dobr'] > 0) ? 1 : 0;
44
-        $dohtml      = (isset($_POST['dohtml']) && (int)$_POST['dohtml'] > 0) ? 1 : 0;
41
+        $dosmiley    = (isset($_POST['dosmiley']) && (int) $_POST['dosmiley'] > 0) ? 1 : 0;
42
+        $doxcode     = (isset($_POST['doxcode']) && (int) $_POST['doxcode'] > 0) ? 1 : 0;
43
+        $dobr        = (isset($_POST['dobr']) && (int) $_POST['dobr'] > 0) ? 1 : 0;
44
+        $dohtml      = (isset($_POST['dohtml']) && (int) $_POST['dohtml'] > 0) ? 1 : 0;
45 45
         //$dohtml      = InstructionUtility::cleanVars( $_POST, 'dohtml', 0, 'int' );
46 46
         //$dosmiley    = InstructionUtility::cleanVars( $_POST, 'dosmiley', 0, 'int' );
47 47
         //$doxcode     = InstructionUtility::cleanVars( $_POST, 'doxcode', 0, 'int' );
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         $instrid = InstructionUtility::cleanVars($_POST, 'instrid', 0, 'int');
51 51
 
52 52
         // Проверка
53
-        if (!$GLOBALS['xoopsSecurity']->check()) {
53
+        if ( ! $GLOBALS['xoopsSecurity']->check()) {
54 54
             $err         = true;
55 55
             $err_txt     = implode(', ', $GLOBALS['xoopsSecurity']->getErrors());
56 56
             $message_err .= $err_txt . '<br>' . _AM_INSTR_TRY_AGAIN . '<br>';
@@ -110,28 +110,28 @@  discard block
 block discarded – undo
110 110
         $objInspage->setVar('dobr', $dobr);
111 111
 
112 112
         // Проверка категорий
113
-        if (!$pageid && !$instrid) {
114
-            $err         = true;
113
+        if ( ! $pageid && ! $instrid) {
114
+            $err = true;
115 115
             $message_err .= _AM_INSTRUCTION_ERR_INSTR . '<br>';
116 116
         }
117 117
         // Проверка веса
118 118
         if (0 == $weight) {
119
-            $err         = true;
119
+            $err = true;
120 120
             $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>';
121 121
         }
122 122
         // Проверка родительской страницы
123 123
         if ($pageid && ($pageid == $pid)) {
124
-            $err         = true;
124
+            $err = true;
125 125
             $message_err .= _AM_INSTRUCTION_ERR_PPAGE . '<br>';
126 126
         }
127 127
         // Проверка названия
128
-        if (!$title) {
129
-            $err         = true;
128
+        if ( ! $title) {
129
+            $err = true;
130 130
             $message_err .= _AM_INSTR_ERR_TITLE . '<br>';
131 131
         }
132 132
         // Проверка основного текста
133
-        if (!$hometext) {
134
-            $err         = true;
133
+        if ( ! $hometext) {
134
+            $err = true;
135 135
             $message_err .= _AM_INSTR_ERR_HOMETEXT . '<br>';
136 136
         }
137 137
 
Please login to merge, or discard this patch.
admin/instr.php 2 patches
Indentation   +577 added lines, -577 removed lines patch added patch discarded remove patch
@@ -40,582 +40,582 @@
 block discarded – undo
40 40
 // Выбор
41 41
 switch ($op) {
42 42
 
43
-    case 'main':
44
-
45
-        // Заголовок админки
46
-        xoops_cp_header();
47
-        // Меню
48
-        $adminObject->displayNavigation(basename(__FILE__));
49
-        $adminObject->addItemButton(_AM_INSTRUCTION_ADDINSTR, 'instr.php?op=editinstr', 'add');
50
-        $adminObject->displayButton('left', '');
51
-
52
-        //
53
-        $criteria = new CriteriaCompo();
54
-
55
-        // Если была передана категория
56
-        if ($cid) {
57
-            // Добавляем в выборку ID категории
58
-            $criteria->add(new Criteria('cid', $cid, '='));
59
-            // Получаем объект категории
60
-            $objInscat = $inscatHandler->get($cid);
61
-            // Если нет такой категории
62
-            if (!is_object($objInscat)) {
63
-                redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT);
64
-            }
65
-        }
66
-
67
-        // Число инструкций, удовлетворяющих данному условию
68
-        $numrows = $insinstrHandler->getCount($criteria);
69
-
70
-        // Число выборки
71
-        $criteria->setLimit($limit);
72
-        // Начинасть с данного элемента
73
-        $criteria->setStart($start);
74
-        // Сортировать по
75
-        $criteria->setSort('instrid');
76
-        // Порядок сортировки
77
-        $criteria->setOrder('DESC');
78
-        // Находим все справки
79
-        $instr_arr = $insinstrHandler->getall($criteria);
80
-        // Если записей больше чем $limit, то выводим пагинатор
81
-        if ($numrows > $limit) {
82
-            $pagenav = new XoopsPageNav($numrows, $limit, $start, 'start', 'op=' . $op . '&amp;cid=' . $cid);
83
-            $pagenav = $pagenav->renderNav(4);
84
-        } else {
85
-            $pagenav = '';
86
-        }
87
-        // Выводим пагинатор в шаблон
88
-        $GLOBALS['xoopsTpl']->assign('insPagenav', $pagenav);
89
-
90
-        // Если есть записи
91
-        if ($numrows > 0) {
92
-            $class = 'odd';
93
-            foreach (array_keys($instr_arr) as $i) {
94
-
95
-                //
96
-                $class = ('even' === $class) ? 'odd' : 'even';
97
-                // ID
98
-                $insinstr_instrid = $instr_arr[$i]->getVar('instrid');
99
-                // Название
100
-                $insinstr_title = $instr_arr[$i]->getVar('title');
101
-                // Статус
102
-                $insinstr_status = $instr_arr[$i]->getVar('status');
103
-                // Количество страниц
104
-                $insinstr_pages = $instr_arr[$i]->getVar('pages');
105
-                // Категория
106
-                $insinstr_cat = $inscatHandler->get($instr_arr[$i]->getVar('cid'));
107
-
108
-                // Выводим в шаблон
109
-                $GLOBALS['xoopsTpl']->append('insListInstr', ['instrid' => $insinstr_instrid, 'title' => $insinstr_title, 'status' => $insinstr_status, 'pages' => $insinstr_pages, 'ctitle' => $insinstr_cat->getVar('title'), 'cid' => $insinstr_cat->getVar('cid'), 'class' => $class]);
110
-            }
111
-
112
-            //
113
-            $inshead = isset($objInscat) && is_object($objInscat) ? sprintf(_AM_INSTR_LISTINSTRINCAT, $objInscat->getVar('title')) : _AM_INSTR_LISTINSTRALL;
114
-            $GLOBALS['xoopsTpl']->assign('insHead', $inshead);
115
-            // Языковые константы
116
-            $GLOBALS['xoopsTpl']->assign('lang_title', _AM_INSTRUCTION_TITLE);
117
-            $GLOBALS['xoopsTpl']->assign('lang_cat', _AM_INSTRUCTION_CAT);
118
-            $GLOBALS['xoopsTpl']->assign('lang_pages', _AM_INSTRUCTION_PAGES);
119
-            $GLOBALS['xoopsTpl']->assign('lang_action', _AM_INSTRUCTION_ACTION);
120
-            $GLOBALS['xoopsTpl']->assign('lang_display', _AM_INSTRUCTION_DISPLAY);
121
-            $GLOBALS['xoopsTpl']->assign('lang_edit', _AM_INSTRUCTION_EDIT);
122
-            $GLOBALS['xoopsTpl']->assign('lang_del', _AM_INSTRUCTION_DEL);
123
-            $GLOBALS['xoopsTpl']->assign('lang_lock', _AM_INSTRUCTION_LOCK);
124
-            $GLOBALS['xoopsTpl']->assign('lang_unlock', _AM_INSTRUCTION_UNLOCK);
125
-            $GLOBALS['xoopsTpl']->assign('lang_addpage', _AM_INSTRUCTION_ADDPAGE);
126
-            $GLOBALS['xoopsTpl']->assign('lang_addinstr', _AM_INSTRUCTION_ADDINSTR);
127
-        }
128
-
129
-        // Выводим шаблон
130
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_instr.tpl');
131
-
132
-        // Текст внизу админки
133
-        include __DIR__ . '/admin_footer.php';
134
-        // Подвал админки
135
-        xoops_cp_footer();
136
-
137
-        break;
138
-
139
-    // Редактирование категории
140
-    case 'editinstr':
141
-
142
-        // Заголовок админки
143
-        xoops_cp_header();
144
-        // Меню
145
-        $adminObject->displayNavigation(basename(__FILE__));
146
-
147
-        // Если мы редактируем инструкцию
148
-        if ($instrid) {
149
-            $objInsinstr = $insinstrHandler->get($instrid);
150
-            // Создание новой страницы
151
-        } else {
152
-            $objInsinstr = $insinstrHandler->create();
153
-        }
154
-
155
-        // Выводим шаблон
156
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editinstr.tpl');
157
-        $form = $objInsinstr->getForm('instr.php');
158
-        // Форма
159
-        echo $form->render();
160
-
161
-        // Текст внизу админки
162
-        include __DIR__ . '/admin_footer.php';
163
-        // Подвал админки
164
-        xoops_cp_footer();
165
-
166
-        break;
167
-
168
-    // Сохранение инструкций
169
-    case 'saveinstr':
170
-
171
-        // Проверка
172
-        if (!$GLOBALS['xoopsSecurity']->check()) {
173
-            redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
174
-        }
175
-        // Если мы редактируем
176
-        if ($instrid) {
177
-            $objInsinstr = $insinstrHandler->get($instrid);
178
-        } else {
179
-            $objInsinstr = $insinstrHandler->create();
180
-            // Указываем дату создания
181
-            $objInsinstr->setVar('datecreated', $time);
182
-            // Указываем пользователя
183
-            $objInsinstr->setVar('uid', $uid);
184
-        }
185
-
186
-        $err         = false;
187
-        $message_err = '';
188
-        //
189
-        $instr_title       = InstructionUtility::cleanVars($_POST, 'title', '', 'string');
190
-        $instr_description = InstructionUtility::cleanVars($_POST, 'description', '', 'string');
191
-
192
-        // Дата обновления
193
-        $objInsinstr->setVar('dateupdated', $time);
194
-        //
195
-        $objInsinstr->setVar('cid', $cid);
196
-        $objInsinstr->setVar('title', $instr_title);
197
-        $objInsinstr->setVar('status', $_POST['status']);
198
-        $objInsinstr->setVar('description', $instr_description);
199
-        $objInsinstr->setVar('metakeywords', $_POST['metakeywords']);
200
-        $objInsinstr->setVar('metadescription', $_POST['metadescription']);
201
-
202
-        // Проверка категорий
203
-        if (!$cid) {
204
-            $err         = true;
205
-            $message_err .= _AM_INSTRUCTION_ERR_CAT . '<br>';
206
-        }
207
-        // Проверка названия
208
-        if (!$instr_title) {
209
-            $err         = true;
210
-            $message_err .= _AM_INSTR_ERR_TITLE . '<br>';
211
-        }
212
-        // Проверка основного текста
213
-        if (!$instr_description) {
214
-            $err         = true;
215
-            $message_err .= _AM_INSTR_ERR_DESCRIPTION . '<br>';
216
-        }
217
-
218
-        // Если были ошибки
219
-        if (true === $err) {
220
-            xoops_cp_header();
221
-            // Меню страницы
222
-            $adminObject->displayNavigation(basename(__FILE__));
223
-
224
-            $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
225
-            // Выводим ошибки в шаблон
226
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
227
-            // Если небыло ошибок
228
-        } else {
229
-            // Вставляем данные в БД
230
-            if ($insinstrHandler->insert($objInsinstr)) {
231
-                // Получаем ID созданной записи
232
-                $instrid_new = $instrid ?: $objInsinstr->get_new_enreg();
233
-                // Обновление даты в категории
234
-                $inscatHandler->updateDateupdated($cid, $time);
235
-                // Тэги
236
-                if (xoops_getModuleOption('usetag', 'instruction')) {
237
-                    $tagHandler = xoops_getModuleHandler('tag', 'tag');
238
-                    $tagHandler->updateByItem($_POST['tag'], $instrid_new, $GLOBALS['xoopsModule']->getVar('dirname'), 0);
239
-                }
240
-
241
-                // Если мы редактируем
242
-                if ($instrid) {
243
-                    redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRMODIFY);
244
-                } else {
245
-                    redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRADDED);
246
-                }
247
-            }
248
-            xoops_cp_header();
249
-            // Меню страницы
250
-            $adminObject->displayNavigation(basename(__FILE__));
251
-
252
-            // Выводим ошибки в шаблон
253
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors());
254
-        }
255
-        // Выводим шаблон
256
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_saveinstr.tpl');
257
-        // Выводим форму
258
-        $form = $objInsinstr->getForm();
259
-        // Форма
260
-        echo $form->render();
261
-        // Текст внизу админки
262
-        include __DIR__ . '/admin_footer.php';
263
-        // Подвал админки
264
-        xoops_cp_footer();
265
-
266
-        break;
267
-
268
-    // Просмотр категории
269
-    case 'viewinstr':
270
-
271
-        // Подключаем трей
272
-        include_once XOOPS_ROOT_PATH . '/modules/instruction/class/tree.php';
273
-
274
-        // Заголовок админки
275
-        xoops_cp_header();
276
-        // Меню
277
-        $adminObject->displayNavigation(basename(__FILE__));
278
-        // Кнопки
279
-        $adminObject->addItemButton(_AM_INSTRUCTION_ADDPAGE, 'instr.php?op=editpage&instrid=' . $instrid, 'add');
280
-        $adminObject->displayButton('left', '');
281
-
282
-        //
283
-        $objInsinstr = $insinstrHandler->get($instrid);
284
-
285
-        // Находим все страницы в данной инструкции
286
-        $criteria = new CriteriaCompo();
287
-        $criteria->add(new Criteria('instrid', $instrid, '='));
288
-        $criteria->setSort('weight');
289
-        $criteria->setOrder('ASC');
290
-        $ins_page = $inspageHandler->getall($criteria);
291
-        //
292
-        unset($criteria);
293
-
294
-        // Инициализируем
295
-        $instree = new InstructionTree($ins_page, 'pageid', 'pid');
296
-        // Выводим список страниц в шаблон
297
-        $GLOBALS['xoopsTpl']->assign('insListPage', $instree->makePagesAdmin($objInsinstr, '--'));
298
-
299
-        // Выводим шаблон
300
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_viewinstr.tpl');
301
-
302
-        // Текст внизу админки
303
-        include __DIR__ . '/admin_footer.php';
304
-        // Подвал админки
305
-        xoops_cp_footer();
306
-
307
-        break;
308
-
309
-    // Удаление категории
310
-    case 'delinstr':
311
-
312
-        // Проверка на instrid
313
-        // ==================
314
-        // Объект инструкций
315
-        $objInsinstr = $insinstrHandler->get($instrid);
316
-
317
-        // Нажали ли мы на кнопку OK
318
-        $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
319
-        //
320
-        if ($ok) {
321
-
322
-            // Проверка
323
-            if (!$GLOBALS['xoopsSecurity']->check()) {
324
-                redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
325
-            }
326
-            // Находим все страницы, пренадлежащие этой инструкции
327
-            $criteria = new CriteriaCompo();
328
-            $criteria->add(new Criteria('instrid', $instrid));
329
-            $ins_page = $inspageHandler->getall($criteria);
330
-            //
331
-            unset($criteria);
332
-            // Перебираем все страницы в данной инструкции
333
-            foreach (array_keys($ins_page) as $i) {
334
-                // Декримент комментов
335
-                // Делает дикримент одного коммента, а не всех в цикле...
336
-                // Удаляем комментарии
337
-                xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $ins_page[$i]->getVar('pageid'));
338
-                // Декримент страниц (Опционально)
339
-                // ==============================
340
-
341
-                // Удаляем страницу
342
-                // Сделать проверку на удалённость страницы
343
-                // ========================================
344
-                $inspageHandler->delete($ins_page[$i]);
345
-            }
346
-            // Пытаемся удалить инструкцию
347
-            if ($insinstrHandler->delete($objInsinstr)) {
348
-                // Редирект
349
-                redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRDELETED);
350
-            } else {
351
-                // Редирект
352
-                redirect_header('instr.php', 3, _AM_INSTRUCTION_ERR_DELINSTR);
353
-            }
354
-        } else {
355
-            xoops_cp_header();
356
-
357
-            $adminObject->displayNavigation(basename(__FILE__));
358
-            // Форма
359
-            xoops_confirm(['ok' => 1, 'instrid' => $instrid, 'op' => 'delinstr'], 'instr.php', sprintf(_AM_INSTRUCTION_FORMDELINSTR, $objInsinstr->getVar('title')));
360
-            // Текст внизу админки
361
-            include __DIR__ . '/admin_footer.php';
362
-            // Подвал админки
363
-            xoops_cp_footer();
364
-        }
365
-
366
-        break;
367
-
368
-    // Добавление страницы
369
-    case 'editpage':
370
-
371
-        // Заголовок админки
372
-        xoops_cp_header();
373
-        // Скрипты
374
-        $xoTheme->addScript(XOOPS_URL . '/modules/instruction/assets/js/admin.js');
375
-        // Меню
376
-        $adminObject->displayNavigation(basename(__FILE__));
377
-
378
-        // Если мы редактируем страницу
379
-        if ($pageid) {
380
-            // Получаем объект страницы
381
-            $objInspage = $inspageHandler->get($pageid);
382
-            // ID инструкции
383
-            $instrid = $objInspage->getVar('instrid');
384
-            // Создание новой страницы
385
-        } elseif ($instrid) {
386
-            // Создаём объект страницы
387
-            $objInspage = $inspageHandler->create();
388
-            // Устанавливаем родительскую страницу
389
-            $objInspage->setVar('pid', $pid);
390
-        } else {
391
-            redirect_header('instr.php', 3, _AM_INSTRUCTION_BADREQUEST);
392
-        }
393
-        // Форма
394
-        $form = $objInspage->getForm('instr.php', $instrid);
395
-        // Форма
396
-        echo $form->render();
397
-        // Выводим шаблон
398
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editpage.tpl');
399
-
400
-        // Текст внизу админки
401
-        include __DIR__ . '/admin_footer.php';
402
-        // Подвал админки
403
-        xoops_cp_footer();
404
-
405
-        break;
406
-
407
-    // Сохранение страницы
408
-    case 'savepage':
409
-        // Ошибки
410
-        $err         = false;
411
-        $message_err = '';
412
-
413
-        // Проверка сессии
414
-        if (!$GLOBALS['xoopsSecurity']->check()) {
415
-            $err         = true;
416
-            $err_txt     = implode(', ', $GLOBALS['xoopsSecurity']->getErrors());
417
-            $message_err .= $err_txt . '<br>';
418
-        }
419
-
420
-        // Если мы редактируем
421
-        if ($pageid) {
422
-            $objInspage = $inspageHandler->get($pageid);
423
-        } elseif ($instrid) {
424
-            $objInspage = $inspageHandler->create();
425
-            // Если мы создаём страницу необходимо указать к какой инструкции
426
-            $objInspage->setVar('instrid', $instrid);
427
-            // Указываем дату создания
428
-            $objInspage->setVar('datecreated', $time);
429
-            // Указываем пользователя
430
-            $objInspage->setVar('uid', $uid);
431
-        } else {
432
-            redirect_header('instr.php', 3, _AM_INSTRUCTION_BADREQUEST);
433
-        }
434
-
435
-        //
436
-        $page_title    = InstructionUtility::cleanVars($_POST, 'title', '', 'string');
437
-        $page_hometext = InstructionUtility::cleanVars($_POST, 'hometext', '', 'string');
438
-
439
-        // Родительская страница
440
-        $objInspage->setVar('pid', $pid);
441
-        // Дата обновления
442
-        $objInspage->setVar('dateupdated', $time);
443
-        // Название страницы
444
-        $objInspage->setVar('title', $page_title);
445
-        // Вес страницы
446
-        $objInspage->setVar('weight', $weight);
447
-        // Основной текст
448
-        $objInspage->setVar('hometext', $page_hometext);
449
-        // Сноска
450
-        $objInspage->setVar('footnote', InstructionUtility::cleanVars($_POST, 'footnote', '', 'string'));
451
-        // Статус
452
-        $objInspage->setVar('status', InstructionUtility::cleanVars($_POST, 'status', 0, 'int'));
453
-        // Тип
454
-        $objInspage->setVar('type', InstructionUtility::cleanVars($_POST, 'type', 0, 'int'));
455
-        // Мета-теги описания
456
-        $objInspage->setVar('keywords', InstructionUtility::cleanVars($_POST, 'keywords', '', 'string'));
457
-        // Мета-теги ключевых слов
458
-        $objInspage->setVar('description', InstructionUtility::cleanVars($_POST, 'description', '', 'string'));
459
-        //
460
-        $dosmiley = (isset($_POST['dosmiley']) && (int)$_POST['dosmiley'] > 0) ? 1 : 0;
461
-        $doxcode  = (isset($_POST['doxcode']) && (int)$_POST['doxcode'] > 0) ? 1 : 0;
462
-        $dobr     = (isset($_POST['dobr']) && (int)$_POST['dobr'] > 0) ? 1 : 0;
463
-        $dohtml   = (isset($_POST['dohtml']) && (int)$_POST['dohtml'] > 0) ? 1 : 0;
464
-        //$doimage = ( isset( $_POST['doimage'] ) && intval( $_POST['doimage'] ) > 0 ) ? 1 : 0;
465
-        $objInspage->setVar('dohtml', $dohtml);
466
-        $objInspage->setVar('dosmiley', $dosmiley);
467
-        $objInspage->setVar('doxcode', $doxcode);
468
-        //$objInspage->setVar( 'doimage', $doimage );
469
-        $objInspage->setVar('dobr', $dobr);
470
-
471
-        //
472
-        if (!$pageid && !$instrid) {
473
-            $err         = true;
474
-            $message_err .= _AM_INSTRUCTION_ERR_INSTR . '<br>';
475
-        }
476
-        // Проверка веса
477
-        if (0 == $weight) {
478
-            $err         = true;
479
-            $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>';
480
-        }
481
-        // Проверка родительской страницы
482
-        if ($pageid && ($pageid == $pid)) {
483
-            $err         = true;
484
-            $message_err .= _AM_INSTRUCTION_ERR_PPAGE . '<br>';
485
-        }
486
-        // Проверка названия
487
-        if (!$page_title) {
488
-            $err         = true;
489
-            $message_err .= _AM_INSTR_ERR_TITLE . '<br>';
490
-        }
491
-        // Проверка основного текста
492
-        if (!$page_hometext) {
493
-            $err         = true;
494
-            $message_err .= _AM_INSTR_ERR_HOMETEXT . '<br>';
495
-        }
496
-
497
-        // Если были ошибки
498
-        if (true === $err) {
499
-            xoops_cp_header();
500
-            // Меню страницы
501
-            $adminObject->displayNavigation(basename(__FILE__));
502
-
503
-            $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
504
-            // Выводим ошибки в шаблон
505
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
506
-            // Если небыло ошибок
507
-        } else {
508
-            // Вставляем данные в БД
509
-            if ($inspageHandler->insert($objInspage)) {
510
-                // Ссылка для редиректа
511
-                $redirect_url = 'instr.php?op=viewinstr&amp;instrid=' . $instrid . '#pageid_' . $pid;
512
-                // Получаем ID инструкции
513
-                $instrid = $objInspage->getInstrid();
514
-                // Обновляем в инструкции число страниц и дату
515
-                $insinstrHandler->updatePages($instrid);
516
-                // Если мы редактируем
517
-                if ($pageid) {
518
-                    // Редирект
519
-                    redirect_header($redirect_url, 3, _AM_INSTRUCTION_PAGEMODIFY);
520
-                    // Если мы добавляем
521
-                } else {
522
-                    // Инкримент комментов
523
-                    $inspageHandler->updateposts($uid, $_POST['status'], 'add');
524
-                    // Редирект
525
-                    redirect_header($redirect_url, 3, _AM_INSTRUCTION_PAGEADDED);
526
-                }
527
-            }
528
-            xoops_cp_header();
529
-            // Меню страницы
530
-            $adminObject->displayNavigation(basename(__FILE__));
531
-
532
-            // Выводим ошибки в шаблон
533
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInspage->getHtmlErrors());
534
-        }
535
-        // Скрипты
536
-        $xoTheme->addScript(XOOPS_URL . '/modules/instruction/assets/js/admin.js');
537
-        // Выводим шаблон
538
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savepage.tpl');
539
-        // Выводим форму
540
-        $form = $objInspage->getForm('instr.php', $instrid);
541
-        // Форма
542
-        echo $form->render();
543
-        // Текст внизу админки
544
-        include __DIR__ . '/admin_footer.php';
545
-        // Подвал админки
546
-        xoops_cp_footer();
547
-
548
-        break;
549
-
550
-    // Удаление страницы
551
-    case 'delpage':
552
-
553
-        // Проверка на pageid
554
-        // ==================
555
-
556
-        $objInspage = $inspageHandler->get($pageid);
557
-        // Нажали ли мы на кнопку OK
558
-        $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
559
-        // Если мы нажали на кнопку
560
-        if ($ok) {
561
-
562
-            // Проверка
563
-            if (!$GLOBALS['xoopsSecurity']->check()) {
564
-                redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
565
-            }
566
-            // ID инструкции
567
-            $page_instrid = $objInspage->getVar('instrid');
568
-            // Декримент комментов
569
-            $inspageHandler->updateposts($objInspage->getVar('uid'), $objInspage->getVar('status'), 'delete');
570
-            // Пытаемся удалить страницу
571
-            if ($inspageHandler->delete($objInspage)) {
572
-                // Обновляем в инструкции число страниц и дату
573
-                $insinstrHandler->updatePages($page_instrid);
574
-                // Удаляем комментарии
575
-                xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $pageid);
576
-                //
577
-                redirect_header('instr.php?op=viewinstr&amp;instrid=' . $page_instrid, 3, _AM_INSTRUCTION_PAGEDELETED);
578
-                // Если не смогли удалить страницу
579
-            } else {
580
-                redirect_header('instr.php?op=viewinstr&amp;instrid=' . $page_instrid, 3, _AM_INSTRUCTION_ERR_DELPAGE);
581
-            }
582
-        } else {
583
-
584
-            // Заголовок админки
585
-            xoops_cp_header();
586
-            // Меню
587
-            $adminObject->displayNavigation(basename(__FILE__));
588
-            // Форма
589
-            xoops_confirm(['ok' => 1, 'pageid' => $pageid, 'op' => 'delpage'], 'instr.php', sprintf(_AM_INSTRUCTION_FORMDELPAGE, $objInspage->getVar('title')));
590
-            // Текст внизу админки
591
-            include __DIR__ . '/admin_footer.php';
592
-            // Подвал админки
593
-            xoops_cp_footer();
594
-        }
595
-
596
-        break;
597
-
598
-    // Удаление страницы
599
-    case 'updpage':
600
-
601
-        // Принимаем данные
602
-        $pageids = $_POST['pageids'];
603
-        $weights = $_POST['weights'];
604
-        // Перебираем все значения
605
-        foreach ($pageids as $key => $pageid) {
606
-
607
-            // Объявляем объект
608
-            $objInspage = $inspageHandler->get($pageid);
609
-            // Устанавливаем вес
610
-            $objInspage->setVar('weight', $weights[$key]);
611
-            // Вставляем данные в БД
612
-            $inspageHandler->insert($objInspage);
613
-            // Удаляем объект
614
-            unset($objInspage);
615
-        }
616
-        // Редирект
617
-        redirect_header('instr.php?op=viewinstr&instrid=' . $instrid, 3, _AM_INSTRUCTION_PAGESUPDATE);
618
-
619
-        break;
43
+	case 'main':
44
+
45
+		// Заголовок админки
46
+		xoops_cp_header();
47
+		// Меню
48
+		$adminObject->displayNavigation(basename(__FILE__));
49
+		$adminObject->addItemButton(_AM_INSTRUCTION_ADDINSTR, 'instr.php?op=editinstr', 'add');
50
+		$adminObject->displayButton('left', '');
51
+
52
+		//
53
+		$criteria = new CriteriaCompo();
54
+
55
+		// Если была передана категория
56
+		if ($cid) {
57
+			// Добавляем в выборку ID категории
58
+			$criteria->add(new Criteria('cid', $cid, '='));
59
+			// Получаем объект категории
60
+			$objInscat = $inscatHandler->get($cid);
61
+			// Если нет такой категории
62
+			if (!is_object($objInscat)) {
63
+				redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT);
64
+			}
65
+		}
66
+
67
+		// Число инструкций, удовлетворяющих данному условию
68
+		$numrows = $insinstrHandler->getCount($criteria);
69
+
70
+		// Число выборки
71
+		$criteria->setLimit($limit);
72
+		// Начинасть с данного элемента
73
+		$criteria->setStart($start);
74
+		// Сортировать по
75
+		$criteria->setSort('instrid');
76
+		// Порядок сортировки
77
+		$criteria->setOrder('DESC');
78
+		// Находим все справки
79
+		$instr_arr = $insinstrHandler->getall($criteria);
80
+		// Если записей больше чем $limit, то выводим пагинатор
81
+		if ($numrows > $limit) {
82
+			$pagenav = new XoopsPageNav($numrows, $limit, $start, 'start', 'op=' . $op . '&amp;cid=' . $cid);
83
+			$pagenav = $pagenav->renderNav(4);
84
+		} else {
85
+			$pagenav = '';
86
+		}
87
+		// Выводим пагинатор в шаблон
88
+		$GLOBALS['xoopsTpl']->assign('insPagenav', $pagenav);
89
+
90
+		// Если есть записи
91
+		if ($numrows > 0) {
92
+			$class = 'odd';
93
+			foreach (array_keys($instr_arr) as $i) {
94
+
95
+				//
96
+				$class = ('even' === $class) ? 'odd' : 'even';
97
+				// ID
98
+				$insinstr_instrid = $instr_arr[$i]->getVar('instrid');
99
+				// Название
100
+				$insinstr_title = $instr_arr[$i]->getVar('title');
101
+				// Статус
102
+				$insinstr_status = $instr_arr[$i]->getVar('status');
103
+				// Количество страниц
104
+				$insinstr_pages = $instr_arr[$i]->getVar('pages');
105
+				// Категория
106
+				$insinstr_cat = $inscatHandler->get($instr_arr[$i]->getVar('cid'));
107
+
108
+				// Выводим в шаблон
109
+				$GLOBALS['xoopsTpl']->append('insListInstr', ['instrid' => $insinstr_instrid, 'title' => $insinstr_title, 'status' => $insinstr_status, 'pages' => $insinstr_pages, 'ctitle' => $insinstr_cat->getVar('title'), 'cid' => $insinstr_cat->getVar('cid'), 'class' => $class]);
110
+			}
111
+
112
+			//
113
+			$inshead = isset($objInscat) && is_object($objInscat) ? sprintf(_AM_INSTR_LISTINSTRINCAT, $objInscat->getVar('title')) : _AM_INSTR_LISTINSTRALL;
114
+			$GLOBALS['xoopsTpl']->assign('insHead', $inshead);
115
+			// Языковые константы
116
+			$GLOBALS['xoopsTpl']->assign('lang_title', _AM_INSTRUCTION_TITLE);
117
+			$GLOBALS['xoopsTpl']->assign('lang_cat', _AM_INSTRUCTION_CAT);
118
+			$GLOBALS['xoopsTpl']->assign('lang_pages', _AM_INSTRUCTION_PAGES);
119
+			$GLOBALS['xoopsTpl']->assign('lang_action', _AM_INSTRUCTION_ACTION);
120
+			$GLOBALS['xoopsTpl']->assign('lang_display', _AM_INSTRUCTION_DISPLAY);
121
+			$GLOBALS['xoopsTpl']->assign('lang_edit', _AM_INSTRUCTION_EDIT);
122
+			$GLOBALS['xoopsTpl']->assign('lang_del', _AM_INSTRUCTION_DEL);
123
+			$GLOBALS['xoopsTpl']->assign('lang_lock', _AM_INSTRUCTION_LOCK);
124
+			$GLOBALS['xoopsTpl']->assign('lang_unlock', _AM_INSTRUCTION_UNLOCK);
125
+			$GLOBALS['xoopsTpl']->assign('lang_addpage', _AM_INSTRUCTION_ADDPAGE);
126
+			$GLOBALS['xoopsTpl']->assign('lang_addinstr', _AM_INSTRUCTION_ADDINSTR);
127
+		}
128
+
129
+		// Выводим шаблон
130
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_instr.tpl');
131
+
132
+		// Текст внизу админки
133
+		include __DIR__ . '/admin_footer.php';
134
+		// Подвал админки
135
+		xoops_cp_footer();
136
+
137
+		break;
138
+
139
+	// Редактирование категории
140
+	case 'editinstr':
141
+
142
+		// Заголовок админки
143
+		xoops_cp_header();
144
+		// Меню
145
+		$adminObject->displayNavigation(basename(__FILE__));
146
+
147
+		// Если мы редактируем инструкцию
148
+		if ($instrid) {
149
+			$objInsinstr = $insinstrHandler->get($instrid);
150
+			// Создание новой страницы
151
+		} else {
152
+			$objInsinstr = $insinstrHandler->create();
153
+		}
154
+
155
+		// Выводим шаблон
156
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editinstr.tpl');
157
+		$form = $objInsinstr->getForm('instr.php');
158
+		// Форма
159
+		echo $form->render();
160
+
161
+		// Текст внизу админки
162
+		include __DIR__ . '/admin_footer.php';
163
+		// Подвал админки
164
+		xoops_cp_footer();
165
+
166
+		break;
167
+
168
+	// Сохранение инструкций
169
+	case 'saveinstr':
170
+
171
+		// Проверка
172
+		if (!$GLOBALS['xoopsSecurity']->check()) {
173
+			redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
174
+		}
175
+		// Если мы редактируем
176
+		if ($instrid) {
177
+			$objInsinstr = $insinstrHandler->get($instrid);
178
+		} else {
179
+			$objInsinstr = $insinstrHandler->create();
180
+			// Указываем дату создания
181
+			$objInsinstr->setVar('datecreated', $time);
182
+			// Указываем пользователя
183
+			$objInsinstr->setVar('uid', $uid);
184
+		}
185
+
186
+		$err         = false;
187
+		$message_err = '';
188
+		//
189
+		$instr_title       = InstructionUtility::cleanVars($_POST, 'title', '', 'string');
190
+		$instr_description = InstructionUtility::cleanVars($_POST, 'description', '', 'string');
191
+
192
+		// Дата обновления
193
+		$objInsinstr->setVar('dateupdated', $time);
194
+		//
195
+		$objInsinstr->setVar('cid', $cid);
196
+		$objInsinstr->setVar('title', $instr_title);
197
+		$objInsinstr->setVar('status', $_POST['status']);
198
+		$objInsinstr->setVar('description', $instr_description);
199
+		$objInsinstr->setVar('metakeywords', $_POST['metakeywords']);
200
+		$objInsinstr->setVar('metadescription', $_POST['metadescription']);
201
+
202
+		// Проверка категорий
203
+		if (!$cid) {
204
+			$err         = true;
205
+			$message_err .= _AM_INSTRUCTION_ERR_CAT . '<br>';
206
+		}
207
+		// Проверка названия
208
+		if (!$instr_title) {
209
+			$err         = true;
210
+			$message_err .= _AM_INSTR_ERR_TITLE . '<br>';
211
+		}
212
+		// Проверка основного текста
213
+		if (!$instr_description) {
214
+			$err         = true;
215
+			$message_err .= _AM_INSTR_ERR_DESCRIPTION . '<br>';
216
+		}
217
+
218
+		// Если были ошибки
219
+		if (true === $err) {
220
+			xoops_cp_header();
221
+			// Меню страницы
222
+			$adminObject->displayNavigation(basename(__FILE__));
223
+
224
+			$message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
225
+			// Выводим ошибки в шаблон
226
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
227
+			// Если небыло ошибок
228
+		} else {
229
+			// Вставляем данные в БД
230
+			if ($insinstrHandler->insert($objInsinstr)) {
231
+				// Получаем ID созданной записи
232
+				$instrid_new = $instrid ?: $objInsinstr->get_new_enreg();
233
+				// Обновление даты в категории
234
+				$inscatHandler->updateDateupdated($cid, $time);
235
+				// Тэги
236
+				if (xoops_getModuleOption('usetag', 'instruction')) {
237
+					$tagHandler = xoops_getModuleHandler('tag', 'tag');
238
+					$tagHandler->updateByItem($_POST['tag'], $instrid_new, $GLOBALS['xoopsModule']->getVar('dirname'), 0);
239
+				}
240
+
241
+				// Если мы редактируем
242
+				if ($instrid) {
243
+					redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRMODIFY);
244
+				} else {
245
+					redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRADDED);
246
+				}
247
+			}
248
+			xoops_cp_header();
249
+			// Меню страницы
250
+			$adminObject->displayNavigation(basename(__FILE__));
251
+
252
+			// Выводим ошибки в шаблон
253
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors());
254
+		}
255
+		// Выводим шаблон
256
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_saveinstr.tpl');
257
+		// Выводим форму
258
+		$form = $objInsinstr->getForm();
259
+		// Форма
260
+		echo $form->render();
261
+		// Текст внизу админки
262
+		include __DIR__ . '/admin_footer.php';
263
+		// Подвал админки
264
+		xoops_cp_footer();
265
+
266
+		break;
267
+
268
+	// Просмотр категории
269
+	case 'viewinstr':
270
+
271
+		// Подключаем трей
272
+		include_once XOOPS_ROOT_PATH . '/modules/instruction/class/tree.php';
273
+
274
+		// Заголовок админки
275
+		xoops_cp_header();
276
+		// Меню
277
+		$adminObject->displayNavigation(basename(__FILE__));
278
+		// Кнопки
279
+		$adminObject->addItemButton(_AM_INSTRUCTION_ADDPAGE, 'instr.php?op=editpage&instrid=' . $instrid, 'add');
280
+		$adminObject->displayButton('left', '');
281
+
282
+		//
283
+		$objInsinstr = $insinstrHandler->get($instrid);
284
+
285
+		// Находим все страницы в данной инструкции
286
+		$criteria = new CriteriaCompo();
287
+		$criteria->add(new Criteria('instrid', $instrid, '='));
288
+		$criteria->setSort('weight');
289
+		$criteria->setOrder('ASC');
290
+		$ins_page = $inspageHandler->getall($criteria);
291
+		//
292
+		unset($criteria);
293
+
294
+		// Инициализируем
295
+		$instree = new InstructionTree($ins_page, 'pageid', 'pid');
296
+		// Выводим список страниц в шаблон
297
+		$GLOBALS['xoopsTpl']->assign('insListPage', $instree->makePagesAdmin($objInsinstr, '--'));
298
+
299
+		// Выводим шаблон
300
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_viewinstr.tpl');
301
+
302
+		// Текст внизу админки
303
+		include __DIR__ . '/admin_footer.php';
304
+		// Подвал админки
305
+		xoops_cp_footer();
306
+
307
+		break;
308
+
309
+	// Удаление категории
310
+	case 'delinstr':
311
+
312
+		// Проверка на instrid
313
+		// ==================
314
+		// Объект инструкций
315
+		$objInsinstr = $insinstrHandler->get($instrid);
316
+
317
+		// Нажали ли мы на кнопку OK
318
+		$ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
319
+		//
320
+		if ($ok) {
321
+
322
+			// Проверка
323
+			if (!$GLOBALS['xoopsSecurity']->check()) {
324
+				redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
325
+			}
326
+			// Находим все страницы, пренадлежащие этой инструкции
327
+			$criteria = new CriteriaCompo();
328
+			$criteria->add(new Criteria('instrid', $instrid));
329
+			$ins_page = $inspageHandler->getall($criteria);
330
+			//
331
+			unset($criteria);
332
+			// Перебираем все страницы в данной инструкции
333
+			foreach (array_keys($ins_page) as $i) {
334
+				// Декримент комментов
335
+				// Делает дикримент одного коммента, а не всех в цикле...
336
+				// Удаляем комментарии
337
+				xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $ins_page[$i]->getVar('pageid'));
338
+				// Декримент страниц (Опционально)
339
+				// ==============================
340
+
341
+				// Удаляем страницу
342
+				// Сделать проверку на удалённость страницы
343
+				// ========================================
344
+				$inspageHandler->delete($ins_page[$i]);
345
+			}
346
+			// Пытаемся удалить инструкцию
347
+			if ($insinstrHandler->delete($objInsinstr)) {
348
+				// Редирект
349
+				redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRDELETED);
350
+			} else {
351
+				// Редирект
352
+				redirect_header('instr.php', 3, _AM_INSTRUCTION_ERR_DELINSTR);
353
+			}
354
+		} else {
355
+			xoops_cp_header();
356
+
357
+			$adminObject->displayNavigation(basename(__FILE__));
358
+			// Форма
359
+			xoops_confirm(['ok' => 1, 'instrid' => $instrid, 'op' => 'delinstr'], 'instr.php', sprintf(_AM_INSTRUCTION_FORMDELINSTR, $objInsinstr->getVar('title')));
360
+			// Текст внизу админки
361
+			include __DIR__ . '/admin_footer.php';
362
+			// Подвал админки
363
+			xoops_cp_footer();
364
+		}
365
+
366
+		break;
367
+
368
+	// Добавление страницы
369
+	case 'editpage':
370
+
371
+		// Заголовок админки
372
+		xoops_cp_header();
373
+		// Скрипты
374
+		$xoTheme->addScript(XOOPS_URL . '/modules/instruction/assets/js/admin.js');
375
+		// Меню
376
+		$adminObject->displayNavigation(basename(__FILE__));
377
+
378
+		// Если мы редактируем страницу
379
+		if ($pageid) {
380
+			// Получаем объект страницы
381
+			$objInspage = $inspageHandler->get($pageid);
382
+			// ID инструкции
383
+			$instrid = $objInspage->getVar('instrid');
384
+			// Создание новой страницы
385
+		} elseif ($instrid) {
386
+			// Создаём объект страницы
387
+			$objInspage = $inspageHandler->create();
388
+			// Устанавливаем родительскую страницу
389
+			$objInspage->setVar('pid', $pid);
390
+		} else {
391
+			redirect_header('instr.php', 3, _AM_INSTRUCTION_BADREQUEST);
392
+		}
393
+		// Форма
394
+		$form = $objInspage->getForm('instr.php', $instrid);
395
+		// Форма
396
+		echo $form->render();
397
+		// Выводим шаблон
398
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editpage.tpl');
399
+
400
+		// Текст внизу админки
401
+		include __DIR__ . '/admin_footer.php';
402
+		// Подвал админки
403
+		xoops_cp_footer();
404
+
405
+		break;
406
+
407
+	// Сохранение страницы
408
+	case 'savepage':
409
+		// Ошибки
410
+		$err         = false;
411
+		$message_err = '';
412
+
413
+		// Проверка сессии
414
+		if (!$GLOBALS['xoopsSecurity']->check()) {
415
+			$err         = true;
416
+			$err_txt     = implode(', ', $GLOBALS['xoopsSecurity']->getErrors());
417
+			$message_err .= $err_txt . '<br>';
418
+		}
419
+
420
+		// Если мы редактируем
421
+		if ($pageid) {
422
+			$objInspage = $inspageHandler->get($pageid);
423
+		} elseif ($instrid) {
424
+			$objInspage = $inspageHandler->create();
425
+			// Если мы создаём страницу необходимо указать к какой инструкции
426
+			$objInspage->setVar('instrid', $instrid);
427
+			// Указываем дату создания
428
+			$objInspage->setVar('datecreated', $time);
429
+			// Указываем пользователя
430
+			$objInspage->setVar('uid', $uid);
431
+		} else {
432
+			redirect_header('instr.php', 3, _AM_INSTRUCTION_BADREQUEST);
433
+		}
434
+
435
+		//
436
+		$page_title    = InstructionUtility::cleanVars($_POST, 'title', '', 'string');
437
+		$page_hometext = InstructionUtility::cleanVars($_POST, 'hometext', '', 'string');
438
+
439
+		// Родительская страница
440
+		$objInspage->setVar('pid', $pid);
441
+		// Дата обновления
442
+		$objInspage->setVar('dateupdated', $time);
443
+		// Название страницы
444
+		$objInspage->setVar('title', $page_title);
445
+		// Вес страницы
446
+		$objInspage->setVar('weight', $weight);
447
+		// Основной текст
448
+		$objInspage->setVar('hometext', $page_hometext);
449
+		// Сноска
450
+		$objInspage->setVar('footnote', InstructionUtility::cleanVars($_POST, 'footnote', '', 'string'));
451
+		// Статус
452
+		$objInspage->setVar('status', InstructionUtility::cleanVars($_POST, 'status', 0, 'int'));
453
+		// Тип
454
+		$objInspage->setVar('type', InstructionUtility::cleanVars($_POST, 'type', 0, 'int'));
455
+		// Мета-теги описания
456
+		$objInspage->setVar('keywords', InstructionUtility::cleanVars($_POST, 'keywords', '', 'string'));
457
+		// Мета-теги ключевых слов
458
+		$objInspage->setVar('description', InstructionUtility::cleanVars($_POST, 'description', '', 'string'));
459
+		//
460
+		$dosmiley = (isset($_POST['dosmiley']) && (int)$_POST['dosmiley'] > 0) ? 1 : 0;
461
+		$doxcode  = (isset($_POST['doxcode']) && (int)$_POST['doxcode'] > 0) ? 1 : 0;
462
+		$dobr     = (isset($_POST['dobr']) && (int)$_POST['dobr'] > 0) ? 1 : 0;
463
+		$dohtml   = (isset($_POST['dohtml']) && (int)$_POST['dohtml'] > 0) ? 1 : 0;
464
+		//$doimage = ( isset( $_POST['doimage'] ) && intval( $_POST['doimage'] ) > 0 ) ? 1 : 0;
465
+		$objInspage->setVar('dohtml', $dohtml);
466
+		$objInspage->setVar('dosmiley', $dosmiley);
467
+		$objInspage->setVar('doxcode', $doxcode);
468
+		//$objInspage->setVar( 'doimage', $doimage );
469
+		$objInspage->setVar('dobr', $dobr);
470
+
471
+		//
472
+		if (!$pageid && !$instrid) {
473
+			$err         = true;
474
+			$message_err .= _AM_INSTRUCTION_ERR_INSTR . '<br>';
475
+		}
476
+		// Проверка веса
477
+		if (0 == $weight) {
478
+			$err         = true;
479
+			$message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>';
480
+		}
481
+		// Проверка родительской страницы
482
+		if ($pageid && ($pageid == $pid)) {
483
+			$err         = true;
484
+			$message_err .= _AM_INSTRUCTION_ERR_PPAGE . '<br>';
485
+		}
486
+		// Проверка названия
487
+		if (!$page_title) {
488
+			$err         = true;
489
+			$message_err .= _AM_INSTR_ERR_TITLE . '<br>';
490
+		}
491
+		// Проверка основного текста
492
+		if (!$page_hometext) {
493
+			$err         = true;
494
+			$message_err .= _AM_INSTR_ERR_HOMETEXT . '<br>';
495
+		}
496
+
497
+		// Если были ошибки
498
+		if (true === $err) {
499
+			xoops_cp_header();
500
+			// Меню страницы
501
+			$adminObject->displayNavigation(basename(__FILE__));
502
+
503
+			$message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
504
+			// Выводим ошибки в шаблон
505
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
506
+			// Если небыло ошибок
507
+		} else {
508
+			// Вставляем данные в БД
509
+			if ($inspageHandler->insert($objInspage)) {
510
+				// Ссылка для редиректа
511
+				$redirect_url = 'instr.php?op=viewinstr&amp;instrid=' . $instrid . '#pageid_' . $pid;
512
+				// Получаем ID инструкции
513
+				$instrid = $objInspage->getInstrid();
514
+				// Обновляем в инструкции число страниц и дату
515
+				$insinstrHandler->updatePages($instrid);
516
+				// Если мы редактируем
517
+				if ($pageid) {
518
+					// Редирект
519
+					redirect_header($redirect_url, 3, _AM_INSTRUCTION_PAGEMODIFY);
520
+					// Если мы добавляем
521
+				} else {
522
+					// Инкримент комментов
523
+					$inspageHandler->updateposts($uid, $_POST['status'], 'add');
524
+					// Редирект
525
+					redirect_header($redirect_url, 3, _AM_INSTRUCTION_PAGEADDED);
526
+				}
527
+			}
528
+			xoops_cp_header();
529
+			// Меню страницы
530
+			$adminObject->displayNavigation(basename(__FILE__));
531
+
532
+			// Выводим ошибки в шаблон
533
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInspage->getHtmlErrors());
534
+		}
535
+		// Скрипты
536
+		$xoTheme->addScript(XOOPS_URL . '/modules/instruction/assets/js/admin.js');
537
+		// Выводим шаблон
538
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savepage.tpl');
539
+		// Выводим форму
540
+		$form = $objInspage->getForm('instr.php', $instrid);
541
+		// Форма
542
+		echo $form->render();
543
+		// Текст внизу админки
544
+		include __DIR__ . '/admin_footer.php';
545
+		// Подвал админки
546
+		xoops_cp_footer();
547
+
548
+		break;
549
+
550
+	// Удаление страницы
551
+	case 'delpage':
552
+
553
+		// Проверка на pageid
554
+		// ==================
555
+
556
+		$objInspage = $inspageHandler->get($pageid);
557
+		// Нажали ли мы на кнопку OK
558
+		$ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
559
+		// Если мы нажали на кнопку
560
+		if ($ok) {
561
+
562
+			// Проверка
563
+			if (!$GLOBALS['xoopsSecurity']->check()) {
564
+				redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
565
+			}
566
+			// ID инструкции
567
+			$page_instrid = $objInspage->getVar('instrid');
568
+			// Декримент комментов
569
+			$inspageHandler->updateposts($objInspage->getVar('uid'), $objInspage->getVar('status'), 'delete');
570
+			// Пытаемся удалить страницу
571
+			if ($inspageHandler->delete($objInspage)) {
572
+				// Обновляем в инструкции число страниц и дату
573
+				$insinstrHandler->updatePages($page_instrid);
574
+				// Удаляем комментарии
575
+				xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $pageid);
576
+				//
577
+				redirect_header('instr.php?op=viewinstr&amp;instrid=' . $page_instrid, 3, _AM_INSTRUCTION_PAGEDELETED);
578
+				// Если не смогли удалить страницу
579
+			} else {
580
+				redirect_header('instr.php?op=viewinstr&amp;instrid=' . $page_instrid, 3, _AM_INSTRUCTION_ERR_DELPAGE);
581
+			}
582
+		} else {
583
+
584
+			// Заголовок админки
585
+			xoops_cp_header();
586
+			// Меню
587
+			$adminObject->displayNavigation(basename(__FILE__));
588
+			// Форма
589
+			xoops_confirm(['ok' => 1, 'pageid' => $pageid, 'op' => 'delpage'], 'instr.php', sprintf(_AM_INSTRUCTION_FORMDELPAGE, $objInspage->getVar('title')));
590
+			// Текст внизу админки
591
+			include __DIR__ . '/admin_footer.php';
592
+			// Подвал админки
593
+			xoops_cp_footer();
594
+		}
595
+
596
+		break;
597
+
598
+	// Удаление страницы
599
+	case 'updpage':
600
+
601
+		// Принимаем данные
602
+		$pageids = $_POST['pageids'];
603
+		$weights = $_POST['weights'];
604
+		// Перебираем все значения
605
+		foreach ($pageids as $key => $pageid) {
606
+
607
+			// Объявляем объект
608
+			$objInspage = $inspageHandler->get($pageid);
609
+			// Устанавливаем вес
610
+			$objInspage->setVar('weight', $weights[$key]);
611
+			// Вставляем данные в БД
612
+			$inspageHandler->insert($objInspage);
613
+			// Удаляем объект
614
+			unset($objInspage);
615
+		}
616
+		// Редирект
617
+		redirect_header('instr.php?op=viewinstr&instrid=' . $instrid, 3, _AM_INSTRUCTION_PAGESUPDATE);
618
+
619
+		break;
620 620
 
621 621
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
             // Получаем объект категории
60 60
             $objInscat = $inscatHandler->get($cid);
61 61
             // Если нет такой категории
62
-            if (!is_object($objInscat)) {
62
+            if ( ! is_object($objInscat)) {
63 63
                 redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT);
64 64
             }
65 65
         }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     case 'saveinstr':
170 170
 
171 171
         // Проверка
172
-        if (!$GLOBALS['xoopsSecurity']->check()) {
172
+        if ( ! $GLOBALS['xoopsSecurity']->check()) {
173 173
             redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
174 174
         }
175 175
         // Если мы редактируем
@@ -200,18 +200,18 @@  discard block
 block discarded – undo
200 200
         $objInsinstr->setVar('metadescription', $_POST['metadescription']);
201 201
 
202 202
         // Проверка категорий
203
-        if (!$cid) {
204
-            $err         = true;
203
+        if ( ! $cid) {
204
+            $err = true;
205 205
             $message_err .= _AM_INSTRUCTION_ERR_CAT . '<br>';
206 206
         }
207 207
         // Проверка названия
208
-        if (!$instr_title) {
209
-            $err         = true;
208
+        if ( ! $instr_title) {
209
+            $err = true;
210 210
             $message_err .= _AM_INSTR_ERR_TITLE . '<br>';
211 211
         }
212 212
         // Проверка основного текста
213
-        if (!$instr_description) {
214
-            $err         = true;
213
+        if ( ! $instr_description) {
214
+            $err = true;
215 215
             $message_err .= _AM_INSTR_ERR_DESCRIPTION . '<br>';
216 216
         }
217 217
 
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
         $objInsinstr = $insinstrHandler->get($instrid);
316 316
 
317 317
         // Нажали ли мы на кнопку OK
318
-        $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
318
+        $ok = isset($_POST['ok']) ? (int) $_POST['ok'] : 0;
319 319
         //
320 320
         if ($ok) {
321 321
 
322 322
             // Проверка
323
-            if (!$GLOBALS['xoopsSecurity']->check()) {
323
+            if ( ! $GLOBALS['xoopsSecurity']->check()) {
324 324
                 redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
325 325
             }
326 326
             // Находим все страницы, пренадлежащие этой инструкции
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
         $message_err = '';
412 412
 
413 413
         // Проверка сессии
414
-        if (!$GLOBALS['xoopsSecurity']->check()) {
414
+        if ( ! $GLOBALS['xoopsSecurity']->check()) {
415 415
             $err         = true;
416 416
             $err_txt     = implode(', ', $GLOBALS['xoopsSecurity']->getErrors());
417 417
             $message_err .= $err_txt . '<br>';
@@ -457,10 +457,10 @@  discard block
 block discarded – undo
457 457
         // Мета-теги ключевых слов
458 458
         $objInspage->setVar('description', InstructionUtility::cleanVars($_POST, 'description', '', 'string'));
459 459
         //
460
-        $dosmiley = (isset($_POST['dosmiley']) && (int)$_POST['dosmiley'] > 0) ? 1 : 0;
461
-        $doxcode  = (isset($_POST['doxcode']) && (int)$_POST['doxcode'] > 0) ? 1 : 0;
462
-        $dobr     = (isset($_POST['dobr']) && (int)$_POST['dobr'] > 0) ? 1 : 0;
463
-        $dohtml   = (isset($_POST['dohtml']) && (int)$_POST['dohtml'] > 0) ? 1 : 0;
460
+        $dosmiley = (isset($_POST['dosmiley']) && (int) $_POST['dosmiley'] > 0) ? 1 : 0;
461
+        $doxcode  = (isset($_POST['doxcode']) && (int) $_POST['doxcode'] > 0) ? 1 : 0;
462
+        $dobr     = (isset($_POST['dobr']) && (int) $_POST['dobr'] > 0) ? 1 : 0;
463
+        $dohtml   = (isset($_POST['dohtml']) && (int) $_POST['dohtml'] > 0) ? 1 : 0;
464 464
         //$doimage = ( isset( $_POST['doimage'] ) && intval( $_POST['doimage'] ) > 0 ) ? 1 : 0;
465 465
         $objInspage->setVar('dohtml', $dohtml);
466 466
         $objInspage->setVar('dosmiley', $dosmiley);
@@ -469,28 +469,28 @@  discard block
 block discarded – undo
469 469
         $objInspage->setVar('dobr', $dobr);
470 470
 
471 471
         //
472
-        if (!$pageid && !$instrid) {
473
-            $err         = true;
472
+        if ( ! $pageid && ! $instrid) {
473
+            $err = true;
474 474
             $message_err .= _AM_INSTRUCTION_ERR_INSTR . '<br>';
475 475
         }
476 476
         // Проверка веса
477 477
         if (0 == $weight) {
478
-            $err         = true;
478
+            $err = true;
479 479
             $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>';
480 480
         }
481 481
         // Проверка родительской страницы
482 482
         if ($pageid && ($pageid == $pid)) {
483
-            $err         = true;
483
+            $err = true;
484 484
             $message_err .= _AM_INSTRUCTION_ERR_PPAGE . '<br>';
485 485
         }
486 486
         // Проверка названия
487
-        if (!$page_title) {
488
-            $err         = true;
487
+        if ( ! $page_title) {
488
+            $err = true;
489 489
             $message_err .= _AM_INSTR_ERR_TITLE . '<br>';
490 490
         }
491 491
         // Проверка основного текста
492
-        if (!$page_hometext) {
493
-            $err         = true;
492
+        if ( ! $page_hometext) {
493
+            $err = true;
494 494
             $message_err .= _AM_INSTR_ERR_HOMETEXT . '<br>';
495 495
         }
496 496
 
@@ -555,12 +555,12 @@  discard block
 block discarded – undo
555 555
 
556 556
         $objInspage = $inspageHandler->get($pageid);
557 557
         // Нажали ли мы на кнопку OK
558
-        $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
558
+        $ok = isset($_POST['ok']) ? (int) $_POST['ok'] : 0;
559 559
         // Если мы нажали на кнопку
560 560
         if ($ok) {
561 561
 
562 562
             // Проверка
563
-            if (!$GLOBALS['xoopsSecurity']->check()) {
563
+            if ( ! $GLOBALS['xoopsSecurity']->check()) {
564 564
                 redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
565 565
             }
566 566
             // ID инструкции
Please login to merge, or discard this patch.
instr.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 $criteria->add(new Criteria('instrid', $instrid));
19 19
 $criteria->add(new Criteria('status ', '0', '>'));
20 20
 if (0 == $insinstrHandler->getCount($criteria)) {
21
-    redirect_header('index.php', 3, _MD_INSTRUCTION_INSTRNOTEXIST);
22
-    exit();
21
+	redirect_header('index.php', 3, _MD_INSTRUCTION_INSTRNOTEXIST);
22
+	exit();
23 23
 }
24 24
 //
25 25
 unset($criteria);
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 // Права на просмотр инструкции
42 42
 $categories = InstructionUtility::getItemIds();
43 43
 if (!in_array($objInsinstr->getVar('cid'), $categories)) {
44
-    redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM);
45
-    exit();
44
+	redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM);
45
+	exit();
46 46
 }
47 47
 
48 48
 // Массив данных об инструкции
@@ -55,29 +55,29 @@  discard block
 block discarded – undo
55 55
 $instrs['description'] = $objInsinstr->getVar('description');
56 56
 // Если админ, рисуем админлинк
57 57
 if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid())) {
58
-    $instrs['adminlink'] = '&nbsp;<a href="'
59
-                           . XOOPS_URL
60
-                           . '/modules/'
61
-                           . $moduleDirName
62
-                           . '/admin/instr.php?op=editinstr&instrid='
63
-                           . $instrid
64
-                           . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt='
65
-                           . _EDIT
66
-                           . ' title='
67
-                           . _EDIT
68
-                           . '></a>&nbsp;<a href="'
69
-                           . XOOPS_URL
70
-                           . '/modules/'
71
-                           . $moduleDirName
72
-                           . '/admin/instr.php?op=delinstr&instrid='
73
-                           . $instrid
74
-                           . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt='
75
-                           . _DELETE
76
-                           . ' title='
77
-                           . _DELETE
78
-                           . '></a>&nbsp;';
58
+	$instrs['adminlink'] = '&nbsp;<a href="'
59
+						   . XOOPS_URL
60
+						   . '/modules/'
61
+						   . $moduleDirName
62
+						   . '/admin/instr.php?op=editinstr&instrid='
63
+						   . $instrid
64
+						   . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt='
65
+						   . _EDIT
66
+						   . ' title='
67
+						   . _EDIT
68
+						   . '></a>&nbsp;<a href="'
69
+						   . XOOPS_URL
70
+						   . '/modules/'
71
+						   . $moduleDirName
72
+						   . '/admin/instr.php?op=delinstr&instrid='
73
+						   . $instrid
74
+						   . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt='
75
+						   . _DELETE
76
+						   . ' title='
77
+						   . _DELETE
78
+						   . '></a>&nbsp;';
79 79
 } else {
80
-    $instrs['adminlink'] = '';
80
+	$instrs['adminlink'] = '';
81 81
 }
82 82
 
83 83
 // Выводим в шаблон
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 $nav_parent_id = array_reverse($nav_parent_id);
102 102
 $navigation    = '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/">' . $GLOBALS['xoopsModule']->name() . '</a>&nbsp;:&nbsp;';
103 103
 foreach (array_keys($nav_parent_id) as $i) {
104
-    $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $nav_parent_id[$i]->getVar('cid') . '">' . $nav_parent_id[$i]->getVar('title') . '</a>&nbsp;:&nbsp;';
104
+	$navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $nav_parent_id[$i]->getVar('cid') . '">' . $nav_parent_id[$i]->getVar('title') . '</a>&nbsp;:&nbsp;';
105 105
 }
106 106
 $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $objInscat->getVar('cid') . '">' . $objInscat->getVar('title') . '</a>&nbsp;:&nbsp;';
107 107
 $navigation .= $objInsinstr->getVar('title');
@@ -128,18 +128,18 @@  discard block
 block discarded – undo
128 128
 
129 129
 // Теги
130 130
 if (xoops_getModuleOption('usetag', 'instruction')) {
131
-    include_once $GLOBALS['xoops']->path('modules/tag/include/tagbar.php');
132
-    $xoopsTpl->assign('tags', true);
133
-    $xoopsTpl->assign('tagbar', tagBar($instrid, 0));
131
+	include_once $GLOBALS['xoops']->path('modules/tag/include/tagbar.php');
132
+	$xoopsTpl->assign('tags', true);
133
+	$xoopsTpl->assign('tagbar', tagBar($instrid, 0));
134 134
 } else {
135
-    $xoopsTpl->assign('tags', false);
135
+	$xoopsTpl->assign('tags', false);
136 136
 }
137 137
 
138 138
 // Рейтинг
139 139
 if (xoops_getModuleOption('userat', 'instruction')) {
140
-    $xoopsTpl->assign('insUserat', true);
140
+	$xoopsTpl->assign('insUserat', true);
141 141
 } else {
142
-    $xoopsTpl->assign('insUserat', false);
142
+	$xoopsTpl->assign('insUserat', false);
143 143
 }
144 144
 
145 145
 // Подвал
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 $inscatHandler   = xoops_getModuleHandler('category', 'instruction');
12 12
 $inspageHandler  = xoops_getModuleHandler('page', 'instruction');
13 13
 
14
-$instrid = isset($_GET['id']) ? (int)$_GET['id'] : 0;
14
+$instrid = isset($_GET['id']) ? (int) $_GET['id'] : 0;
15 15
 
16 16
 // Существует ли такая инструкция
17 17
 $criteria = new CriteriaCompo();
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
 // Права на просмотр инструкции
42 42
 $categories = InstructionUtility::getItemIds();
43
-if (!in_array($objInsinstr->getVar('cid'), $categories)) {
43
+if ( ! in_array($objInsinstr->getVar('cid'), $categories)) {
44 44
     redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM);
45 45
     exit();
46 46
 }
Please login to merge, or discard this patch.
blocks/instr_lastinstr.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -6,65 +6,65 @@
 block discarded – undo
6 6
 function b_instr_lastinstr_show($options = [])
7 7
 {
8 8
 
9
-    // Подключаем функции
9
+	// Подключаем функции
10 10
 //    $moduleDirName = dirname(__DIR__);
11
-    $moduleDirName = basename(dirname(__DIR__));
12
-    include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/class/utility.php');
13
-    //
14
-    $myts = MyTextSanitizer::getInstance();
15
-    //
16
-    $insinstrHandler = xoops_getModuleHandler('instruction', 'instruction');
11
+	$moduleDirName = basename(dirname(__DIR__));
12
+	include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/class/utility.php');
13
+	//
14
+	$myts = MyTextSanitizer::getInstance();
15
+	//
16
+	$insinstrHandler = xoops_getModuleHandler('instruction', 'instruction');
17 17
 
18
-    // Добавляем стили
19
-    //global $xoTheme;
20
-    //$xoTheme->addStylesheet( XOOPS_URL . '/modules/instruction/css/blocks.css' );
18
+	// Добавляем стили
19
+	//global $xoTheme;
20
+	//$xoTheme->addStylesheet( XOOPS_URL . '/modules/instruction/css/blocks.css' );
21 21
 
22
-    // Опции
23
-    // Количество страниц
24
-    $limit = $options[0];
25
-    // Количество символов
26
-    $numchars = $options[1];
22
+	// Опции
23
+	// Количество страниц
24
+	$limit = $options[0];
25
+	// Количество символов
26
+	$numchars = $options[1];
27 27
 
28
-    // Права на просмотр
29
-    $cat_view = InstructionUtility::getItemIds();
30
-    // Массив выходных данных
31
-    $block = [];
28
+	// Права на просмотр
29
+	$cat_view = InstructionUtility::getItemIds();
30
+	// Массив выходных данных
31
+	$block = [];
32 32
 
33
-    // Если есть категории для прасмотра
34
-    if (is_array($cat_view) && count($cat_view) > 0) {
33
+	// Если есть категории для прасмотра
34
+	if (is_array($cat_view) && count($cat_view) > 0) {
35 35
 
36
-        // Находим последние инструкции
37
-        $sql = "SELECT `instrid`, `cid`, `title`, `pages`, `dateupdated` FROM {$insinstrHandler->table} WHERE `cid` IN (" . implode(', ', $cat_view) . ') AND `status` > 0 ORDER BY `dateupdated` DESC';
38
-        // Лимит запроса
39
-        $result = $GLOBALS['xoopsDB']->query($sql, $limit);
40
-        // Перебираем все значения
41
-        $i = 0;
42
-        while (list($instrid, $cid, $ititle, $pages, $dateupdated) = $GLOBALS['xoopsDB']->fetchRow($result)) {
43
-            // ID инструкции
44
-            $block[$i]['instrid'] = $instrid;
45
-            // ID категории
46
-            $block[$i]['cid'] = $cid;
47
-            // Название инструкции
48
-            $block[$i]['ititle'] = $myts->htmlSpecialChars($ititle);
49
-            // Число страниц
50
-            $block[$i]['pages'] = $pages;
51
-            // Дата обновления инструкции
52
-            $block[$i]['dateupdated'] = formatTimeStamp($dateupdated, 's');
53
-            // Инкримент
54
-            $i++;
55
-        }
56
-    }
57
-    // Возвращаем массив
58
-    return $block;
36
+		// Находим последние инструкции
37
+		$sql = "SELECT `instrid`, `cid`, `title`, `pages`, `dateupdated` FROM {$insinstrHandler->table} WHERE `cid` IN (" . implode(', ', $cat_view) . ') AND `status` > 0 ORDER BY `dateupdated` DESC';
38
+		// Лимит запроса
39
+		$result = $GLOBALS['xoopsDB']->query($sql, $limit);
40
+		// Перебираем все значения
41
+		$i = 0;
42
+		while (list($instrid, $cid, $ititle, $pages, $dateupdated) = $GLOBALS['xoopsDB']->fetchRow($result)) {
43
+			// ID инструкции
44
+			$block[$i]['instrid'] = $instrid;
45
+			// ID категории
46
+			$block[$i]['cid'] = $cid;
47
+			// Название инструкции
48
+			$block[$i]['ititle'] = $myts->htmlSpecialChars($ititle);
49
+			// Число страниц
50
+			$block[$i]['pages'] = $pages;
51
+			// Дата обновления инструкции
52
+			$block[$i]['dateupdated'] = formatTimeStamp($dateupdated, 's');
53
+			// Инкримент
54
+			$i++;
55
+		}
56
+	}
57
+	// Возвращаем массив
58
+	return $block;
59 59
 }
60 60
 
61 61
 // Редактирование последних инструкций
62 62
 function b_instr_lastinstr_edit($options = [])
63 63
 {
64
-    $form = '';
65
-    $form .= _MB_INSTR_DISPLAYINSTRC . ' <input name="options[0]" size="5" maxlength="255" value="' . $options[0] . '" type="text" /><br>' . "\n";
66
-    $form .= _MB_INSTR_NUMCHARSC . ' <input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text" /><br>' . "\n";
64
+	$form = '';
65
+	$form .= _MB_INSTR_DISPLAYINSTRC . ' <input name="options[0]" size="5" maxlength="255" value="' . $options[0] . '" type="text" /><br>' . "\n";
66
+	$form .= _MB_INSTR_NUMCHARSC . ' <input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text" /><br>' . "\n";
67 67
 
68
-    // Возвращаем форму
69
-    return $form;
68
+	// Возвращаем форму
69
+	return $form;
70 70
 }
Please login to merge, or discard this patch.