These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | use Xmf\Request; |
||
4 | use Xoopsmodules\instruction; |
||
5 | |||
6 | require_once __DIR__ . '/header.php'; |
||
7 | |||
8 | // Пагинатор |
||
9 | include_once $GLOBALS['xoops']->path('class/pagenav.php'); |
||
10 | |||
11 | // Задание тайтла |
||
12 | $xoopsOption['xoops_pagetitle'] = $GLOBALS['xoopsModule']->name(); |
||
13 | // Шаблон |
||
14 | $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_index.tpl'; |
||
15 | // Заголовок |
||
16 | include_once $GLOBALS['xoops']->path('header.php'); |
||
17 | // Стили |
||
18 | $xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/style.css'); |
||
19 | // |
||
20 | $cid = Request::getInt('cid', 0, 'GET'); |
||
21 | // |
||
22 | $start = Request::getInt('start', 0, 'GET'); |
||
23 | // |
||
24 | |||
25 | //mb $limit = xoops_getModuleOption('perpagemain', 'instruction'); |
||
0 ignored issues
–
show
|
|||
26 | $limit = xoops_getModuleOption('perpagemain', 'instruction'); |
||
27 | |||
28 | // Права на просмотр |
||
29 | $categories = Xoopsmodules\instruction\Utility::getItemIds(); |
||
30 | // Права на добавление |
||
31 | $cat_submit = Xoopsmodules\instruction\Utility::getItemIds($moduleDirName . '_submit'); |
||
32 | // Права на редактирование |
||
33 | $cat_edit = Xoopsmodules\instruction\Utility::getItemIds($moduleDirName . '_edit'); |
||
34 | |||
35 | // Находим список категорий |
||
36 | $criteria = new \CriteriaCompo(); |
||
37 | $criteria->add(new \Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN')); |
||
38 | $criteria->setSort('weight ASC, title'); |
||
39 | $criteria->setOrder('ASC'); |
||
40 | $inscat_arr = $categoryHandler->getall($criteria); |
||
41 | unset($criteria); |
||
42 | $mytree = new \XoopsObjectTree($inscat_arr, 'cid', 'pid'); |
||
43 | // Выводим в шаблон |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
63% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
44 | //$GLOBALS['xoopsTpl']->assign('insFormSelCat', $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'")); |
||
45 | $moduleDirName = basename(__DIR__); |
||
46 | |||
47 | //$helper = \Helper::getInstance(); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
48 | $module = $helper->getModule(); |
||
49 | |||
50 | if (Xoopsmodules\instruction\Utility::checkVerXoops($module, '2.5.9')) { |
||
51 | $cat_select = $mytree->makeSelectElement('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'", ''); |
||
52 | $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select->render()); |
||
53 | } else { |
||
54 | $cat_select = $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'"); |
||
55 | $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select); |
||
56 | } |
||
57 | |||
58 | // Находим список всех инструкций |
||
59 | // Критерий выборки |
||
60 | $criteria = new \CriteriaCompo(); |
||
61 | // Все активные |
||
62 | $criteria->add(new \Criteria('status', '0', '>')); |
||
63 | // Если есть категория |
||
64 | if ($cid) { |
||
65 | // Если нельзя просматривать эту категорию |
||
66 | if (!in_array($cid, $categories)) { |
||
67 | redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT); |
||
68 | } |
||
69 | $criteria->add(new \Criteria('cid', $cid, '=')); |
||
70 | // Иначе находим список всех |
||
71 | } else { |
||
72 | $criteria->add(new \Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN')); |
||
73 | } |
||
74 | |||
75 | // Число инструкций, удовлетворяющих данному условию |
||
76 | $numrows = $instructionHandler->getCount($criteria); |
||
77 | // Число выборки |
||
78 | $criteria->setLimit($limit); |
||
79 | // Начинасть с данного элемента |
||
80 | $criteria->setStart($start); |
||
81 | // Сортировать по |
||
82 | $criteria->setSort('instrid'); |
||
83 | // Порядок сортировки |
||
84 | $criteria->setOrder('DESC'); |
||
85 | // Находим все инструкции |
||
86 | $instr_arr = $instructionHandler->getall($criteria); |
||
87 | // Если записей больше чем $limit, то выводим пагинатор |
||
88 | View Code Duplication | if ($numrows > $limit) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
89 | $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'cid=' . $cid); |
||
90 | $pagenav = $pagenav->renderNav(4); |
||
91 | } else { |
||
92 | $pagenav = ''; |
||
93 | } |
||
94 | // Выводим пагинатор в шаблон |
||
95 | $GLOBALS['xoopsTpl']->assign('insPagenav', $pagenav); |
||
96 | |||
97 | // Мета-теги страницы |
||
98 | $index_metakeywords = []; |
||
99 | $index_metadescript = []; |
||
100 | |||
101 | // Если есть записи |
||
102 | if ($numrows > 0) { |
||
103 | $class = 'odd'; |
||
104 | foreach (array_keys($instr_arr) as $i) { |
||
105 | |||
106 | // |
||
107 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
108 | // ID |
||
109 | $insinstr_instrid = $instr_arr[$i]->getVar('instrid'); |
||
110 | // Название |
||
111 | $insinstr_title = $instr_arr[$i]->getVar('title'); |
||
112 | // Статус |
||
113 | $insinstr_status = $instr_arr[$i]->getVar('status'); |
||
114 | // Количество страниц |
||
115 | $insinstr_pages = $instr_arr[$i]->getVar('pages'); |
||
116 | // Категория |
||
117 | $insinstr_cid = $instr_arr[$i]->getVar('cid'); |
||
118 | $insinstr_cat = $categoryHandler->get($insinstr_cid); |
||
119 | // Права на добавление |
||
120 | $perm_submit = in_array($insinstr_cid, $cat_submit) ? true : false; |
||
121 | // Права на редактирование |
||
122 | $perm_edit = in_array($insinstr_cid, $cat_edit) ? true : false; |
||
123 | //Мета-теги ключевых слов |
||
124 | $insinstr_metakeywords = $instr_arr[$i]->getVar('metakeywords'); |
||
125 | // Если есть - добавляем в мета-теги страницы |
||
126 | if ($insinstr_metakeywords) { |
||
127 | $index_metakeywords[] = $insinstr_metakeywords; |
||
128 | } |
||
129 | // Мета-теги описания |
||
130 | $insinstr_metadescript = $instr_arr[$i]->getVar('metadescription'); |
||
131 | // Если есть - добавляем в мета-теги страницы |
||
132 | if ($insinstr_metadescript) { |
||
133 | $index_metadescript[] = $insinstr_metadescript; |
||
134 | } |
||
135 | |||
136 | // Выводим в шаблон |
||
137 | $GLOBALS['xoopsTpl']->append('insListInstr', |
||
138 | ['instrid' => $insinstr_instrid, 'title' => $insinstr_title, 'status' => $insinstr_status, 'pages' => $insinstr_pages, 'ctitle' => $insinstr_cat->getVar('title'), 'cid' => $insinstr_cid, 'permsubmit' => $perm_submit, 'permedit' => $perm_edit, 'class' => $class] |
||
139 | ); |
||
140 | } |
||
141 | |||
142 | // Языковые константы |
||
143 | } |
||
144 | |||
145 | // Если есть мета-теги |
||
146 | if (count($index_metakeywords)) { |
||
147 | $xoTheme->addMeta('meta', 'keywords', implode(', ', $index_metakeywords)); |
||
148 | } |
||
149 | if (count($index_metadescript)) { |
||
150 | $xoTheme->addMeta('meta', 'description', implode(', ', $index_metadescript)); |
||
151 | } |
||
152 | |||
153 | // Подвал |
||
154 | include_once $GLOBALS['xoops']->path('footer.php'); |
||
155 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.