Completed
Push — master ( a4e09c...825da9 )
by Michael
01:51
created
blocks/instr_lastpage.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -12,63 +12,63 @@  discard block
 block discarded – undo
12 12
 function b_instr_lastpage_show($options = [])
13 13
 {
14 14
 
15
-    // Подключаем функции
16
-    $moduleDirName = basename(dirname(__DIR__));
17
-    include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/class/utility.php');
18
-    //
19
-    $myts = MyTextSanitizer::getInstance();
20
-    //
21
-    //mb    $instructionHandler = xoops_getModuleHandler('instruction', 'instruction');
22
-    //mb    $pageHandler  = xoops_getModuleHandler('page', 'instruction');
15
+	// Подключаем функции
16
+	$moduleDirName = basename(dirname(__DIR__));
17
+	include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/class/utility.php');
18
+	//
19
+	$myts = MyTextSanitizer::getInstance();
20
+	//
21
+	//mb    $instructionHandler = xoops_getModuleHandler('instruction', 'instruction');
22
+	//mb    $pageHandler  = xoops_getModuleHandler('page', 'instruction');
23 23
 
24
-    $db                 = \XoopsDatabaseFactory::getDatabase();
25
-    $instructionHandler = new \Xoopsmodules\instruction\InstructionHandler($db);
26
-    $pageHandler        = new \Xoopsmodules\instruction\PageHandler($db);
24
+	$db                 = \XoopsDatabaseFactory::getDatabase();
25
+	$instructionHandler = new \Xoopsmodules\instruction\InstructionHandler($db);
26
+	$pageHandler        = new \Xoopsmodules\instruction\PageHandler($db);
27 27
 
28
-    // Добавляем стили
29
-    //global $xoTheme;
30
-    //$xoTheme->addStylesheet( XOOPS_URL . '/modules/instruction/css/blocks.css' );
28
+	// Добавляем стили
29
+	//global $xoTheme;
30
+	//$xoTheme->addStylesheet( XOOPS_URL . '/modules/instruction/css/blocks.css' );
31 31
 
32
-    // Опции
33
-    // Количество страниц
34
-    $limit = $options[0];
35
-    // Количество символов
36
-    $numchars = $options[1];
32
+	// Опции
33
+	// Количество страниц
34
+	$limit = $options[0];
35
+	// Количество символов
36
+	$numchars = $options[1];
37 37
 
38
-    // Права на просмотр
39
-    $cat_view = Xoopsmodules\instruction\Utility::getItemIds();
40
-    // Массив выходных данных
41
-    $block = [];
38
+	// Права на просмотр
39
+	$cat_view = Xoopsmodules\instruction\Utility::getItemIds();
40
+	// Массив выходных данных
41
+	$block = [];
42 42
 
43
-    // Если есть категории для прасмотра
44
-    if (is_array($cat_view) && count($cat_view) > 0) {
43
+	// Если есть категории для прасмотра
44
+	if (is_array($cat_view) && count($cat_view) > 0) {
45 45
 
46
-        // Находим последние страницы
47
-        $sql = "SELECT p.pageid, p.instrid, p.title, p.dateupdated, i.title, i.cid FROM {$pageHandler->table} p, {$instructionHandler->table} i WHERE p.instrid = i.instrid AND i.cid IN (" . implode(', ', $cat_view) . ') AND p.status > 0 AND i.status > 0 ORDER BY p.dateupdated DESC';
48
-        // Лимит запроса
49
-        $result = $GLOBALS['xoopsDB']->query($sql, $limit);
50
-        // Перебираем все значения
51
-        $i = 0;
52
-        while (list($pageid, $instrid, $ptitle, $dateupdated, $ititle, $cid) = $GLOBALS['xoopsDB']->fetchRow($result)) {
53
-            // ID страницы
54
-            $block[$i]['pageid'] = $pageid;
55
-            // ID инструкции
56
-            $block[$i]['instrid'] = $instrid;
57
-            // Название страницы
58
-            $block[$i]['ptitle'] = $myts->htmlSpecialChars($ptitle);
59
-            // Название инструкции
60
-            $block[$i]['ititle'] = $myts->htmlSpecialChars($ititle);
61
-            // Дата обновления страницы
62
-            $block[$i]['dateupdated'] = formatTimeStamp($dateupdated, 's');
63
-            // Категория инстркции
64
-            $block[$i]['cid'] = $cid;
65
-            // Инкримент
66
-            $i++;
67
-        }
68
-    }
46
+		// Находим последние страницы
47
+		$sql = "SELECT p.pageid, p.instrid, p.title, p.dateupdated, i.title, i.cid FROM {$pageHandler->table} p, {$instructionHandler->table} i WHERE p.instrid = i.instrid AND i.cid IN (" . implode(', ', $cat_view) . ') AND p.status > 0 AND i.status > 0 ORDER BY p.dateupdated DESC';
48
+		// Лимит запроса
49
+		$result = $GLOBALS['xoopsDB']->query($sql, $limit);
50
+		// Перебираем все значения
51
+		$i = 0;
52
+		while (list($pageid, $instrid, $ptitle, $dateupdated, $ititle, $cid) = $GLOBALS['xoopsDB']->fetchRow($result)) {
53
+			// ID страницы
54
+			$block[$i]['pageid'] = $pageid;
55
+			// ID инструкции
56
+			$block[$i]['instrid'] = $instrid;
57
+			// Название страницы
58
+			$block[$i]['ptitle'] = $myts->htmlSpecialChars($ptitle);
59
+			// Название инструкции
60
+			$block[$i]['ititle'] = $myts->htmlSpecialChars($ititle);
61
+			// Дата обновления страницы
62
+			$block[$i]['dateupdated'] = formatTimeStamp($dateupdated, 's');
63
+			// Категория инстркции
64
+			$block[$i]['cid'] = $cid;
65
+			// Инкримент
66
+			$i++;
67
+		}
68
+	}
69 69
 
70
-    // Возвращаем массив
71
-    return $block;
70
+	// Возвращаем массив
71
+	return $block;
72 72
 }
73 73
 
74 74
 // Редактирование последних страниц
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
  */
79 79
 function b_instr_lastpage_edit($options = [])
80 80
 {
81
-    $form = '';
82
-    $form .= _MB_INSTR_DISPLAYPAGESC . ' <input name="options[0]" size="5" maxlength="255" value="' . $options[0] . '" type="text" /><br>' . "\n";
83
-    $form .= _MB_INSTR_NUMCHARSC . ' <input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text" /><br>' . "\n";
81
+	$form = '';
82
+	$form .= _MB_INSTR_DISPLAYPAGESC . ' <input name="options[0]" size="5" maxlength="255" value="' . $options[0] . '" type="text" /><br>' . "\n";
83
+	$form .= _MB_INSTR_NUMCHARSC . ' <input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text" /><br>' . "\n";
84 84
 
85
-    // Возвращаем форму
86
-    return $form;
85
+	// Возвращаем форму
86
+	return $form;
87 87
 }
Please login to merge, or discard this patch.
blocks/instr_lastinstr.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -13,59 +13,59 @@  discard block
 block discarded – undo
13 13
 function b_instr_lastinstr_show($options = [])
14 14
 {
15 15
 
16
-    // Подключаем функции
17
-    //    $moduleDirName = dirname(__DIR__);
18
-    $moduleDirName = basename(dirname(__DIR__));
19
-    //    include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/class/utility.php');
20
-    include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/include/common.php');
21
-    //
22
-    $myts = MyTextSanitizer::getInstance();
23
-    //
24
-    //mb    $instructionHandler = xoops_getModuleHandler('instruction', 'instruction');
25
-    $db                 = \XoopsDatabaseFactory::getDatabase();
26
-    $instructionHandler = new \Xoopsmodules\instruction\InstructionHandler($db);
16
+	// Подключаем функции
17
+	//    $moduleDirName = dirname(__DIR__);
18
+	$moduleDirName = basename(dirname(__DIR__));
19
+	//    include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/class/utility.php');
20
+	include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/include/common.php');
21
+	//
22
+	$myts = MyTextSanitizer::getInstance();
23
+	//
24
+	//mb    $instructionHandler = xoops_getModuleHandler('instruction', 'instruction');
25
+	$db                 = \XoopsDatabaseFactory::getDatabase();
26
+	$instructionHandler = new \Xoopsmodules\instruction\InstructionHandler($db);
27 27
 
28
-    // Добавляем стили
29
-    //global $xoTheme;
30
-    //$xoTheme->addStylesheet( XOOPS_URL . '/modules/instruction/css/blocks.css' );
28
+	// Добавляем стили
29
+	//global $xoTheme;
30
+	//$xoTheme->addStylesheet( XOOPS_URL . '/modules/instruction/css/blocks.css' );
31 31
 
32
-    // Опции
33
-    // Количество страниц
34
-    $limit = $options[0];
35
-    // Количество символов
36
-    $numchars = $options[1];
32
+	// Опции
33
+	// Количество страниц
34
+	$limit = $options[0];
35
+	// Количество символов
36
+	$numchars = $options[1];
37 37
 
38
-    // Права на просмотр
39
-    $cat_view = Xoopsmodules\instruction\Utility::getItemIds();
40
-    // Массив выходных данных
41
-    $block = [];
38
+	// Права на просмотр
39
+	$cat_view = Xoopsmodules\instruction\Utility::getItemIds();
40
+	// Массив выходных данных
41
+	$block = [];
42 42
 
43
-    // Если есть категории для прасмотра
44
-    if (is_array($cat_view) && count($cat_view) > 0) {
43
+	// Если есть категории для прасмотра
44
+	if (is_array($cat_view) && count($cat_view) > 0) {
45 45
 
46
-        // Находим последние инструкции
47
-        $sql = "SELECT `instrid`, `cid`, `title`, `pages`, `dateupdated` FROM {$instructionHandler->table} WHERE `cid` IN (" . implode(', ', $cat_view) . ') AND `status` > 0 ORDER BY `dateupdated` DESC';
48
-        // Лимит запроса
49
-        $result = $GLOBALS['xoopsDB']->query($sql, $limit);
50
-        // Перебираем все значения
51
-        $i = 0;
52
-        while (list($instrid, $cid, $ititle, $pages, $dateupdated) = $GLOBALS['xoopsDB']->fetchRow($result)) {
53
-            // ID инструкции
54
-            $block[$i]['instrid'] = $instrid;
55
-            // ID категории
56
-            $block[$i]['cid'] = $cid;
57
-            // Название инструкции
58
-            $block[$i]['ititle'] = $myts->htmlSpecialChars($ititle);
59
-            // Число страниц
60
-            $block[$i]['pages'] = $pages;
61
-            // Дата обновления инструкции
62
-            $block[$i]['dateupdated'] = formatTimeStamp($dateupdated, 's');
63
-            // Инкримент
64
-            $i++;
65
-        }
66
-    }
67
-    // Возвращаем массив
68
-    return $block;
46
+		// Находим последние инструкции
47
+		$sql = "SELECT `instrid`, `cid`, `title`, `pages`, `dateupdated` FROM {$instructionHandler->table} WHERE `cid` IN (" . implode(', ', $cat_view) . ') AND `status` > 0 ORDER BY `dateupdated` DESC';
48
+		// Лимит запроса
49
+		$result = $GLOBALS['xoopsDB']->query($sql, $limit);
50
+		// Перебираем все значения
51
+		$i = 0;
52
+		while (list($instrid, $cid, $ititle, $pages, $dateupdated) = $GLOBALS['xoopsDB']->fetchRow($result)) {
53
+			// ID инструкции
54
+			$block[$i]['instrid'] = $instrid;
55
+			// ID категории
56
+			$block[$i]['cid'] = $cid;
57
+			// Название инструкции
58
+			$block[$i]['ititle'] = $myts->htmlSpecialChars($ititle);
59
+			// Число страниц
60
+			$block[$i]['pages'] = $pages;
61
+			// Дата обновления инструкции
62
+			$block[$i]['dateupdated'] = formatTimeStamp($dateupdated, 's');
63
+			// Инкримент
64
+			$i++;
65
+		}
66
+	}
67
+	// Возвращаем массив
68
+	return $block;
69 69
 }
70 70
 
71 71
 // Редактирование последних инструкций
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
  */
76 76
 function b_instr_lastinstr_edit($options = [])
77 77
 {
78
-    $form = '';
79
-    $form .= _MB_INSTR_DISPLAYINSTRC . ' <input name="options[0]" size="5" maxlength="255" value="' . $options[0] . '" type="text" /><br>' . "\n";
80
-    $form .= _MB_INSTR_NUMCHARSC . ' <input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text" /><br>' . "\n";
78
+	$form = '';
79
+	$form .= _MB_INSTR_DISPLAYINSTRC . ' <input name="options[0]" size="5" maxlength="255" value="' . $options[0] . '" type="text" /><br>' . "\n";
80
+	$form .= _MB_INSTR_NUMCHARSC . ' <input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text" /><br>' . "\n";
81 81
 
82
-    // Возвращаем форму
83
-    return $form;
82
+	// Возвращаем форму
83
+	return $form;
84 84
 }
