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 | include_once __DIR__ . '/class/tree.php'; |
||
9 | |||
10 | $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||
11 | $gpermHandler = xoops_getHandler('groupperm'); |
||
12 | |||
13 | // Права на просмотр страницы |
||
14 | // ========================== |
||
15 | |||
16 | // Объявляем объекты |
||
0 ignored issues
–
show
|
|||
17 | //$instructionHandler = xoops_getModuleHandler('instruction', 'instruction'); |
||
18 | //$categoryHandler = xoops_getModuleHandler('category', 'instruction'); |
||
19 | //$pageHandler = xoops_getModuleHandler('page', 'instruction'); |
||
20 | |||
21 | // Получаем данные |
||
22 | // ID страницы |
||
23 | $pageid = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
||
24 | // Без кэша |
||
25 | $nocache = Xoopsmodules\instruction\Utility::cleanVars($_GET, 'nocache', 0, 'int'); |
||
26 | |||
27 | // Существует ли такая страница |
||
28 | $criteria = new \CriteriaCompo(); |
||
29 | $criteria->add(new \Criteria('pageid ', $pageid)); |
||
30 | $criteria->add(new \Criteria('status ', '0', '>')); |
||
31 | if (0 == $pageHandler->getCount($criteria)) { |
||
32 | redirect_header('index.php', 3, _MD_INSTRUCTION_PAGENOTEXIST); |
||
33 | exit(); |
||
34 | } |
||
35 | // |
||
36 | unset($criteria); |
||
37 | |||
38 | // Находим данные о странице |
||
39 | $objInspage = $pageHandler->get($pageid); |
||
40 | // Находим данные об инструкции |
||
41 | $objInsinstr = $instructionHandler->get($objInspage->getVar('instrid')); |
||
42 | |||
43 | // Если админ и ссылка на отключение кэша |
||
44 | if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin() && $nocache) { |
||
45 | // Отключаем кэш |
||
46 | $GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0; |
||
47 | } |
||
48 | |||
49 | // Задание тайтла |
||
50 | $xoopsOption['xoops_pagetitle'] = $GLOBALS['xoopsModule']->name() . ' - ' . $objInsinstr->getVar('title') . ' - ' . $objInspage->getVar('title'); |
||
51 | // Шаблон |
||
52 | $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_page.tpl'; |
||
53 | // Заголовок |
||
54 | include_once $GLOBALS['xoops']->path('header.php'); |
||
55 | // Стили |
||
56 | $xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/style.css'); |
||
57 | // Скрипты |
||
58 | $xoTheme->addScript(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/js/tree.js'); |
||
59 | |||
60 | // Права на просмотр инструкции |
||
61 | $categories = Xoopsmodules\instruction\Utility::getItemIds(); |
||
62 | View Code Duplication | if (!in_array($objInsinstr->getVar('cid'), $categories)) { |
|
63 | redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM); |
||
64 | exit(); |
||
65 | } |
||
66 | |||
67 | // Массив данных о странице |
||
68 | $pages = []; |
||
69 | // Название страницы |
||
70 | $pages['title'] = $objInspage->getVar('title'); |
||
71 | // ID страницы |
||
72 | $pages['pageid'] = $objInspage->getVar('pageid'); |
||
73 | // ID инструкции |
||
74 | $pages['instrid'] = $objInspage->getVar('instrid'); |
||
75 | // Основной текст |
||
76 | $pages['hometext'] = $objInspage->getVar('hometext'); |
||
77 | // Сноска - массив строк |
||
78 | $footnote = $objInspage->getVar('footnote'); |
||
79 | // Если есть сноски |
||
80 | if ($footnote) { |
||
81 | $pages['footnotes'] = explode('|', $objInspage->getVar('footnote')); |
||
82 | } else { |
||
83 | $pages['footnotes'] = false; |
||
84 | } |
||
85 | // Мета-теги ключевых слов |
||
86 | $pages['keywords'] = $objInspage->getVar('keywords'); |
||
87 | // Мета-теги описания |
||
88 | $pages['description'] = $objInspage->getVar('description'); |
||
89 | // |
||
90 | // Если админ, рисуем админлинк |
||
91 | if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid())) { |
||
92 | $pages['adminlink'] = ' <a href="' |
||
93 | . XOOPS_URL |
||
94 | . '/modules/' |
||
95 | . $moduleDirName |
||
96 | . '/admin/instr.php?op=editpage&pageid=' |
||
97 | . $pages['pageid'] |
||
98 | . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' |
||
99 | . _EDIT |
||
100 | . ' title=' |
||
101 | . _EDIT |
||
102 | . '></a> <a href="' |
||
103 | . XOOPS_URL |
||
104 | . '/modules/' |
||
105 | . $moduleDirName |
||
106 | . '/admin/instr.php?op=delpage&pageid=' |
||
107 | . $pages['pageid'] |
||
108 | . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt=' |
||
109 | . _DELETE |
||
110 | . ' title=' |
||
111 | . _DELETE |
||
112 | . '></a> '; |
||
113 | } else { |
||
114 | $pages['adminlink'] = ' '; |
||
115 | // Если можно редактировать |
||
116 | if ($gpermHandler->checkRight($moduleDirName . '_edit', $objInsinstr->getVar('cid'), $groups, $GLOBALS['xoopsModule']->getVar('mid'))) { |
||
117 | $pages['adminlink'] .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/submit.php?op=editpage&pageid=' . $pages['pageid'] . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' . _EDIT . ' title=' . _EDIT . '></a>'; |
||
118 | } |
||
119 | |||
120 | $pages['adminlink'] .= ' '; |
||
121 | // Если нет админлика |
||
122 | if ('[ ]' === $pages['adminlink']) { |
||
123 | $pages['adminlink'] = ''; |
||
124 | } |
||
125 | } |
||
126 | // Выводим в шаблон |
||
127 | $GLOBALS['xoopsTpl']->assign('insPage', $pages); |
||
128 | |||
129 | // Находим данные об категории |
||
130 | $objInscat = $categoryHandler->get($objInsinstr->getVar('cid')); |
||
131 | |||
132 | // Навигация |
||
133 | $criteria = new \CriteriaCompo(); |
||
134 | $criteria->setSort('weight ASC, title'); |
||
135 | $criteria->setOrder('ASC'); |
||
136 | $inscat_arr = $categoryHandler->getall($criteria); |
||
137 | $mytree = new \XoopsObjectTree($inscat_arr, 'cid', 'pid'); |
||
138 | $nav_parent_id = $mytree->getAllParent($objInsinstr->getVar('cid')); |
||
139 | $titre_page = $nav_parent_id; |
||
140 | $nav_parent_id = array_reverse($nav_parent_id); |
||
141 | $navigation = '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/">' . $GLOBALS['xoopsModule']->name() . '</a> : '; |
||
142 | View Code Duplication | foreach (array_keys($nav_parent_id) as $i) { |
|
143 | $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $nav_parent_id[$i]->getVar('cid') . '">' . $nav_parent_id[$i]->getVar('title') . '</a> : '; |
||
144 | } |
||
145 | $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $objInscat->getVar('cid') . '">' . $objInscat->getVar('title') . '</a> : '; |
||
146 | $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/instr.php?id=' . $pages['instrid'] . '">' . $objInsinstr->getVar('title') . '</a>'; |
||
147 | $xoopsTpl->assign('insNav', $navigation); |
||
148 | |||
149 | unset($criteria); |
||
150 | |||
151 | // Список страниц в данной справке |
||
152 | $criteria = new \CriteriaCompo(); |
||
153 | $criteria->add(new \Criteria('instrid', $pages['instrid'], '=')); |
||
154 | $criteria->add(new \Criteria('status ', '0', '>')); |
||
155 | $criteria->setSort('weight'); |
||
156 | $criteria->setOrder('ASC'); |
||
157 | $ins_page = $pageHandler->getall($criteria); |
||
158 | unset($criteria); |
||
159 | // Предыдущая и следующая страницы |
||
160 | $prevpages = []; |
||
161 | $nextpages = []; |
||
162 | // Инициализируем |
||
163 | $instree = new Xoopsmodules\instruction\Tree($ins_page, 'pageid', 'pid'); |
||
164 | // Выводим список страниц в шаблон |
||
165 | $GLOBALS['xoopsTpl']->assign('insListPage', $instree->makePagesUser($pageid, $prevpages, $nextpages)); |
||
166 | // Выводим в шаблон |
||
167 | $xoopsTpl->assign('insPrevpages', $prevpages); |
||
168 | $xoopsTpl->assign('insNextpages', $nextpages); |
||
169 | // Языковые константы |
||
170 | //$xoopsTpl->assign( 'lang_listpages', _MD_INSTRUCTION_LISTPAGES ); |
||
171 | $xoopsTpl->assign('lang_menu', _MD_INSTRUCTION_MENU); |
||
172 | |||
173 | // Рейтинг |
||
174 | View Code Duplication | if (xoops_getModuleOption('userat', 'instruction')) { |
|
175 | $xoopsTpl->assign('insUserat', true); |
||
176 | } else { |
||
177 | $xoopsTpl->assign('insUserat', false); |
||
178 | } |
||
179 | |||
180 | // Мета теги |
||
181 | $xoTheme->addMeta('meta', 'keywords', $objInspage->getVar('keywords')); |
||
182 | $xoTheme->addMeta('meta', 'description', $objInspage->getVar('description')); |
||
183 | |||
184 | // Комментарии |
||
185 | include_once $GLOBALS['xoops']->path('include/comment_view.php'); |
||
186 | // Подвал |
||
187 | include_once $GLOBALS['xoops']->path('footer.php'); |
||
188 |
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.