@@ -1,7 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -use Xoopsmodules\instruction; |
|
| 4 | - |
|
| 5 | 3 | // Автор: andrey3761 |
| 6 | 4 | $moduleDirName = basename(dirname(__DIR__)); |
| 7 | 5 | require_once __DIR__ . '/../../../include/cp_header.php'; |
@@ -12,19 +12,19 @@ |
||
| 12 | 12 | |
| 13 | 13 | //if (is_object($GLOBALS['xoopsUser'])) { |
| 14 | 14 | if ($GLOBALS['xoopsUser'] instanceof XoopsUser) { |
| 15 | - if (!$helper->isUserAdmin()) { |
|
| 16 | - $helper->redirect(XOOPS_URL . '/', 3, _NOPERM); |
|
| 17 | - } |
|
| 15 | + if (!$helper->isUserAdmin()) { |
|
| 16 | + $helper->redirect(XOOPS_URL . '/', 3, _NOPERM); |
|
| 17 | + } |
|
| 18 | 18 | } else { |
| 19 | - $helper->redirect(XOOPS_URL . '/user.php', 1, _NOPERM); |
|
| 19 | + $helper->redirect(XOOPS_URL . '/user.php', 1, _NOPERM); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** @var Xmf\Module\Admin $adminObject */ |
| 23 | 23 | $adminObject = \Xmf\Module\Admin::getInstance(); |
| 24 | 24 | |
| 25 | 25 | if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) { |
| 26 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 27 | - $xoopsTpl = new \XoopsTpl(); |
|
| 26 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 27 | + $xoopsTpl = new \XoopsTpl(); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $pathIcon16 = Xmf\Module\Admin::iconUrl('', 16); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | //if (is_object($GLOBALS['xoopsUser'])) { |
| 14 | 14 | if ($GLOBALS['xoopsUser'] instanceof XoopsUser) { |
| 15 | - if (!$helper->isUserAdmin()) { |
|
| 15 | + if ( ! $helper->isUserAdmin()) { |
|
| 16 | 16 | $helper->redirect(XOOPS_URL . '/', 3, _NOPERM); |
| 17 | 17 | } |
| 18 | 18 | } else { |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** @var Xmf\Module\Admin $adminObject */ |
| 23 | 23 | $adminObject = \Xmf\Module\Admin::getInstance(); |
| 24 | 24 | |
| 25 | -if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) { |
|
| 25 | +if ( ! isset($GLOBALS['xoopsTpl']) || ! ($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) { |
|
| 26 | 26 | require_once $GLOBALS['xoops']->path('class/template.php'); |
| 27 | 27 | $xoopsTpl = new \XoopsTpl(); |
| 28 | 28 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | class InstructionHandler extends \XoopsPersistableObjectHandler |
| 16 | 16 | { |
| 17 | 17 | /** |
| 18 | - * @param null|mixed $db |
|
| 18 | + * @param null|\XoopsDatabase $db |
|
| 19 | 19 | */ |
| 20 | 20 | public function __construct(\XoopsDatabase $db = null) |
| 21 | 21 | { |
@@ -14,51 +14,51 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class InstructionHandler extends \XoopsPersistableObjectHandler |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @param null|mixed $db |
|
| 19 | - */ |
|
| 20 | - public function __construct(\XoopsDatabase $db = null) |
|
| 21 | - { |
|
| 22 | - parent::__construct($db, 'instruction_instr', Instruction::class, 'instrid', 'title'); |
|
| 23 | - } |
|
| 17 | + /** |
|
| 18 | + * @param null|mixed $db |
|
| 19 | + */ |
|
| 20 | + public function __construct(\XoopsDatabase $db = null) |
|
| 21 | + { |
|
| 22 | + parent::__construct($db, 'instruction_instr', Instruction::class, 'instrid', 'title'); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - // Обновление даты обновления инструкций |
|
| 25 | + // Обновление даты обновления инструкций |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @param int $instrid |
|
| 29 | - * @param bool|int $time |
|
| 30 | - * @return mixed |
|
| 31 | - */ |
|
| 32 | - public function updateDateupdated($instrid = 0, $time = null) |
|
| 33 | - { |
|
| 34 | - // Если не передали время |
|
| 35 | - $time = null === $time ? time() : (int)$time; |
|
| 36 | - // |
|
| 37 | - $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `instrid` = %u', $this->table, $time, (int)$instrid); |
|
| 38 | - // |
|
| 39 | - return $this->db->query($sql); |
|
| 40 | - } |
|
| 27 | + /** |
|
| 28 | + * @param int $instrid |
|
| 29 | + * @param bool|int $time |
|
| 30 | + * @return mixed |
|
| 31 | + */ |
|
| 32 | + public function updateDateupdated($instrid = 0, $time = null) |
|
| 33 | + { |
|
| 34 | + // Если не передали время |
|
| 35 | + $time = null === $time ? time() : (int)$time; |
|
| 36 | + // |
|
| 37 | + $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `instrid` = %u', $this->table, $time, (int)$instrid); |
|
| 38 | + // |
|
| 39 | + return $this->db->query($sql); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - // Обновление числа страниц |
|
| 42 | + // Обновление числа страниц |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @param int $instrid |
|
| 46 | - * @return mixed |
|
| 47 | - */ |
|
| 48 | - public function updatePages($instrid = 0) |
|
| 49 | - { |
|
| 50 | - // $pageHandler = xoops_getModuleHandler('page', 'instruction'); |
|
| 51 | - // Находим число активных страниц |
|
| 52 | - $criteria = new \CriteriaCompo(); |
|
| 53 | - $criteria->add(new \Criteria('instrid', $instrid, '=')); |
|
| 54 | - $criteria->add(new \Criteria('status ', '0', '>')); |
|
| 55 | - // Число страниц |
|
| 56 | - $pages = $pageHandler->getCount($criteria); |
|
| 57 | - unset($criteria); |
|
| 44 | + /** |
|
| 45 | + * @param int $instrid |
|
| 46 | + * @return mixed |
|
| 47 | + */ |
|
| 48 | + public function updatePages($instrid = 0) |
|
| 49 | + { |
|
| 50 | + // $pageHandler = xoops_getModuleHandler('page', 'instruction'); |
|
| 51 | + // Находим число активных страниц |
|
| 52 | + $criteria = new \CriteriaCompo(); |
|
| 53 | + $criteria->add(new \Criteria('instrid', $instrid, '=')); |
|
| 54 | + $criteria->add(new \Criteria('status ', '0', '>')); |
|
| 55 | + // Число страниц |
|
| 56 | + $pages = $pageHandler->getCount($criteria); |
|
| 57 | + unset($criteria); |
|
| 58 | 58 | |
| 59 | - // Сохраняем это число |
|
| 60 | - $sql = sprintf('UPDATE `%s` SET `pages` = %u, `dateupdated` = %u WHERE `instrid` = %u', $this->table, $pages, time(), $instrid); |
|
| 61 | - // |
|
| 62 | - return $this->db->query($sql); |
|
| 63 | - } |
|
| 59 | + // Сохраняем это число |
|
| 60 | + $sql = sprintf('UPDATE `%s` SET `pages` = %u, `dateupdated` = %u WHERE `instrid` = %u', $this->table, $pages, time(), $instrid); |
|
| 61 | + // |
|
| 62 | + return $this->db->query($sql); |
|
| 63 | + } |
|
| 64 | 64 | } |
@@ -32,9 +32,9 @@ |
||
| 32 | 32 | public function updateDateupdated($instrid = 0, $time = null) |
| 33 | 33 | { |
| 34 | 34 | // Если не передали время |
| 35 | - $time = null === $time ? time() : (int)$time; |
|
| 35 | + $time = null === $time ? time() : (int) $time; |
|
| 36 | 36 | // |
| 37 | - $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `instrid` = %u', $this->table, $time, (int)$instrid); |
|
| 37 | + $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `instrid` = %u', $this->table, $time, (int) $instrid); |
|
| 38 | 38 | // |
| 39 | 39 | return $this->db->query($sql); |
| 40 | 40 | } |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | // } |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * @param $key |
|
| 27 | - * @param $ret |
|
| 28 | - * @param $prefix_orig |
|
| 26 | + * @param integer $key |
|
| 27 | + * @param string $ret |
|
| 28 | + * @param string $prefix_orig |
|
| 29 | 29 | * @param $objInsinstr |
| 30 | 30 | * @param string $class |
| 31 | 31 | * @param string $prefix_curr |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | // ================================== |
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | - * @param $key |
|
| 144 | - * @param $ret |
|
| 145 | - * @param $prefix_orig |
|
| 143 | + * @param integer $key |
|
| 144 | + * @param string $ret |
|
| 145 | + * @param string $prefix_orig |
|
| 146 | 146 | * @param array $cidinstrids |
| 147 | 147 | * @param string $class |
| 148 | 148 | * @param string $prefix_curr |
@@ -239,8 +239,8 @@ discard block |
||
| 239 | 239 | // ====================================== |
| 240 | 240 | |
| 241 | 241 | /** |
| 242 | - * @param $key |
|
| 243 | - * @param $ret |
|
| 242 | + * @param integer $key |
|
| 243 | + * @param string $ret |
|
| 244 | 244 | * @param int $currpageid |
| 245 | 245 | * @param array $lastpageids |
| 246 | 246 | * @param int $level |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | // Находим предыдущую и следующую страницы. |
| 351 | 351 | // Находим последнии страницы на каждом уровне. |
| 352 | 352 | /** |
| 353 | - * @param $key |
|
| 353 | + * @param integer $key |
|
| 354 | 354 | * @param int $currpageid |
| 355 | 355 | * @param array $prevpages |
| 356 | 356 | * @param array $nextpages |
@@ -18,96 +18,96 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Tree extends \XoopsObjectTree |
| 20 | 20 | { |
| 21 | - // public function __construct() |
|
| 22 | - // { |
|
| 23 | - // } |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @param $key |
|
| 27 | - * @param $ret |
|
| 28 | - * @param $prefix_orig |
|
| 29 | - * @param $objInsinstr |
|
| 30 | - * @param string $class |
|
| 31 | - * @param string $prefix_curr |
|
| 32 | - */ |
|
| 33 | - public function _makePagesAdminOptions($key, &$ret, $prefix_orig, $objInsinstr, $class = 'odd', $prefix_curr = '') |
|
| 34 | - { |
|
| 35 | - if ($key > 0) { |
|
| 36 | - |
|
| 37 | - // |
|
| 38 | - $class = ('even' === $class) ? 'odd' : 'even'; |
|
| 39 | - // ID инструкции ( Можно сделать статической ) |
|
| 40 | - $instrid = $objInsinstr->getVar('instrid'); |
|
| 41 | - |
|
| 42 | - // ID страницы |
|
| 43 | - $pageid = $this->tree[$key]['obj']->getVar('pageid'); |
|
| 44 | - // Название страницы |
|
| 45 | - $pagetitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 46 | - // Вес |
|
| 47 | - $pageweight = $this->tree[$key]['obj']->getVar('weight'); |
|
| 48 | - // Статус |
|
| 49 | - $pagestatus = $this->tree[$key]['obj']->getVar('status'); |
|
| 50 | - // Тип страницы |
|
| 51 | - $pagetype = $this->tree[$key]['obj']->getVar('type'); |
|
| 52 | - |
|
| 53 | - // Дочернии страницы |
|
| 54 | - $page_childs = $this->getAllChild($pageid); |
|
| 55 | - // Число дочерних страниц |
|
| 56 | - $num_childs = count($page_childs); |
|
| 57 | - |
|
| 58 | - // Действие - удаление |
|
| 59 | - $act_del = ($num_childs > 0) ? '<img src="../assets/icons/no_delete_mini.png" alt="' . _AM_INSTR_NODELPAGE . '" title="' . _AM_INSTR_NODELPAGE . '" />' : '<a href="instr.php?op=delpage&pageid=' |
|
| 60 | - . $pageid |
|
| 61 | - . '"><img src="../assets/icons/delete_mini.png" alt="' |
|
| 62 | - . _AM_INSTRUCTION_DEL |
|
| 63 | - . '" title="' |
|
| 64 | - . _AM_INSTRUCTION_DEL |
|
| 65 | - . '"></a>'; |
|
| 66 | - // |
|
| 67 | - $page_link = '<a name="pageid_' . $pageid . '" ' . ($pagetype ? 'href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/page.php?id=' . $pageid . '#pagetext"' : '') . '>' . $pagetitle . '</a>'; |
|
| 68 | - |
|
| 69 | - $ret .= '<tr class="' . $class . '"> |
|
| 21 | + // public function __construct() |
|
| 22 | + // { |
|
| 23 | + // } |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @param $key |
|
| 27 | + * @param $ret |
|
| 28 | + * @param $prefix_orig |
|
| 29 | + * @param $objInsinstr |
|
| 30 | + * @param string $class |
|
| 31 | + * @param string $prefix_curr |
|
| 32 | + */ |
|
| 33 | + public function _makePagesAdminOptions($key, &$ret, $prefix_orig, $objInsinstr, $class = 'odd', $prefix_curr = '') |
|
| 34 | + { |
|
| 35 | + if ($key > 0) { |
|
| 36 | + |
|
| 37 | + // |
|
| 38 | + $class = ('even' === $class) ? 'odd' : 'even'; |
|
| 39 | + // ID инструкции ( Можно сделать статической ) |
|
| 40 | + $instrid = $objInsinstr->getVar('instrid'); |
|
| 41 | + |
|
| 42 | + // ID страницы |
|
| 43 | + $pageid = $this->tree[$key]['obj']->getVar('pageid'); |
|
| 44 | + // Название страницы |
|
| 45 | + $pagetitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 46 | + // Вес |
|
| 47 | + $pageweight = $this->tree[$key]['obj']->getVar('weight'); |
|
| 48 | + // Статус |
|
| 49 | + $pagestatus = $this->tree[$key]['obj']->getVar('status'); |
|
| 50 | + // Тип страницы |
|
| 51 | + $pagetype = $this->tree[$key]['obj']->getVar('type'); |
|
| 52 | + |
|
| 53 | + // Дочернии страницы |
|
| 54 | + $page_childs = $this->getAllChild($pageid); |
|
| 55 | + // Число дочерних страниц |
|
| 56 | + $num_childs = count($page_childs); |
|
| 57 | + |
|
| 58 | + // Действие - удаление |
|
| 59 | + $act_del = ($num_childs > 0) ? '<img src="../assets/icons/no_delete_mini.png" alt="' . _AM_INSTR_NODELPAGE . '" title="' . _AM_INSTR_NODELPAGE . '" />' : '<a href="instr.php?op=delpage&pageid=' |
|
| 60 | + . $pageid |
|
| 61 | + . '"><img src="../assets/icons/delete_mini.png" alt="' |
|
| 62 | + . _AM_INSTRUCTION_DEL |
|
| 63 | + . '" title="' |
|
| 64 | + . _AM_INSTRUCTION_DEL |
|
| 65 | + . '"></a>'; |
|
| 66 | + // |
|
| 67 | + $page_link = '<a name="pageid_' . $pageid . '" ' . ($pagetype ? 'href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/page.php?id=' . $pageid . '#pagetext"' : '') . '>' . $pagetitle . '</a>'; |
|
| 68 | + |
|
| 69 | + $ret .= '<tr class="' . $class . '"> |
|
| 70 | 70 | <td>' . $prefix_curr . ' ' . $page_link . '</td> |
| 71 | 71 | <td align="center" width="50"> |
| 72 | 72 | <input type="text" name="weights[]" size="2" value="' . $pageweight . '" /> |
| 73 | 73 | <input type="hidden" name="pageids[]" value="' . $pageid . '" /> |
| 74 | 74 | </td> |
| 75 | 75 | <td align="center" width="180">'; |
| 76 | - // Просмотре без кэша |
|
| 77 | - $ret .= ' <a href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/page.php?id=' . $pageid . '&nocache=1"><img src="../assets/icons/no_cache.png" alt="' . _AM_INSTR_DISPLAY_NOCACHE . '" title="' . _AM_INSTR_DISPLAY_NOCACHE . '" /></a> '; |
|
| 78 | - // Добавить подстраницу |
|
| 79 | - $ret .= ' <a href="instr.php?op=editpage&instrid=' . $instrid . '&pid=' . $pageid . '"><img src="../assets/icons/add_mini.png" alt="' . _AM_INSTRUCTION_ADDSUBPAGE . '" title="' . _AM_INSTRUCTION_ADDSUBPAGE . '" /></a> '; |
|
| 80 | - |
|
| 81 | - if ($pagestatus) { |
|
| 82 | - $ret .= ' <img src="../assets/icons/lock_mini.png" alt="' . _AM_INSTRUCTION_LOCK . '" title="' . _AM_INSTRUCTION_LOCK . '"> '; |
|
| 83 | - } else { |
|
| 84 | - $ret .= ' <img src="../assets/icons/unlock_mini.png" alt="' . _AM_INSTRUCTION_UNLOCK . '" title="' . _AM_INSTRUCTION_UNLOCK . '"> '; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $ret .= ' <a href="instr.php?op=editpage&pageid=' . $pageid . '"><img src="../assets/icons/edit_mini.png" alt="' . _AM_INSTRUCTION_EDIT . '" title="' . _AM_INSTRUCTION_EDIT . '"></a> ' . $act_del . ' |
|
| 76 | + // Просмотре без кэша |
|
| 77 | + $ret .= ' <a href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/page.php?id=' . $pageid . '&nocache=1"><img src="../assets/icons/no_cache.png" alt="' . _AM_INSTR_DISPLAY_NOCACHE . '" title="' . _AM_INSTR_DISPLAY_NOCACHE . '" /></a> '; |
|
| 78 | + // Добавить подстраницу |
|
| 79 | + $ret .= ' <a href="instr.php?op=editpage&instrid=' . $instrid . '&pid=' . $pageid . '"><img src="../assets/icons/add_mini.png" alt="' . _AM_INSTRUCTION_ADDSUBPAGE . '" title="' . _AM_INSTRUCTION_ADDSUBPAGE . '" /></a> '; |
|
| 80 | + |
|
| 81 | + if ($pagestatus) { |
|
| 82 | + $ret .= ' <img src="../assets/icons/lock_mini.png" alt="' . _AM_INSTRUCTION_LOCK . '" title="' . _AM_INSTRUCTION_LOCK . '"> '; |
|
| 83 | + } else { |
|
| 84 | + $ret .= ' <img src="../assets/icons/unlock_mini.png" alt="' . _AM_INSTRUCTION_UNLOCK . '" title="' . _AM_INSTRUCTION_UNLOCK . '"> '; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $ret .= ' <a href="instr.php?op=editpage&pageid=' . $pageid . '"><img src="../assets/icons/edit_mini.png" alt="' . _AM_INSTRUCTION_EDIT . '" title="' . _AM_INSTRUCTION_EDIT . '"></a> ' . $act_del . ' |
|
| 88 | 88 | </td> |
| 89 | 89 | </tr>'; |
| 90 | 90 | |
| 91 | - // Устанавливаем префикс |
|
| 92 | - $prefix_curr .= $prefix_orig; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 96 | - foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 97 | - $this->_makePagesAdminOptions($childkey, $ret, $prefix_orig, $objInsinstr, $class, $prefix_curr); |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @param $objInsinstr |
|
| 104 | - * @param string $prefix |
|
| 105 | - * @param int $key |
|
| 106 | - * @return string |
|
| 107 | - */ |
|
| 108 | - public function makePagesAdmin(&$objInsinstr, $prefix = '-', $key = 0) |
|
| 109 | - { |
|
| 110 | - $ret = '<form name="inspages" action="instr.php" method="post"> |
|
| 91 | + // Устанавливаем префикс |
|
| 92 | + $prefix_curr .= $prefix_orig; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 96 | + foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 97 | + $this->_makePagesAdminOptions($childkey, $ret, $prefix_orig, $objInsinstr, $class, $prefix_curr); |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @param $objInsinstr |
|
| 104 | + * @param string $prefix |
|
| 105 | + * @param int $key |
|
| 106 | + * @return string |
|
| 107 | + */ |
|
| 108 | + public function makePagesAdmin(&$objInsinstr, $prefix = '-', $key = 0) |
|
| 109 | + { |
|
| 110 | + $ret = '<form name="inspages" action="instr.php" method="post"> |
|
| 111 | 111 | <table width="100%" cellspacing="1" class="outer"> |
| 112 | 112 | <tr> |
| 113 | 113 | <th align="center" colspan="3">' . sprintf(_AM_INSTRUCTION_LISTPAGESININSTR, $objInsinstr->getVar('title')) . '</th> |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | <td class="head" align="center" width="180">' . _AM_INSTRUCTION_ACTION . '</td> |
| 119 | 119 | </tr>'; |
| 120 | 120 | |
| 121 | - // Выводим все страницы |
|
| 122 | - $this->_makePagesAdminOptions($key, $ret, $prefix, $objInsinstr); |
|
| 121 | + // Выводим все страницы |
|
| 122 | + $this->_makePagesAdminOptions($key, $ret, $prefix, $objInsinstr); |
|
| 123 | 123 | |
| 124 | - $ret .= '<tr class="foot"> |
|
| 124 | + $ret .= '<tr class="foot"> |
|
| 125 | 125 | <td><a href="instr.php?op=editpage&instrid=' . $objInsinstr->getVar('instrid') . '"><img src="../assets/icons/add_mini.png" alt="' . _AM_INSTRUCTION_ADDPAGE . '" title="' . _AM_INSTRUCTION_ADDPAGE . '"></a></td> |
| 126 | 126 | <td colspan="2"> |
| 127 | 127 | <input type="hidden" name="instrid" value="' . $objInsinstr->getVar('instrid') . '" /> |
@@ -132,60 +132,60 @@ discard block |
||
| 132 | 132 | </table> |
| 133 | 133 | </form>'; |
| 134 | 134 | |
| 135 | - return $ret; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - // ================================== |
|
| 139 | - // === Дерево категорий в админке === |
|
| 140 | - // ================================== |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * @param $key |
|
| 144 | - * @param $ret |
|
| 145 | - * @param $prefix_orig |
|
| 146 | - * @param array $cidinstrids |
|
| 147 | - * @param string $class |
|
| 148 | - * @param string $prefix_curr |
|
| 149 | - */ |
|
| 150 | - public function _makeCatsAdminOptions($key, &$ret, $prefix_orig, $cidinstrids = [], &$class = 'odd', $prefix_curr = '') |
|
| 151 | - { |
|
| 152 | - if ($key > 0) { |
|
| 153 | - |
|
| 154 | - // |
|
| 155 | - $class = ('even' === $class) ? 'odd' : 'even'; |
|
| 156 | - |
|
| 157 | - // ID категории |
|
| 158 | - $catid = $this->tree[$key]['obj']->getVar('cid'); |
|
| 159 | - // Название категории |
|
| 160 | - $cattitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 161 | - // Вес |
|
| 162 | - $catweight = $this->tree[$key]['obj']->getVar('weight'); |
|
| 163 | - // Статус |
|
| 164 | - $pagestatus = $this->tree[$key]['obj']->getVar('status'); |
|
| 165 | - |
|
| 166 | - // Дочернии категории |
|
| 167 | - $cat_childs = $this->getAllChild($catid); |
|
| 168 | - // Число дочерних категорий |
|
| 169 | - $num_childs = count($cat_childs); |
|
| 170 | - // Число инструкций |
|
| 171 | - $num_instrs = isset($cidinstrids[$catid]) ? $cidinstrids[$catid] : 0; |
|
| 172 | - |
|
| 173 | - // Действие - удаление |
|
| 174 | - $act_del = (($num_instrs > 0) || ($num_childs > 0)) ? '<img src="../assets/icons/no_delete_mini.png" alt="' . _AM_INSTR_NODELCAT . '" title="' . _AM_INSTR_NODELCAT . '" />' : '<a href="cat.php?op=delcat&cid=' |
|
| 175 | - . $catid |
|
| 176 | - . '"><img src="../assets/icons/delete_mini.png" alt="' |
|
| 177 | - . _AM_INSTRUCTION_DEL |
|
| 178 | - . '" title="' |
|
| 179 | - . _AM_INSTRUCTION_DEL |
|
| 180 | - . '" /></a>'; |
|
| 181 | - // Действие - просмотр |
|
| 182 | - $act_view = ($num_instrs > 0) ? '<a href="instr.php?cid=' . $catid . '"><img src="../assets/icons/view_mini.png" alt="' . _AM_INSTR_VIEWINSTR . '" title="' . _AM_INSTR_VIEWINSTR . '" /></a>' : '<img src="../assets/icons/no_view_mini.png" alt="' |
|
| 183 | - . _AM_INSTR_NOVIEWINSTR |
|
| 184 | - . '" title="' |
|
| 185 | - . _AM_INSTR_NOVIEWINSTR |
|
| 186 | - . '" />'; |
|
| 187 | - |
|
| 188 | - $ret .= '<tr class="' . $class . '"> |
|
| 135 | + return $ret; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + // ================================== |
|
| 139 | + // === Дерево категорий в админке === |
|
| 140 | + // ================================== |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * @param $key |
|
| 144 | + * @param $ret |
|
| 145 | + * @param $prefix_orig |
|
| 146 | + * @param array $cidinstrids |
|
| 147 | + * @param string $class |
|
| 148 | + * @param string $prefix_curr |
|
| 149 | + */ |
|
| 150 | + public function _makeCatsAdminOptions($key, &$ret, $prefix_orig, $cidinstrids = [], &$class = 'odd', $prefix_curr = '') |
|
| 151 | + { |
|
| 152 | + if ($key > 0) { |
|
| 153 | + |
|
| 154 | + // |
|
| 155 | + $class = ('even' === $class) ? 'odd' : 'even'; |
|
| 156 | + |
|
| 157 | + // ID категории |
|
| 158 | + $catid = $this->tree[$key]['obj']->getVar('cid'); |
|
| 159 | + // Название категории |
|
| 160 | + $cattitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 161 | + // Вес |
|
| 162 | + $catweight = $this->tree[$key]['obj']->getVar('weight'); |
|
| 163 | + // Статус |
|
| 164 | + $pagestatus = $this->tree[$key]['obj']->getVar('status'); |
|
| 165 | + |
|
| 166 | + // Дочернии категории |
|
| 167 | + $cat_childs = $this->getAllChild($catid); |
|
| 168 | + // Число дочерних категорий |
|
| 169 | + $num_childs = count($cat_childs); |
|
| 170 | + // Число инструкций |
|
| 171 | + $num_instrs = isset($cidinstrids[$catid]) ? $cidinstrids[$catid] : 0; |
|
| 172 | + |
|
| 173 | + // Действие - удаление |
|
| 174 | + $act_del = (($num_instrs > 0) || ($num_childs > 0)) ? '<img src="../assets/icons/no_delete_mini.png" alt="' . _AM_INSTR_NODELCAT . '" title="' . _AM_INSTR_NODELCAT . '" />' : '<a href="cat.php?op=delcat&cid=' |
|
| 175 | + . $catid |
|
| 176 | + . '"><img src="../assets/icons/delete_mini.png" alt="' |
|
| 177 | + . _AM_INSTRUCTION_DEL |
|
| 178 | + . '" title="' |
|
| 179 | + . _AM_INSTRUCTION_DEL |
|
| 180 | + . '" /></a>'; |
|
| 181 | + // Действие - просмотр |
|
| 182 | + $act_view = ($num_instrs > 0) ? '<a href="instr.php?cid=' . $catid . '"><img src="../assets/icons/view_mini.png" alt="' . _AM_INSTR_VIEWINSTR . '" title="' . _AM_INSTR_VIEWINSTR . '" /></a>' : '<img src="../assets/icons/no_view_mini.png" alt="' |
|
| 183 | + . _AM_INSTR_NOVIEWINSTR |
|
| 184 | + . '" title="' |
|
| 185 | + . _AM_INSTR_NOVIEWINSTR |
|
| 186 | + . '" />'; |
|
| 187 | + |
|
| 188 | + $ret .= '<tr class="' . $class . '"> |
|
| 189 | 189 | <td>' . $prefix_curr . ' <a href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/index.php?cid=' . $catid . '">' . $cattitle . '</a></td> |
| 190 | 190 | <td align="center" width="50">' . $catweight . '</td> |
| 191 | 191 | <td align="center" width="100">' . $num_instrs . '</td> |
@@ -196,26 +196,26 @@ discard block |
||
| 196 | 196 | </td> |
| 197 | 197 | </tr>'; |
| 198 | 198 | |
| 199 | - // Устанавливаем префикс |
|
| 200 | - $prefix_curr .= $prefix_orig; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 204 | - foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 205 | - $this->_makeCatsAdminOptions($childkey, $ret, $prefix_orig, $cidinstrids, $class, $prefix_curr); |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * @param string $prefix |
|
| 212 | - * @param array $cidinstrids |
|
| 213 | - * @param int $key |
|
| 214 | - * @return string |
|
| 215 | - */ |
|
| 216 | - public function makeCatsAdmin($prefix = '-', $cidinstrids = [], $key = 0) |
|
| 217 | - { |
|
| 218 | - $ret = '<table width="100%" cellspacing="1" class="outer"> |
|
| 199 | + // Устанавливаем префикс |
|
| 200 | + $prefix_curr .= $prefix_orig; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 204 | + foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 205 | + $this->_makeCatsAdminOptions($childkey, $ret, $prefix_orig, $cidinstrids, $class, $prefix_curr); |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * @param string $prefix |
|
| 212 | + * @param array $cidinstrids |
|
| 213 | + * @param int $key |
|
| 214 | + * @return string |
|
| 215 | + */ |
|
| 216 | + public function makeCatsAdmin($prefix = '-', $cidinstrids = [], $key = 0) |
|
| 217 | + { |
|
| 218 | + $ret = '<table width="100%" cellspacing="1" class="outer"> |
|
| 219 | 219 | <tr> |
| 220 | 220 | <th align="center" colspan="4">' . _AM_INSTR_LISTALLCATS . '</th> |
| 221 | 221 | </tr> |
@@ -226,215 +226,215 @@ discard block |
||
| 226 | 226 | <td class="head" align="center" width="150">' . _AM_INSTRUCTION_ACTION . '</td> |
| 227 | 227 | </tr>'; |
| 228 | 228 | |
| 229 | - // Выводим все страницы |
|
| 230 | - $this->_makeCatsAdminOptions($key, $ret, $prefix, $cidinstrids); |
|
| 231 | - |
|
| 232 | - $ret .= '</table>'; |
|
| 233 | - |
|
| 234 | - return $ret; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - // ====================================== |
|
| 238 | - // Список страниц на стороне пользователя |
|
| 239 | - // ====================================== |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * @param $key |
|
| 243 | - * @param $ret |
|
| 244 | - * @param int $currpageid |
|
| 245 | - * @param array $lastpageids |
|
| 246 | - * @param int $level |
|
| 247 | - */ |
|
| 248 | - public function _makePagesUserTree($key, &$ret, $currpageid = 0, &$lastpageids = [], $level = 0) |
|
| 249 | - { |
|
| 250 | - |
|
| 251 | - // Сохраняем значение предыдущей страницы |
|
| 252 | - //static $stat_prevpages; |
|
| 253 | - |
|
| 254 | - if ($key > 0) { |
|
| 255 | - |
|
| 256 | - // ID страницы |
|
| 257 | - $pageid = $this->tree[$key]['obj']->getVar('pageid'); |
|
| 258 | - // Название страницы |
|
| 259 | - $pagetitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 260 | - // Тип страницы |
|
| 261 | - $pagetype = $this->tree[$key]['obj']->getVar('type'); |
|
| 262 | - |
|
| 263 | - // Дочернии категории |
|
| 264 | - $page_childs = $this->getAllChild($pageid); |
|
| 265 | - // Число дочерних страниц |
|
| 266 | - $num_childs = count($page_childs); |
|
| 267 | - |
|
| 268 | - // Генерируем класс |
|
| 269 | - // InstrTreeNode InstrTreeIsRoot InstrTreeExpandClosed InstrTreeIsLast |
|
| 270 | - $class = []; |
|
| 271 | - // Данный класс должен быть у любого узла |
|
| 272 | - $class[] = 'InstrTreeNode'; |
|
| 273 | - // Если узел нулевого уровня, добавляем InstrTreeIsRoot |
|
| 274 | - if (0 === $level) { |
|
| 275 | - $class[] = 'InstrTreeIsRoot'; |
|
| 276 | - } |
|
| 277 | - // Тип узла InstrTreeExpandClosed|InstrTreeExpandLeaf |
|
| 278 | - // Если у узла нет потомков - InstrTreeExpandLeaf |
|
| 279 | - if (0 == $num_childs) { |
|
| 280 | - $class[] = 'InstrTreeExpandLeaf'; |
|
| 281 | - // Если у искомого элемента есть потомки - открываем список |
|
| 282 | - } elseif ($currpageid == $pageid) { |
|
| 283 | - $class[] = 'InstrTreeExpandOpen'; |
|
| 284 | - // Если искомый элемент есть в потомках текущего, то ставим класс InstrTreeExpandOpen |
|
| 285 | - } elseif (array_key_exists($currpageid, $page_childs)) { |
|
| 286 | - $class[] = 'InstrTreeExpandOpen'; |
|
| 287 | - // |
|
| 288 | - } else { |
|
| 289 | - $class[] = 'InstrTreeExpandClosed'; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - // Данный класс нужно добавлять последнему узлу в каждом уровне |
|
| 293 | - |
|
| 294 | - if (isset($lastpageids[$level]) && ($pageid == $lastpageids[$level])) { |
|
| 295 | - $class[] = 'InstrTreeIsLast'; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - //$class[] = 'InstrTreeIsLast'; |
|
| 299 | - |
|
| 300 | - // Test |
|
| 301 | - //$ret .= '<div id="' . $pageid . '">'; |
|
| 302 | - |
|
| 303 | - // Создаём запись |
|
| 304 | - $ret .= '<li class="' . implode(' ', $class) . '">'; |
|
| 305 | - // |
|
| 306 | - $ret .= '<div class="InstrTreeExpand"></div>'; |
|
| 307 | - // |
|
| 308 | - $ret .= '<div class="InstrTreeContent">'; |
|
| 309 | - |
|
| 310 | - // Если это лист дерева |
|
| 311 | - if (0 == $pagetype) { |
|
| 312 | - $ret .= '<span class="InstrTreeEmptyPage">' . $pagetitle . '</span>'; |
|
| 313 | - // |
|
| 314 | - } elseif ($currpageid == $pageid) { |
|
| 315 | - $ret .= $pagetitle; |
|
| 316 | - // |
|
| 317 | - } else { |
|
| 318 | - $ret .= '<a href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/page.php?id=' . $pageid . '#pagetext">' . $pagetitle . '</a>'; |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - $ret .= '</div>'; |
|
| 322 | - |
|
| 323 | - // Если есть потомки |
|
| 324 | - if ($num_childs > 0) { |
|
| 325 | - $ret .= '<ul class="InstrTreeContainer">'; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - // Инкримент уровня |
|
| 329 | - $level++; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - // Рекурсия |
|
| 333 | - if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 334 | - foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 335 | - $this->_makePagesUserTree($childkey, $ret, $currpageid, $lastpageids, $level); |
|
| 336 | - } |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - // Test |
|
| 340 | - if ($key > 0) { |
|
| 341 | - // Если есть потомки |
|
| 342 | - if ($num_childs > 0) { |
|
| 343 | - $ret .= '</ul>'; |
|
| 344 | - } |
|
| 345 | - // Конец текущей записи |
|
| 346 | - $ret .= '</li>'; |
|
| 347 | - } |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - // Находим предыдущую и следующую страницы. |
|
| 351 | - // Находим последнии страницы на каждом уровне. |
|
| 352 | - /** |
|
| 353 | - * @param $key |
|
| 354 | - * @param int $currpageid |
|
| 355 | - * @param array $prevpages |
|
| 356 | - * @param array $nextpages |
|
| 357 | - * @param array $lastpageids |
|
| 358 | - * @param int $level |
|
| 359 | - */ |
|
| 360 | - public function _makePagesUserCalc($key, $currpageid = 0, &$prevpages = [], &$nextpages = [], &$lastpageids = [], $level = 0) |
|
| 361 | - { |
|
| 362 | - |
|
| 363 | - // Сохраняем значение предыдущей страницы |
|
| 364 | - static $stat_prevpages; |
|
| 365 | - |
|
| 366 | - if ($key > 0) { |
|
| 367 | - // ID страницы |
|
| 368 | - $pageid = $this->tree[$key]['obj']->getVar('pageid'); |
|
| 369 | - // Название страницы |
|
| 370 | - $pagetitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 371 | - // Тип страницы |
|
| 372 | - $pagetype = $this->tree[$key]['obj']->getVar('type'); |
|
| 373 | - |
|
| 374 | - // Если мы передали ID текущей страницы, то находить предыдудую и следующую страницы |
|
| 375 | - // Не находить предыдущие и следующие для "Пустой страницы" |
|
| 376 | - if ($currpageid && $pagetype) { |
|
| 377 | - // Если элемент равен текущей странице |
|
| 378 | - if (isset($stat_prevpages) && ($currpageid == $pageid)) { |
|
| 379 | - // Забиваем массив предыдущей страницы |
|
| 380 | - $prevpages['pageid'] = $stat_prevpages['pageid']; |
|
| 381 | - $prevpages['title'] = $stat_prevpages['title']; |
|
| 382 | - |
|
| 383 | - // Если предыдущий равен текущей странице |
|
| 384 | - } elseif (isset($stat_prevpages) && ($currpageid == $stat_prevpages['pageid'])) { |
|
| 385 | - // Забиваем массив следующей страницы |
|
| 386 | - $nextpages['pageid'] = $pageid; |
|
| 387 | - $nextpages['title'] = $pagetitle; |
|
| 388 | - } |
|
| 389 | - // Заносим текущие данные в массив предыдущей страницы |
|
| 390 | - $stat_prevpages['pageid'] = $pageid; |
|
| 391 | - $stat_prevpages['title'] = $pagetitle; |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - // Заносим текущую страницу в массив "последних страний" |
|
| 395 | - $lastpageids[$level] = $pageid; |
|
| 396 | - |
|
| 397 | - // Инкримент уровня |
|
| 398 | - $level++; |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - // Рекурсия |
|
| 402 | - if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 403 | - foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 404 | - $this->_makePagesUserCalc($childkey, $currpageid, $prevpages, $nextpages, $lastpageids, $level); |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - // |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * @param int $currpageid |
|
| 413 | - * @param array $prevpages |
|
| 414 | - * @param array $nextpages |
|
| 415 | - * @param int $key |
|
| 416 | - * @return string |
|
| 417 | - */ |
|
| 418 | - public function makePagesUser($currpageid = 0, &$prevpages = [], &$nextpages = [], $key = 0) |
|
| 419 | - { |
|
| 420 | - |
|
| 421 | - // Массив последней страницы на каждом уровне |
|
| 422 | - // level => pageid |
|
| 423 | - $lastpageids = []; |
|
| 424 | - |
|
| 425 | - // Расчёт |
|
| 426 | - $this->_makePagesUserCalc($key, $currpageid, $prevpages, $nextpages, $lastpageids); |
|
| 427 | - |
|
| 428 | - $ret = '<div onclick="instr_tree_toggle(arguments[0])"> |
|
| 229 | + // Выводим все страницы |
|
| 230 | + $this->_makeCatsAdminOptions($key, $ret, $prefix, $cidinstrids); |
|
| 231 | + |
|
| 232 | + $ret .= '</table>'; |
|
| 233 | + |
|
| 234 | + return $ret; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + // ====================================== |
|
| 238 | + // Список страниц на стороне пользователя |
|
| 239 | + // ====================================== |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * @param $key |
|
| 243 | + * @param $ret |
|
| 244 | + * @param int $currpageid |
|
| 245 | + * @param array $lastpageids |
|
| 246 | + * @param int $level |
|
| 247 | + */ |
|
| 248 | + public function _makePagesUserTree($key, &$ret, $currpageid = 0, &$lastpageids = [], $level = 0) |
|
| 249 | + { |
|
| 250 | + |
|
| 251 | + // Сохраняем значение предыдущей страницы |
|
| 252 | + //static $stat_prevpages; |
|
| 253 | + |
|
| 254 | + if ($key > 0) { |
|
| 255 | + |
|
| 256 | + // ID страницы |
|
| 257 | + $pageid = $this->tree[$key]['obj']->getVar('pageid'); |
|
| 258 | + // Название страницы |
|
| 259 | + $pagetitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 260 | + // Тип страницы |
|
| 261 | + $pagetype = $this->tree[$key]['obj']->getVar('type'); |
|
| 262 | + |
|
| 263 | + // Дочернии категории |
|
| 264 | + $page_childs = $this->getAllChild($pageid); |
|
| 265 | + // Число дочерних страниц |
|
| 266 | + $num_childs = count($page_childs); |
|
| 267 | + |
|
| 268 | + // Генерируем класс |
|
| 269 | + // InstrTreeNode InstrTreeIsRoot InstrTreeExpandClosed InstrTreeIsLast |
|
| 270 | + $class = []; |
|
| 271 | + // Данный класс должен быть у любого узла |
|
| 272 | + $class[] = 'InstrTreeNode'; |
|
| 273 | + // Если узел нулевого уровня, добавляем InstrTreeIsRoot |
|
| 274 | + if (0 === $level) { |
|
| 275 | + $class[] = 'InstrTreeIsRoot'; |
|
| 276 | + } |
|
| 277 | + // Тип узла InstrTreeExpandClosed|InstrTreeExpandLeaf |
|
| 278 | + // Если у узла нет потомков - InstrTreeExpandLeaf |
|
| 279 | + if (0 == $num_childs) { |
|
| 280 | + $class[] = 'InstrTreeExpandLeaf'; |
|
| 281 | + // Если у искомого элемента есть потомки - открываем список |
|
| 282 | + } elseif ($currpageid == $pageid) { |
|
| 283 | + $class[] = 'InstrTreeExpandOpen'; |
|
| 284 | + // Если искомый элемент есть в потомках текущего, то ставим класс InstrTreeExpandOpen |
|
| 285 | + } elseif (array_key_exists($currpageid, $page_childs)) { |
|
| 286 | + $class[] = 'InstrTreeExpandOpen'; |
|
| 287 | + // |
|
| 288 | + } else { |
|
| 289 | + $class[] = 'InstrTreeExpandClosed'; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + // Данный класс нужно добавлять последнему узлу в каждом уровне |
|
| 293 | + |
|
| 294 | + if (isset($lastpageids[$level]) && ($pageid == $lastpageids[$level])) { |
|
| 295 | + $class[] = 'InstrTreeIsLast'; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + //$class[] = 'InstrTreeIsLast'; |
|
| 299 | + |
|
| 300 | + // Test |
|
| 301 | + //$ret .= '<div id="' . $pageid . '">'; |
|
| 302 | + |
|
| 303 | + // Создаём запись |
|
| 304 | + $ret .= '<li class="' . implode(' ', $class) . '">'; |
|
| 305 | + // |
|
| 306 | + $ret .= '<div class="InstrTreeExpand"></div>'; |
|
| 307 | + // |
|
| 308 | + $ret .= '<div class="InstrTreeContent">'; |
|
| 309 | + |
|
| 310 | + // Если это лист дерева |
|
| 311 | + if (0 == $pagetype) { |
|
| 312 | + $ret .= '<span class="InstrTreeEmptyPage">' . $pagetitle . '</span>'; |
|
| 313 | + // |
|
| 314 | + } elseif ($currpageid == $pageid) { |
|
| 315 | + $ret .= $pagetitle; |
|
| 316 | + // |
|
| 317 | + } else { |
|
| 318 | + $ret .= '<a href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/page.php?id=' . $pageid . '#pagetext">' . $pagetitle . '</a>'; |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + $ret .= '</div>'; |
|
| 322 | + |
|
| 323 | + // Если есть потомки |
|
| 324 | + if ($num_childs > 0) { |
|
| 325 | + $ret .= '<ul class="InstrTreeContainer">'; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + // Инкримент уровня |
|
| 329 | + $level++; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + // Рекурсия |
|
| 333 | + if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 334 | + foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 335 | + $this->_makePagesUserTree($childkey, $ret, $currpageid, $lastpageids, $level); |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + // Test |
|
| 340 | + if ($key > 0) { |
|
| 341 | + // Если есть потомки |
|
| 342 | + if ($num_childs > 0) { |
|
| 343 | + $ret .= '</ul>'; |
|
| 344 | + } |
|
| 345 | + // Конец текущей записи |
|
| 346 | + $ret .= '</li>'; |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + // Находим предыдущую и следующую страницы. |
|
| 351 | + // Находим последнии страницы на каждом уровне. |
|
| 352 | + /** |
|
| 353 | + * @param $key |
|
| 354 | + * @param int $currpageid |
|
| 355 | + * @param array $prevpages |
|
| 356 | + * @param array $nextpages |
|
| 357 | + * @param array $lastpageids |
|
| 358 | + * @param int $level |
|
| 359 | + */ |
|
| 360 | + public function _makePagesUserCalc($key, $currpageid = 0, &$prevpages = [], &$nextpages = [], &$lastpageids = [], $level = 0) |
|
| 361 | + { |
|
| 362 | + |
|
| 363 | + // Сохраняем значение предыдущей страницы |
|
| 364 | + static $stat_prevpages; |
|
| 365 | + |
|
| 366 | + if ($key > 0) { |
|
| 367 | + // ID страницы |
|
| 368 | + $pageid = $this->tree[$key]['obj']->getVar('pageid'); |
|
| 369 | + // Название страницы |
|
| 370 | + $pagetitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 371 | + // Тип страницы |
|
| 372 | + $pagetype = $this->tree[$key]['obj']->getVar('type'); |
|
| 373 | + |
|
| 374 | + // Если мы передали ID текущей страницы, то находить предыдудую и следующую страницы |
|
| 375 | + // Не находить предыдущие и следующие для "Пустой страницы" |
|
| 376 | + if ($currpageid && $pagetype) { |
|
| 377 | + // Если элемент равен текущей странице |
|
| 378 | + if (isset($stat_prevpages) && ($currpageid == $pageid)) { |
|
| 379 | + // Забиваем массив предыдущей страницы |
|
| 380 | + $prevpages['pageid'] = $stat_prevpages['pageid']; |
|
| 381 | + $prevpages['title'] = $stat_prevpages['title']; |
|
| 382 | + |
|
| 383 | + // Если предыдущий равен текущей странице |
|
| 384 | + } elseif (isset($stat_prevpages) && ($currpageid == $stat_prevpages['pageid'])) { |
|
| 385 | + // Забиваем массив следующей страницы |
|
| 386 | + $nextpages['pageid'] = $pageid; |
|
| 387 | + $nextpages['title'] = $pagetitle; |
|
| 388 | + } |
|
| 389 | + // Заносим текущие данные в массив предыдущей страницы |
|
| 390 | + $stat_prevpages['pageid'] = $pageid; |
|
| 391 | + $stat_prevpages['title'] = $pagetitle; |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + // Заносим текущую страницу в массив "последних страний" |
|
| 395 | + $lastpageids[$level] = $pageid; |
|
| 396 | + |
|
| 397 | + // Инкримент уровня |
|
| 398 | + $level++; |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + // Рекурсия |
|
| 402 | + if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 403 | + foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 404 | + $this->_makePagesUserCalc($childkey, $currpageid, $prevpages, $nextpages, $lastpageids, $level); |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + // |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * @param int $currpageid |
|
| 413 | + * @param array $prevpages |
|
| 414 | + * @param array $nextpages |
|
| 415 | + * @param int $key |
|
| 416 | + * @return string |
|
| 417 | + */ |
|
| 418 | + public function makePagesUser($currpageid = 0, &$prevpages = [], &$nextpages = [], $key = 0) |
|
| 419 | + { |
|
| 420 | + |
|
| 421 | + // Массив последней страницы на каждом уровне |
|
| 422 | + // level => pageid |
|
| 423 | + $lastpageids = []; |
|
| 424 | + |
|
| 425 | + // Расчёт |
|
| 426 | + $this->_makePagesUserCalc($key, $currpageid, $prevpages, $nextpages, $lastpageids); |
|
| 427 | + |
|
| 428 | + $ret = '<div onclick="instr_tree_toggle(arguments[0])"> |
|
| 429 | 429 | <div>' . _MD_INSTRUCTION_LISTPAGES . '</div> |
| 430 | 430 | <div><ul class="InstrTreeContainer">'; |
| 431 | 431 | |
| 432 | - // Генерируем дерево |
|
| 433 | - $this->_makePagesUserTree($key, $ret, $currpageid, $lastpageids); |
|
| 432 | + // Генерируем дерево |
|
| 433 | + $this->_makePagesUserTree($key, $ret, $currpageid, $lastpageids); |
|
| 434 | 434 | |
| 435 | - $ret .= '</ul> |
|
| 435 | + $ret .= '</ul> |
|
| 436 | 436 | </div>'; |
| 437 | 437 | |
| 438 | - return $ret; |
|
| 439 | - } |
|
| 438 | + return $ret; |
|
| 439 | + } |
|
| 440 | 440 | } |
@@ -46,8 +46,8 @@ |
||
| 46 | 46 | // Редактор |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | - * @param $caption |
|
| 50 | - * @param $name |
|
| 49 | + * @param string $caption |
|
| 50 | + * @param string $name |
|
| 51 | 51 | * @param string $value |
| 52 | 52 | * @return bool|\XoopsFormEditor |
| 53 | 53 | */ |
@@ -1,6 +1,5 @@ |
||
| 1 | 1 | <?php namespace Xoopsmodules\instruction; |
| 2 | 2 | |
| 3 | -use Xmf\Request; |
|
| 4 | 3 | use Xoopsmodules\instruction\common; |
| 5 | 4 | |
| 6 | 5 | require_once __DIR__ . '/common/VersionChecks.php'; |
@@ -14,82 +14,82 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class Utility |
| 16 | 16 | { |
| 17 | - use common\VersionChecks; //checkVerXoops, checkVerPhp Traits |
|
| 17 | + use common\VersionChecks; //checkVerXoops, checkVerPhp Traits |
|
| 18 | 18 | |
| 19 | - use common\ServerStats; // getServerStats Trait |
|
| 19 | + use common\ServerStats; // getServerStats Trait |
|
| 20 | 20 | |
| 21 | - use common\FilesManagement; // Files Management Trait |
|
| 21 | + use common\FilesManagement; // Files Management Trait |
|
| 22 | 22 | |
| 23 | - // Права |
|
| 24 | - /** |
|
| 25 | - * @param string $permtype |
|
| 26 | - * @return mixed |
|
| 27 | - */ |
|
| 28 | - public static function getItemIds($permtype = 'instruction_view') |
|
| 29 | - { |
|
| 30 | - //global $xoopsUser; |
|
| 31 | - static $permissions = []; |
|
| 32 | - // Если есть в статике |
|
| 33 | - if (is_array($permissions) && array_key_exists($permtype, $permissions)) { |
|
| 34 | - return $permissions[$permtype]; |
|
| 35 | - } |
|
| 36 | - // Находим из базы |
|
| 37 | - $moduleHandler = xoops_getHandler('module'); |
|
| 38 | - $instrModule = $moduleHandler->getByDirname('instruction'); |
|
| 39 | - $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; |
|
| 40 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
| 41 | - $categories = $gpermHandler->getItemIds($permtype, $groups, $instrModule->getVar('mid')); |
|
| 42 | - $permissions[$permtype] = $categories; |
|
| 43 | - return $categories; |
|
| 44 | - } |
|
| 23 | + // Права |
|
| 24 | + /** |
|
| 25 | + * @param string $permtype |
|
| 26 | + * @return mixed |
|
| 27 | + */ |
|
| 28 | + public static function getItemIds($permtype = 'instruction_view') |
|
| 29 | + { |
|
| 30 | + //global $xoopsUser; |
|
| 31 | + static $permissions = []; |
|
| 32 | + // Если есть в статике |
|
| 33 | + if (is_array($permissions) && array_key_exists($permtype, $permissions)) { |
|
| 34 | + return $permissions[$permtype]; |
|
| 35 | + } |
|
| 36 | + // Находим из базы |
|
| 37 | + $moduleHandler = xoops_getHandler('module'); |
|
| 38 | + $instrModule = $moduleHandler->getByDirname('instruction'); |
|
| 39 | + $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; |
|
| 40 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
| 41 | + $categories = $gpermHandler->getItemIds($permtype, $groups, $instrModule->getVar('mid')); |
|
| 42 | + $permissions[$permtype] = $categories; |
|
| 43 | + return $categories; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - // Редактор |
|
| 46 | + // Редактор |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @param $caption |
|
| 50 | - * @param $name |
|
| 51 | - * @param string $value |
|
| 52 | - * @return bool|\XoopsFormEditor |
|
| 53 | - */ |
|
| 54 | - public static function getWysiwygForm($caption, $name, $value = '') |
|
| 55 | - { |
|
| 56 | - $editor = false; |
|
| 57 | - $editor_configs = []; |
|
| 58 | - $editor_configs['name'] = $name; |
|
| 59 | - $editor_configs['value'] = $value; |
|
| 60 | - $editor_configs['rows'] = 35; |
|
| 61 | - $editor_configs['cols'] = 60; |
|
| 62 | - $editor_configs['width'] = '100%'; |
|
| 63 | - $editor_configs['height'] = '350px'; |
|
| 64 | - $editor_configs['editor'] = strtolower(xoops_getModuleOption('form_options', 'instruction')); |
|
| 48 | + /** |
|
| 49 | + * @param $caption |
|
| 50 | + * @param $name |
|
| 51 | + * @param string $value |
|
| 52 | + * @return bool|\XoopsFormEditor |
|
| 53 | + */ |
|
| 54 | + public static function getWysiwygForm($caption, $name, $value = '') |
|
| 55 | + { |
|
| 56 | + $editor = false; |
|
| 57 | + $editor_configs = []; |
|
| 58 | + $editor_configs['name'] = $name; |
|
| 59 | + $editor_configs['value'] = $value; |
|
| 60 | + $editor_configs['rows'] = 35; |
|
| 61 | + $editor_configs['cols'] = 60; |
|
| 62 | + $editor_configs['width'] = '100%'; |
|
| 63 | + $editor_configs['height'] = '350px'; |
|
| 64 | + $editor_configs['editor'] = strtolower(xoops_getModuleOption('form_options', 'instruction')); |
|
| 65 | 65 | |
| 66 | - $editor = new \XoopsFormEditor($caption, $name, $editor_configs); |
|
| 67 | - return $editor; |
|
| 68 | - } |
|
| 66 | + $editor = new \XoopsFormEditor($caption, $name, $editor_configs); |
|
| 67 | + return $editor; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - // Получение значения переменной, переданной через GET или POST запрос |
|
| 70 | + // Получение значения переменной, переданной через GET или POST запрос |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @param $global |
|
| 74 | - * @param $key |
|
| 75 | - * @param string $default |
|
| 76 | - * @param string $type |
|
| 77 | - * @return int|string |
|
| 78 | - */ |
|
| 79 | - public static function cleanVars(&$global, $key, $default = '', $type = 'int') |
|
| 80 | - { |
|
| 81 | - switch ($type) { |
|
| 82 | - case 'string': |
|
| 83 | - $ret = isset($global[$key]) ? $global[$key] : $default; |
|
| 84 | - break; |
|
| 85 | - case 'int': |
|
| 86 | - default: |
|
| 87 | - $ret = isset($global[$key]) ? (int)$global[$key] : (int)$default; |
|
| 88 | - break; |
|
| 89 | - } |
|
| 90 | - if (false === $ret) { |
|
| 91 | - return $default; |
|
| 92 | - } |
|
| 93 | - return $ret; |
|
| 94 | - } |
|
| 72 | + /** |
|
| 73 | + * @param $global |
|
| 74 | + * @param $key |
|
| 75 | + * @param string $default |
|
| 76 | + * @param string $type |
|
| 77 | + * @return int|string |
|
| 78 | + */ |
|
| 79 | + public static function cleanVars(&$global, $key, $default = '', $type = 'int') |
|
| 80 | + { |
|
| 81 | + switch ($type) { |
|
| 82 | + case 'string': |
|
| 83 | + $ret = isset($global[$key]) ? $global[$key] : $default; |
|
| 84 | + break; |
|
| 85 | + case 'int': |
|
| 86 | + default: |
|
| 87 | + $ret = isset($global[$key]) ? (int)$global[$key] : (int)$default; |
|
| 88 | + break; |
|
| 89 | + } |
|
| 90 | + if (false === $ret) { |
|
| 91 | + return $default; |
|
| 92 | + } |
|
| 93 | + return $ret; |
|
| 94 | + } |
|
| 95 | 95 | } |
@@ -12,63 +12,63 @@ discard block |
||
| 12 | 12 | function b_instr_lastpage_show($options = []) |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - // Подключаем функции |
|
| 16 | - $moduleDirName = basename(dirname(__DIR__)); |
|
| 17 | - include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/class/utility.php'); |
|
| 18 | - // |
|
| 19 | - $myts = MyTextSanitizer::getInstance(); |
|
| 20 | - // |
|
| 21 | - //mb $instructionHandler = xoops_getModuleHandler('instruction', 'instruction'); |
|
| 22 | - //mb $pageHandler = xoops_getModuleHandler('page', 'instruction'); |
|
| 15 | + // Подключаем функции |
|
| 16 | + $moduleDirName = basename(dirname(__DIR__)); |
|
| 17 | + include_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/class/utility.php'); |
|
| 18 | + // |
|
| 19 | + $myts = MyTextSanitizer::getInstance(); |
|
| 20 | + // |
|
| 21 | + //mb $instructionHandler = xoops_getModuleHandler('instruction', 'instruction'); |
|
| 22 | + //mb $pageHandler = xoops_getModuleHandler('page', 'instruction'); |
|
| 23 | 23 | |
| 24 | - $db = \XoopsDatabaseFactory::getDatabase(); |
|
| 25 | - $instructionHandler = new \Xoopsmodules\instruction\InstructionHandler($db); |
|
| 26 | - $pageHandler = new \Xoopsmodules\instruction\PageHandler($db); |
|
| 24 | + $db = \XoopsDatabaseFactory::getDatabase(); |
|
| 25 | + $instructionHandler = new \Xoopsmodules\instruction\InstructionHandler($db); |
|
| 26 | + $pageHandler = new \Xoopsmodules\instruction\PageHandler($db); |
|
| 27 | 27 | |
| 28 | - // Добавляем стили |
|
| 29 | - //global $xoTheme; |
|
| 30 | - //$xoTheme->addStylesheet( XOOPS_URL . '/modules/instruction/css/blocks.css' ); |
|
| 28 | + // Добавляем стили |
|
| 29 | + //global $xoTheme; |
|
| 30 | + //$xoTheme->addStylesheet( XOOPS_URL . '/modules/instruction/css/blocks.css' ); |
|
| 31 | 31 | |
| 32 | - // Опции |
|
| 33 | - // Количество страниц |
|
| 34 | - $limit = $options[0]; |
|
| 35 | - // Количество символов |
|
| 36 | - $numchars = $options[1]; |
|
| 32 | + // Опции |
|
| 33 | + // Количество страниц |
|
| 34 | + $limit = $options[0]; |
|
| 35 | + // Количество символов |
|
| 36 | + $numchars = $options[1]; |
|
| 37 | 37 | |
| 38 | - // Права на просмотр |
|
| 39 | - $cat_view = Xoopsmodules\instruction\Utility::getItemIds(); |
|
| 40 | - // Массив выходных данных |
|
| 41 | - $block = []; |
|
| 38 | + // Права на просмотр |
|
| 39 | + $cat_view = Xoopsmodules\instruction\Utility::getItemIds(); |
|
| 40 | + // Массив выходных данных |
|
| 41 | + $block = []; |
|
| 42 | 42 | |
| 43 | - // Если есть категории для прасмотра |
|
| 44 | - if (is_array($cat_view) && count($cat_view) > 0) { |
|
| 43 | + // Если есть категории для прасмотра |
|
| 44 | + if (is_array($cat_view) && count($cat_view) > 0) { |
|
| 45 | 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 | - } |
|
| 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 | 69 | |
| 70 | - // Возвращаем массив |
|
| 71 | - return $block; |
|
| 70 | + // Возвращаем массив |
|
| 71 | + return $block; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Редактирование последних страниц |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | function b_instr_lastpage_edit($options = []) |
| 80 | 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"; |
|
| 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 | 84 | |
| 85 | - // Возвращаем форму |
|
| 86 | - return $form; |
|
| 85 | + // Возвращаем форму |
|
| 86 | + return $form; |
|
| 87 | 87 | } |
@@ -13,59 +13,59 @@ discard block |
||
| 13 | 13 | function b_instr_lastinstr_show($options = []) |
| 14 | 14 | { |
| 15 | 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); |
|
| 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 | 27 | |
| 28 | - // Добавляем стили |
|
| 29 | - //global $xoTheme; |
|
| 30 | - //$xoTheme->addStylesheet( XOOPS_URL . '/modules/instruction/css/blocks.css' ); |
|
| 28 | + // Добавляем стили |
|
| 29 | + //global $xoTheme; |
|
| 30 | + //$xoTheme->addStylesheet( XOOPS_URL . '/modules/instruction/css/blocks.css' ); |
|
| 31 | 31 | |
| 32 | - // Опции |
|
| 33 | - // Количество страниц |
|
| 34 | - $limit = $options[0]; |
|
| 35 | - // Количество символов |
|
| 36 | - $numchars = $options[1]; |
|
| 32 | + // Опции |
|
| 33 | + // Количество страниц |
|
| 34 | + $limit = $options[0]; |
|
| 35 | + // Количество символов |
|
| 36 | + $numchars = $options[1]; |
|
| 37 | 37 | |
| 38 | - // Права на просмотр |
|
| 39 | - $cat_view = Xoopsmodules\instruction\Utility::getItemIds(); |
|
| 40 | - // Массив выходных данных |
|
| 41 | - $block = []; |
|
| 38 | + // Права на просмотр |
|
| 39 | + $cat_view = Xoopsmodules\instruction\Utility::getItemIds(); |
|
| 40 | + // Массив выходных данных |
|
| 41 | + $block = []; |
|
| 42 | 42 | |
| 43 | - // Если есть категории для прасмотра |
|
| 44 | - if (is_array($cat_view) && count($cat_view) > 0) { |
|
| 43 | + // Если есть категории для прасмотра |
|
| 44 | + if (is_array($cat_view) && count($cat_view) > 0) { |
|
| 45 | 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; |
|
| 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 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // Редактирование последних инструкций |
@@ -75,10 +75,10 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | function b_instr_lastinstr_edit($options = []) |
| 77 | 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"; |
|
| 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 | 81 | |
| 82 | - // Возвращаем форму |
|
| 83 | - return $form; |
|
| 82 | + // Возвращаем форму |
|
| 83 | + return $form; |
|
| 84 | 84 | } |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | $criteria->add(new \Criteria('instrid', $instrid)); |
| 20 | 20 | $criteria->add(new \Criteria('status ', '0', '>')); |
| 21 | 21 | if (0 == $instructionHandler->getCount($criteria)) { |
| 22 | - redirect_header('index.php', 3, _MD_INSTRUCTION_INSTRNOTEXIST); |
|
| 23 | - exit(); |
|
| 22 | + redirect_header('index.php', 3, _MD_INSTRUCTION_INSTRNOTEXIST); |
|
| 23 | + exit(); |
|
| 24 | 24 | } |
| 25 | 25 | // |
| 26 | 26 | unset($criteria); |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | // Права на просмотр инструкции |
| 43 | 43 | $categories = Xoopsmodules\instruction\Utility::getItemIds(); |
| 44 | 44 | if (!in_array($objInsinstr->getVar('cid'), $categories)) { |
| 45 | - redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM); |
|
| 46 | - exit(); |
|
| 45 | + redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM); |
|
| 46 | + exit(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // Массив данных об инструкции |
@@ -56,29 +56,29 @@ discard block |
||
| 56 | 56 | $instrs['description'] = $objInsinstr->getVar('description'); |
| 57 | 57 | // Если админ, рисуем админлинк |
| 58 | 58 | if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid())) { |
| 59 | - $instrs['adminlink'] = ' <a href="' |
|
| 60 | - . XOOPS_URL |
|
| 61 | - . '/modules/' |
|
| 62 | - . $moduleDirName |
|
| 63 | - . '/admin/instr.php?op=editinstr&instrid=' |
|
| 64 | - . $instrid |
|
| 65 | - . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' |
|
| 66 | - . _EDIT |
|
| 67 | - . ' title=' |
|
| 68 | - . _EDIT |
|
| 69 | - . '></a> <a href="' |
|
| 70 | - . XOOPS_URL |
|
| 71 | - . '/modules/' |
|
| 72 | - . $moduleDirName |
|
| 73 | - . '/admin/instr.php?op=delinstr&instrid=' |
|
| 74 | - . $instrid |
|
| 75 | - . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt=' |
|
| 76 | - . _DELETE |
|
| 77 | - . ' title=' |
|
| 78 | - . _DELETE |
|
| 79 | - . '></a> '; |
|
| 59 | + $instrs['adminlink'] = ' <a href="' |
|
| 60 | + . XOOPS_URL |
|
| 61 | + . '/modules/' |
|
| 62 | + . $moduleDirName |
|
| 63 | + . '/admin/instr.php?op=editinstr&instrid=' |
|
| 64 | + . $instrid |
|
| 65 | + . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' |
|
| 66 | + . _EDIT |
|
| 67 | + . ' title=' |
|
| 68 | + . _EDIT |
|
| 69 | + . '></a> <a href="' |
|
| 70 | + . XOOPS_URL |
|
| 71 | + . '/modules/' |
|
| 72 | + . $moduleDirName |
|
| 73 | + . '/admin/instr.php?op=delinstr&instrid=' |
|
| 74 | + . $instrid |
|
| 75 | + . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt=' |
|
| 76 | + . _DELETE |
|
| 77 | + . ' title=' |
|
| 78 | + . _DELETE |
|
| 79 | + . '></a> '; |
|
| 80 | 80 | } else { |
| 81 | - $instrs['adminlink'] = ''; |
|
| 81 | + $instrs['adminlink'] = ''; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // Выводим в шаблон |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $nav_parent_id = array_reverse($nav_parent_id); |
| 103 | 103 | $navigation = '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/">' . $GLOBALS['xoopsModule']->name() . '</a> : '; |
| 104 | 104 | foreach (array_keys($nav_parent_id) as $i) { |
| 105 | - $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $nav_parent_id[$i]->getVar('cid') . '">' . $nav_parent_id[$i]->getVar('title') . '</a> : '; |
|
| 105 | + $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $nav_parent_id[$i]->getVar('cid') . '">' . $nav_parent_id[$i]->getVar('title') . '</a> : '; |
|
| 106 | 106 | } |
| 107 | 107 | $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $objInscat->getVar('cid') . '">' . $objInscat->getVar('title') . '</a> : '; |
| 108 | 108 | $navigation .= $objInsinstr->getVar('title'); |
@@ -129,18 +129,18 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | // Теги |
| 131 | 131 | if (xoops_getModuleOption('usetag', 'instruction')) { |
| 132 | - include_once $GLOBALS['xoops']->path('modules/tag/include/tagbar.php'); |
|
| 133 | - $xoopsTpl->assign('tags', true); |
|
| 134 | - $xoopsTpl->assign('tagbar', tagBar($instrid, 0)); |
|
| 132 | + include_once $GLOBALS['xoops']->path('modules/tag/include/tagbar.php'); |
|
| 133 | + $xoopsTpl->assign('tags', true); |
|
| 134 | + $xoopsTpl->assign('tagbar', tagBar($instrid, 0)); |
|
| 135 | 135 | } else { |
| 136 | - $xoopsTpl->assign('tags', false); |
|
| 136 | + $xoopsTpl->assign('tags', false); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Рейтинг |
| 140 | 140 | if (xoops_getModuleOption('userat', 'instruction')) { |
| 141 | - $xoopsTpl->assign('insUserat', true); |
|
| 141 | + $xoopsTpl->assign('insUserat', true); |
|
| 142 | 142 | } else { |
| 143 | - $xoopsTpl->assign('insUserat', false); |
|
| 143 | + $xoopsTpl->assign('insUserat', false); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Подвал |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | //$categoryHandler = xoops_getModuleHandler('category', 'instruction'); |
| 13 | 13 | //$pageHandler = xoops_getModuleHandler('page', 'instruction'); |
| 14 | 14 | |
| 15 | -$instrid = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
| 15 | +$instrid = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
| 16 | 16 | |
| 17 | 17 | // Существует ли такая инструкция |
| 18 | 18 | $criteria = new \CriteriaCompo(); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | // Права на просмотр инструкции |
| 43 | 43 | $categories = Xoopsmodules\instruction\Utility::getItemIds(); |
| 44 | -if (!in_array($objInsinstr->getVar('cid'), $categories)) { |
|
| 44 | +if ( ! in_array($objInsinstr->getVar('cid'), $categories)) { |
|
| 45 | 45 | redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM); |
| 46 | 46 | exit(); |
| 47 | 47 | } |
@@ -10,60 +10,60 @@ discard block |
||
| 10 | 10 | $xoops_url = parse_url(XOOPS_URL); |
| 11 | 11 | |
| 12 | 12 | $modversion = [ |
| 13 | - 'version' => 1.07, |
|
| 14 | - 'module_status' => 'RC1', |
|
| 15 | - 'release_date' => '2017/10/04', |
|
| 16 | - 'name' => _MI_INSTRUCTION_NAME, |
|
| 17 | - 'description' => _MI_INSTRUCTION_DESC, |
|
| 18 | - 'credits' => 'radio-hobby.org, www.shmel.org', |
|
| 19 | - 'author' => 'andrey3761, Mamba, Aerograf', |
|
| 20 | - 'nickname' => '', |
|
| 21 | - 'help' => 'page=help', |
|
| 22 | - 'license' => 'GNU GPL 2.0', |
|
| 23 | - 'license_url' => 'www.gnu.org/licenses/gpl-2.0.html/', |
|
| 24 | - 'official' => 0, |
|
| 25 | - 'image' => 'assets/images/logoModule.png', |
|
| 26 | - 'dirname' => $moduleDirName, |
|
| 27 | - 'modicons16' => 'assets/images/icons/16', |
|
| 28 | - 'modicons32' => 'assets/images/icons/32', |
|
| 29 | - // О модуле |
|
| 30 | - 'module_website_url' => 'radio-hobby.org', |
|
| 31 | - 'module_website_name' => 'radio-hobby.org', |
|
| 13 | + 'version' => 1.07, |
|
| 14 | + 'module_status' => 'RC1', |
|
| 15 | + 'release_date' => '2017/10/04', |
|
| 16 | + 'name' => _MI_INSTRUCTION_NAME, |
|
| 17 | + 'description' => _MI_INSTRUCTION_DESC, |
|
| 18 | + 'credits' => 'radio-hobby.org, www.shmel.org', |
|
| 19 | + 'author' => 'andrey3761, Mamba, Aerograf', |
|
| 20 | + 'nickname' => '', |
|
| 21 | + 'help' => 'page=help', |
|
| 22 | + 'license' => 'GNU GPL 2.0', |
|
| 23 | + 'license_url' => 'www.gnu.org/licenses/gpl-2.0.html/', |
|
| 24 | + 'official' => 0, |
|
| 25 | + 'image' => 'assets/images/logoModule.png', |
|
| 26 | + 'dirname' => $moduleDirName, |
|
| 27 | + 'modicons16' => 'assets/images/icons/16', |
|
| 28 | + 'modicons32' => 'assets/images/icons/32', |
|
| 29 | + // О модуле |
|
| 30 | + 'module_website_url' => 'radio-hobby.org', |
|
| 31 | + 'module_website_name' => 'radio-hobby.org', |
|
| 32 | 32 | |
| 33 | - 'author_website_url' => 'radio-hobby.org', |
|
| 34 | - 'author_website_name' => 'andrey3761', |
|
| 35 | - 'min_php' => '5.5', |
|
| 36 | - 'min_xoops' => '2.5.8', |
|
| 37 | - 'min_admin' => '1.1', |
|
| 38 | - 'min_db' => ['mysql' => '5.5'], |
|
| 39 | - // Файл базы данных |
|
| 40 | - 'sqlfile' => ['mysql' => 'sql/mysql.sql'], |
|
| 41 | - // Таблицы |
|
| 42 | - 'tables' => [ |
|
| 43 | - $moduleDirName . '_cat', |
|
| 44 | - $moduleDirName . '_instr', |
|
| 45 | - $moduleDirName . '_page' |
|
| 46 | - ], |
|
| 47 | - // Имеет админку |
|
| 48 | - 'hasAdmin' => 1, |
|
| 49 | - 'adminindex' => 'admin/index.php', |
|
| 50 | - 'adminmenu' => 'admin/menu.php', |
|
| 51 | - 'system_menu' => 1, |
|
| 52 | - // Меню |
|
| 53 | - 'hasMain' => 1, |
|
| 54 | - // Search |
|
| 55 | - 'hasSearch' => 1, |
|
| 56 | - 'search' => [ |
|
| 57 | - 'file' => 'include/search.inc.php', |
|
| 58 | - 'func' => $moduleDirName . '_search', |
|
| 59 | - ], |
|
| 33 | + 'author_website_url' => 'radio-hobby.org', |
|
| 34 | + 'author_website_name' => 'andrey3761', |
|
| 35 | + 'min_php' => '5.5', |
|
| 36 | + 'min_xoops' => '2.5.8', |
|
| 37 | + 'min_admin' => '1.1', |
|
| 38 | + 'min_db' => ['mysql' => '5.5'], |
|
| 39 | + // Файл базы данных |
|
| 40 | + 'sqlfile' => ['mysql' => 'sql/mysql.sql'], |
|
| 41 | + // Таблицы |
|
| 42 | + 'tables' => [ |
|
| 43 | + $moduleDirName . '_cat', |
|
| 44 | + $moduleDirName . '_instr', |
|
| 45 | + $moduleDirName . '_page' |
|
| 46 | + ], |
|
| 47 | + // Имеет админку |
|
| 48 | + 'hasAdmin' => 1, |
|
| 49 | + 'adminindex' => 'admin/index.php', |
|
| 50 | + 'adminmenu' => 'admin/menu.php', |
|
| 51 | + 'system_menu' => 1, |
|
| 52 | + // Меню |
|
| 53 | + 'hasMain' => 1, |
|
| 54 | + // Search |
|
| 55 | + 'hasSearch' => 1, |
|
| 56 | + 'search' => [ |
|
| 57 | + 'file' => 'include/search.inc.php', |
|
| 58 | + 'func' => $moduleDirName . '_search', |
|
| 59 | + ], |
|
| 60 | 60 | ]; |
| 61 | 61 | // Help files |
| 62 | 62 | $modversion['helpsection'] = [ |
| 63 | - ['name' => _MI_INSTRUCTION_HELP_OVERVIEW, 'link' => 'page=help'], |
|
| 64 | - ['name' => _MI_INSTRUCTION_DISCLAIMER, 'link' => 'page=disclaimer'], |
|
| 65 | - ['name' => _MI_INSTRUCTION_LICENSE, 'link' => 'page=license'], |
|
| 66 | - ['name' => _MI_INSTRUCTION_SUPPORT, 'link' => 'page=support'], |
|
| 63 | + ['name' => _MI_INSTRUCTION_HELP_OVERVIEW, 'link' => 'page=help'], |
|
| 64 | + ['name' => _MI_INSTRUCTION_DISCLAIMER, 'link' => 'page=disclaimer'], |
|
| 65 | + ['name' => _MI_INSTRUCTION_LICENSE, 'link' => 'page=license'], |
|
| 66 | + ['name' => _MI_INSTRUCTION_SUPPORT, 'link' => 'page=support'], |
|
| 67 | 67 | ]; |
| 68 | 68 | |
| 69 | 69 | // Comments |
@@ -76,144 +76,144 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | // Templates |
| 78 | 78 | $modversion['templates'] = [ |
| 79 | - [ |
|
| 80 | - 'file' => 'admin/' . $moduleDirName . '_admin_index.tpl', |
|
| 81 | - 'description' => '' |
|
| 82 | - ], |
|
| 83 | - [ |
|
| 84 | - 'file' => 'admin/' . $moduleDirName . '_admin_cat.tpl', |
|
| 85 | - 'description' => '' |
|
| 86 | - ], |
|
| 87 | - [ |
|
| 88 | - 'file' => 'admin/' . $moduleDirName . '_admin_editcat.tpl', |
|
| 89 | - 'description' => '' |
|
| 90 | - ], |
|
| 91 | - [ |
|
| 92 | - 'file' => 'admin/' . $moduleDirName . '_admin_savecat.tpl', |
|
| 93 | - 'description' => '' |
|
| 94 | - ], |
|
| 95 | - [ |
|
| 96 | - 'file' => 'admin/' . $moduleDirName . '_admin_viewcat.tpl', |
|
| 97 | - 'description' => '' |
|
| 98 | - ], |
|
| 99 | - [ |
|
| 100 | - 'file' => 'admin/' . $moduleDirName . '_admin_instr.tpl', |
|
| 101 | - 'description' => '' |
|
| 102 | - ], |
|
| 103 | - [ |
|
| 104 | - 'file' => 'admin/' . $moduleDirName . '_admin_editinstr.tpl', |
|
| 105 | - 'description' => '' |
|
| 106 | - ], |
|
| 107 | - [ |
|
| 108 | - 'file' => 'admin/' . $moduleDirName . '_admin_saveinstr.tpl', |
|
| 109 | - 'description' => '' |
|
| 110 | - ], |
|
| 111 | - [ |
|
| 112 | - 'file' => 'admin/' . $moduleDirName . '_admin_viewinstr.tpl', |
|
| 113 | - 'description' => '' |
|
| 114 | - ], |
|
| 115 | - [ |
|
| 116 | - 'file' => 'admin/' . $moduleDirName . '_admin_editpage.tpl', |
|
| 117 | - 'description' => '' |
|
| 118 | - ], |
|
| 119 | - [ |
|
| 120 | - 'file' => 'admin/' . $moduleDirName . '_admin_savepage.tpl', |
|
| 121 | - 'description' => '' |
|
| 122 | - ], |
|
| 123 | - [ |
|
| 124 | - 'file' => 'admin/' . $moduleDirName . '_admin_perm.tpl', |
|
| 125 | - 'description' => '' |
|
| 126 | - ], |
|
| 127 | - [ |
|
| 128 | - 'file' => 'admin/' . $moduleDirName . '_admin_about.tpl', |
|
| 129 | - 'description' => '' |
|
| 130 | - ], |
|
| 131 | - [ |
|
| 132 | - 'file' => $moduleDirName . '_page.tpl', |
|
| 133 | - 'description' => '' |
|
| 134 | - ], |
|
| 135 | - [ |
|
| 136 | - 'file' => $moduleDirName . '_instr.tpl', |
|
| 137 | - 'description' => '' |
|
| 138 | - ], |
|
| 139 | - [ |
|
| 140 | - 'file' => $moduleDirName . '_index.tpl', |
|
| 141 | - 'description' => '' |
|
| 142 | - ], |
|
| 143 | - [ |
|
| 144 | - 'file' => $moduleDirName . '_editpage.tpl', |
|
| 145 | - 'description' => '' |
|
| 146 | - ], |
|
| 147 | - [ |
|
| 148 | - 'file' => $moduleDirName . '_savepage.tpl', |
|
| 149 | - 'description' => '' |
|
| 150 | - ], |
|
| 79 | + [ |
|
| 80 | + 'file' => 'admin/' . $moduleDirName . '_admin_index.tpl', |
|
| 81 | + 'description' => '' |
|
| 82 | + ], |
|
| 83 | + [ |
|
| 84 | + 'file' => 'admin/' . $moduleDirName . '_admin_cat.tpl', |
|
| 85 | + 'description' => '' |
|
| 86 | + ], |
|
| 87 | + [ |
|
| 88 | + 'file' => 'admin/' . $moduleDirName . '_admin_editcat.tpl', |
|
| 89 | + 'description' => '' |
|
| 90 | + ], |
|
| 91 | + [ |
|
| 92 | + 'file' => 'admin/' . $moduleDirName . '_admin_savecat.tpl', |
|
| 93 | + 'description' => '' |
|
| 94 | + ], |
|
| 95 | + [ |
|
| 96 | + 'file' => 'admin/' . $moduleDirName . '_admin_viewcat.tpl', |
|
| 97 | + 'description' => '' |
|
| 98 | + ], |
|
| 99 | + [ |
|
| 100 | + 'file' => 'admin/' . $moduleDirName . '_admin_instr.tpl', |
|
| 101 | + 'description' => '' |
|
| 102 | + ], |
|
| 103 | + [ |
|
| 104 | + 'file' => 'admin/' . $moduleDirName . '_admin_editinstr.tpl', |
|
| 105 | + 'description' => '' |
|
| 106 | + ], |
|
| 107 | + [ |
|
| 108 | + 'file' => 'admin/' . $moduleDirName . '_admin_saveinstr.tpl', |
|
| 109 | + 'description' => '' |
|
| 110 | + ], |
|
| 111 | + [ |
|
| 112 | + 'file' => 'admin/' . $moduleDirName . '_admin_viewinstr.tpl', |
|
| 113 | + 'description' => '' |
|
| 114 | + ], |
|
| 115 | + [ |
|
| 116 | + 'file' => 'admin/' . $moduleDirName . '_admin_editpage.tpl', |
|
| 117 | + 'description' => '' |
|
| 118 | + ], |
|
| 119 | + [ |
|
| 120 | + 'file' => 'admin/' . $moduleDirName . '_admin_savepage.tpl', |
|
| 121 | + 'description' => '' |
|
| 122 | + ], |
|
| 123 | + [ |
|
| 124 | + 'file' => 'admin/' . $moduleDirName . '_admin_perm.tpl', |
|
| 125 | + 'description' => '' |
|
| 126 | + ], |
|
| 127 | + [ |
|
| 128 | + 'file' => 'admin/' . $moduleDirName . '_admin_about.tpl', |
|
| 129 | + 'description' => '' |
|
| 130 | + ], |
|
| 131 | + [ |
|
| 132 | + 'file' => $moduleDirName . '_page.tpl', |
|
| 133 | + 'description' => '' |
|
| 134 | + ], |
|
| 135 | + [ |
|
| 136 | + 'file' => $moduleDirName . '_instr.tpl', |
|
| 137 | + 'description' => '' |
|
| 138 | + ], |
|
| 139 | + [ |
|
| 140 | + 'file' => $moduleDirName . '_index.tpl', |
|
| 141 | + 'description' => '' |
|
| 142 | + ], |
|
| 143 | + [ |
|
| 144 | + 'file' => $moduleDirName . '_editpage.tpl', |
|
| 145 | + 'description' => '' |
|
| 146 | + ], |
|
| 147 | + [ |
|
| 148 | + 'file' => $moduleDirName . '_savepage.tpl', |
|
| 149 | + 'description' => '' |
|
| 150 | + ], |
|
| 151 | 151 | ]; |
| 152 | 152 | // Конфигурация |
| 153 | 153 | $modversion['config'][] = [ |
| 154 | - 'name' => 'form_options', |
|
| 155 | - 'title' => '_MI_INSTRUCTION_FORM_OPTIONS', |
|
| 156 | - 'description' => '_MI_INSTRUCTION_FORM_OPTIONS_DESC', |
|
| 157 | - 'formtype' => 'select', |
|
| 158 | - 'valuetype' => 'text', |
|
| 159 | - 'default' => 'dhtml', |
|
| 160 | - 'options' => array_flip($editorHandler->getList()) |
|
| 154 | + 'name' => 'form_options', |
|
| 155 | + 'title' => '_MI_INSTRUCTION_FORM_OPTIONS', |
|
| 156 | + 'description' => '_MI_INSTRUCTION_FORM_OPTIONS_DESC', |
|
| 157 | + 'formtype' => 'select', |
|
| 158 | + 'valuetype' => 'text', |
|
| 159 | + 'default' => 'dhtml', |
|
| 160 | + 'options' => array_flip($editorHandler->getList()) |
|
| 161 | 161 | ]; |
| 162 | 162 | $modversion['config'][] = [ |
| 163 | - 'name' => 'perpageadmin', |
|
| 164 | - 'title' => '_MI_INSTRUCTION_PERPAGEADMIN', |
|
| 165 | - 'description' => '_MI_INSTRUCTION_PERPAGEADMINDSC', |
|
| 166 | - 'formtype' => 'textbox', |
|
| 167 | - 'valuetype' => 'int', |
|
| 168 | - 'default' => 20 |
|
| 163 | + 'name' => 'perpageadmin', |
|
| 164 | + 'title' => '_MI_INSTRUCTION_PERPAGEADMIN', |
|
| 165 | + 'description' => '_MI_INSTRUCTION_PERPAGEADMINDSC', |
|
| 166 | + 'formtype' => 'textbox', |
|
| 167 | + 'valuetype' => 'int', |
|
| 168 | + 'default' => 20 |
|
| 169 | 169 | ]; |
| 170 | 170 | $modversion['config'][] = [ |
| 171 | - 'name' => 'perpagemain', |
|
| 172 | - 'title' => '_MI_INSTRUCTION_PERPAGEMAIN', |
|
| 173 | - 'description' => '_MI_INSTRUCTION_PERPAGEMAINDSC', |
|
| 174 | - 'formtype' => 'textbox', |
|
| 175 | - 'valuetype' => 'int', |
|
| 176 | - 'default' => 20 |
|
| 171 | + 'name' => 'perpagemain', |
|
| 172 | + 'title' => '_MI_INSTRUCTION_PERPAGEMAIN', |
|
| 173 | + 'description' => '_MI_INSTRUCTION_PERPAGEMAINDSC', |
|
| 174 | + 'formtype' => 'textbox', |
|
| 175 | + 'valuetype' => 'int', |
|
| 176 | + 'default' => 20 |
|
| 177 | 177 | ]; |
| 178 | 178 | // Теги |
| 179 | 179 | $modversion['config'][] = [ |
| 180 | - 'name' => 'usetag', |
|
| 181 | - 'title' => '_MI_INSTRUCTION_USETAG', |
|
| 182 | - 'description' => '_MI_INSTRUCTION_USETAGDSC', |
|
| 183 | - 'formtype' => 'yesno', |
|
| 184 | - 'valuetype' => 'int', |
|
| 185 | - 'default' => 0 |
|
| 180 | + 'name' => 'usetag', |
|
| 181 | + 'title' => '_MI_INSTRUCTION_USETAG', |
|
| 182 | + 'description' => '_MI_INSTRUCTION_USETAGDSC', |
|
| 183 | + 'formtype' => 'yesno', |
|
| 184 | + 'valuetype' => 'int', |
|
| 185 | + 'default' => 0 |
|
| 186 | 186 | ]; |
| 187 | 187 | // Оценки |
| 188 | 188 | $modversion['config'][] = [ |
| 189 | - 'name' => 'userat', |
|
| 190 | - 'title' => '_MI_INSTRUCTION_USERAT', |
|
| 191 | - 'description' => '_MI_INSTRUCTION_USERATDSC', |
|
| 192 | - 'formtype' => 'yesno', |
|
| 193 | - 'valuetype' => 'int', |
|
| 194 | - 'default' => 0 |
|
| 189 | + 'name' => 'userat', |
|
| 190 | + 'title' => '_MI_INSTRUCTION_USERAT', |
|
| 191 | + 'description' => '_MI_INSTRUCTION_USERATDSC', |
|
| 192 | + 'formtype' => 'yesno', |
|
| 193 | + 'valuetype' => 'int', |
|
| 194 | + 'default' => 0 |
|
| 195 | 195 | ]; |
| 196 | 196 | |
| 197 | 197 | // Блоки |
| 198 | 198 | // Блок последних страниц |
| 199 | 199 | $modversion['blocks'][] = [ |
| 200 | - 'file' => 'instr_lastpage.php', |
|
| 201 | - 'name' => _MI_INSTR_BLOCK_LASTPAGE, |
|
| 202 | - 'description' => _MI_INSTR_BLOCK_LASTPAGE_DESC, |
|
| 203 | - 'show_func' => 'b_instr_lastpage_show', |
|
| 204 | - 'edit_func' => 'b_instr_lastpage_edit', |
|
| 205 | - 'options' => '10|20', |
|
| 206 | - 'template' => $moduleDirName . '_block_lastpage.tpl' |
|
| 200 | + 'file' => 'instr_lastpage.php', |
|
| 201 | + 'name' => _MI_INSTR_BLOCK_LASTPAGE, |
|
| 202 | + 'description' => _MI_INSTR_BLOCK_LASTPAGE_DESC, |
|
| 203 | + 'show_func' => 'b_instr_lastpage_show', |
|
| 204 | + 'edit_func' => 'b_instr_lastpage_edit', |
|
| 205 | + 'options' => '10|20', |
|
| 206 | + 'template' => $moduleDirName . '_block_lastpage.tpl' |
|
| 207 | 207 | ]; |
| 208 | 208 | // Блок последних инструкций |
| 209 | 209 | $modversion['blocks'][] = [ |
| 210 | - 'file' => 'instr_lastinstr.php', |
|
| 211 | - 'name' => _MI_INSTR_BLOCK_LASTINSTR, |
|
| 212 | - 'description' => _MI_INSTR_BLOCK_LASTINSTR_DESC, |
|
| 213 | - 'show_func' => 'b_instr_lastinstr_show', |
|
| 214 | - 'edit_func' => 'b_instr_lastinstr_edit', |
|
| 215 | - 'options' => '10|20', |
|
| 216 | - 'template' => $moduleDirName . '_block_lastinstr.tpl' |
|
| 210 | + 'file' => 'instr_lastinstr.php', |
|
| 211 | + 'name' => _MI_INSTR_BLOCK_LASTINSTR, |
|
| 212 | + 'description' => _MI_INSTR_BLOCK_LASTINSTR_DESC, |
|
| 213 | + 'show_func' => 'b_instr_lastinstr_show', |
|
| 214 | + 'edit_func' => 'b_instr_lastinstr_edit', |
|
| 215 | + 'options' => '10|20', |
|
| 216 | + 'template' => $moduleDirName . '_block_lastinstr.tpl' |
|
| 217 | 217 | ]; |
| 218 | 218 | |
| 219 | 219 | // Notification |
@@ -29,264 +29,264 @@ |
||
| 29 | 29 | // Выбор |
| 30 | 30 | switch ($op) { |
| 31 | 31 | |
| 32 | - case 'main': |
|
| 33 | - |
|
| 34 | - // Подключаем трей |
|
| 35 | - |
|
| 36 | - // include_once __DIR__ . '/../class/tree.php'; |
|
| 37 | - //include_once $GLOBALS['xoops']->path('modules/instruction/class/tree.php'); |
|
| 38 | - |
|
| 39 | - // Заголовок админки |
|
| 40 | - xoops_cp_header(); |
|
| 41 | - // Навигация |
|
| 42 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 43 | - |
|
| 44 | - // Находим ID-категории => Число страниц |
|
| 45 | - $cidinstrids = []; |
|
| 46 | - $sql = "SELECT `cid`, COUNT( `instrid` ) FROM {$instructionHandler->table} GROUP BY `cid`"; |
|
| 47 | - $result = $GLOBALS['xoopsDB']->query($sql); |
|
| 48 | - while (list($cid, $count) = $GLOBALS['xoopsDB']->fetchRow($result)) { |
|
| 49 | - // Заполняем массив |
|
| 50 | - $cidinstrids[$cid] = $count; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - // Выбираем категории из БД |
|
| 54 | - $criteria = new \CriteriaCompo(); |
|
| 55 | - $criteria->setSort('weight ASC, title'); |
|
| 56 | - $criteria->setOrder('ASC'); |
|
| 57 | - $ins_cat = $categoryHandler->getall($criteria); |
|
| 58 | - unset($criteria); |
|
| 59 | - |
|
| 60 | - // Инициализируем |
|
| 61 | - $cattree = new instruction\Tree($ins_cat, 'cid', 'pid'); |
|
| 62 | - // Выводим списко категорий в шаблон |
|
| 63 | - $GLOBALS['xoopsTpl']->assign('insListCat', $cattree->makeCatsAdmin('--', $cidinstrids)); |
|
| 64 | - |
|
| 65 | - // Создание новой категории |
|
| 66 | - $objInstructioncat = $categoryHandler->create(); |
|
| 67 | - $form = $objInstructioncat->getForm('cat.php'); |
|
| 68 | - // Форма |
|
| 69 | - $GLOBALS['xoopsTpl']->assign('insFormCat', $form->render()); |
|
| 70 | - // Выводим шаблон |
|
| 71 | - $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_cat.tpl'); |
|
| 72 | - |
|
| 73 | - // Текст внизу админки |
|
| 74 | - include __DIR__ . '/admin_footer.php'; |
|
| 75 | - |
|
| 76 | - break; |
|
| 77 | - |
|
| 78 | - // Редактирование категории |
|
| 79 | - case 'editcat': |
|
| 80 | - |
|
| 81 | - // Заголовок админки |
|
| 82 | - xoops_cp_header(); |
|
| 83 | - // Навигация |
|
| 84 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 85 | - |
|
| 86 | - $objInstructioncat = $categoryHandler->get($cid); |
|
| 87 | - $form = $objInstructioncat->getForm('cat.php'); |
|
| 88 | - // Форма |
|
| 89 | - //$GLOBALS['xoopsTpl']->assign( 'insFormCat', $form->render() ); |
|
| 90 | - echo $form->render(); |
|
| 91 | - // Выводим шаблон |
|
| 92 | - $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editcat.tpl'); |
|
| 93 | - |
|
| 94 | - // Текст внизу админки |
|
| 95 | - include __DIR__ . '/admin_footer.php'; |
|
| 96 | - |
|
| 97 | - break; |
|
| 98 | - |
|
| 99 | - // Сохранение категорий |
|
| 100 | - case 'savecat': |
|
| 101 | - |
|
| 102 | - // Проверка |
|
| 103 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 104 | - redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 105 | - } |
|
| 106 | - // Если мы редактируем |
|
| 107 | - if ($cid) { |
|
| 108 | - $objInstructioncat = $categoryHandler->get($cid); |
|
| 109 | - } else { |
|
| 110 | - $objInstructioncat = $categoryHandler->create(); |
|
| 111 | - // Указываем дату создания |
|
| 112 | - $objInstructioncat->setVar('datecreated', $time); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - $err = false; |
|
| 116 | - $message_err = ''; |
|
| 117 | - |
|
| 118 | - // Дата обновления |
|
| 119 | - $objInstructioncat->setVar('dateupdated', $time); |
|
| 120 | - $objInstructioncat->setVar('pid', $pid); |
|
| 121 | - $objInstructioncat->setVar('title', $_POST['title']); |
|
| 122 | - $objInstructioncat->setVar('description', $_POST['description']); |
|
| 123 | - $objInstructioncat->setVar('weight', $weight); |
|
| 124 | - $objInstructioncat->setVar('metakeywords', $_POST['metakeywords']); |
|
| 125 | - $objInstructioncat->setVar('metadescription', $_POST['metadescription']); |
|
| 126 | - |
|
| 127 | - // Проверка веса |
|
| 128 | - if (0 == $weight) { |
|
| 129 | - $err = true; |
|
| 130 | - $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>'; |
|
| 131 | - } |
|
| 132 | - // Проверка категорий |
|
| 133 | - if ($cid && ($cid == $pid)) { |
|
| 134 | - $err = true; |
|
| 135 | - $message_err .= _AM_INSTRUCTION_ERR_PCAT . '<br>'; |
|
| 136 | - } |
|
| 137 | - // Если были ошибки |
|
| 138 | - if (true === $err) { |
|
| 139 | - xoops_cp_header(); |
|
| 140 | - // Навигация |
|
| 141 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 142 | - |
|
| 143 | - $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>'; |
|
| 144 | - // Выводим ошибки в шаблон |
|
| 145 | - $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err); |
|
| 146 | - // Если небыло ошибок |
|
| 147 | - } else { |
|
| 148 | - // Вставляем данные в БД |
|
| 149 | - if ($categoryHandler->insert($objInstructioncat)) { |
|
| 150 | - |
|
| 151 | - // ID категории. Если редактируем - то не изменяется. Если создаём новую - то получаем ID созданной записи. |
|
| 152 | - $new_cid = $cid ?: $objInstructioncat->get_new_enreg(); |
|
| 153 | - |
|
| 154 | - // =============== |
|
| 155 | - // ==== Права ==== |
|
| 156 | - // =============== |
|
| 157 | - |
|
| 158 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
| 159 | - |
|
| 160 | - // Если мы редактируем категорию, то старые права нужно удалить |
|
| 161 | - if ($cid) { |
|
| 162 | - // Права на просмотр |
|
| 163 | - $criteria = new\ CriteriaCompo(); |
|
| 164 | - $criteria->add(new \Criteria('gperm_itemid', $new_cid, '=')); |
|
| 165 | - $criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
|
| 166 | - $criteria->add(new \Criteria('gperm_name', 'instruction_view', '=')); |
|
| 167 | - $gpermHandler->deleteAll($criteria); |
|
| 168 | - // Права на добавление |
|
| 169 | - $criteria = new \CriteriaCompo(); |
|
| 170 | - $criteria->add(new \Criteria('gperm_itemid', $new_cid, '=')); |
|
| 171 | - $criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
|
| 172 | - $criteria->add(new \Criteria('gperm_name', 'instruction_submit', '=')); |
|
| 173 | - $gpermHandler->deleteAll($criteria); |
|
| 174 | - // Права на редактирование |
|
| 175 | - $criteria = new \CriteriaCompo(); |
|
| 176 | - $criteria->add(new \Criteria('gperm_itemid', $new_cid, '=')); |
|
| 177 | - $criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
|
| 178 | - $criteria->add(new \Criteria('gperm_name', 'instruction_edit', '=')); |
|
| 179 | - $gpermHandler->deleteAll($criteria); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - // Добавляем права |
|
| 183 | - // Права на просмотр |
|
| 184 | - if (isset($_POST['groups_instr_view'])) { |
|
| 185 | - foreach ($_POST['groups_instr_view'] as $onegroup_id) { |
|
| 186 | - $gpermHandler->addRight('instruction_view', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - // Права на добавление |
|
| 190 | - if (isset($_POST['groups_instr_submit'])) { |
|
| 191 | - foreach ($_POST['groups_instr_submit'] as $onegroup_id) { |
|
| 192 | - $gpermHandler->addRight('instruction_submit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - // Права на редактирование |
|
| 196 | - if (isset($_POST['groups_instr_edit'])) { |
|
| 197 | - foreach ($_POST['groups_instr_edit'] as $onegroup_id) { |
|
| 198 | - $gpermHandler->addRight('instruction_edit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - // |
|
| 203 | - redirect_header('cat.php', 3, _AM_INSTRUCTION_NEWCATADDED); |
|
| 204 | - } |
|
| 205 | - xoops_cp_header(); |
|
| 206 | - // Навигация |
|
| 207 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 208 | - // Выводим ошибки в шаблон |
|
| 209 | - $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors()); |
|
| 210 | - } |
|
| 211 | - // Выводим шаблон |
|
| 212 | - $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savecat.tpl'); |
|
| 213 | - // Выводим форму |
|
| 214 | - $form = $objInstructioncat->getForm(); |
|
| 215 | - // Форма |
|
| 216 | - echo $form->render(); |
|
| 217 | - // Текст внизу админки |
|
| 218 | - include __DIR__ . '/admin_footer.php'; |
|
| 219 | - |
|
| 220 | - break; |
|
| 221 | - |
|
| 222 | - // Удаление категории |
|
| 223 | - case 'delcat': |
|
| 224 | - |
|
| 225 | - // Находим число инструкций в данной категории |
|
| 226 | - // Критерий выборки |
|
| 227 | - $criteria = new \CriteriaCompo(); |
|
| 228 | - // Все инструкции в данной категории |
|
| 229 | - $criteria->add(new \Criteria('cid', $cid, '=')); |
|
| 230 | - $numrows = $instructionHandler->getCount($criteria); |
|
| 231 | - // |
|
| 232 | - unset($criteria); |
|
| 233 | - // Если есть хоть одна инструкция |
|
| 234 | - if ($numrows) { |
|
| 235 | - redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTEMPTY); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - $objInscat = $categoryHandler->get($cid); |
|
| 239 | - // Если нет такой категории |
|
| 240 | - if (!is_object($objInscat)) { |
|
| 241 | - redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT); |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - // Нельзя удалять пока есть доченрии категории |
|
| 245 | - // Подключаем трей |
|
| 246 | - include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
| 247 | - $inscat_arr = $categoryHandler->getall(); |
|
| 248 | - $mytree = new \XoopsObjectTree($inscat_arr, 'cid', 'pid'); |
|
| 249 | - $ins_childcat = $mytree->getAllChild($cid); |
|
| 250 | - // Если есть дочернии категории |
|
| 251 | - if (count($ins_childcat)) { |
|
| 252 | - redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATCHILDREN); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - // Нажали ли мы на кнопку OK |
|
| 256 | - $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0; |
|
| 257 | - // Если мы нажали на кнопку |
|
| 258 | - if ($ok) { |
|
| 259 | - |
|
| 260 | - // Проверка |
|
| 261 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 262 | - redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 263 | - } |
|
| 264 | - // Пытаемся удалить категорию |
|
| 265 | - if ($categoryHandler->delete($objInscat)) { |
|
| 266 | - |
|
| 267 | - // Удалить права доступа к категории |
|
| 268 | - // ================================= |
|
| 269 | - |
|
| 270 | - // Редирект |
|
| 271 | - redirect_header('cat.php', 3, _AM_INSTRUCTION_CATDELETED); |
|
| 272 | - // Если не смогли удалить категорию |
|
| 273 | - } else { |
|
| 274 | - // Редирект |
|
| 275 | - redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_DELCAT); |
|
| 276 | - } |
|
| 277 | - } else { |
|
| 278 | - |
|
| 279 | - // Заголовок админки |
|
| 280 | - xoops_cp_header(); |
|
| 281 | - // Навигация |
|
| 282 | - $adminObject->displayNavigation(basename(__FILE__)); |
|
| 283 | - |
|
| 284 | - xoops_confirm(['ok' => 1, 'cid' => $cid, 'op' => 'delcat'], 'cat.php', sprintf(_AM_INSTRUCTION_FORMDELCAT, $objInscat->getVar('title'))); |
|
| 285 | - |
|
| 286 | - // Текст внизу админки |
|
| 287 | - include __DIR__ . '/admin_footer.php'; |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - break; |
|
| 32 | + case 'main': |
|
| 33 | + |
|
| 34 | + // Подключаем трей |
|
| 35 | + |
|
| 36 | + // include_once __DIR__ . '/../class/tree.php'; |
|
| 37 | + //include_once $GLOBALS['xoops']->path('modules/instruction/class/tree.php'); |
|
| 38 | + |
|
| 39 | + // Заголовок админки |
|
| 40 | + xoops_cp_header(); |
|
| 41 | + // Навигация |
|
| 42 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 43 | + |
|
| 44 | + // Находим ID-категории => Число страниц |
|
| 45 | + $cidinstrids = []; |
|
| 46 | + $sql = "SELECT `cid`, COUNT( `instrid` ) FROM {$instructionHandler->table} GROUP BY `cid`"; |
|
| 47 | + $result = $GLOBALS['xoopsDB']->query($sql); |
|
| 48 | + while (list($cid, $count) = $GLOBALS['xoopsDB']->fetchRow($result)) { |
|
| 49 | + // Заполняем массив |
|
| 50 | + $cidinstrids[$cid] = $count; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + // Выбираем категории из БД |
|
| 54 | + $criteria = new \CriteriaCompo(); |
|
| 55 | + $criteria->setSort('weight ASC, title'); |
|
| 56 | + $criteria->setOrder('ASC'); |
|
| 57 | + $ins_cat = $categoryHandler->getall($criteria); |
|
| 58 | + unset($criteria); |
|
| 59 | + |
|
| 60 | + // Инициализируем |
|
| 61 | + $cattree = new instruction\Tree($ins_cat, 'cid', 'pid'); |
|
| 62 | + // Выводим списко категорий в шаблон |
|
| 63 | + $GLOBALS['xoopsTpl']->assign('insListCat', $cattree->makeCatsAdmin('--', $cidinstrids)); |
|
| 64 | + |
|
| 65 | + // Создание новой категории |
|
| 66 | + $objInstructioncat = $categoryHandler->create(); |
|
| 67 | + $form = $objInstructioncat->getForm('cat.php'); |
|
| 68 | + // Форма |
|
| 69 | + $GLOBALS['xoopsTpl']->assign('insFormCat', $form->render()); |
|
| 70 | + // Выводим шаблон |
|
| 71 | + $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_cat.tpl'); |
|
| 72 | + |
|
| 73 | + // Текст внизу админки |
|
| 74 | + include __DIR__ . '/admin_footer.php'; |
|
| 75 | + |
|
| 76 | + break; |
|
| 77 | + |
|
| 78 | + // Редактирование категории |
|
| 79 | + case 'editcat': |
|
| 80 | + |
|
| 81 | + // Заголовок админки |
|
| 82 | + xoops_cp_header(); |
|
| 83 | + // Навигация |
|
| 84 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 85 | + |
|
| 86 | + $objInstructioncat = $categoryHandler->get($cid); |
|
| 87 | + $form = $objInstructioncat->getForm('cat.php'); |
|
| 88 | + // Форма |
|
| 89 | + //$GLOBALS['xoopsTpl']->assign( 'insFormCat', $form->render() ); |
|
| 90 | + echo $form->render(); |
|
| 91 | + // Выводим шаблон |
|
| 92 | + $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editcat.tpl'); |
|
| 93 | + |
|
| 94 | + // Текст внизу админки |
|
| 95 | + include __DIR__ . '/admin_footer.php'; |
|
| 96 | + |
|
| 97 | + break; |
|
| 98 | + |
|
| 99 | + // Сохранение категорий |
|
| 100 | + case 'savecat': |
|
| 101 | + |
|
| 102 | + // Проверка |
|
| 103 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 104 | + redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 105 | + } |
|
| 106 | + // Если мы редактируем |
|
| 107 | + if ($cid) { |
|
| 108 | + $objInstructioncat = $categoryHandler->get($cid); |
|
| 109 | + } else { |
|
| 110 | + $objInstructioncat = $categoryHandler->create(); |
|
| 111 | + // Указываем дату создания |
|
| 112 | + $objInstructioncat->setVar('datecreated', $time); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + $err = false; |
|
| 116 | + $message_err = ''; |
|
| 117 | + |
|
| 118 | + // Дата обновления |
|
| 119 | + $objInstructioncat->setVar('dateupdated', $time); |
|
| 120 | + $objInstructioncat->setVar('pid', $pid); |
|
| 121 | + $objInstructioncat->setVar('title', $_POST['title']); |
|
| 122 | + $objInstructioncat->setVar('description', $_POST['description']); |
|
| 123 | + $objInstructioncat->setVar('weight', $weight); |
|
| 124 | + $objInstructioncat->setVar('metakeywords', $_POST['metakeywords']); |
|
| 125 | + $objInstructioncat->setVar('metadescription', $_POST['metadescription']); |
|
| 126 | + |
|
| 127 | + // Проверка веса |
|
| 128 | + if (0 == $weight) { |
|
| 129 | + $err = true; |
|
| 130 | + $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>'; |
|
| 131 | + } |
|
| 132 | + // Проверка категорий |
|
| 133 | + if ($cid && ($cid == $pid)) { |
|
| 134 | + $err = true; |
|
| 135 | + $message_err .= _AM_INSTRUCTION_ERR_PCAT . '<br>'; |
|
| 136 | + } |
|
| 137 | + // Если были ошибки |
|
| 138 | + if (true === $err) { |
|
| 139 | + xoops_cp_header(); |
|
| 140 | + // Навигация |
|
| 141 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 142 | + |
|
| 143 | + $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>'; |
|
| 144 | + // Выводим ошибки в шаблон |
|
| 145 | + $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err); |
|
| 146 | + // Если небыло ошибок |
|
| 147 | + } else { |
|
| 148 | + // Вставляем данные в БД |
|
| 149 | + if ($categoryHandler->insert($objInstructioncat)) { |
|
| 150 | + |
|
| 151 | + // ID категории. Если редактируем - то не изменяется. Если создаём новую - то получаем ID созданной записи. |
|
| 152 | + $new_cid = $cid ?: $objInstructioncat->get_new_enreg(); |
|
| 153 | + |
|
| 154 | + // =============== |
|
| 155 | + // ==== Права ==== |
|
| 156 | + // =============== |
|
| 157 | + |
|
| 158 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
| 159 | + |
|
| 160 | + // Если мы редактируем категорию, то старые права нужно удалить |
|
| 161 | + if ($cid) { |
|
| 162 | + // Права на просмотр |
|
| 163 | + $criteria = new\ CriteriaCompo(); |
|
| 164 | + $criteria->add(new \Criteria('gperm_itemid', $new_cid, '=')); |
|
| 165 | + $criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
|
| 166 | + $criteria->add(new \Criteria('gperm_name', 'instruction_view', '=')); |
|
| 167 | + $gpermHandler->deleteAll($criteria); |
|
| 168 | + // Права на добавление |
|
| 169 | + $criteria = new \CriteriaCompo(); |
|
| 170 | + $criteria->add(new \Criteria('gperm_itemid', $new_cid, '=')); |
|
| 171 | + $criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
|
| 172 | + $criteria->add(new \Criteria('gperm_name', 'instruction_submit', '=')); |
|
| 173 | + $gpermHandler->deleteAll($criteria); |
|
| 174 | + // Права на редактирование |
|
| 175 | + $criteria = new \CriteriaCompo(); |
|
| 176 | + $criteria->add(new \Criteria('gperm_itemid', $new_cid, '=')); |
|
| 177 | + $criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
|
| 178 | + $criteria->add(new \Criteria('gperm_name', 'instruction_edit', '=')); |
|
| 179 | + $gpermHandler->deleteAll($criteria); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + // Добавляем права |
|
| 183 | + // Права на просмотр |
|
| 184 | + if (isset($_POST['groups_instr_view'])) { |
|
| 185 | + foreach ($_POST['groups_instr_view'] as $onegroup_id) { |
|
| 186 | + $gpermHandler->addRight('instruction_view', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + // Права на добавление |
|
| 190 | + if (isset($_POST['groups_instr_submit'])) { |
|
| 191 | + foreach ($_POST['groups_instr_submit'] as $onegroup_id) { |
|
| 192 | + $gpermHandler->addRight('instruction_submit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + // Права на редактирование |
|
| 196 | + if (isset($_POST['groups_instr_edit'])) { |
|
| 197 | + foreach ($_POST['groups_instr_edit'] as $onegroup_id) { |
|
| 198 | + $gpermHandler->addRight('instruction_edit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + // |
|
| 203 | + redirect_header('cat.php', 3, _AM_INSTRUCTION_NEWCATADDED); |
|
| 204 | + } |
|
| 205 | + xoops_cp_header(); |
|
| 206 | + // Навигация |
|
| 207 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 208 | + // Выводим ошибки в шаблон |
|
| 209 | + $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors()); |
|
| 210 | + } |
|
| 211 | + // Выводим шаблон |
|
| 212 | + $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savecat.tpl'); |
|
| 213 | + // Выводим форму |
|
| 214 | + $form = $objInstructioncat->getForm(); |
|
| 215 | + // Форма |
|
| 216 | + echo $form->render(); |
|
| 217 | + // Текст внизу админки |
|
| 218 | + include __DIR__ . '/admin_footer.php'; |
|
| 219 | + |
|
| 220 | + break; |
|
| 221 | + |
|
| 222 | + // Удаление категории |
|
| 223 | + case 'delcat': |
|
| 224 | + |
|
| 225 | + // Находим число инструкций в данной категории |
|
| 226 | + // Критерий выборки |
|
| 227 | + $criteria = new \CriteriaCompo(); |
|
| 228 | + // Все инструкции в данной категории |
|
| 229 | + $criteria->add(new \Criteria('cid', $cid, '=')); |
|
| 230 | + $numrows = $instructionHandler->getCount($criteria); |
|
| 231 | + // |
|
| 232 | + unset($criteria); |
|
| 233 | + // Если есть хоть одна инструкция |
|
| 234 | + if ($numrows) { |
|
| 235 | + redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTEMPTY); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + $objInscat = $categoryHandler->get($cid); |
|
| 239 | + // Если нет такой категории |
|
| 240 | + if (!is_object($objInscat)) { |
|
| 241 | + redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT); |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + // Нельзя удалять пока есть доченрии категории |
|
| 245 | + // Подключаем трей |
|
| 246 | + include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
| 247 | + $inscat_arr = $categoryHandler->getall(); |
|
| 248 | + $mytree = new \XoopsObjectTree($inscat_arr, 'cid', 'pid'); |
|
| 249 | + $ins_childcat = $mytree->getAllChild($cid); |
|
| 250 | + // Если есть дочернии категории |
|
| 251 | + if (count($ins_childcat)) { |
|
| 252 | + redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATCHILDREN); |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + // Нажали ли мы на кнопку OK |
|
| 256 | + $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0; |
|
| 257 | + // Если мы нажали на кнопку |
|
| 258 | + if ($ok) { |
|
| 259 | + |
|
| 260 | + // Проверка |
|
| 261 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 262 | + redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 263 | + } |
|
| 264 | + // Пытаемся удалить категорию |
|
| 265 | + if ($categoryHandler->delete($objInscat)) { |
|
| 266 | + |
|
| 267 | + // Удалить права доступа к категории |
|
| 268 | + // ================================= |
|
| 269 | + |
|
| 270 | + // Редирект |
|
| 271 | + redirect_header('cat.php', 3, _AM_INSTRUCTION_CATDELETED); |
|
| 272 | + // Если не смогли удалить категорию |
|
| 273 | + } else { |
|
| 274 | + // Редирект |
|
| 275 | + redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_DELCAT); |
|
| 276 | + } |
|
| 277 | + } else { |
|
| 278 | + |
|
| 279 | + // Заголовок админки |
|
| 280 | + xoops_cp_header(); |
|
| 281 | + // Навигация |
|
| 282 | + $adminObject->displayNavigation(basename(__FILE__)); |
|
| 283 | + |
|
| 284 | + xoops_confirm(['ok' => 1, 'cid' => $cid, 'op' => 'delcat'], 'cat.php', sprintf(_AM_INSTRUCTION_FORMDELCAT, $objInscat->getVar('title'))); |
|
| 285 | + |
|
| 286 | + // Текст внизу админки |
|
| 287 | + include __DIR__ . '/admin_footer.php'; |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + break; |
|
| 291 | 291 | |
| 292 | 292 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | case 'savecat': |
| 101 | 101 | |
| 102 | 102 | // Проверка |
| 103 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 103 | + if ( ! $GLOBALS['xoopsSecurity']->check()) { |
|
| 104 | 104 | redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
| 105 | 105 | } |
| 106 | 106 | // Если мы редактируем |
@@ -126,12 +126,12 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | // Проверка веса |
| 128 | 128 | if (0 == $weight) { |
| 129 | - $err = true; |
|
| 129 | + $err = true; |
|
| 130 | 130 | $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>'; |
| 131 | 131 | } |
| 132 | 132 | // Проверка категорий |
| 133 | 133 | if ($cid && ($cid == $pid)) { |
| 134 | - $err = true; |
|
| 134 | + $err = true; |
|
| 135 | 135 | $message_err .= _AM_INSTRUCTION_ERR_PCAT . '<br>'; |
| 136 | 136 | } |
| 137 | 137 | // Если были ошибки |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | $objInscat = $categoryHandler->get($cid); |
| 239 | 239 | // Если нет такой категории |
| 240 | - if (!is_object($objInscat)) { |
|
| 240 | + if ( ! is_object($objInscat)) { |
|
| 241 | 241 | redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT); |
| 242 | 242 | } |
| 243 | 243 | |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | // Нажали ли мы на кнопку OK |
| 256 | - $ok = isset($_POST['ok']) ? (int)$_POST['ok'] : 0; |
|
| 256 | + $ok = isset($_POST['ok']) ? (int) $_POST['ok'] : 0; |
|
| 257 | 257 | // Если мы нажали на кнопку |
| 258 | 258 | if ($ok) { |
| 259 | 259 | |
| 260 | 260 | // Проверка |
| 261 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 261 | + if ( ! $GLOBALS['xoopsSecurity']->check()) { |
|
| 262 | 262 | redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
| 263 | 263 | } |
| 264 | 264 | // Пытаемся удалить категорию |