Please login to merge, or discard this patch.
instr.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 $criteria->add(new \Criteria('instrid', $instrid));
20 20
 $criteria->add(new \Criteria('status ', '0', '>'));
21 21
 if (0 == $instructionHandler->getCount($criteria)) {
22
-    redirect_header('index.php', 3, _MD_INSTRUCTION_INSTRNOTEXIST);
23
-    exit();
22
+	redirect_header('index.php', 3, _MD_INSTRUCTION_INSTRNOTEXIST);
23
+	exit();
24 24
 }
25 25
 //
26 26
 unset($criteria);
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 // Права на просмотр инструкции
43 43
 $categories = Xoopsmodules\instruction\Utility::getItemIds();
44 44
 if (!in_array($objInsinstr->getVar('cid'), $categories)) {
45
-    redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM);
46
-    exit();
45
+	redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM);
46
+	exit();
47 47
 }
48 48
 
49 49
 // Массив данных об инструкции
@@ -56,29 +56,29 @@  discard block
 block discarded – undo
56 56
 $instrs['description'] = $objInsinstr->getVar('description');
57 57
 // Если админ, рисуем админлинк
58 58
 if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid())) {
59
-    $instrs['adminlink'] = '&nbsp;<a href="'
60
-                           . XOOPS_URL
61
-                           . '/modules/'
62
-                           . $moduleDirName
63
-                           . '/admin/instr.php?op=editinstr&instrid='
64
-                           . $instrid
65
-                           . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt='
66
-                           . _EDIT
67
-                           . ' title='
68
-                           . _EDIT
69
-                           . '></a>&nbsp;<a href="'
70
-                           . XOOPS_URL
71
-                           . '/modules/'
72
-                           . $moduleDirName
73
-                           . '/admin/instr.php?op=delinstr&instrid='
74
-                           . $instrid
75
-                           . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt='
76
-                           . _DELETE
77
-                           . ' title='
78
-                           . _DELETE
79
-                           . '></a>&nbsp;';
59
+	$instrs['adminlink'] = '&nbsp;<a href="'
60
+						   . XOOPS_URL
61
+						   . '/modules/'
62
+						   . $moduleDirName
63
+						   . '/admin/instr.php?op=editinstr&instrid='
64
+						   . $instrid
65
+						   . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt='
66
+						   . _EDIT
67
+						   . ' title='
68
+						   . _EDIT
69
+						   . '></a>&nbsp;<a href="'
70
+						   . XOOPS_URL
71
+						   . '/modules/'
72
+						   . $moduleDirName
73
+						   . '/admin/instr.php?op=delinstr&instrid='
74
+						   . $instrid
75
+						   . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt='
76
+						   . _DELETE
77
+						   . ' title='
78
+						   . _DELETE
79
+						   . '></a>&nbsp;';
80 80
 } else {
81
-    $instrs['adminlink'] = '';
81
+	$instrs['adminlink'] = '';
82 82
 }
83 83
 
84 84
 // Выводим в шаблон
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 $nav_parent_id = array_reverse($nav_parent_id);
103 103
 $navigation    = '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/">' . $GLOBALS['xoopsModule']->name() . '</a>&nbsp;:&nbsp;';
104 104
 foreach (array_keys($nav_parent_id) as $i) {
105
-    $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
+	$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;';
106 106
 }
107 107
 $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $objInscat->getVar('cid') . '">' . $objInscat->getVar('title') . '</a>&nbsp;:&nbsp;';
108 108
 $navigation .= $objInsinstr->getVar('title');
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
 
130 130
 // Теги
131 131
 if (xoops_getModuleOption('usetag', 'instruction')) {
132
-    include_once $GLOBALS['xoops']->path('modules/tag/include/tagbar.php');
133
-    $xoopsTpl->assign('tags', true);
134
-    $xoopsTpl->assign('tagbar', tagBar($instrid, 0));
132
+	include_once $GLOBALS['xoops']->path('modules/tag/include/tagbar.php');
133
+	$xoopsTpl->assign('tags', true);
134
+	$xoopsTpl->assign('tagbar', tagBar($instrid, 0));
135 135
 } else {
136
-    $xoopsTpl->assign('tags', false);
136
+	$xoopsTpl->assign('tags', false);
137 137
 }
138 138
 
139 139
 // Рейтинг
140 140
 if (xoops_getModuleOption('userat', 'instruction')) {
141
-    $xoopsTpl->assign('insUserat', true);
141
+	$xoopsTpl->assign('insUserat', true);
142 142
 } else {
143
-    $xoopsTpl->assign('insUserat', false);
143
+	$xoopsTpl->assign('insUserat', false);
144 144
 }
145 145
 
146 146
 // Подвал
Please login to merge, or discard this patch.
xoops_version.php 1 patch
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -10,60 +10,60 @@  discard block
 block discarded – undo
10 10
 $xoops_url     = parse_url(XOOPS_URL);
11 11
 
12 12
 $modversion = [
13
-    'version'             => 1.07,
14
-    'module_status'       => 'RC1',
15
-    'release_date'        => '2017/10/04',
16
-    'name'                => _MI_INSTRUCTION_NAME,
17
-    'description'         => _MI_INSTRUCTION_DESC,
18
-    'credits'             => 'radio-hobby.org, www.shmel.org',
19
-    'author'              => 'andrey3761, Mamba, Aerograf',
20
-    'nickname'            => '',
21
-    'help'                => 'page=help',
22
-    'license'             => 'GNU GPL 2.0',
23
-    'license_url'         => 'www.gnu.org/licenses/gpl-2.0.html/',
24
-    'official'            => 0,
25
-    'image'               => 'assets/images/logoModule.png',
26
-    'dirname'             => $moduleDirName,
27
-    'modicons16'          => 'assets/images/icons/16',
28
-    'modicons32'          => 'assets/images/icons/32',
29
-    // О модуле
30
-    'module_website_url'  => 'radio-hobby.org',
31
-    'module_website_name' => 'radio-hobby.org',
13
+	'version'             => 1.07,
14
+	'module_status'       => 'RC1',
15
+	'release_date'        => '2017/10/04',
16
+	'name'                => _MI_INSTRUCTION_NAME,
17
+	'description'         => _MI_INSTRUCTION_DESC,
18
+	'credits'             => 'radio-hobby.org, www.shmel.org',
19
+	'author'              => 'andrey3761, Mamba, Aerograf',
20
+	'nickname'            => '',
21
+	'help'                => 'page=help',
22
+	'license'             => 'GNU GPL 2.0',
23
+	'license_url'         => 'www.gnu.org/licenses/gpl-2.0.html/',
24
+	'official'            => 0,
25
+	'image'               => 'assets/images/logoModule.png',
26
+	'dirname'             => $moduleDirName,
27
+	'modicons16'          => 'assets/images/icons/16',
28
+	'modicons32'          => 'assets/images/icons/32',
29
+	// О модуле
30
+	'module_website_url'  => 'radio-hobby.org',
31
+	'module_website_name' => 'radio-hobby.org',
32 32
 
33
-    'author_website_url'  => 'radio-hobby.org',
34
-    'author_website_name' => 'andrey3761',
35
-    'min_php'             => '5.5',
36
-    'min_xoops'           => '2.5.8',
37
-    'min_admin'           => '1.1',
38
-    'min_db'              => ['mysql' => '5.5'],
39
-    // Файл базы данных
40
-    'sqlfile'             => ['mysql' => 'sql/mysql.sql'],
41
-    // Таблицы
42
-    'tables'              => [
43
-        $moduleDirName . '_cat',
44
-        $moduleDirName . '_instr',
45
-        $moduleDirName . '_page'
46
-    ],
47
-    // Имеет админку
48
-    'hasAdmin'            => 1,
49
-    'adminindex'          => 'admin/index.php',
50
-    'adminmenu'           => 'admin/menu.php',
51
-    'system_menu'         => 1,
52
-    // Меню
53
-    'hasMain'             => 1,
54
-    // Search
55
-    'hasSearch'           => 1,
56
-    'search'              => [
57
-        'file' => 'include/search.inc.php',
58
-        'func' => $moduleDirName . '_search',
59
-    ],
33
+	'author_website_url'  => 'radio-hobby.org',
34
+	'author_website_name' => 'andrey3761',
35
+	'min_php'             => '5.5',
36
+	'min_xoops'           => '2.5.8',
37
+	'min_admin'           => '1.1',
38
+	'min_db'              => ['mysql' => '5.5'],
39
+	// Файл базы данных
40
+	'sqlfile'             => ['mysql' => 'sql/mysql.sql'],
41
+	// Таблицы
42
+	'tables'              => [
43
+		$moduleDirName . '_cat',
44
+		$moduleDirName . '_instr',
45
+		$moduleDirName . '_page'
46
+	],
47
+	// Имеет админку
48
+	'hasAdmin'            => 1,
49
+	'adminindex'          => 'admin/index.php',
50
+	'adminmenu'           => 'admin/menu.php',
51
+	'system_menu'         => 1,
52
+	// Меню
53
+	'hasMain'             => 1,
54
+	// Search
55
+	'hasSearch'           => 1,
56
+	'search'              => [
57
+		'file' => 'include/search.inc.php',
58
+		'func' => $moduleDirName . '_search',
59
+	],
60 60
 ];
61 61
 //  Help files
62 62
 $modversion['helpsection'] = [
63
-    ['name' => _MI_INSTRUCTION_HELP_OVERVIEW, 'link' => 'page=help'],
64
-    ['name' => _MI_INSTRUCTION_DISCLAIMER, 'link' => 'page=disclaimer'],
65
-    ['name' => _MI_INSTRUCTION_LICENSE, 'link' => 'page=license'],
66
-    ['name' => _MI_INSTRUCTION_SUPPORT, 'link' => 'page=support'],
63
+	['name' => _MI_INSTRUCTION_HELP_OVERVIEW, 'link' => 'page=help'],
64
+	['name' => _MI_INSTRUCTION_DISCLAIMER, 'link' => 'page=disclaimer'],
65
+	['name' => _MI_INSTRUCTION_LICENSE, 'link' => 'page=license'],
66
+	['name' => _MI_INSTRUCTION_SUPPORT, 'link' => 'page=support'],
67 67
 ];
68 68
 
69 69
 // Comments
@@ -76,144 +76,144 @@  discard block
 block discarded – undo
76 76
 
77 77
 // Templates
78 78
 $modversion['templates'] = [
79
-    [
80
-        'file'        => 'admin/' . $moduleDirName . '_admin_index.tpl',
81
-        'description' => ''
82
-    ],
83
-    [
84
-        'file'        => 'admin/' . $moduleDirName . '_admin_cat.tpl',
85
-        'description' => ''
86
-    ],
87
-    [
88
-        'file'        => 'admin/' . $moduleDirName . '_admin_editcat.tpl',
89
-        'description' => ''
90
-    ],
91
-    [
92
-        'file'        => 'admin/' . $moduleDirName . '_admin_savecat.tpl',
93
-        'description' => ''
94
-    ],
95
-    [
96
-        'file'        => 'admin/' . $moduleDirName . '_admin_viewcat.tpl',
97
-        'description' => ''
98
-    ],
99
-    [
100
-        'file'        => 'admin/' . $moduleDirName . '_admin_instr.tpl',
101
-        'description' => ''
102
-    ],
103
-    [
104
-        'file'        => 'admin/' . $moduleDirName . '_admin_editinstr.tpl',
105
-        'description' => ''
106
-    ],
107
-    [
108
-        'file'        => 'admin/' . $moduleDirName . '_admin_saveinstr.tpl',
109
-        'description' => ''
110
-    ],
111
-    [
112
-        'file'        => 'admin/' . $moduleDirName . '_admin_viewinstr.tpl',
113
-        'description' => ''
114
-    ],
115
-    [
116
-        'file'        => 'admin/' . $moduleDirName . '_admin_editpage.tpl',
117
-        'description' => ''
118
-    ],
119
-    [
120
-        'file'        => 'admin/' . $moduleDirName . '_admin_savepage.tpl',
121
-        'description' => ''
122
-    ],
123
-    [
124
-        'file'        => 'admin/' . $moduleDirName . '_admin_perm.tpl',
125
-        'description' => ''
126
-    ],
127
-    [
128
-        'file'        => 'admin/' . $moduleDirName . '_admin_about.tpl',
129
-        'description' => ''
130
-    ],
131
-    [
132
-        'file'        => $moduleDirName . '_page.tpl',
133
-        'description' => ''
134
-    ],
135
-    [
136
-        'file'        => $moduleDirName . '_instr.tpl',
137
-        'description' => ''
138
-    ],
139
-    [
140
-        'file'        => $moduleDirName . '_index.tpl',
141
-        'description' => ''
142
-    ],
143
-    [
144
-        'file'        => $moduleDirName . '_editpage.tpl',
145
-        'description' => ''
146
-    ],
147
-    [
148
-        'file'        => $moduleDirName . '_savepage.tpl',
149
-        'description' => ''
150
-    ],
79
+	[
80
+		'file'        => 'admin/' . $moduleDirName . '_admin_index.tpl',
81
+		'description' => ''
82
+	],
83
+	[
84
+		'file'        => 'admin/' . $moduleDirName . '_admin_cat.tpl',
85
+		'description' => ''
86
+	],
87
+	[
88
+		'file'        => 'admin/' . $moduleDirName . '_admin_editcat.tpl',
89
+		'description' => ''
90
+	],
91
+	[
92
+		'file'        => 'admin/' . $moduleDirName . '_admin_savecat.tpl',
93
+		'description' => ''
94
+	],
95
+	[
96
+		'file'        => 'admin/' . $moduleDirName . '_admin_viewcat.tpl',
97
+		'description' => ''
98
+	],
99
+	[
100
+		'file'        => 'admin/' . $moduleDirName . '_admin_instr.tpl',
101
+		'description' => ''
102
+	],
103
+	[
104
+		'file'        => 'admin/' . $moduleDirName . '_admin_editinstr.tpl',
105
+		'description' => ''
106
+	],
107
+	[
108
+		'file'        => 'admin/' . $moduleDirName . '_admin_saveinstr.tpl',
109
+		'description' => ''
110
+	],
111
+	[
112
+		'file'        => 'admin/' . $moduleDirName . '_admin_viewinstr.tpl',
113
+		'description' => ''
114
+	],
115
+	[
116
+		'file'        => 'admin/' . $moduleDirName . '_admin_editpage.tpl',
117
+		'description' => ''
118
+	],
119
+	[
120
+		'file'        => 'admin/' . $moduleDirName . '_admin_savepage.tpl',
121
+		'description' => ''
122
+	],
123
+	[
124
+		'file'        => 'admin/' . $moduleDirName . '_admin_perm.tpl',
125
+		'description' => ''
126
+	],
127
+	[
128
+		'file'        => 'admin/' . $moduleDirName . '_admin_about.tpl',
129
+		'description' => ''
130
+	],
131
+	[
132
+		'file'        => $moduleDirName . '_page.tpl',
133
+		'description' => ''
134
+	],
135
+	[
136
+		'file'        => $moduleDirName . '_instr.tpl',
137
+		'description' => ''
138
+	],
139
+	[
140
+		'file'        => $moduleDirName . '_index.tpl',
141
+		'description' => ''
142
+	],
143
+	[
144
+		'file'        => $moduleDirName . '_editpage.tpl',
145
+		'description' => ''
146
+	],
147
+	[
148
+		'file'        => $moduleDirName . '_savepage.tpl',
149
+		'description' => ''
150
+	],
151 151
 ];
