1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Xoopsmodules\instruction; |
4
|
|
|
|
5
|
|
|
// Блоки модуля инструкций |
6
|
|
|
|
7
|
|
|
// Последние страницы |
8
|
|
|
/** |
9
|
|
|
* @param array $options |
10
|
|
|
* @return array |
11
|
|
|
*/ |
12
|
|
|
function b_instr_lastpage_show($options = []) |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
// Подключаем функции |
16
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
17
|
|
|
include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/include/common.php'); |
18
|
|
|
// |
19
|
|
|
$myts = MyTextSanitizer::getInstance(); |
20
|
|
|
// |
21
|
|
|
//mb $instructionHandler = xoops_getModuleHandler('instruction', 'instruction'); |
|
|
|
|
22
|
|
|
//mb $pageHandler = xoops_getModuleHandler('page', 'instruction'); |
|
|
|
|
23
|
|
|
|
24
|
|
|
$db = \XoopsDatabaseFactory::getDatabase(); |
25
|
|
|
$instructionHandler = new \Xoopsmodules\instruction\InstructionHandler($db); |
26
|
|
|
$pageHandler = new \Xoopsmodules\instruction\PageHandler($db); |
27
|
|
|
|
28
|
|
|
// Добавляем стили |
29
|
|
|
//global $xoTheme; |
30
|
|
|
//$xoTheme->addStylesheet( XOOPS_URL . '/modules/instruction/css/blocks.css' ); |
|
|
|
|
31
|
|
|
|
32
|
|
|
// Опции |
33
|
|
|
// Количество страниц |
34
|
|
|
$limit = $options[0]; |
35
|
|
|
// Количество символов |
36
|
|
|
$numchars = $options[1]; |
|
|
|
|
37
|
|
|
|
38
|
|
|
// Права на просмотр |
39
|
|
|
$cat_view = Xoopsmodules\instruction\Utility::getItemIds(); |
40
|
|
|
// Массив выходных данных |
41
|
|
|
$block = []; |
42
|
|
|
|
43
|
|
|
// Если есть категории для прасмотра |
44
|
|
|
if (is_array($cat_view) && count($cat_view) > 0) { |
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
|
|
|
} |
69
|
|
|
|
70
|
|
|
// Возвращаем массив |
71
|
|
|
return $block; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
// Редактирование последних страниц |
75
|
|
|
/** |
76
|
|
|
* @param array $options |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
|
View Code Duplication |
function b_instr_lastpage_edit($options = []) |
|
|
|
|
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"; |
84
|
|
|
|
85
|
|
|
// Возвращаем форму |
86
|
|
|
return $form; |
87
|
|
|
} |
88
|
|
|
|
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.