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