152 152
 // Конфигурация
153 153
 $modversion['config'][] = [
154
-    'name'        => 'form_options',
155
-    'title'       => '_MI_INSTRUCTION_FORM_OPTIONS',
156
-    'description' => '_MI_INSTRUCTION_FORM_OPTIONS_DESC',
157
-    'formtype'    => 'select',
158
-    'valuetype'   => 'text',
159
-    'default'     => 'dhtml',
160
-    'options'     => array_flip($editorHandler->getList())
154
+	'name'        => 'form_options',
155
+	'title'       => '_MI_INSTRUCTION_FORM_OPTIONS',
156
+	'description' => '_MI_INSTRUCTION_FORM_OPTIONS_DESC',
157
+	'formtype'    => 'select',
158
+	'valuetype'   => 'text',
159
+	'default'     => 'dhtml',
160
+	'options'     => array_flip($editorHandler->getList())
161 161
 ];
162 162
 $modversion['config'][] = [
163
-    'name'        => 'perpageadmin',
164
-    'title'       => '_MI_INSTRUCTION_PERPAGEADMIN',
165
-    'description' => '_MI_INSTRUCTION_PERPAGEADMINDSC',
166
-    'formtype'    => 'textbox',
167
-    'valuetype'   => 'int',
168
-    'default'     => 20
163
+	'name'        => 'perpageadmin',
164
+	'title'       => '_MI_INSTRUCTION_PERPAGEADMIN',
165
+	'description' => '_MI_INSTRUCTION_PERPAGEADMINDSC',
166
+	'formtype'    => 'textbox',
167
+	'valuetype'   => 'int',
168
+	'default'     => 20
169 169
 ];
170 170
 $modversion['config'][] = [
171
-    'name'        => 'perpagemain',
172
-    'title'       => '_MI_INSTRUCTION_PERPAGEMAIN',
173
-    'description' => '_MI_INSTRUCTION_PERPAGEMAINDSC',
174
-    'formtype'    => 'textbox',
175
-    'valuetype'   => 'int',
176
-    'default'     => 20
171
+	'name'        => 'perpagemain',
172
+	'title'       => '_MI_INSTRUCTION_PERPAGEMAIN',
173
+	'description' => '_MI_INSTRUCTION_PERPAGEMAINDSC',
174
+	'formtype'    => 'textbox',
175
+	'valuetype'   => 'int',
176
+	'default'     => 20
177 177
 ];
178 178
 // Теги
179 179
 $modversion['config'][] = [
180
-    'name'        => 'usetag',
181
-    'title'       => '_MI_INSTRUCTION_USETAG',
182
-    'description' => '_MI_INSTRUCTION_USETAGDSC',
183
-    'formtype'    => 'yesno',
184
-    'valuetype'   => 'int',
185
-    'default'     => 0
180
+	'name'        => 'usetag',
181
+	'title'       => '_MI_INSTRUCTION_USETAG',
182
+	'description' => '_MI_INSTRUCTION_USETAGDSC',
183
+	'formtype'    => 'yesno',
184
+	'valuetype'   => 'int',
185
+	'default'     => 0
186 186
 ];
187 187
 // Оценки
188 188
 $modversion['config'][] = [
189
-    'name'        => 'userat',
190
-    'title'       => '_MI_INSTRUCTION_USERAT',
191
-    'description' => '_MI_INSTRUCTION_USERATDSC',
192
-    'formtype'    => 'yesno',
193
-    'valuetype'   => 'int',
194
-    'default'     => 0
189
+	'name'        => 'userat',
190
+	'title'       => '_MI_INSTRUCTION_USERAT',
191
+	'description' => '_MI_INSTRUCTION_USERATDSC',
192
+	'formtype'    => 'yesno',
193
+	'valuetype'   => 'int',
194
+	'default'     => 0
195 195
 ];
196 196
 
197 197
 // Блоки
198 198
 // Блок последних страниц
199 199
 $modversion['blocks'][] = [
200
-    'file'        => 'instr_lastpage.php',
201
-    'name'        => _MI_INSTR_BLOCK_LASTPAGE,
202
-    'description' => _MI_INSTR_BLOCK_LASTPAGE_DESC,
203
-    'show_func'   => 'b_instr_lastpage_show',
204
-    'edit_func'   => 'b_instr_lastpage_edit',
205
-    'options'     => '10|20',
206
-    'template'    => $moduleDirName . '_block_lastpage.tpl'
200
+	'file'        => 'instr_lastpage.php',
201
+	'name'        => _MI_INSTR_BLOCK_LASTPAGE,
202
+	'description' => _MI_INSTR_BLOCK_LASTPAGE_DESC,
203
+	'show_func'   => 'b_instr_lastpage_show',
204
+	'edit_func'   => 'b_instr_lastpage_edit',
205
+	'options'     => '10|20',
206
+	'template'    => $moduleDirName . '_block_lastpage.tpl'
207 207
 ];
208 208
 // Блок последних инструкций
209 209
 $modversion['blocks'][] = [
210
-    'file'        => 'instr_lastinstr.php',
211
-    'name'        => _MI_INSTR_BLOCK_LASTINSTR,
212
-    'description' => _MI_INSTR_BLOCK_LASTINSTR_DESC,
213
-    'show_func'   => 'b_instr_lastinstr_show',
214
-    'edit_func'   => 'b_instr_lastinstr_edit',
215
-    'options'     => '10|20',
216
-    'template'    => $moduleDirName . '_block_lastinstr.tpl'
210
+	'file'        => 'instr_lastinstr.php',
211
+	'name'        => _MI_INSTR_BLOCK_LASTINSTR,
212
+	'description' => _MI_INSTR_BLOCK_LASTINSTR_DESC,
213
+	'show_func'   => 'b_instr_lastinstr_show',
214
+	'edit_func'   => 'b_instr_lastinstr_edit',
215
+	'options'     => '10|20',
216
+	'template'    => $moduleDirName . '_block_lastinstr.tpl'
217 217
 ];
218 218
 
219 219
 // Notification
Please login to merge, or discard this patch.
admin/cat.php 1 patch
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -29,264 +29,264 @@
 block discarded – undo
29 29
 // Выбор
