1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Xoopsmodules\instruction; |
4
|
|
|
|
5
|
|
|
// Блоки модуля инструкций |
6
|
|
|
// Блок последних инструкций |
7
|
|
|
|
8
|
|
|
// Последние инструкции |
9
|
|
|
/** |
10
|
|
|
* @param array $options |
11
|
|
|
* @return array |
12
|
|
|
*/ |
13
|
|
|
function b_instr_lastinstr_show($options = []) |
14
|
|
|
{ |
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); |
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 `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
|
|
|
} |
70
|
|
|
|
71
|
|
|
// Редактирование последних инструкций |
72
|
|
|
/** |
73
|
|
|
* @param array $options |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
View Code Duplication |
function b_instr_lastinstr_edit($options = []) |
|
|
|
|
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"; |
81
|
|
|
|
82
|
|
|
// Возвращаем форму |
83
|
|
|
return $form; |
84
|
|
|
} |
85
|
|
|
|
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.