30 30
 switch ($op) {
31 31
 
32
-    case 'main':
33
-
34
-        // Подключаем трей
35
-
36
-        //        include_once __DIR__  . '/../class/tree.php';
37
-        //include_once $GLOBALS['xoops']->path('modules/instruction/class/tree.php');
38
-
39
-        // Заголовок админки
40
-        xoops_cp_header();
41
-        // Навигация
42
-        $adminObject->displayNavigation(basename(__FILE__));
43
-
44
-        // Находим ID-категории => Число страниц
45
-        $cidinstrids = [];
46
-        $sql         = "SELECT `cid`, COUNT( `instrid` ) FROM {$instructionHandler->table} GROUP BY `cid`";
47
-        $result      = $GLOBALS['xoopsDB']->query($sql);
48
-        while (list($cid, $count) = $GLOBALS['xoopsDB']->fetchRow($result)) {
49
-            // Заполняем массив
50
-            $cidinstrids[$cid] = $count;
51
-        }
52
-
53
-        // Выбираем категории из БД
54
-        $criteria = new \CriteriaCompo();
55
-        $criteria->setSort('weight ASC, title');
56
-        $criteria->setOrder('ASC');
57
-        $ins_cat = $categoryHandler->getall($criteria);
58
-        unset($criteria);
59
-
60
-        // Инициализируем
61
-        $cattree = new instruction\Tree($ins_cat, 'cid', 'pid');
62
-        // Выводим списко категорий в шаблон
63
-        $GLOBALS['xoopsTpl']->assign('insListCat', $cattree->makeCatsAdmin('--', $cidinstrids));
64
-
65
-        // Создание новой категории
66
-        $objInstructioncat = $categoryHandler->create();
67
-        $form              = $objInstructioncat->getForm('cat.php');
68
-        // Форма
69
-        $GLOBALS['xoopsTpl']->assign('insFormCat', $form->render());
70
-        // Выводим шаблон
71
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_cat.tpl');
72
-
73
-        // Текст внизу админки
74
-        include __DIR__ . '/admin_footer.php';
75
-
76
-        break;
77
-
78
-    // Редактирование категории
79
-    case 'editcat':
80
-
81
-        // Заголовок админки
82
-        xoops_cp_header();
83
-        // Навигация
84
-        $adminObject->displayNavigation(basename(__FILE__));
85
-
86
-        $objInstructioncat = $categoryHandler->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
-        break;
98
-
99
-    // Сохранение категорий
100
-    case 'savecat':
101
-
102
-        // Проверка
103
-        if (!$GLOBALS['xoopsSecurity']->check()) {
104
-            redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
105
-        }
106
-        // Если мы редактируем
107
-        if ($cid) {
108
-            $objInstructioncat = $categoryHandler->get($cid);
109
-        } else {
110
-            $objInstructioncat = $categoryHandler->create();
111
-            // Указываем дату создания
112
-            $objInstructioncat->setVar('datecreated', $time);
113
-        }
114
-
115
-        $err         = false;
116
-        $message_err = '';
117
-
118
-        // Дата обновления
119
-        $objInstructioncat->setVar('dateupdated', $time);
120
-        $objInstructioncat->setVar('pid', $pid);
121
-        $objInstructioncat->setVar('title', $_POST['title']);
122
-        $objInstructioncat->setVar('description', $_POST['description']);
123
-        $objInstructioncat->setVar('weight', $weight);
124
-        $objInstructioncat->setVar('metakeywords', $_POST['metakeywords']);
125
-        $objInstructioncat->setVar('metadescription', $_POST['metadescription']);
126
-
127
-        // Проверка веса
128
-        if (0 == $weight) {
129
-            $err         = true;
130
-            $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>';
131
-        }
132
-        // Проверка категорий
133
-        if ($cid && ($cid == $pid)) {
134
-            $err         = true;
135
-            $message_err .= _AM_INSTRUCTION_ERR_PCAT . '<br>';
136
-        }
137
-        // Если были ошибки
138
-        if (true === $err) {
139
-            xoops_cp_header();
140
-            // Навигация
141
-            $adminObject->displayNavigation(basename(__FILE__));
142
-
143
-            $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
144
-            // Выводим ошибки в шаблон
145
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
146
-            // Если небыло ошибок
147
-        } else {
148
-            // Вставляем данные в БД
149
-            if ($categoryHandler->insert($objInstructioncat)) {
150
-
151
-                // ID категории. Если редактируем - то не изменяется. Если создаём новую - то получаем ID созданной записи.
152
-                $new_cid = $cid ?: $objInstructioncat->get_new_enreg();
153
-
154
-                // ===============
155
-                // ==== Права ====
156
-                // ===============
157
-
158
-                $gpermHandler = xoops_getHandler('groupperm');
159
-
160
-                // Если мы редактируем категорию, то старые права нужно удалить
161
-                if ($cid) {
162
-                    // Права на просмотр
163
-                    $criteria = new\ CriteriaCompo();
164
-                    $criteria->add(new \Criteria('gperm_itemid', $new_cid, '='));
165
-                    $criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '='));
166
-                    $criteria->add(new \Criteria('gperm_name', 'instruction_view', '='));
167
-                    $gpermHandler->deleteAll($criteria);
168
-                    // Права на добавление
169
-                    $criteria = new \CriteriaCompo();
170
-                    $criteria->add(new \Criteria('gperm_itemid', $new_cid, '='));
171
-                    $criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '='));
172
-                    $criteria->add(new \Criteria('gperm_name', 'instruction_submit', '='));
173
-                    $gpermHandler->deleteAll($criteria);
174
-                    // Права на редактирование
175
-                    $criteria = new \CriteriaCompo();
176
-                    $criteria->add(new \Criteria('gperm_itemid', $new_cid, '='));
177
-                    $criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '='));
178
-                    $criteria->add(new \Criteria('gperm_name', 'instruction_edit', '='));
179
-                    $gpermHandler->deleteAll($criteria);
180
-                }
181
-
182
-                // Добавляем права
183
-                // Права на просмотр
184
-                if (isset($_POST['groups_instr_view'])) {
185
-                    foreach ($_POST['groups_instr_view'] as $onegroup_id) {
186
-                        $gpermHandler->addRight('instruction_view', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid'));
187
-                    }
188
-                }
189
-                // Права на добавление
190
-                if (isset($_POST['groups_instr_submit'])) {
191
-                    foreach ($_POST['groups_instr_submit'] as $onegroup_id) {
192
-                        $gpermHandler->addRight('instruction_submit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid'));
193
-                    }
194
-                }
195
-                // Права на редактирование
196
-                if (isset($_POST['groups_instr_edit'])) {
197
-                    foreach ($_POST['groups_instr_edit'] as $onegroup_id) {
198
-                        $gpermHandler->addRight('instruction_edit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid'));
199
-                    }
200
-                }
201
-
202
-                //
203
-                redirect_header('cat.php', 3, _AM_INSTRUCTION_NEWCATADDED);
204
-            }
205
-            xoops_cp_header();
206
-            // Навигация
207
-            $adminObject->displayNavigation(basename(__FILE__));
208
-            // Выводим ошибки в шаблон
209
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors());
210
-        }
211
-        // Выводим шаблон
212
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savecat.tpl');
213
-        // Выводим форму
214
-        $form = $objInstructioncat->getForm();
215
-        // Форма
216
-        echo $form->render();
217
-        // Текст внизу админки
218
-        include __DIR__ . '/admin_footer.php';
219
-
220
-        break;
221
-
222
-    // Удаление категории
223
-    case 'delcat':
224
-
225
-        // Находим число инструкций в данной категории
226
-        // Критерий выборки
227
-        $criteria = new \CriteriaCompo();
228
-        // Все инструкции в данной категории
229
-        $criteria->add(new \Criteria('cid', $cid, '='));
230
-        $numrows = $instructionHandler->getCount($criteria);
231
-        //
232
-        unset($criteria);
233
-        // Если есть хоть одна инструкция
234
-        if ($numrows) {
235
-            redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTEMPTY);
236
-        }
237
-
238
-        $objInscat = $categoryHandler->get($cid);
239
-        // Если нет такой категории
240
-        if (!is_object($objInscat)) {
241
-            redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT);
242
-        }
243
-
244
-        // Нельзя удалять пока есть доченрии категории
245
-        // Подключаем трей
246
-        include_once $GLOBALS['xoops']->path('class/tree.php');
247
-        $inscat_arr   = $categoryHandler->getall();
248
-        $mytree       = new \XoopsObjectTree($inscat_arr, 'cid', 'pid');
249
-        $ins_childcat = $mytree->getAllChild($cid);
250
-        // Если есть дочернии категории
251
-        if (count($ins_childcat)) {
252
-            redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATCHILDREN);
253
-        }
254
-
255
-        // Нажали ли мы на кнопку OK
256
-        $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
257
-        // Если мы нажали на кнопку
258
-        if ($ok) {
259
-
260
-            // Проверка
261
-            if (!$GLOBALS['xoopsSecurity']->check()) {
262
-                redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
263
-            }
264
-            // Пытаемся удалить категорию
265
-            if ($categoryHandler->delete($objInscat)) {
266
-
267
-                // Удалить права доступа к категории
268
-                // =================================
269
-
270
-                // Редирект
271
-                redirect_header('cat.php', 3, _AM_INSTRUCTION_CATDELETED);
272
-                // Если не смогли удалить категорию
273
-            } else {
274
-                // Редирект
275
-                redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_DELCAT);
276
-            }
277
-        } else {
278
-
279
-            // Заголовок админки
280
-            xoops_cp_header();
281
-            // Навигация
282
-            $adminObject->displayNavigation(basename(__FILE__));
283
-
284
-            xoops_confirm(['ok' => 1, 'cid' => $cid, 'op' => 'delcat'], 'cat.php', sprintf(_AM_INSTRUCTION_FORMDELCAT, $objInscat->getVar('title')));
285
-
286
-            // Текст внизу админки
287
-            include __DIR__ . '/admin_footer.php';
288
-        }
289
-
290
-        break;
32
+	case 'main':
33
+
34
+		// Подключаем трей
35
+
36
+		//        include_once __DIR__  . '/../class/tree.php';
37
+		//include_once $GLOBALS['xoops']->path('modules/instruction/class/tree.php');
38
+
39
+		// Заголовок админки
40
+		xoops_cp_header();
41
+		// Навигация
42
+		$adminObject->displayNavigation(basename(__FILE__));
43
+
44
+		// Находим ID-категории => Число страниц
45
+		$cidinstrids = [];
46
+		$sql         = "SELECT `cid`, COUNT( `instrid` ) FROM {$instructionHandler->table} GROUP BY `cid`";
47
+		$result      = $GLOBALS['xoopsDB']->query($sql);
48
+		while (list($cid, $count) = $GLOBALS['xoopsDB']->fetchRow($result)) {
49
+			// Заполняем массив
50
+			$cidinstrids[$cid] = $count;
51
+		}
52
+
53
+		// Выбираем категории из БД
54
+		$criteria = new \CriteriaCompo();
55
+		$criteria->setSort('weight ASC, title');
56
+		$criteria->setOrder('ASC');
57
+		$ins_cat = $categoryHandler->getall($criteria);
58
+		unset($criteria);
59
+
60
+		// Инициализируем
61
+		$cattree = new instruction\Tree($ins_cat, 'cid', 'pid');
62
+		// Выводим списко категорий в шаблон
63
+		$GLOBALS['xoopsTpl']->assign('insListCat', $cattree->makeCatsAdmin('--', $cidinstrids));
64
+
65
+		// Создание новой категории
66
+		$objInstructioncat = $categoryHandler->create();
67
+		$form              = $objInstructioncat->getForm('cat.php');
68
+		// Форма
69
+		$GLOBALS['xoopsTpl']->assign('insFormCat', $form->render());
70
+		// Выводим шаблон
71
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_cat.tpl');
72
+
73
+		// Текст внизу админки
74
+		include __DIR__ . '/admin_footer.php';
75
+
76
+		break;
77
+
78
+	// Редактирование категории
79
+	case 'editcat':
80
+
81
+		// Заголовок админки
82
+		xoops_cp_header();
83
+		// Навигация
84
+		$adminObject->displayNavigation(basename(__FILE__));
85
+
86
+		$objInstructioncat = $categoryHandler->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
+		break;
98
+
99
+	// Сохранение категорий
100
+	case 'savecat':
101
+
102
+		// Проверка
103
+		if (!$GLOBALS['xoopsSecurity']->check()) {
104
+			redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
105
+		}
106
+		// Если мы редактируем
107
+		if ($cid) {
108
+			$objInstructioncat = $categoryHandler->get($cid);
109
+		} else {
110
+			$objInstructioncat = $categoryHandler->create();
111
+			// Указываем дату создания
112
+			$objInstructioncat->setVar('datecreated', $time);
113
+		}
114
+
115
+		$err         = false;
116
+		$message_err = '';
117
+
118
+		// Дата обновления
119
+		$objInstructioncat->setVar('dateupdated', $time);
120
+		$objInstructioncat->setVar('pid', $pid);
121
+		$objInstructioncat->setVar('title', $_POST['title']);
122
+		$objInstructioncat->setVar('description', $_POST['description']);
123
+		$objInstructioncat->setVar('weight', $weight);
124
+		$objInstructioncat->setVar('metakeywords', $_POST['metakeywords']);
125
+		$objInstructioncat->setVar('metadescription', $_POST['metadescription']);
126
+
127
+		// Проверка веса
128
+		if (0 == $weight) {
129
+			$err         = true;
130
+			$message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>';
131
+		}
132
+		// Проверка категорий
133
+		if ($cid && ($cid == $pid)) {
134
+			$err         = true;
135
+			$message_err .= _AM_INSTRUCTION_ERR_PCAT . '<br>';
136
+		}
137
+		// Если были ошибки
138
+		if (true === $err) {
139
+			xoops_cp_header();
140
+			// Навигация
141
+			$adminObject->displayNavigation(basename(__FILE__));
142
+
143
+			$message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
144
+			// Выводим ошибки в шаблон
145
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
146
+			// Если небыло ошибок
147
+		} else {
148
+			// Вставляем данные в БД
149
+			if ($categoryHandler->insert($objInstructioncat)) {
150
+
151
+				// ID категории. Если редактируем - то не изменяется. Если создаём новую - то получаем ID созданной записи.
152
+				$new_cid = $cid ?: $objInstructioncat->get_new_enreg();
153
+
154
+				// ===============
155
+				// ==== Права ====
156
+				// ===============
157
+
158
+				$gpermHandler = xoops_getHandler('groupperm');
159
+
160
+				// Если мы редактируем категорию, то старые права нужно удалить
161
+				if ($cid) {
162
+					// Права на просмотр
163
+					$criteria = new\ CriteriaCompo();
164
+					$criteria->add(new \Criteria('gperm_itemid', $new_cid, '='));
165
+					$criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '='));
166
+					$criteria->add(new \Criteria('gperm_name', 'instruction_view', '='));
167
+					$gpermHandler->deleteAll($criteria);
168
+					// Права на добавление
169
+					$criteria = new \CriteriaCompo();
170
+					$criteria->add(new \Criteria('gperm_itemid', $new_cid, '='));
171
+					$criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '='));
172
+					$criteria->add(new \Criteria('gperm_name', 'instruction_submit', '='));
173
+					$gpermHandler->deleteAll($criteria);
174
+					// Права на редактирование
175
+					$criteria = new \CriteriaCompo();
176
+					$criteria->add(new \Criteria('gperm_itemid', $new_cid, '='));
177
+					$criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '='));
178
+					$criteria->add(new \Criteria('gperm_name', 'instruction_edit', '='));
179
+					$gpermHandler->deleteAll($criteria);
180
+				}
181
+
182
+				// Добавляем права
183
+				// Права на просмотр
184
+				if (isset($_POST['groups_instr_view'])) {
185
+					foreach ($_POST['groups_instr_view'] as $onegroup_id) {
186
+						$gpermHandler->addRight('instruction_view', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid'));
187
+					}
188
+				}
189
+				// Права на добавление
190
+				if (isset($_POST['groups_instr_submit'])) {
191
+					foreach ($_POST['groups_instr_submit'] as $onegroup_id) {
192
+						$gpermHandler->addRight('instruction_submit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid'));
193
+					}
194
+				}
195
+				// Права на редактирование
196
+				if (isset($_POST['groups_instr_edit'])) {
197
+					foreach ($_POST['groups_instr_edit'] as $onegroup_id) {
198
+						$gpermHandler->addRight('instruction_edit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid'));
199
+					}
200
+				}
201
+
202
+				//
203
+				redirect_header('cat.php', 3, _AM_INSTRUCTION_NEWCATADDED);
204
+			}
205
+			xoops_cp_header();
206
+			// Навигация
207
+			$adminObject->displayNavigation(basename(__FILE__));
208
+			// Выводим ошибки в шаблон
209
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors());
210
+		}
211
+		// Выводим шаблон
212
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savecat.tpl');
213
+		// Выводим форму
214
+		$form = $objInstructioncat->getForm();
215
+		// Форма
216
+		echo $form->render();
217
+		// Текст внизу админки
218
+		include __DIR__ . '/admin_footer.php';
219
+
220
+		break;
221
+
222
+	// Удаление категории
223
+	case 'delcat':
224
+
225
+		// Находим число инструкций в данной категории
226
+		// Критерий выборки
227
+		$criteria = new \CriteriaCompo();
228
+		// Все инструкции в данной категории
229
+		$criteria->add(new \Criteria('cid', $cid, '='));
230
+		$numrows = $instructionHandler->getCount($criteria);
231
+		//
232
+		unset($criteria);
233
+		// Если есть хоть одна инструкция
234
+		if ($numrows) {
235
+			redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTEMPTY);
236
+		}
237
+
238
+		$objInscat = $categoryHandler->get($cid);
239
+		// Если нет такой категории
240
+		if (!is_object($objInscat)) {
241
+			redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT);
242
+		}
243
+
244
+		// Нельзя удалять пока есть доченрии категории
245
+		// Подключаем трей
246
+		include_once $GLOBALS['xoops']->path('class/tree.php');
247
+		$inscat_arr   = $categoryHandler->getall();
248
+		$mytree       = new \XoopsObjectTree($inscat_arr, 'cid', 'pid');
249
+		$ins_childcat = $mytree->getAllChild($cid);
250
+		// Если есть дочернии категории
251
+		if (count($ins_childcat)) {
252
+			redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATCHILDREN);
253
+		}
254
+
255
+		// Нажали ли мы на кнопку OK
256
+		$ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
257
+		// Если мы нажали на кнопку
258
+		if ($ok) {
259
+
260
+			// Проверка
261
+			if (!$GLOBALS['xoopsSecurity']->check()) {
262
+				redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
263
+			}
264
+			// Пытаемся удалить категорию
265
+			if ($categoryHandler->delete($objInscat)) {
266
+
267
+				// Удалить права доступа к категории
268
+				// =================================
269
+
270
+				// Редирект
271
+				redirect_header('cat.php', 3, _AM_INSTRUCTION_CATDELETED);
272
+				// Если не смогли удалить категорию
273
+			} else {
274
+				// Редирект
275
+				redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_DELCAT);
276
+			}
277
+		} else {
278
+
279
+			// Заголовок админки
280
+			xoops_cp_header();
281
+			// Навигация
282
+			$adminObject->displayNavigation(basename(__FILE__));
283
+
284
+			xoops_confirm(['ok' => 1, 'cid' => $cid, 'op' => 'delcat'], 'cat.php', sprintf(_AM_INSTRUCTION_FORMDELCAT, $objInscat->getVar('title')));
285
+
286
+			// Текст внизу админки
287
+			include __DIR__ . '/admin_footer.php';
288
+		}
289
+
290
+		break;
291 291
 
292 292
 }
Please login to merge, or discard this patch.
admin/instr.php 1 patch
Indentation   +561 added lines, -561 removed lines patch added patch discarded remove patch
@@ -42,566 +42,566 @@
 block discarded – undo
42 42
 // Выбор
43 43
 switch ($op) {
44 44
 
45
-    case 'main':
46
-
47
-        // Заголовок админки
48
-        xoops_cp_header();
49
-        // Меню
50
-        $adminObject->displayNavigation(basename(__FILE__));
51
-        $adminObject->addItemButton(_AM_INSTRUCTION_ADDINSTR, 'instr.php?op=editinstr', 'add');
52
-        $adminObject->displayButton('left', '');
53
-
54
-        //
55
-        $criteria = new \CriteriaCompo();
56
-
57
-        // Если была передана категория
58
-        if ($cid) {
59
-            // Добавляем в выборку ID категории
60
-            $criteria->add(new \Criteria('cid', $cid, '='));
61
-            // Получаем объект категории
62
-            $objInscat = $categoryHandler->get($cid);
63
-            // Если нет такой категории
64
-            if (!is_object($objInscat)) {
65
-                redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT);
66
-            }
67
-        }
68
-
69
-        // Число инструкций, удовлетворяющих данному условию
70
-        $numrows = $instructionHandler->getCount($criteria);
71
-
72
-        // Число выборки
73
-        $criteria->setLimit($limit);
74
-        // Начинасть с данного элемента
75
-        $criteria->setStart($start);
76
-        // Сортировать по
77
-        $criteria->setSort('instrid');
78
-        // Порядок сортировки
79
-        $criteria->setOrder('DESC');
80
-        // Находим все справки
81
-        $instr_arr = $instructionHandler->getall($criteria);
82
-        // Если записей больше чем $limit, то выводим пагинатор
83
-        if ($numrows > $limit) {
84
-            $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'op=' . $op . '&amp;cid=' . $cid);
85
-            $pagenav = $pagenav->renderNav(4);
86
-        } else {
87
-            $pagenav = '';
88
-        }
89
-        // Выводим пагинатор в шаблон
90
-        $GLOBALS['xoopsTpl']->assign('insPagenav', $pagenav);
91
-
92
-        // Если есть записи
93
-        if ($numrows > 0) {
94
-            $class = 'odd';
95
-            foreach (array_keys($instr_arr) as $i) {
96
-
97
-                //
98
-                $class = ('even' === $class) ? 'odd' : 'even';
99
-                // ID
100
-                $insinstr_instrid = $instr_arr[$i]->getVar('instrid');
101
-                // Название
102
-                $insinstr_title = $instr_arr[$i]->getVar('title');
103
-                // Статус
104
-                $insinstr_status = $instr_arr[$i]->getVar('status');
105
-                // Количество страниц
106
-                $insinstr_pages = $instr_arr[$i]->getVar('pages');
107
-                // Категория
108
-                $insinstr_cat = $categoryHandler->get($instr_arr[$i]->getVar('cid'));
109
-
110
-                // Выводим в шаблон
111
-                $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]);
112
-            }
113
-
114
-            //
115
-            $inshead = isset($objInscat) && is_object($objInscat) ? sprintf(_AM_INSTR_LISTINSTRINCAT, $objInscat->getVar('title')) : _AM_INSTR_LISTINSTRALL;
116
-            $GLOBALS['xoopsTpl']->assign('insHead', $inshead);
117
-            // Языковые константы
118
-            $GLOBALS['xoopsTpl']->assign('lang_title', _AM_INSTRUCTION_TITLE);
119
-            $GLOBALS['xoopsTpl']->assign('lang_cat', _AM_INSTRUCTION_CAT);
120
-            $GLOBALS['xoopsTpl']->assign('lang_pages', _AM_INSTRUCTION_PAGES);
121
-            $GLOBALS['xoopsTpl']->assign('lang_action', _AM_INSTRUCTION_ACTION);
122
-            $GLOBALS['xoopsTpl']->assign('lang_display', _AM_INSTRUCTION_DISPLAY);
123
-            $GLOBALS['xoopsTpl']->assign('lang_edit', _AM_INSTRUCTION_EDIT);
124
-            $GLOBALS['xoopsTpl']->assign('lang_del', _AM_INSTRUCTION_DEL);
125
-            $GLOBALS['xoopsTpl']->assign('lang_lock', _AM_INSTRUCTION_LOCK);
126
-            $GLOBALS['xoopsTpl']->assign('lang_unlock', _AM_INSTRUCTION_UNLOCK);
127
-            $GLOBALS['xoopsTpl']->assign('lang_addpage', _AM_INSTRUCTION_ADDPAGE);
128
-            $GLOBALS['xoopsTpl']->assign('lang_addinstr', _AM_INSTRUCTION_ADDINSTR);
129
-        }
130
-
131
-        // Выводим шаблон
132
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_instr.tpl');
133
-
134
-        // Текст внизу админки
135
-        include __DIR__ . '/admin_footer.php';
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 = $instructionHandler->get($instrid);
150
-            // Создание новой страницы
151
-        } else {
152
-            $objInsinstr = $instructionHandler->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
-        break;
165
-
166
-    // Сохранение инструкций
167
-    case 'saveinstr':
168
-
169
-        // Проверка
170
-        if (!$GLOBALS['xoopsSecurity']->check()) {
171
-            redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
172
-        }
173
-        // Если мы редактируем
174
-        if ($instrid) {
175
-            $objInsinstr = $instructionHandler->get($instrid);
176
-        } else {
177
-            $objInsinstr = $instructionHandler->create();
178
-            // Указываем дату создания
179
-            $objInsinstr->setVar('datecreated', $time);
180
-            // Указываем пользователя
181
-            $objInsinstr->setVar('uid', $uid);
182
-        }
183
-
184
-        $err         = false;
185
-        $message_err = '';
186
-        //
187
-        $instr_title       = Xoopsmodules\instruction\Utility::cleanVars($_POST, 'title', '', 'string');
188
-        $instr_description = Xoopsmodules\instruction\Utility::cleanVars($_POST, 'description', '', 'string');
189
-
190
-        // Дата обновления
191
-        $objInsinstr->setVar('dateupdated', $time);
192
-        //
193
-        $objInsinstr->setVar('cid', $cid);
194
-        $objInsinstr->setVar('title', $instr_title);
195
-        $objInsinstr->setVar('status', $_POST['status']);
196
-        $objInsinstr->setVar('description', $instr_description);
197
-        $objInsinstr->setVar('metakeywords', $_POST['metakeywords']);
198
-        $objInsinstr->setVar('metadescription', $_POST['metadescription']);
199
-
200
-        // Проверка категорий
201
-        if (!$cid) {
202
-            $err         = true;
203
-            $message_err .= _AM_INSTRUCTION_ERR_CAT . '<br>';
204
-        }
205
-        // Проверка названия
206
-        if (!$instr_title) {
207
-            $err         = true;
208
-            $message_err .= _AM_INSTR_ERR_TITLE . '<br>';
209
-        }
210
-        // Проверка основного текста
211
-        if (!$instr_description) {
212
-            $err         = true;
213
-            $message_err .= _AM_INSTR_ERR_DESCRIPTION . '<br>';
214
-        }
215
-
216
-        // Если были ошибки
217
-        if (true === $err) {
218
-            xoops_cp_header();
219
-            // Меню страницы
220
-            $adminObject->displayNavigation(basename(__FILE__));
221
-
222
-            $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
223
-            // Выводим ошибки в шаблон
224
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
225
-            // Если небыло ошибок
226
-        } else {
227
-            // Вставляем данные в БД
228
-            if ($instructionHandler->insert($objInsinstr)) {
229
-                // Получаем ID созданной записи
230
-                $instrid_new = $instrid ?: $objInsinstr->get_new_enreg();
231
-                // Обновление даты в категории
232
-                $categoryHandler->updateDateupdated($cid, $time);
233
-                // Тэги
234
-                if (xoops_getModuleOption('usetag', 'instruction')) {
235
-                    $tagHandler = xoops_getModuleHandler('tag', 'tag');
236
-                    $tagHandler->updateByItem($_POST['tag'], $instrid_new, $GLOBALS['xoopsModule']->getVar('dirname'), 0);
237
-                }
238
-
239
-                // Если мы редактируем
240
-                if ($instrid) {
241
-                    redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRMODIFY);
242
-                } else {
243
-                    redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRADDED);
244
-                }
245
-            }
246
-            xoops_cp_header();
247
-            // Меню страницы
248
-            $adminObject->displayNavigation(basename(__FILE__));
249
-
250
-            // Выводим ошибки в шаблон
251
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors());
252
-        }
253
-        // Выводим шаблон
254
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_saveinstr.tpl');
255
-        // Выводим форму
256
-        $form = $objInsinstr->getForm();
257
-        // Форма
258
-        echo $form->render();
259
-        // Текст внизу админки
260
-        include __DIR__ . '/admin_footer.php';
261
-
262
-        break;
263
-
264
-    // Просмотр категории
265
-    case 'viewinstr':
266
-
267
-        // Подключаем трей
268
-        include_once XOOPS_ROOT_PATH . '/modules/instruction/class/tree.php';
269
-
270
-        // Заголовок админки
271
-        xoops_cp_header();
272
-        // Меню
273
-        $adminObject->displayNavigation(basename(__FILE__));
274
-        // Кнопки
275
-        $adminObject->addItemButton(_AM_INSTRUCTION_ADDPAGE, 'instr.php?op=editpage&instrid=' . $instrid, 'add');
276
-        $adminObject->displayButton('left', '');
277
-
278
-        //
279
-        $objInsinstr = $instructionHandler->get($instrid);
280
-
281
-        // Находим все страницы в данной инструкции
282
-        $criteria = new \CriteriaCompo();
283
-        $criteria->add(new \Criteria('instrid', $instrid, '='));
284
-        $criteria->setSort('weight');
285
-        $criteria->setOrder('ASC');
286
-        $ins_page = $pageHandler->getall($criteria);
287
-        //
288
-        unset($criteria);
289
-
290
-        // Инициализируем
291
-        $instree = new instruction\Tree($ins_page, 'pageid', 'pid');
292
-        // Выводим список страниц в шаблон
293
-        $GLOBALS['xoopsTpl']->assign('insListPage', $instree->makePagesAdmin($objInsinstr, '--'));
294
-
295
-        // Выводим шаблон
296
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_viewinstr.tpl');
297
-
298
-        // Текст внизу админки
299
-        include __DIR__ . '/admin_footer.php';
300
-
301
-        break;
302
-
303
-    // Удаление категории
304
-    case 'delinstr':
305
-
306
-        // Проверка на instrid
307
-        // ==================
308
-        // Объект инструкций
309
-        $objInsinstr = $instructionHandler->get($instrid);
310
-
311
-        // Нажали ли мы на кнопку OK
312
-        $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
313
-        //
314
-        if ($ok) {
315
-
316
-            // Проверка
317
-            if (!$GLOBALS['xoopsSecurity']->check()) {
318
-                redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
319
-            }
320
-            // Находим все страницы, пренадлежащие этой инструкции
321
-            $criteria = new \CriteriaCompo();
322
-            $criteria->add(new \Criteria('instrid', $instrid));
323
-            $ins_page = $pageHandler->getall($criteria);
324
-            //
325
-            unset($criteria);
326
-            // Перебираем все страницы в данной инструкции
327
-            foreach (array_keys($ins_page) as $i) {
328
-                // Декримент комментов
329
-                // Делает дикримент одного коммента, а не всех в цикле...
330
-                // Удаляем комментарии
331
-                xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $ins_page[$i]->getVar('pageid'));
332
-                // Декримент страниц (Опционально)
333
-                // ==============================
334
-
335
-                // Удаляем страницу
336
-                // Сделать проверку на удалённость страницы
337
-                // ========================================
338
-                $pageHandler->delete($ins_page[$i]);
339
-            }
340
-            // Пытаемся удалить инструкцию
341
-            if ($instructionHandler->delete($objInsinstr)) {
342
-                // Редирект
343
-                redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRDELETED);
344
-            } else {
345
-                // Редирект
346
-                redirect_header('instr.php', 3, _AM_INSTRUCTION_ERR_DELINSTR);
347
-            }
348
-        } else {
349
-            xoops_cp_header();
350
-
351
-            $adminObject->displayNavigation(basename(__FILE__));
352
-            // Форма
353
-            xoops_confirm(['ok' => 1, 'instrid' => $instrid, 'op' => 'delinstr'], 'instr.php', sprintf(_AM_INSTRUCTION_FORMDELINSTR, $objInsinstr->getVar('title')));
354
-            // Текст внизу админки
355
-            include __DIR__ . '/admin_footer.php';
356
-        }
357
-
358
-        break;
359
-
360
-    // Добавление страницы
361
-    case 'editpage':
362
-
363
-        // Заголовок админки
364
-        xoops_cp_header();
365
-        // Скрипты
366
-        $xoTheme->addScript(XOOPS_URL . '/modules/instruction/assets/js/admin.js');
367
-        // Меню
368
-        $adminObject->displayNavigation(basename(__FILE__));
369
-
370
-        // Если мы редактируем страницу
371
-        if ($pageid) {
372
-            // Получаем объект страницы
373
-            $objInspage = $pageHandler->get($pageid);
374
-            // ID инструкции
375
-            $instrid = $objInspage->getVar('instrid');
376
-            // Создание новой страницы
377
-        } elseif ($instrid) {
378
-            // Создаём объект страницы
379
-            $objInspage = $pageHandler->create();
380
-            // Устанавливаем родительскую страницу
381
-            $objInspage->setVar('pid', $pid);
382
-        } else {
383
-            redirect_header('instr.php', 3, _AM_INSTRUCTION_BADREQUEST);
384
-        }
385
-        // Форма
386
-        $form = $objInspage->getForm('instr.php', $instrid);
387
-        // Форма
388
-        echo $form->render();
389
-        // Выводим шаблон
390
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editpage.tpl');
391
-
392
-        // Текст внизу админки
393
-        include __DIR__ . '/admin_footer.php';
394
-
395
-        break;
396
-
397
-    // Сохранение страницы
398
-    case 'savepage':
399
-        // Ошибки
400
-        $err         = false;
401
-        $message_err = '';
402
-
403
-        // Проверка сессии
404
-        if (!$GLOBALS['xoopsSecurity']->check()) {
405
-            $err         = true;
406
-            $err_txt     = implode(', ', $GLOBALS['xoopsSecurity']->getErrors());
407
-            $message_err .= $err_txt . '<br>';
408
-        }
409
-
410
-        // Если мы редактируем
411
-        if ($pageid) {
412
-            $objInspage = $pageHandler->get($pageid);
413
-        } elseif ($instrid) {
414
-            $objInspage = $pageHandler->create();
415
-            // Если мы создаём страницу необходимо указать к какой инструкции
416
-            $objInspage->setVar('instrid', $instrid);
417
-            // Указываем дату создания
418
-            $objInspage->setVar('datecreated', $time);
419
-            // Указываем пользователя
420
-            $objInspage->setVar('uid', $uid);
421
-        } else {
422
-            redirect_header('instr.php', 3, _AM_INSTRUCTION_BADREQUEST);
423
-        }
424
-
425
-        //
426
-        $page_title    = Xoopsmodules\instruction\Utility::cleanVars($_POST, 'title', '', 'string');
427
-        $page_hometext = Xoopsmodules\instruction\Utility::cleanVars($_POST, 'hometext', '', 'string');
428
-
429
-        // Родительская страница
430
-        $objInspage->setVar('pid', $pid);
431
-        // Дата обновления
432
-        $objInspage->setVar('dateupdated', $time);
433
-        // Название страницы
434
-        $objInspage->setVar('title', $page_title);
435
-        // Вес страницы
436
-        $objInspage->setVar('weight', $weight);
437
-        // Основной текст
438
-        $objInspage->setVar('hometext', $page_hometext);
439
-        // Сноска
440
-        $objInspage->setVar('footnote', Xoopsmodules\instruction\Utility::cleanVars($_POST, 'footnote', '', 'string'));
441
-        // Статус
442
-        $objInspage->setVar('status', Xoopsmodules\instruction\Utility::cleanVars($_POST, 'status', 0, 'int'));
443
-        // Тип
444
-        $objInspage->setVar('type', Xoopsmodules\instruction\Utility::cleanVars($_POST, 'type', 0, 'int'));
445
-        // Мета-теги описания
446
-        $objInspage->setVar('keywords', Xoopsmodules\instruction\Utility::cleanVars($_POST, 'keywords', '', 'string'));
447
-        // Мета-теги ключевых слов
448
-        $objInspage->setVar('description', Xoopsmodules\instruction\Utility::cleanVars($_POST, 'description', '', 'string'));
449
-        //
450
-        $dosmiley = (isset($_POST['dosmiley']) && (int)$_POST['dosmiley'] > 0) ? 1 : 0;
451
-        $doxcode  = (isset($_POST['doxcode']) && (int)$_POST['doxcode'] > 0) ? 1 : 0;
452
-        $dobr     = (isset($_POST['dobr']) && (int)$_POST['dobr'] > 0) ? 1 : 0;
453
-        $dohtml   = (isset($_POST['dohtml']) && (int)$_POST['dohtml'] > 0) ? 1 : 0;
454
-        //$doimage = ( isset( $_POST['doimage'] ) && intval( $_POST['doimage'] ) > 0 ) ? 1 : 0;
455
-        $objInspage->setVar('dohtml', $dohtml);
456
-        $objInspage->setVar('dosmiley', $dosmiley);
457
-        $objInspage->setVar('doxcode', $doxcode);
458
-        //$objInspage->setVar( 'doimage', $doimage );
459
-        $objInspage->setVar('dobr', $dobr);
460
-
461
-        //
462
-        if (!$pageid && !$instrid) {
463
-            $err         = true;
464
-            $message_err .= _AM_INSTRUCTION_ERR_INSTR . '<br>';
465
-        }
466
-        // Проверка веса
467
-        if (0 == $weight) {
468
-            $err         = true;
469
-            $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>';
470
-        }
471
-        // Проверка родительской страницы
472
-        if ($pageid && ($pageid == $pid)) {
473
-            $err         = true;
474
-            $message_err .= _AM_INSTRUCTION_ERR_PPAGE . '<br>';
475
-        }
476
-        // Проверка названия
477
-        if (!$page_title) {
478
-            $err         = true;
479
-            $message_err .= _AM_INSTR_ERR_TITLE . '<br>';
480
-        }
481
-        // Проверка основного текста
482
-        if (!$page_hometext) {
483
-            $err         = true;
484
-            $message_err .= _AM_INSTR_ERR_HOMETEXT . '<br>';
485
-        }
486
-
487
-        // Если были ошибки
488
-        if (true === $err) {
489
-            xoops_cp_header();
490
-            // Меню страницы
491
-            $adminObject->displayNavigation(basename(__FILE__));
492
-
493
-            $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
494
-            // Выводим ошибки в шаблон
495
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
496
-            // Если небыло ошибок
497
-        } else {
498
-            // Вставляем данные в БД
499
-            if ($pageHandler->insert($objInspage)) {
500
-                // Ссылка для редиректа
501
-                $redirect_url = 'instr.php?op=viewinstr&amp;instrid=' . $instrid . '#pageid_' . $pid;
502
-                // Получаем ID инструкции
503
-                $instrid = $objInspage->getInstrid();
504
-                // Обновляем в инструкции число страниц и дату
505
-                $instructionHandler->updatePages($instrid);
506
-                // Если мы редактируем
507
-                if ($pageid) {
508
-                    // Редирект
509
-                    redirect_header($redirect_url, 3, _AM_INSTRUCTION_PAGEMODIFY);
510
-                    // Если мы добавляем
511
-                } else {
512
-                    // Инкримент комментов
513
-                    $pageHandler->updateposts($uid, $_POST['status'], 'add');
514
-                    // Редирект
515
-                    redirect_header($redirect_url, 3, _AM_INSTRUCTION_PAGEADDED);
516
-                }
517
-            }
518
-            xoops_cp_header();
519
-            // Меню страницы
520
-            $adminObject->displayNavigation(basename(__FILE__));
521
-
522
-            // Выводим ошибки в шаблон
523
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInspage->getHtmlErrors());
524
-        }
525
-        // Скрипты
526
-        $xoTheme->addScript(XOOPS_URL . '/modules/instruction/assets/js/admin.js');
527
-        // Выводим шаблон
528
-        $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savepage.tpl');
529
-        // Выводим форму
530
-        $form = $objInspage->getForm('instr.php', $instrid);
531
-        // Форма
532
-        echo $form->render();
533
-        // Текст внизу админки
534
-        include __DIR__ . '/admin_footer.php';
535
-
536
-        break;
537
-
538
-    // Удаление страницы
539
-    case 'delpage':
540
-
541
-        // Проверка на pageid
542
-        // ==================
543
-
544
-        $objInspage = $pageHandler->get($pageid);
545
-        // Нажали ли мы на кнопку OK
546
-        $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
547
-        // Если мы нажали на кнопку
548
-        if ($ok) {
549
-
550
-            // Проверка
551
-            if (!$GLOBALS['xoopsSecurity']->check()) {
552
-                redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
553
-            }
554
-            // ID инструкции
555
-            $page_instrid = $objInspage->getVar('instrid');
556
-            // Декримент комментов
557
-            $pageHandler->updateposts($objInspage->getVar('uid'), $objInspage->getVar('status'), 'delete');
558
-            // Пытаемся удалить страницу
559
-            if ($pageHandler->delete($objInspage)) {
560
-                // Обновляем в инструкции число страниц и дату
561
-                $instructionHandler->updatePages($page_instrid);
562
-                // Удаляем комментарии
563
-                xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $pageid);
564
-                //
565
-                redirect_header('instr.php?op=viewinstr&amp;instrid=' . $page_instrid, 3, _AM_INSTRUCTION_PAGEDELETED);
566
-                // Если не смогли удалить страницу
567
-            } else {
568
-                redirect_header('instr.php?op=viewinstr&amp;instrid=' . $page_instrid, 3, _AM_INSTRUCTION_ERR_DELPAGE);
569
-            }
570
-        } else {
571
-
572
-            // Заголовок админки
573
-            xoops_cp_header();
574
-            // Меню
575
-            $adminObject->displayNavigation(basename(__FILE__));
576
-            // Форма
577
-            xoops_confirm(['ok' => 1, 'pageid' => $pageid, 'op' => 'delpage'], 'instr.php', sprintf(_AM_INSTRUCTION_FORMDELPAGE, $objInspage->getVar('title')));
578
-            // Текст внизу админки
579
-            include __DIR__ . '/admin_footer.php';
580
-        }
581
-
582
-        break;
583
-
584
-    // Удаление страницы
585
-    case 'updpage':
586
-
587
-        // Принимаем данные
588
-        $pageids = $_POST['pageids'];
589
-        $weights = $_POST['weights'];
590
-        // Перебираем все значения
591
-        foreach ($pageids as $key => $pageid) {
592
-
593
-            // Объявляем объект
594
-            $objInspage = $pageHandler->get($pageid);
595
-            // Устанавливаем вес
596
-            $objInspage->setVar('weight', $weights[$key]);
597
-            // Вставляем данные в БД
598
-            $pageHandler->insert($objInspage);
599
-            // Удаляем объект
600
-            unset($objInspage);
601
-        }
602
-        // Редирект
603
-        redirect_header('instr.php?op=viewinstr&instrid=' . $instrid, 3, _AM_INSTRUCTION_PAGESUPDATE);
604
-
605
-        break;
45
+	case 'main':
46
+
47
+		// Заголовок админки
48
+		xoops_cp_header();
49
+		// Меню
50
+		$adminObject->displayNavigation(basename(__FILE__));
51
+		$adminObject->addItemButton(_AM_INSTRUCTION_ADDINSTR, 'instr.php?op=editinstr', 'add');
52
+		$adminObject->displayButton('left', '');
53
+
54
+		//
55
+		$criteria = new \CriteriaCompo();
56
+
57
+		// Если была передана категория
58
+		if ($cid) {
59
+			// Добавляем в выборку ID категории
60
+			$criteria->add(new \Criteria('cid', $cid, '='));
61
+			// Получаем объект категории
62
+			$objInscat = $categoryHandler->get($cid);
63
+			// Если нет такой категории
64
+			if (!is_object($objInscat)) {
65
+				redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT);
66
+			}
67
+		}
68
+
69
+		// Число инструкций, удовлетворяющих данному условию
70
+		$numrows = $instructionHandler->getCount($criteria);
71
+
72
+		// Число выборки
73
+		$criteria->setLimit($limit);
74
+		// Начинасть с данного элемента
75
+		$criteria->setStart($start);
76
+		// Сортировать по
77
+		$criteria->setSort('instrid');
78
+		// Порядок сортировки
79
+		$criteria->setOrder('DESC');
80
+		// Находим все справки
81
+		$instr_arr = $instructionHandler->getall($criteria);
82
+		// Если записей больше чем $limit, то выводим пагинатор
83
+		if ($numrows > $limit) {
84
+			$pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'op=' . $op . '&amp;cid=' . $cid);
85
+			$pagenav = $pagenav->renderNav(4);
86
+		} else {
87
+			$pagenav = '';
88
+		}
89
+		// Выводим пагинатор в шаблон
90
+		$GLOBALS['xoopsTpl']->assign('insPagenav', $pagenav);
91
+
92
+		// Если есть записи
93
+		if ($numrows > 0) {
94
+			$class = 'odd';
95
+			foreach (array_keys($instr_arr) as $i) {
96
+
97
+				//
98
+				$class = ('even' === $class) ? 'odd' : 'even';
99
+				// ID
100
+				$insinstr_instrid = $instr_arr[$i]->getVar('instrid');
101
+				// Название
102
+				$insinstr_title = $instr_arr[$i]->getVar('title');
103
+				// Статус
104
+				$insinstr_status = $instr_arr[$i]->getVar('status');
105
+				// Количество страниц
106
+				$insinstr_pages = $instr_arr[$i]->getVar('pages');
107
+				// Категория
108
+				$insinstr_cat = $categoryHandler->get($instr_arr[$i]->getVar('cid'));
109
+
110
+				// Выводим в шаблон
111
+				$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]);
112
+			}
113
+
114
+			//
115
+			$inshead = isset($objInscat) && is_object($objInscat) ? sprintf(_AM_INSTR_LISTINSTRINCAT, $objInscat->getVar('title')) : _AM_INSTR_LISTINSTRALL;
116
+			$GLOBALS['xoopsTpl']->assign('insHead', $inshead);
117
+			// Языковые константы
118
+			$GLOBALS['xoopsTpl']->assign('lang_title', _AM_INSTRUCTION_TITLE);
119
+			$GLOBALS['xoopsTpl']->assign('lang_cat', _AM_INSTRUCTION_CAT);
120
+			$GLOBALS['xoopsTpl']->assign('lang_pages', _AM_INSTRUCTION_PAGES);
121
+			$GLOBALS['xoopsTpl']->assign('lang_action', _AM_INSTRUCTION_ACTION);
122
+			$GLOBALS['xoopsTpl']->assign('lang_display', _AM_INSTRUCTION_DISPLAY);
123
+			$GLOBALS['xoopsTpl']->assign('lang_edit', _AM_INSTRUCTION_EDIT);
124
+			$GLOBALS['xoopsTpl']->assign('lang_del', _AM_INSTRUCTION_DEL);
125
+			$GLOBALS['xoopsTpl']->assign('lang_lock', _AM_INSTRUCTION_LOCK);
126
+			$GLOBALS['xoopsTpl']->assign('lang_unlock', _AM_INSTRUCTION_UNLOCK);
127
+			$GLOBALS['xoopsTpl']->assign('lang_addpage', _AM_INSTRUCTION_ADDPAGE);
128
+			$GLOBALS['xoopsTpl']->assign('lang_addinstr', _AM_INSTRUCTION_ADDINSTR);
129
+		}
130
+
131
+		// Выводим шаблон
132
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_instr.tpl');
133
+
134
+		// Текст внизу админки
135
+		include __DIR__ . '/admin_footer.php';
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 = $instructionHandler->get($instrid);
150
+			// Создание новой страницы
151
+		} else {
152
+			$objInsinstr = $instructionHandler->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
+		break;
165
+
166
+	// Сохранение инструкций
167
+	case 'saveinstr':
168
+
169
+		// Проверка
170
+		if (!$GLOBALS['xoopsSecurity']->check()) {
171
+			redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
172
+		}
173
+		// Если мы редактируем
174
+		if ($instrid) {
175
+			$objInsinstr = $instructionHandler->get($instrid);
176
+		} else {
177
+			$objInsinstr = $instructionHandler->create();
178
+			// Указываем дату создания
179
+			$objInsinstr->setVar('datecreated', $time);
180
+			// Указываем пользователя
181
+			$objInsinstr->setVar('uid', $uid);
182
+		}
183
+
184
+		$err         = false;
185
+		$message_err = '';
186
+		//
187
+		$instr_title       = Xoopsmodules\instruction\Utility::cleanVars($_POST, 'title', '', 'string');
188
+		$instr_description = Xoopsmodules\instruction\Utility::cleanVars($_POST, 'description', '', 'string');
189
+
190
+		// Дата обновления
191
+		$objInsinstr->setVar('dateupdated', $time);
192
+		//
193
+		$objInsinstr->setVar('cid', $cid);
194
+		$objInsinstr->setVar('title', $instr_title);
195
+		$objInsinstr->setVar('status', $_POST['status']);
196
+		$objInsinstr->setVar('description', $instr_description);
197
+		$objInsinstr->setVar('metakeywords', $_POST['metakeywords']);
198
+		$objInsinstr->setVar('metadescription', $_POST['metadescription']);
199
+
200
+		// Проверка категорий
201
+		if (!$cid) {
202
+			$err         = true;
203
+			$message_err .= _AM_INSTRUCTION_ERR_CAT . '<br>';
204
+		}
205
+		// Проверка названия
206
+		if (!$instr_title) {
207
+			$err         = true;
208
+			$message_err .= _AM_INSTR_ERR_TITLE . '<br>';
209
+		}
210
+		// Проверка основного текста
211
+		if (!$instr_description) {
212
+			$err         = true;
213
+			$message_err .= _AM_INSTR_ERR_DESCRIPTION . '<br>';
214
+		}
215
+
216
+		// Если были ошибки
217
+		if (true === $err) {
218
+			xoops_cp_header();
219
+			// Меню страницы
220
+			$adminObject->displayNavigation(basename(__FILE__));
221
+
222
+			$message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
223
+			// Выводим ошибки в шаблон
224
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
225
+			// Если небыло ошибок
226
+		} else {
227
+			// Вставляем данные в БД
228
+			if ($instructionHandler->insert($objInsinstr)) {
229
+				// Получаем ID созданной записи
230
+				$instrid_new = $instrid ?: $objInsinstr->get_new_enreg();
231
+				// Обновление даты в категории
232
+				$categoryHandler->updateDateupdated($cid, $time);
233
+				// Тэги
234
+				if (xoops_getModuleOption('usetag', 'instruction')) {
235
+					$tagHandler = xoops_getModuleHandler('tag', 'tag');
236
+					$tagHandler->updateByItem($_POST['tag'], $instrid_new, $GLOBALS['xoopsModule']->getVar('dirname'), 0);
237
+				}
238
+
239
+				// Если мы редактируем
240
+				if ($instrid) {
241
+					redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRMODIFY);
242
+				} else {
243
+					redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRADDED);
244
+				}
245
+			}
246
+			xoops_cp_header();
247
+			// Меню страницы
248
+			$adminObject->displayNavigation(basename(__FILE__));
249
+
250
+			// Выводим ошибки в шаблон
251
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors());
252
+		}
253
+		// Выводим шаблон
254
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_saveinstr.tpl');
255
+		// Выводим форму
256
+		$form = $objInsinstr->getForm();
257
+		// Форма
258
+		echo $form->render();
259
+		// Текст внизу админки
260
+		include __DIR__ . '/admin_footer.php';
261
+
262
+		break;
263
+
264
+	// Просмотр категории
265
+	case 'viewinstr':
266
+
267
+		// Подключаем трей
268
+		include_once XOOPS_ROOT_PATH . '/modules/instruction/class/tree.php';
269
+
270
+		// Заголовок админки
271
+		xoops_cp_header();
272
+		// Меню
273
+		$adminObject->displayNavigation(basename(__FILE__));
274
+		// Кнопки
275
+		$adminObject->addItemButton(_AM_INSTRUCTION_ADDPAGE, 'instr.php?op=editpage&instrid=' . $instrid, 'add');
276
+		$adminObject->displayButton('left', '');
277
+
278
+		//
279
+		$objInsinstr = $instructionHandler->get($instrid);
280
+
281
+		// Находим все страницы в данной инструкции
282
+		$criteria = new \CriteriaCompo();
283
+		$criteria->add(new \Criteria('instrid', $instrid, '='));
284
+		$criteria->setSort('weight');
285
+		$criteria->setOrder('ASC');
286
+		$ins_page = $pageHandler->getall($criteria);
287
+		//
288
+		unset($criteria);
289
+
290
+		// Инициализируем
291
+		$instree = new instruction\Tree($ins_page, 'pageid', 'pid');
292
+		// Выводим список страниц в шаблон
293
+		$GLOBALS['xoopsTpl']->assign('insListPage', $instree->makePagesAdmin($objInsinstr, '--'));
294
+
295
+		// Выводим шаблон
296
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_viewinstr.tpl');
297
+
298
+		// Текст внизу админки
299
+		include __DIR__ . '/admin_footer.php';
300
+
301
+		break;
302
+
303
+	// Удаление категории
304
+	case 'delinstr':
305
+
306
+		// Проверка на instrid
307
+		// ==================
308
+		// Объект инструкций
309
+		$objInsinstr = $instructionHandler->get($instrid);
310
+
311
+		// Нажали ли мы на кнопку OK
312
+		$ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
313
+		//
314
+		if ($ok) {
315
+
316
+			// Проверка
317
+			if (!$GLOBALS['xoopsSecurity']->check()) {
318
+				redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
319
+			}
320
+			// Находим все страницы, пренадлежащие этой инструкции
321
+			$criteria = new \CriteriaCompo();
322
+			$criteria->add(new \Criteria('instrid', $instrid));
323
+			$ins_page = $pageHandler->getall($criteria);
324
+			//
325
+			unset($criteria);
326
+			// Перебираем все страницы в данной инструкции
327
+			foreach (array_keys($ins_page) as $i) {
328
+				// Декримент комментов
329
+				// Делает дикримент одного коммента, а не всех в цикле...
330
+				// Удаляем комментарии
331
+				xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $ins_page[$i]->getVar('pageid'));
332
+				// Декримент страниц (Опционально)
333
+				// ==============================
334
+
335
+				// Удаляем страницу
336
+				// Сделать проверку на удалённость страницы
337
+				// ========================================
338
+				$pageHandler->delete($ins_page[$i]);
339
+			}
340
+			// Пытаемся удалить инструкцию
341
+			if ($instructionHandler->delete($objInsinstr)) {
342
+				// Редирект
343
+				redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRDELETED);
344
+			} else {
345
+				// Редирект
346
+				redirect_header('instr.php', 3, _AM_INSTRUCTION_ERR_DELINSTR);
347
+			}
348
+		} else {
349
+			xoops_cp_header();
350
+
351
+			$adminObject->displayNavigation(basename(__FILE__));
352
+			// Форма
353
+			xoops_confirm(['ok' => 1, 'instrid' => $instrid, 'op' => 'delinstr'], 'instr.php', sprintf(_AM_INSTRUCTION_FORMDELINSTR, $objInsinstr->getVar('title')));
354
+			// Текст внизу админки
355
+			include __DIR__ . '/admin_footer.php';
356
+		}
357
+
358
+		break;
359
+
360
+	// Добавление страницы
361
+	case 'editpage':
362
+
363
+		// Заголовок админки
364
+		xoops_cp_header();
365
+		// Скрипты
366
+		$xoTheme->addScript(XOOPS_URL . '/modules/instruction/assets/js/admin.js');
367
+		// Меню
368
+		$adminObject->displayNavigation(basename(__FILE__));
369
+
370
+		// Если мы редактируем страницу
371
+		if ($pageid) {
372
+			// Получаем объект страницы
373
+			$objInspage = $pageHandler->get($pageid);
374
+			// ID инструкции
375
+			$instrid = $objInspage->getVar('instrid');
376
+			// Создание новой страницы
377
+		} elseif ($instrid) {
378
+			// Создаём объект страницы
379
+			$objInspage = $pageHandler->create();
380
+			// Устанавливаем родительскую страницу
381
+			$objInspage->setVar('pid', $pid);
382
+		} else {
383
+			redirect_header('instr.php', 3, _AM_INSTRUCTION_BADREQUEST);
384
+		}
385
+		// Форма
386
+		$form = $objInspage->getForm('instr.php', $instrid);
387
+		// Форма
388
+		echo $form->render();
389
+		// Выводим шаблон
390
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editpage.tpl');
391
+
392
+		// Текст внизу админки
393
+		include __DIR__ . '/admin_footer.php';
394
+
395
+		break;
396
+
397
+	// Сохранение страницы
398
+	case 'savepage':
399
+		// Ошибки
400
+		$err         = false;
401
+		$message_err = '';
402
+
403
+		// Проверка сессии
404
+		if (!$GLOBALS['xoopsSecurity']->check()) {
405
+			$err         = true;
406
+			$err_txt     = implode(', ', $GLOBALS['xoopsSecurity']->getErrors());
407
+			$message_err .= $err_txt . '<br>';
408
+		}
409
+
410
+		// Если мы редактируем
411
+		if ($pageid) {
412
+			$objInspage = $pageHandler->get($pageid);
413
+		} elseif ($instrid) {
414
+			$objInspage = $pageHandler->create();
415
+			// Если мы создаём страницу необходимо указать к какой инструкции
416
+			$objInspage->setVar('instrid', $instrid);
417
+			// Указываем дату создания
418
+			$objInspage->setVar('datecreated', $time);
419
+			// Указываем пользователя
420
+			$objInspage->setVar('uid', $uid);
421
+		} else {
422
+			redirect_header('instr.php', 3, _AM_INSTRUCTION_BADREQUEST);
423
+		}
424
+
425
+		//
426
+		$page_title    = Xoopsmodules\instruction\Utility::cleanVars($_POST, 'title', '', 'string');
427
+		$page_hometext = Xoopsmodules\instruction\Utility::cleanVars($_POST, 'hometext', '', 'string');
428
+
429
+		// Родительская страница
430
+		$objInspage->setVar('pid', $pid);
431
+		// Дата обновления
432
+		$objInspage->setVar('dateupdated', $time);
433
+		// Название страницы
434
+		$objInspage->setVar('title', $page_title);
435
+		// Вес страницы
436
+		$objInspage->setVar('weight', $weight);
437
+		// Основной текст
438
+		$objInspage->setVar('hometext', $page_hometext);
439
+		// Сноска
440
+		$objInspage->setVar('footnote', Xoopsmodules\instruction\Utility::cleanVars($_POST, 'footnote', '', 'string'));
441
+		// Статус
442
+		$objInspage->setVar('status', Xoopsmodules\instruction\Utility::cleanVars($_POST, 'status', 0, 'int'));
443
+		// Тип
444
+		$objInspage->setVar('type', Xoopsmodules\instruction\Utility::cleanVars($_POST, 'type', 0, 'int'));
445
+		// Мета-теги описания
446
+		$objInspage->setVar('keywords', Xoopsmodules\instruction\Utility::cleanVars($_POST, 'keywords', '', 'string'));
447
+		// Мета-теги ключевых слов
448
+		$objInspage->setVar('description', Xoopsmodules\instruction\Utility::cleanVars($_POST, 'description', '', 'string'));
449
+		//
450
+		$dosmiley = (isset($_POST['dosmiley']) && (int)$_POST['dosmiley'] > 0) ? 1 : 0;
451
+		$doxcode  = (isset($_POST['doxcode']) && (int)$_POST['doxcode'] > 0) ? 1 : 0;
452
+		$dobr     = (isset($_POST['dobr']) && (int)$_POST['dobr'] > 0) ? 1 : 0;
453
+		$dohtml   = (isset($_POST['dohtml']) && (int)$_POST['dohtml'] > 0) ? 1 : 0;
454
+		//$doimage = ( isset( $_POST['doimage'] ) && intval( $_POST['doimage'] ) > 0 ) ? 1 : 0;
455
+		$objInspage->setVar('dohtml', $dohtml);
456
+		$objInspage->setVar('dosmiley', $dosmiley);
457
+		$objInspage->setVar('doxcode', $doxcode);
458
+		//$objInspage->setVar( 'doimage', $doimage );
459
+		$objInspage->setVar('dobr', $dobr);
460
+
461
+		//
462
+		if (!$pageid && !$instrid) {
463
+			$err         = true;
464
+			$message_err .= _AM_INSTRUCTION_ERR_INSTR . '<br>';
465
+		}
466
+		// Проверка веса
467
+		if (0 == $weight) {
468
+			$err         = true;
469
+			$message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>';
470
+		}
471
+		// Проверка родительской страницы
472
+		if ($pageid && ($pageid == $pid)) {
473
+			$err         = true;
474
+			$message_err .= _AM_INSTRUCTION_ERR_PPAGE . '<br>';
475
+		}
476
+		// Проверка названия
477
+		if (!$page_title) {
478
+			$err         = true;
479
+			$message_err .= _AM_INSTR_ERR_TITLE . '<br>';
480
+		}
481
+		// Проверка основного текста
482
+		if (!$page_hometext) {
483
+			$err         = true;
484
+			$message_err .= _AM_INSTR_ERR_HOMETEXT . '<br>';
485
+		}
486
+
487
+		// Если были ошибки
488
+		if (true === $err) {
489
+			xoops_cp_header();
490
+			// Меню страницы
491
+			$adminObject->displayNavigation(basename(__FILE__));
492
+
493
+			$message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
494
+			// Выводим ошибки в шаблон
495
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
496
+			// Если небыло ошибок
497
+		} else {
498
+			// Вставляем данные в БД
499
+			if ($pageHandler->insert($objInspage)) {
500
+				// Ссылка для редиректа
501
+				$redirect_url = 'instr.php?op=viewinstr&amp;instrid=' . $instrid . '#pageid_' . $pid;
502
+				// Получаем ID инструкции
503
+				$instrid = $objInspage->getInstrid();
504
+				// Обновляем в инструкции число страниц и дату
505
+				$instructionHandler->updatePages($instrid);
506
+				// Если мы редактируем
507
+				if ($pageid) {
508
+					// Редирект
509
+					redirect_header($redirect_url, 3, _AM_INSTRUCTION_PAGEMODIFY);
510
+					// Если мы добавляем
511
+				} else {
512
+					// Инкримент комментов
513
+					$pageHandler->updateposts($uid, $_POST['status'], 'add');
514
+					// Редирект
515
+					redirect_header($redirect_url, 3, _AM_INSTRUCTION_PAGEADDED);
516
+				}
517
+			}
518
+			xoops_cp_header();
519
+			// Меню страницы
520
+			$adminObject->displayNavigation(basename(__FILE__));
521
+
522
+			// Выводим ошибки в шаблон
523
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInspage->getHtmlErrors());
524
+		}
525
+		// Скрипты
526
+		$xoTheme->addScript(XOOPS_URL . '/modules/instruction/assets/js/admin.js');
527
+		// Выводим шаблон
528
+		$GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savepage.tpl');
529
+		// Выводим форму
530
+		$form = $objInspage->getForm('instr.php', $instrid);
531
+		// Форма
532
+		echo $form->render();
533
+		// Текст внизу админки
534
+		include __DIR__ . '/admin_footer.php';
535
+
536
+		break;
537
+
538
+	// Удаление страницы
539
+	case 'delpage':
540
+
541
+		// Проверка на pageid
542
+		// ==================
543
+
544
+		$objInspage = $pageHandler->get($pageid);
545
+		// Нажали ли мы на кнопку OK
546
+		$ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0;
547
+		// Если мы нажали на кнопку
548
+		if ($ok) {
549
+
550
+			// Проверка
551
+			if (!$GLOBALS['xoopsSecurity']->check()) {
552
+				redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
553
+			}
554
+			// ID инструкции
555
+			$page_instrid = $objInspage->getVar('instrid');
556
+			// Декримент комментов
557
+			$pageHandler->updateposts($objInspage->getVar('uid'), $objInspage->getVar('status'), 'delete');
558
+			// Пытаемся удалить страницу
559
+			if ($pageHandler->delete($objInspage)) {
560
+				// Обновляем в инструкции число страниц и дату
561
+				$instructionHandler->updatePages($page_instrid);
562
+				// Удаляем комментарии
563
+				xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $pageid);
564
+				//
565
+				redirect_header('instr.php?op=viewinstr&amp;instrid=' . $page_instrid, 3, _AM_INSTRUCTION_PAGEDELETED);
566
+				// Если не смогли удалить страницу
567
+			} else {
568
+				redirect_header('instr.php?op=viewinstr&amp;instrid=' . $page_instrid, 3, _AM_INSTRUCTION_ERR_DELPAGE);
569
+			}
570
+		} else {
571
+
572
+			// Заголовок админки
573
+			xoops_cp_header();
574
+			// Меню
575
+			$adminObject->displayNavigation(basename(__FILE__));
576
+			// Форма
577
+			xoops_confirm(['ok' => 1, 'pageid' => $pageid, 'op' => 'delpage'], 'instr.php', sprintf(_AM_INSTRUCTION_FORMDELPAGE, $objInspage->getVar('title')));
578
+			// Текст внизу админки
579
+			include __DIR__ . '/admin_footer.php';
580
+		}
581
+
582
+		break;
583
+
584
+	// Удаление страницы
585
+	case 'updpage':
586
+
587
+		// Принимаем данные
588
+		$pageids = $_POST['pageids'];
589
+		$weights = $_POST['weights'];
590
+		// Перебираем все значения
591
+		foreach ($pageids as $key => $pageid) {
592
+
593
+			// Объявляем объект
594
+			$objInspage = $pageHandler->get($pageid);
595
+			// Устанавливаем вес
596
+			$objInspage->setVar('weight', $weights[$key]);
597
+			// Вставляем данные в БД
598
+			$pageHandler->insert($objInspage);
599
+			// Удаляем объект
600
+			unset($objInspage);
601
+		}
602
+		// Редирект
603
+		redirect_header('instr.php?op=viewinstr&instrid=' . $instrid, 3, _AM_INSTRUCTION_PAGESUPDATE);
604
+
605
+		break;
606 606
 
607 607
 }
Please login to merge, or discard this patch.
admin/admin_header.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,19 +12,19 @@
 block discarded – undo
12 12
 
13 13
 //if (is_object($GLOBALS['xoopsUser'])) {
14 14
 if ($GLOBALS['xoopsUser'] instanceof XoopsUser) {
15
-    if (!$helper->isUserAdmin()) {
16
-        $helper->redirect(XOOPS_URL . '/', 3, _NOPERM);
17
-    }
15
+	if (!$helper->isUserAdmin()) {
16
+		$helper->redirect(XOOPS_URL . '/', 3, _NOPERM);
17
+	}
18 18
 } else {
19
-    $helper->redirect(XOOPS_URL . '/user.php', 1, _NOPERM);
19
+	$helper->redirect(XOOPS_URL . '/user.php', 1, _NOPERM);
20 20
 }
21 21
 
22 22
 /** @var Xmf\Module\Admin $adminObject */
23 23
 $adminObject = \Xmf\Module\Admin::getInstance();
24 24
 
25 25
 if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) {
26
-    require_once $GLOBALS['xoops']->path('class/template.php');
27
-    $xoopsTpl = new \XoopsTpl();
26
+	require_once $GLOBALS['xoops']->path('class/template.php');
27
+	$xoopsTpl = new \XoopsTpl();
28 28
 }
29 29
 
30 30
 $pathIcon16    = Xmf\Module\Admin::iconUrl('', 16);
Please login to merge, or discard this patch.
admin/index.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@
 block discarded – undo
11 11
 
12 12
 $configurator = include __DIR__ . '/../include/config.php';
13 13
 foreach (array_keys($configurator->uploadFolders) as $i) {
14
-    $utility::createFolder($configurator->uploadFolders[$i]);
15
-    $adminObject->addConfigBoxLine($configurator->uploadFolders[$i], 'folder');
14
+	$utility::createFolder($configurator->uploadFolders[$i]);
15
+	$adminObject->addConfigBoxLine($configurator->uploadFolders[$i], 'folder');
16 16
 }
17 17
 
18 18
 //$instructionHandler = xoops_getModuleHandler('instruction', 'instruction');
Please login to merge, or discard this patch.
admin/menu.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use Xoopsmodules\instruction;
4 4
 
5 5
 if (!isset($moduleDirName)) {
6
-    $moduleDirName = basename(dirname(__DIR__));
6
+	$moduleDirName = basename(dirname(__DIR__));
7 7
 }
8 8
 
9 9
 /** @var Xmf\Module\Helper $moduleHelper */
@@ -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.