@@ -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 (($GLOBALS['xoopsUser'] instanceof \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 | // Подвал |
@@ -17,77 +17,77 @@ |
||
17 | 17 | */ |
18 | 18 | trait VersionChecks |
19 | 19 | { |
20 | - /** |
|
21 | - * |
|
22 | - * Verifies XOOPS version meets minimum requirements for this module |
|
23 | - * @static |
|
24 | - * @param \XoopsModule|null $module |
|
25 | - * |
|
26 | - * @param null|string $requiredVer |
|
27 | - * @return bool true if meets requirements, false if not |
|
28 | - */ |
|
29 | - public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) |
|
30 | - { |
|
31 | - $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
32 | - if (null === $module) { |
|
33 | - $module = \XoopsModule::getByDirname($moduleDirName); |
|
34 | - } |
|
35 | - xoops_loadLanguage('admin', $moduleDirName); |
|
36 | - //check for minimum XOOPS version |
|
37 | - $currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string |
|
38 | - $currArray = explode('.', $currentVer); |
|
39 | - if (null === $requiredVer) { |
|
40 | - $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
41 | - } |
|
42 | - $reqArray = explode('.', $requiredVer); |
|
43 | - $success = true; |
|
44 | - foreach ($reqArray as $k => $v) { |
|
45 | - if (isset($currArray[$k])) { |
|
46 | - if ($currArray[$k] > $v) { |
|
47 | - break; |
|
48 | - } elseif ($currArray[$k] == $v) { |
|
49 | - continue; |
|
50 | - } else { |
|
51 | - $success = false; |
|
52 | - break; |
|
53 | - } |
|
54 | - } else { |
|
55 | - if ((int)$v > 0) { // handles versions like x.x.x.0_RC2 |
|
56 | - $success = false; |
|
57 | - break; |
|
58 | - } |
|
59 | - } |
|
60 | - } |
|
20 | + /** |
|
21 | + * |
|
22 | + * Verifies XOOPS version meets minimum requirements for this module |
|
23 | + * @static |
|
24 | + * @param \XoopsModule|null $module |
|
25 | + * |
|
26 | + * @param null|string $requiredVer |
|
27 | + * @return bool true if meets requirements, false if not |
|
28 | + */ |
|
29 | + public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) |
|
30 | + { |
|
31 | + $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
32 | + if (null === $module) { |
|
33 | + $module = \XoopsModule::getByDirname($moduleDirName); |
|
34 | + } |
|
35 | + xoops_loadLanguage('admin', $moduleDirName); |
|
36 | + //check for minimum XOOPS version |
|
37 | + $currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string |
|
38 | + $currArray = explode('.', $currentVer); |
|
39 | + if (null === $requiredVer) { |
|
40 | + $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
41 | + } |
|
42 | + $reqArray = explode('.', $requiredVer); |
|
43 | + $success = true; |
|
44 | + foreach ($reqArray as $k => $v) { |
|
45 | + if (isset($currArray[$k])) { |
|
46 | + if ($currArray[$k] > $v) { |
|
47 | + break; |
|
48 | + } elseif ($currArray[$k] == $v) { |
|
49 | + continue; |
|
50 | + } else { |
|
51 | + $success = false; |
|
52 | + break; |
|
53 | + } |
|
54 | + } else { |
|
55 | + if ((int)$v > 0) { // handles versions like x.x.x.0_RC2 |
|
56 | + $success = false; |
|
57 | + break; |
|
58 | + } |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - if (false === $success) { |
|
63 | - $module->setErrors(sprintf(_AM_INSTRUCTION_ERROR_BAD_XOOPS, $requiredVer, $currentVer)); |
|
64 | - } |
|
62 | + if (false === $success) { |
|
63 | + $module->setErrors(sprintf(_AM_INSTRUCTION_ERROR_BAD_XOOPS, $requiredVer, $currentVer)); |
|
64 | + } |
|
65 | 65 | |
66 | - return $success; |
|
67 | - } |
|
66 | + return $success; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * |
|
71 | - * Verifies PHP version meets minimum requirements for this module |
|
72 | - * @static |
|
73 | - * @param \XoopsModule $module |
|
74 | - * |
|
75 | - * @return bool true if meets requirements, false if not |
|
76 | - */ |
|
77 | - public static function checkVerPhp(\XoopsModule $module) |
|
78 | - { |
|
79 | - xoops_loadLanguage('admin', $module->dirname()); |
|
80 | - // check for minimum PHP version |
|
81 | - $success = true; |
|
82 | - $verNum = PHP_VERSION; |
|
83 | - $reqVer = $module->getInfo('min_php'); |
|
84 | - if (false !== $reqVer && '' !== $reqVer) { |
|
85 | - if (version_compare($verNum, $reqVer, '<')) { |
|
86 | - $module->setErrors(sprintf(_AM_INSTRUCTION_ERROR_BAD_PHP, $reqVer, $verNum)); |
|
87 | - $success = false; |
|
88 | - } |
|
89 | - } |
|
69 | + /** |
|
70 | + * |
|
71 | + * Verifies PHP version meets minimum requirements for this module |
|
72 | + * @static |
|
73 | + * @param \XoopsModule $module |
|
74 | + * |
|
75 | + * @return bool true if meets requirements, false if not |
|
76 | + */ |
|
77 | + public static function checkVerPhp(\XoopsModule $module) |
|
78 | + { |
|
79 | + xoops_loadLanguage('admin', $module->dirname()); |
|
80 | + // check for minimum PHP version |
|
81 | + $success = true; |
|
82 | + $verNum = PHP_VERSION; |
|
83 | + $reqVer = $module->getInfo('min_php'); |
|
84 | + if (false !== $reqVer && '' !== $reqVer) { |
|
85 | + if (version_compare($verNum, $reqVer, '<')) { |
|
86 | + $module->setErrors(sprintf(_AM_INSTRUCTION_ERROR_BAD_PHP, $reqVer, $verNum)); |
|
87 | + $success = false; |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - return $success; |
|
92 | - } |
|
91 | + return $success; |
|
92 | + } |
|
93 | 93 | } |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | $module = $helper->getModule(); |
49 | 49 | |
50 | 50 | if (Xoopsmodules\instruction\Utility::checkVerXoops($module, '2.5.9')) { |
51 | - $cat_select = $mytree->makeSelectElement('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'", ''); |
|
52 | - $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select->render()); |
|
51 | + $cat_select = $mytree->makeSelectElement('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'", ''); |
|
52 | + $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select->render()); |
|
53 | 53 | } else { |
54 | - $cat_select = $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'"); |
|
55 | - $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select); |
|
54 | + $cat_select = $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'"); |
|
55 | + $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | // Находим список всех инструкций |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | $criteria->add(new \Criteria('status', '0', '>')); |
63 | 63 | // Если есть категория |
64 | 64 | if ($cid) { |
65 | - // Если нельзя просматривать эту категорию |
|
66 | - if (!in_array($cid, $categories)) { |
|
67 | - redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT); |
|
68 | - } |
|
69 | - $criteria->add(new \Criteria('cid', $cid, '=')); |
|
70 | - // Иначе находим список всех |
|
65 | + // Если нельзя просматривать эту категорию |
|
66 | + if (!in_array($cid, $categories)) { |
|
67 | + redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT); |
|
68 | + } |
|
69 | + $criteria->add(new \Criteria('cid', $cid, '=')); |
|
70 | + // Иначе находим список всех |
|
71 | 71 | } else { |
72 | - $criteria->add(new \Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN')); |
|
72 | + $criteria->add(new \Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN')); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // Число инструкций, удовлетворяющих данному условию |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | $instr_arr = $instructionHandler->getall($criteria); |
87 | 87 | // Если записей больше чем $limit, то выводим пагинатор |
88 | 88 | if ($numrows > $limit) { |
89 | - $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'cid=' . $cid); |
|
90 | - $pagenav = $pagenav->renderNav(4); |
|
89 | + $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'cid=' . $cid); |
|
90 | + $pagenav = $pagenav->renderNav(4); |
|
91 | 91 | } else { |
92 | - $pagenav = ''; |
|
92 | + $pagenav = ''; |
|
93 | 93 | } |
94 | 94 | // Выводим пагинатор в шаблон |
95 | 95 | $GLOBALS['xoopsTpl']->assign('insPagenav', $pagenav); |
@@ -100,54 +100,54 @@ discard block |
||
100 | 100 | |
101 | 101 | // Если есть записи |
102 | 102 | if ($numrows > 0) { |
103 | - $class = 'odd'; |
|
104 | - foreach (array_keys($instr_arr) as $i) { |
|
105 | - |
|
106 | - // |
|
107 | - $class = ('even' === $class) ? 'odd' : 'even'; |
|
108 | - // ID |
|
109 | - $insinstr_instrid = $instr_arr[$i]->getVar('instrid'); |
|
110 | - // Название |
|
111 | - $insinstr_title = $instr_arr[$i]->getVar('title'); |
|
112 | - // Статус |
|
113 | - $insinstr_status = $instr_arr[$i]->getVar('status'); |
|
114 | - // Количество страниц |
|
115 | - $insinstr_pages = $instr_arr[$i]->getVar('pages'); |
|
116 | - // Категория |
|
117 | - $insinstr_cid = $instr_arr[$i]->getVar('cid'); |
|
118 | - $insinstr_cat = $categoryHandler->get($insinstr_cid); |
|
119 | - // Права на добавление |
|
120 | - $perm_submit = in_array($insinstr_cid, $cat_submit) ? true : false; |
|
121 | - // Права на редактирование |
|
122 | - $perm_edit = in_array($insinstr_cid, $cat_edit) ? true : false; |
|
123 | - //Мета-теги ключевых слов |
|
124 | - $insinstr_metakeywords = $instr_arr[$i]->getVar('metakeywords'); |
|
125 | - // Если есть - добавляем в мета-теги страницы |
|
126 | - if ($insinstr_metakeywords) { |
|
127 | - $index_metakeywords[] = $insinstr_metakeywords; |
|
128 | - } |
|
129 | - // Мета-теги описания |
|
130 | - $insinstr_metadescript = $instr_arr[$i]->getVar('metadescription'); |
|
131 | - // Если есть - добавляем в мета-теги страницы |
|
132 | - if ($insinstr_metadescript) { |
|
133 | - $index_metadescript[] = $insinstr_metadescript; |
|
134 | - } |
|
135 | - |
|
136 | - // Выводим в шаблон |
|
137 | - $GLOBALS['xoopsTpl']->append('insListInstr', |
|
138 | - ['instrid' => $insinstr_instrid, 'title' => $insinstr_title, 'status' => $insinstr_status, 'pages' => $insinstr_pages, 'ctitle' => $insinstr_cat->getVar('title'), 'cid' => $insinstr_cid, 'permsubmit' => $perm_submit, 'permedit' => $perm_edit, 'class' => $class] |
|
139 | - ); |
|
140 | - } |
|
141 | - |
|
142 | - // Языковые константы |
|
103 | + $class = 'odd'; |
|
104 | + foreach (array_keys($instr_arr) as $i) { |
|
105 | + |
|
106 | + // |
|
107 | + $class = ('even' === $class) ? 'odd' : 'even'; |
|
108 | + // ID |
|
109 | + $insinstr_instrid = $instr_arr[$i]->getVar('instrid'); |
|
110 | + // Название |
|
111 | + $insinstr_title = $instr_arr[$i]->getVar('title'); |
|
112 | + // Статус |
|
113 | + $insinstr_status = $instr_arr[$i]->getVar('status'); |
|
114 | + // Количество страниц |
|
115 | + $insinstr_pages = $instr_arr[$i]->getVar('pages'); |
|
116 | + // Категория |
|
117 | + $insinstr_cid = $instr_arr[$i]->getVar('cid'); |
|
118 | + $insinstr_cat = $categoryHandler->get($insinstr_cid); |
|
119 | + // Права на добавление |
|
120 | + $perm_submit = in_array($insinstr_cid, $cat_submit) ? true : false; |
|
121 | + // Права на редактирование |
|
122 | + $perm_edit = in_array($insinstr_cid, $cat_edit) ? true : false; |
|
123 | + //Мета-теги ключевых слов |
|
124 | + $insinstr_metakeywords = $instr_arr[$i]->getVar('metakeywords'); |
|
125 | + // Если есть - добавляем в мета-теги страницы |
|
126 | + if ($insinstr_metakeywords) { |
|
127 | + $index_metakeywords[] = $insinstr_metakeywords; |
|
128 | + } |
|
129 | + // Мета-теги описания |
|
130 | + $insinstr_metadescript = $instr_arr[$i]->getVar('metadescription'); |
|
131 | + // Если есть - добавляем в мета-теги страницы |
|
132 | + if ($insinstr_metadescript) { |
|
133 | + $index_metadescript[] = $insinstr_metadescript; |
|
134 | + } |
|
135 | + |
|
136 | + // Выводим в шаблон |
|
137 | + $GLOBALS['xoopsTpl']->append('insListInstr', |
|
138 | + ['instrid' => $insinstr_instrid, 'title' => $insinstr_title, 'status' => $insinstr_status, 'pages' => $insinstr_pages, 'ctitle' => $insinstr_cat->getVar('title'), 'cid' => $insinstr_cid, 'permsubmit' => $perm_submit, 'permedit' => $perm_edit, 'class' => $class] |
|
139 | + ); |
|
140 | + } |
|
141 | + |
|
142 | + // Языковые константы |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // Если есть мета-теги |
146 | 146 | if (count($index_metakeywords)) { |
147 | - $xoTheme->addMeta('meta', 'keywords', implode(', ', $index_metakeywords)); |
|
147 | + $xoTheme->addMeta('meta', 'keywords', implode(', ', $index_metakeywords)); |
|
148 | 148 | } |
149 | 149 | if (count($index_metadescript)) { |
150 | - $xoTheme->addMeta('meta', 'description', implode(', ', $index_metadescript)); |
|
150 | + $xoTheme->addMeta('meta', 'description', implode(', ', $index_metadescript)); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Подвал |
@@ -12,174 +12,174 @@ |
||
12 | 12 | */ |
13 | 13 | class Page extends \XoopsObject |
14 | 14 | { |
15 | - // constructor |
|
16 | - public function __construct() |
|
17 | - { |
|
18 | - // $this->XoopsObject(); |
|
19 | - $this->initVar('pageid', XOBJ_DTYPE_INT, null, false, 11); |
|
20 | - $this->initVar('pid', XOBJ_DTYPE_INT, 0, false, 11); |
|
21 | - $this->initVar('instrid', XOBJ_DTYPE_INT, 0, false, 11); |
|
22 | - $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11); |
|
23 | - $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
24 | - $this->initVar('status', XOBJ_DTYPE_INT, 1, false, 1); |
|
25 | - $this->initVar('type', XOBJ_DTYPE_INT, 1, false, 1); |
|
26 | - $this->initVar('hometext', XOBJ_DTYPE_TXTAREA, null, false); |
|
27 | - $this->initVar('footnote', XOBJ_DTYPE_TXTAREA, '', false); |
|
28 | - $this->initVar('weight', XOBJ_DTYPE_INT, 0, false, 11); |
|
29 | - $this->initVar('keywords', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
30 | - $this->initVar('description', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
31 | - $this->initVar('comments', XOBJ_DTYPE_INT, 0, false, 11); |
|
32 | - $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
33 | - $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
34 | - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false, 1); |
|
35 | - $this->initVar('dosmiley', XOBJ_DTYPE_INT, 0, false, 1); |
|
36 | - $this->initVar('doxcode', XOBJ_DTYPE_INT, 1, false, 1); |
|
37 | - $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false, 1); |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * @return mixed |
|
42 | - */ |
|
43 | - public function getNewInstertId() |
|
44 | - { |
|
45 | - $newEnreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
46 | - return $newEnreg; |
|
47 | - } |
|
48 | - |
|
49 | - // Получаем форму |
|
50 | - |
|
51 | - /** |
|
52 | - * @param bool|null|string $action |
|
53 | - * @param int $instrid |
|
54 | - * @return \XoopsThemeForm |
|
55 | - */ |
|
56 | - public function getForm($action = false, $instrid = 0) |
|
57 | - { |
|
58 | - // Если нет $action |
|
59 | - if (false === $action) { |
|
60 | - $action = xoops_getenv('REQUEST_URI'); |
|
61 | - } |
|
62 | - |
|
63 | - // Подключаем формы |
|
64 | - include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
65 | - // Подключаем типы страниц |
|
66 | - $pagetypes = include $GLOBALS['xoops']->path('modules/instruction/include/pagetypes.inc.php'); |
|
67 | - |
|
68 | - // Название формы |
|
69 | - $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDPAGE) : sprintf(_AM_INSTRUCTION_FORMEDITPAGE); |
|
70 | - |
|
71 | - // Форма |
|
72 | - $form = new \XoopsThemeForm($title, 'instr_form_page', $action, 'post', true); |
|
73 | - // Название |
|
74 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
75 | - |
|
76 | - // Родительская страница |
|
77 | - // $pageHandler = xoops_getModuleHandler('page', 'instruction'); |
|
78 | - $pageHandler = new PageHandler; |
|
79 | - |
|
80 | - $criteria = new \CriteriaCompo(); |
|
81 | - // ID инструкции в которой данная страница |
|
82 | - $instrid_page = $this->isNew() ? $instrid : $this->getVar('instrid'); |
|
83 | - // Находим все страницы данной инструкции |
|
84 | - $criteria->add(new \Criteria('instrid', $instrid_page, '=')); |
|
85 | - // Если мы редактируем, то убрать текущую страницу из списка выбора родительской |
|
86 | - if (!$this->isNew()) { |
|
87 | - $criteria->add(new \Criteria('pageid', $this->getVar('pageid'), '<>')); |
|
88 | - } |
|
89 | - $criteria->setSort('weight'); |
|
90 | - $criteria->setOrder('ASC'); |
|
91 | - $inspage_arr = $pageHandler->getall($criteria); |
|
92 | - unset($criteria); |
|
93 | - // Подключаем трей |
|
94 | - include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
95 | - $mytree = new \XoopsObjectTree($inspage_arr, 'pageid', 'pid'); |
|
96 | - |
|
97 | - // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_PPAGEC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
98 | - $helper = Helper::getInstance(); |
|
99 | - $module = $helper->getModule(); |
|
100 | - |
|
101 | - if (Utility::checkVerXoops($module, '2.5.9')) { |
|
102 | - $mytree_select = $mytree->makeSelectElement('pid', 'title', '--', $this->getVar('pid'), true, 0, '', _AM_INSTRUCTION_PPAGEC); |
|
103 | - $form->addElement($mytree_select); |
|
104 | - } else { |
|
105 | - $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_PPAGEC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
106 | - } |
|
107 | - |
|
108 | - // Вес |
|
109 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_WEIGHTC, 'weight', 5, 5, $this->getVar('weight')), true); |
|
110 | - // Основной текст |
|
111 | - $form->addElement(Utility::getWysiwygForm(_AM_INSTRUCTION_HOMETEXTC, 'hometext', $this->getVar('hometext', 'e')), true); |
|
112 | - // Сноска |
|
113 | - $form_footnote = new \XoopsFormTextArea(_AM_INSTRUCTION_FOOTNOTEC, 'footnote', $this->getVar('footnote', 'e')); |
|
114 | - $form_footnote->setDescription(_AM_INSTRUCTION_FOOTNOTE_DSC); |
|
115 | - $form->addElement($form_footnote, false); |
|
116 | - unset($form_footnote); |
|
117 | - // Статус |
|
118 | - $form->addElement(new \XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false); |
|
119 | - // Тип страницы |
|
120 | - $form_type = new \XoopsFormSelect(_AM_INSTR_PAGETYPEC, 'type', $this->getVar('type')); |
|
121 | - $form_type->setDescription(_AM_INSTR_PAGETYPEC_DESC); |
|
122 | - $form_type->addOptionArray($pagetypes); |
|
123 | - $form->addElement($form_type, false); |
|
124 | - // Мета-теги ключевых слов |
|
125 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'keywords', 50, 255, $this->getVar('keywords')), false); |
|
126 | - // Мета-теги описания |
|
127 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'description', 50, 255, $this->getVar('description')), false); |
|
128 | - |
|
129 | - // Настройки |
|
130 | - $option_tray = new \XoopsFormElementTray(_OPTIONS, '<br>'); |
|
131 | - // HTML |
|
132 | - $html_checkbox = new \XoopsFormCheckBox('', 'dohtml', $this->getVar('dohtml')); |
|
133 | - $html_checkbox->addOption(1, _AM_INSTR_DOHTML); |
|
134 | - $option_tray->addElement($html_checkbox); |
|
135 | - // Смайлы |
|
136 | - $smiley_checkbox = new \XoopsFormCheckBox('', 'dosmiley', $this->getVar('dosmiley')); |
|
137 | - $smiley_checkbox->addOption(1, _AM_INSTR_DOSMILEY); |
|
138 | - $option_tray->addElement($smiley_checkbox); |
|
139 | - // ББ коды |
|
140 | - $xcode_checkbox = new \XoopsFormCheckBox('', 'doxcode', $this->getVar('doxcode')); |
|
141 | - $xcode_checkbox->addOption(1, _AM_INSTR_DOXCODE); |
|
142 | - $option_tray->addElement($xcode_checkbox); |
|
143 | - // |
|
144 | - $br_checkbox = new \XoopsFormCheckBox('', 'dobr', $this->getVar('dobr')); |
|
145 | - $br_checkbox->addOption(1, _AM_INSTR_DOAUTOWRAP); |
|
146 | - $option_tray->addElement($br_checkbox); |
|
147 | - // |
|
148 | - $form->addElement($option_tray); |
|
149 | - |
|
150 | - // Если мы редактируем страницу |
|
151 | - if (!$this->isNew()) { |
|
152 | - $form->addElement(new \XoopsFormHidden('pageid', $this->getVar('pageid'))); |
|
153 | - } else { |
|
154 | - $form->addElement(new \XoopsFormHidden('pageid', 0)); |
|
155 | - } |
|
156 | - // ID инструкции |
|
157 | - if ($instrid) { |
|
158 | - $form->addElement(new \XoopsFormHidden('instrid', $instrid)); |
|
159 | - } else { |
|
160 | - $form->addElement(new \XoopsFormHidden('instrid', 0)); |
|
161 | - } |
|
162 | - // |
|
163 | - $form->addElement(new \XoopsFormHidden('op', 'savepage')); |
|
164 | - // Кнопка |
|
165 | - $button_tray = new \XoopsFormElementTray('', ''); |
|
166 | - $button_tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
167 | - $save_btn = new \XoopsFormButton('', 'cancel', _AM_INSTR_SAVEFORM); |
|
168 | - $save_btn->setExtra('onclick="instrSavePage();"'); |
|
169 | - $button_tray->addElement($save_btn); |
|
170 | - $form->addElement($button_tray); |
|
171 | - |
|
172 | - return $form; |
|
173 | - } |
|
174 | - |
|
175 | - // |
|
176 | - |
|
177 | - /** |
|
178 | - * @return mixed |
|
179 | - */ |
|
180 | - public function getInstrid() |
|
181 | - { |
|
182 | - // Возвращаем ID инструкции |
|
183 | - return $this->getVar('instrid'); |
|
184 | - } |
|
15 | + // constructor |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + // $this->XoopsObject(); |
|
19 | + $this->initVar('pageid', XOBJ_DTYPE_INT, null, false, 11); |
|
20 | + $this->initVar('pid', XOBJ_DTYPE_INT, 0, false, 11); |
|
21 | + $this->initVar('instrid', XOBJ_DTYPE_INT, 0, false, 11); |
|
22 | + $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11); |
|
23 | + $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
24 | + $this->initVar('status', XOBJ_DTYPE_INT, 1, false, 1); |
|
25 | + $this->initVar('type', XOBJ_DTYPE_INT, 1, false, 1); |
|
26 | + $this->initVar('hometext', XOBJ_DTYPE_TXTAREA, null, false); |
|
27 | + $this->initVar('footnote', XOBJ_DTYPE_TXTAREA, '', false); |
|
28 | + $this->initVar('weight', XOBJ_DTYPE_INT, 0, false, 11); |
|
29 | + $this->initVar('keywords', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
30 | + $this->initVar('description', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
31 | + $this->initVar('comments', XOBJ_DTYPE_INT, 0, false, 11); |
|
32 | + $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
33 | + $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
34 | + $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false, 1); |
|
35 | + $this->initVar('dosmiley', XOBJ_DTYPE_INT, 0, false, 1); |
|
36 | + $this->initVar('doxcode', XOBJ_DTYPE_INT, 1, false, 1); |
|
37 | + $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false, 1); |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * @return mixed |
|
42 | + */ |
|
43 | + public function getNewInstertId() |
|
44 | + { |
|
45 | + $newEnreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
46 | + return $newEnreg; |
|
47 | + } |
|
48 | + |
|
49 | + // Получаем форму |
|
50 | + |
|
51 | + /** |
|
52 | + * @param bool|null|string $action |
|
53 | + * @param int $instrid |
|
54 | + * @return \XoopsThemeForm |
|
55 | + */ |
|
56 | + public function getForm($action = false, $instrid = 0) |
|
57 | + { |
|
58 | + // Если нет $action |
|
59 | + if (false === $action) { |
|
60 | + $action = xoops_getenv('REQUEST_URI'); |
|
61 | + } |
|
62 | + |
|
63 | + // Подключаем формы |
|
64 | + include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
65 | + // Подключаем типы страниц |
|
66 | + $pagetypes = include $GLOBALS['xoops']->path('modules/instruction/include/pagetypes.inc.php'); |
|
67 | + |
|
68 | + // Название формы |
|
69 | + $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDPAGE) : sprintf(_AM_INSTRUCTION_FORMEDITPAGE); |
|
70 | + |
|
71 | + // Форма |
|
72 | + $form = new \XoopsThemeForm($title, 'instr_form_page', $action, 'post', true); |
|
73 | + // Название |
|
74 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
75 | + |
|
76 | + // Родительская страница |
|
77 | + // $pageHandler = xoops_getModuleHandler('page', 'instruction'); |
|
78 | + $pageHandler = new PageHandler; |
|
79 | + |
|
80 | + $criteria = new \CriteriaCompo(); |
|
81 | + // ID инструкции в которой данная страница |
|
82 | + $instrid_page = $this->isNew() ? $instrid : $this->getVar('instrid'); |
|
83 | + // Находим все страницы данной инструкции |
|
84 | + $criteria->add(new \Criteria('instrid', $instrid_page, '=')); |
|
85 | + // Если мы редактируем, то убрать текущую страницу из списка выбора родительской |
|
86 | + if (!$this->isNew()) { |
|
87 | + $criteria->add(new \Criteria('pageid', $this->getVar('pageid'), '<>')); |
|
88 | + } |
|
89 | + $criteria->setSort('weight'); |
|
90 | + $criteria->setOrder('ASC'); |
|
91 | + $inspage_arr = $pageHandler->getall($criteria); |
|
92 | + unset($criteria); |
|
93 | + // Подключаем трей |
|
94 | + include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
95 | + $mytree = new \XoopsObjectTree($inspage_arr, 'pageid', 'pid'); |
|
96 | + |
|
97 | + // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_PPAGEC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
98 | + $helper = Helper::getInstance(); |
|
99 | + $module = $helper->getModule(); |
|
100 | + |
|
101 | + if (Utility::checkVerXoops($module, '2.5.9')) { |
|
102 | + $mytree_select = $mytree->makeSelectElement('pid', 'title', '--', $this->getVar('pid'), true, 0, '', _AM_INSTRUCTION_PPAGEC); |
|
103 | + $form->addElement($mytree_select); |
|
104 | + } else { |
|
105 | + $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_PPAGEC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
106 | + } |
|
107 | + |
|
108 | + // Вес |
|
109 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_WEIGHTC, 'weight', 5, 5, $this->getVar('weight')), true); |
|
110 | + // Основной текст |
|
111 | + $form->addElement(Utility::getWysiwygForm(_AM_INSTRUCTION_HOMETEXTC, 'hometext', $this->getVar('hometext', 'e')), true); |
|
112 | + // Сноска |
|
113 | + $form_footnote = new \XoopsFormTextArea(_AM_INSTRUCTION_FOOTNOTEC, 'footnote', $this->getVar('footnote', 'e')); |
|
114 | + $form_footnote->setDescription(_AM_INSTRUCTION_FOOTNOTE_DSC); |
|
115 | + $form->addElement($form_footnote, false); |
|
116 | + unset($form_footnote); |
|
117 | + // Статус |
|
118 | + $form->addElement(new \XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false); |
|
119 | + // Тип страницы |
|
120 | + $form_type = new \XoopsFormSelect(_AM_INSTR_PAGETYPEC, 'type', $this->getVar('type')); |
|
121 | + $form_type->setDescription(_AM_INSTR_PAGETYPEC_DESC); |
|
122 | + $form_type->addOptionArray($pagetypes); |
|
123 | + $form->addElement($form_type, false); |
|
124 | + // Мета-теги ключевых слов |
|
125 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'keywords', 50, 255, $this->getVar('keywords')), false); |
|
126 | + // Мета-теги описания |
|
127 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'description', 50, 255, $this->getVar('description')), false); |
|
128 | + |
|
129 | + // Настройки |
|
130 | + $option_tray = new \XoopsFormElementTray(_OPTIONS, '<br>'); |
|
131 | + // HTML |
|
132 | + $html_checkbox = new \XoopsFormCheckBox('', 'dohtml', $this->getVar('dohtml')); |
|
133 | + $html_checkbox->addOption(1, _AM_INSTR_DOHTML); |
|
134 | + $option_tray->addElement($html_checkbox); |
|
135 | + // Смайлы |
|
136 | + $smiley_checkbox = new \XoopsFormCheckBox('', 'dosmiley', $this->getVar('dosmiley')); |
|
137 | + $smiley_checkbox->addOption(1, _AM_INSTR_DOSMILEY); |
|
138 | + $option_tray->addElement($smiley_checkbox); |
|
139 | + // ББ коды |
|
140 | + $xcode_checkbox = new \XoopsFormCheckBox('', 'doxcode', $this->getVar('doxcode')); |
|
141 | + $xcode_checkbox->addOption(1, _AM_INSTR_DOXCODE); |
|
142 | + $option_tray->addElement($xcode_checkbox); |
|
143 | + // |
|
144 | + $br_checkbox = new \XoopsFormCheckBox('', 'dobr', $this->getVar('dobr')); |
|
145 | + $br_checkbox->addOption(1, _AM_INSTR_DOAUTOWRAP); |
|
146 | + $option_tray->addElement($br_checkbox); |
|
147 | + // |
|
148 | + $form->addElement($option_tray); |
|
149 | + |
|
150 | + // Если мы редактируем страницу |
|
151 | + if (!$this->isNew()) { |
|
152 | + $form->addElement(new \XoopsFormHidden('pageid', $this->getVar('pageid'))); |
|
153 | + } else { |
|
154 | + $form->addElement(new \XoopsFormHidden('pageid', 0)); |
|
155 | + } |
|
156 | + // ID инструкции |
|
157 | + if ($instrid) { |
|
158 | + $form->addElement(new \XoopsFormHidden('instrid', $instrid)); |
|
159 | + } else { |
|
160 | + $form->addElement(new \XoopsFormHidden('instrid', 0)); |
|
161 | + } |
|
162 | + // |
|
163 | + $form->addElement(new \XoopsFormHidden('op', 'savepage')); |
|
164 | + // Кнопка |
|
165 | + $button_tray = new \XoopsFormElementTray('', ''); |
|
166 | + $button_tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
167 | + $save_btn = new \XoopsFormButton('', 'cancel', _AM_INSTR_SAVEFORM); |
|
168 | + $save_btn->setExtra('onclick="instrSavePage();"'); |
|
169 | + $button_tray->addElement($save_btn); |
|
170 | + $form->addElement($button_tray); |
|
171 | + |
|
172 | + return $form; |
|
173 | + } |
|
174 | + |
|
175 | + // |
|
176 | + |
|
177 | + /** |
|
178 | + * @return mixed |
|
179 | + */ |
|
180 | + public function getInstrid() |
|
181 | + { |
|
182 | + // Возвращаем ID инструкции |
|
183 | + return $this->getVar('instrid'); |
|
184 | + } |
|
185 | 185 | } |
@@ -14,52 +14,52 @@ |
||
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 | - $pageHandler = new PageHandler; |
|
52 | - // Находим число активных страниц |
|
53 | - $criteria = new \CriteriaCompo(); |
|
54 | - $criteria->add(new \Criteria('instrid', $instrid, '=')); |
|
55 | - $criteria->add(new \Criteria('status ', '0', '>')); |
|
56 | - // Число страниц |
|
57 | - $pages = $pageHandler->getCount($criteria); |
|
58 | - 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 | + $pageHandler = new PageHandler; |
|
52 | + // Находим число активных страниц |
|
53 | + $criteria = new \CriteriaCompo(); |
|
54 | + $criteria->add(new \Criteria('instrid', $instrid, '=')); |
|
55 | + $criteria->add(new \Criteria('status ', '0', '>')); |
|
56 | + // Число страниц |
|
57 | + $pages = $pageHandler->getCount($criteria); |
|
58 | + unset($criteria); |
|
59 | 59 | |
60 | - // Сохраняем это число |
|
61 | - $sql = sprintf('UPDATE `%s` SET `pages` = %u, `dateupdated` = %u WHERE `instrid` = %u', $this->table, $pages, time(), $instrid); |
|
62 | - // |
|
63 | - return $this->db->query($sql); |
|
64 | - } |
|
60 | + // Сохраняем это число |
|
61 | + $sql = sprintf('UPDATE `%s` SET `pages` = %u, `dateupdated` = %u WHERE `instrid` = %u', $this->table, $pages, time(), $instrid); |
|
62 | + // |
|
63 | + return $this->db->query($sql); |
|
64 | + } |
|
65 | 65 | } |
@@ -12,114 +12,114 @@ |
||
12 | 12 | */ |
13 | 13 | class Instruction extends \XoopsObject |
14 | 14 | { |
15 | - // constructor |
|
16 | - public function __construct() |
|
17 | - { |
|
18 | - // $this->XoopsObject(); |
|
19 | - $this->initVar('instrid', XOBJ_DTYPE_INT, null, false, 11); |
|
20 | - $this->initVar('cid', XOBJ_DTYPE_INT, 0, false, 5); |
|
21 | - $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11); |
|
22 | - $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false); |
|
23 | - $this->initVar('status', XOBJ_DTYPE_INT, 0, false, 1); |
|
24 | - $this->initVar('pages', XOBJ_DTYPE_INT, 0, false, 11); |
|
25 | - $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
|
26 | - $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
27 | - $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
28 | - $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false); |
|
29 | - $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false); |
|
15 | + // constructor |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + // $this->XoopsObject(); |
|
19 | + $this->initVar('instrid', XOBJ_DTYPE_INT, null, false, 11); |
|
20 | + $this->initVar('cid', XOBJ_DTYPE_INT, 0, false, 5); |
|
21 | + $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11); |
|
22 | + $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false); |
|
23 | + $this->initVar('status', XOBJ_DTYPE_INT, 0, false, 1); |
|
24 | + $this->initVar('pages', XOBJ_DTYPE_INT, 0, false, 11); |
|
25 | + $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
|
26 | + $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
27 | + $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
28 | + $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false); |
|
29 | + $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false); |
|
30 | 30 | |
31 | - // Нет в таблице |
|
32 | - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
|
33 | - $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false); |
|
34 | - } |
|
31 | + // Нет в таблице |
|
32 | + $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
|
33 | + $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @return mixed |
|
38 | - */ |
|
39 | - public function getNewInstertId() |
|
40 | - { |
|
41 | - $newEnreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
42 | - return $newEnreg; |
|
43 | - } |
|
36 | + /** |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | + public function getNewInstertId() |
|
40 | + { |
|
41 | + $newEnreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
42 | + return $newEnreg; |
|
43 | + } |
|
44 | 44 | |
45 | - // Получаем форму |
|
45 | + // Получаем форму |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param bool|null|string $action |
|
49 | - * @return \XoopsThemeForm |
|
50 | - */ |
|
51 | - public function getForm($action = false) |
|
52 | - { |
|
53 | - global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
54 | - // Если нет $action |
|
55 | - if (false === $action) { |
|
56 | - $action = xoops_getenv('REQUEST_URI'); |
|
57 | - } |
|
58 | - // Подключаем формы |
|
59 | - include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
47 | + /** |
|
48 | + * @param bool|null|string $action |
|
49 | + * @return \XoopsThemeForm |
|
50 | + */ |
|
51 | + public function getForm($action = false) |
|
52 | + { |
|
53 | + global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
54 | + // Если нет $action |
|
55 | + if (false === $action) { |
|
56 | + $action = xoops_getenv('REQUEST_URI'); |
|
57 | + } |
|
58 | + // Подключаем формы |
|
59 | + include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
60 | 60 | |
61 | - // Название формы |
|
62 | - $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDINSTR) : sprintf(_AM_INSTRUCTION_FORMEDITINSTR); |
|
61 | + // Название формы |
|
62 | + $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDINSTR) : sprintf(_AM_INSTRUCTION_FORMEDITINSTR); |
|
63 | 63 | |
64 | - // Форма |
|
65 | - $form = new \XoopsThemeForm($title, 'forminstr', $action, 'post', true); |
|
66 | - //$form->setExtra('enctype="multipart/form-data"'); |
|
67 | - // Название инструкции |
|
68 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
69 | - // Категория |
|
70 | - $categoryHandler = new CategoryHandler; |
|
71 | - $criteria = new \CriteriaCompo(); |
|
72 | - $criteria->setSort('weight ASC, title'); |
|
73 | - $criteria->setOrder('ASC'); |
|
74 | - $instructioncat_arr = $categoryHandler->getall($criteria); |
|
75 | - unset($criteria); |
|
76 | - // Подключаем трей |
|
77 | - include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
78 | - $mytree = new \XoopsObjectTree($instructioncat_arr, 'cid', 'pid'); |
|
64 | + // Форма |
|
65 | + $form = new \XoopsThemeForm($title, 'forminstr', $action, 'post', true); |
|
66 | + //$form->setExtra('enctype="multipart/form-data"'); |
|
67 | + // Название инструкции |
|
68 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
69 | + // Категория |
|
70 | + $categoryHandler = new CategoryHandler; |
|
71 | + $criteria = new \CriteriaCompo(); |
|
72 | + $criteria->setSort('weight ASC, title'); |
|
73 | + $criteria->setOrder('ASC'); |
|
74 | + $instructioncat_arr = $categoryHandler->getall($criteria); |
|
75 | + unset($criteria); |
|
76 | + // Подключаем трей |
|
77 | + include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
78 | + $mytree = new \XoopsObjectTree($instructioncat_arr, 'cid', 'pid'); |
|
79 | 79 | |
80 | - // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
|
81 | - $helper = Helper::getInstance(); |
|
82 | - $module = $helper->getModule(); |
|
80 | + // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
|
81 | + $helper = Helper::getInstance(); |
|
82 | + $module = $helper->getModule(); |
|
83 | 83 | |
84 | - if (Utility::checkVerXoops($module, '2.5.9')) { |
|
85 | - $mytree_select = $mytree->makeSelectElement('cid', 'title', '--', $this->getVar('cid'), true, 0, '', _AM_INSTRUCTION_CATC); |
|
86 | - $form->addElement($mytree_select); |
|
87 | - } else { |
|
88 | - $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
|
89 | - } |
|
84 | + if (Utility::checkVerXoops($module, '2.5.9')) { |
|
85 | + $mytree_select = $mytree->makeSelectElement('cid', 'title', '--', $this->getVar('cid'), true, 0, '', _AM_INSTRUCTION_CATC); |
|
86 | + $form->addElement($mytree_select); |
|
87 | + } else { |
|
88 | + $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
|
89 | + } |
|
90 | 90 | |
91 | - // Описание |
|
92 | - $form->addElement(Utility::getWysiwygForm(_AM_INSTRUCTION_DESCRIPTIONC, 'description', $this->getVar('description', 'e')), true); |
|
93 | - // Статус |
|
94 | - $form->addElement(new \XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false); |
|
91 | + // Описание |
|
92 | + $form->addElement(Utility::getWysiwygForm(_AM_INSTRUCTION_DESCRIPTIONC, 'description', $this->getVar('description', 'e')), true); |
|
93 | + // Статус |
|
94 | + $form->addElement(new \XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false); |
|
95 | 95 | |
96 | - // Теги |
|
97 | - $dir_tag_ok = false; |
|
98 | - if (is_dir('../../tag') || is_dir('../tag')) { |
|
99 | - $dir_tag_ok = true; |
|
100 | - } |
|
101 | - // Если влючена поддержка тегов и есть модуль tag |
|
102 | - if (xoops_getModuleOption('usetag', 'instruction') && $dir_tag_ok) { |
|
103 | - $itemIdForTag = $this->isNew() ? 0 : $this->getVar('instrid'); |
|
104 | - // Подключаем форму тегов |
|
105 | - include_once $GLOBALS['xoops']->path('modules/tag/include/formtag.php'); |
|
106 | - // Добавляем элемент в форму |
|
107 | - $form->addElement(new \XoopsFormTag('tag', 60, 255, $itemIdForTag, 0)); |
|
108 | - } |
|
96 | + // Теги |
|
97 | + $dir_tag_ok = false; |
|
98 | + if (is_dir('../../tag') || is_dir('../tag')) { |
|
99 | + $dir_tag_ok = true; |
|
100 | + } |
|
101 | + // Если влючена поддержка тегов и есть модуль tag |
|
102 | + if (xoops_getModuleOption('usetag', 'instruction') && $dir_tag_ok) { |
|
103 | + $itemIdForTag = $this->isNew() ? 0 : $this->getVar('instrid'); |
|
104 | + // Подключаем форму тегов |
|
105 | + include_once $GLOBALS['xoops']->path('modules/tag/include/formtag.php'); |
|
106 | + // Добавляем элемент в форму |
|
107 | + $form->addElement(new \XoopsFormTag('tag', 60, 255, $itemIdForTag, 0)); |
|
108 | + } |
|
109 | 109 | |
110 | - // Мета-теги ключевых слов |
|
111 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false); |
|
112 | - // Мета-теги описания |
|
113 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
|
110 | + // Мета-теги ключевых слов |
|
111 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false); |
|
112 | + // Мета-теги описания |
|
113 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
|
114 | 114 | |
115 | - // Если мы редактируем категорию |
|
116 | - if (!$this->isNew()) { |
|
117 | - $form->addElement(new \XoopsFormHidden('instrid', $this->getVar('instrid'))); |
|
118 | - } |
|
119 | - // |
|
120 | - $form->addElement(new \XoopsFormHidden('op', 'saveinstr')); |
|
121 | - // Кнопка |
|
122 | - $form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
123 | - return $form; |
|
124 | - } |
|
115 | + // Если мы редактируем категорию |
|
116 | + if (!$this->isNew()) { |
|
117 | + $form->addElement(new \XoopsFormHidden('instrid', $this->getVar('instrid'))); |
|
118 | + } |
|
119 | + // |
|
120 | + $form->addElement(new \XoopsFormHidden('op', 'saveinstr')); |
|
121 | + // Кнопка |
|
122 | + $form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
123 | + return $form; |
|
124 | + } |
|
125 | 125 | } |
@@ -14,28 +14,28 @@ |
||
14 | 14 | */ |
15 | 15 | class CategoryHandler extends \XoopsPersistableObjectHandler |
16 | 16 | { |
17 | - /** |
|
18 | - * @param null|mixed $db |
|
19 | - */ |
|
20 | - public function __construct(\XoopsDatabase $db = null) |
|
21 | - { |
|
22 | - parent::__construct($db, 'instruction_cat', Category::class, 'cid', 'title'); |
|
23 | - } |
|
17 | + /** |
|
18 | + * @param null|mixed $db |
|
19 | + */ |
|
20 | + public function __construct(\XoopsDatabase $db = null) |
|
21 | + { |
|
22 | + parent::__construct($db, 'instruction_cat', Category::class, 'cid', 'title'); |
|
23 | + } |
|
24 | 24 | |
25 | - // Обновление даты обновления категории |
|
25 | + // Обновление даты обновления категории |
|
26 | 26 | |
27 | - /** |
|
28 | - * @param int $cid |
|
29 | - * @param null|int $time |
|
30 | - * @return mixed |
|
31 | - */ |
|
32 | - public function updateDateupdated($cid = 0, $time = null) |
|
33 | - { |
|
34 | - // Если не передали время |
|
35 | - $time = null === $time ? time() : (int)$time; |
|
36 | - // |
|
37 | - $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid); |
|
38 | - // |
|
39 | - return $this->db->query($sql); |
|
40 | - } |
|
27 | + /** |
|
28 | + * @param int $cid |
|
29 | + * @param null|int $time |
|
30 | + * @return mixed |
|
31 | + */ |
|
32 | + public function updateDateupdated($cid = 0, $time = null) |
|
33 | + { |
|
34 | + // Если не передали время |
|
35 | + $time = null === $time ? time() : (int)$time; |
|
36 | + // |
|
37 | + $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid); |
|
38 | + // |
|
39 | + return $this->db->query($sql); |
|
40 | + } |
|
41 | 41 | } |
@@ -16,60 +16,60 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class Category extends \XoopsObject |
18 | 18 | { |
19 | - // constructor |
|
20 | - public function __construct() |
|
21 | - { |
|
22 | - // $this->XoopsObject(); |
|
23 | - $this->initVar('cid', XOBJ_DTYPE_INT, null, false, 5); |
|
24 | - $this->initVar('pid', XOBJ_DTYPE_INT, 0, false, 5); |
|
25 | - $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false); |
|
26 | - $this->initVar('imgurl', XOBJ_DTYPE_TXTBOX, '', false); |
|
27 | - $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
|
28 | - $this->initVar('weight', XOBJ_DTYPE_INT, 0, false, 11); |
|
29 | - $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
30 | - $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
31 | - $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false); |
|
32 | - $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false); |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * @return mixed |
|
37 | - */ |
|
38 | - public function getNewInstertId() |
|
39 | - { |
|
40 | - $newEnreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
41 | - return $newEnreg; |
|
42 | - } |
|
43 | - |
|
44 | - // Получаем форму |
|
45 | - |
|
46 | - /** |
|
47 | - * @param bool|null|string $action |
|
48 | - * @return \XoopsThemeForm |
|
49 | - */ |
|
50 | - public function getForm($action = false) |
|
51 | - { |
|
52 | - //global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
53 | - require_once __DIR__ . '/../include/common.php'; |
|
54 | - // Если нет $action |
|
55 | - if (false === $action) { |
|
56 | - $action = xoops_getenv('REQUEST_URI'); |
|
57 | - } |
|
58 | - // Подключаем формы |
|
59 | - include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
60 | - |
|
61 | - // Название формы |
|
62 | - $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDCAT) : sprintf(_AM_INSTRUCTION_FORMEDITCAT); |
|
63 | - |
|
64 | - // Форма |
|
65 | - $form = new \XoopsThemeForm($title, 'formcat', $action, 'post', true); |
|
66 | - //$form->setExtra('enctype="multipart/form-data"'); |
|
67 | - // Название категории |
|
68 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
69 | - // Редактор |
|
70 | - $form->addElement(new \XoopsFormTextArea(_AM_INSTRUCTION_DSCC, 'description', $this->getVar('description', 'e')), true); |
|
71 | - //image |
|
72 | - /* |
|
19 | + // constructor |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + // $this->XoopsObject(); |
|
23 | + $this->initVar('cid', XOBJ_DTYPE_INT, null, false, 5); |
|
24 | + $this->initVar('pid', XOBJ_DTYPE_INT, 0, false, 5); |
|
25 | + $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false); |
|
26 | + $this->initVar('imgurl', XOBJ_DTYPE_TXTBOX, '', false); |
|
27 | + $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
|
28 | + $this->initVar('weight', XOBJ_DTYPE_INT, 0, false, 11); |
|
29 | + $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
30 | + $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
31 | + $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false); |
|
32 | + $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false); |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * @return mixed |
|
37 | + */ |
|
38 | + public function getNewInstertId() |
|
39 | + { |
|
40 | + $newEnreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
41 | + return $newEnreg; |
|
42 | + } |
|
43 | + |
|
44 | + // Получаем форму |
|
45 | + |
|
46 | + /** |
|
47 | + * @param bool|null|string $action |
|
48 | + * @return \XoopsThemeForm |
|
49 | + */ |
|
50 | + public function getForm($action = false) |
|
51 | + { |
|
52 | + //global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
53 | + require_once __DIR__ . '/../include/common.php'; |
|
54 | + // Если нет $action |
|
55 | + if (false === $action) { |
|
56 | + $action = xoops_getenv('REQUEST_URI'); |
|
57 | + } |
|
58 | + // Подключаем формы |
|
59 | + include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
60 | + |
|
61 | + // Название формы |
|
62 | + $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDCAT) : sprintf(_AM_INSTRUCTION_FORMEDITCAT); |
|
63 | + |
|
64 | + // Форма |
|
65 | + $form = new \XoopsThemeForm($title, 'formcat', $action, 'post', true); |
|
66 | + //$form->setExtra('enctype="multipart/form-data"'); |
|
67 | + // Название категории |
|
68 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
69 | + // Редактор |
|
70 | + $form->addElement(new \XoopsFormTextArea(_AM_INSTRUCTION_DSCC, 'description', $this->getVar('description', 'e')), true); |
|
71 | + //image |
|
72 | + /* |
|
73 | 73 | $downloadscat_img = $this->getVar('imgurl') ? $this->getVar('imgurl') : 'blank.gif'; |
74 | 74 | $uploadirectory='/uploads/tdmdownloads/images/cats'; |
75 | 75 | $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG,'<br>'); |
@@ -88,107 +88,107 @@ discard block |
||
88 | 88 | $imgtray->addElement($fileseltray); |
89 | 89 | $form->addElement($imgtray); |
90 | 90 | */ |
91 | - // Родительская категория |
|
92 | - // $categoryHandler = xoops_getModuleHandler('category', 'instruction'); |
|
93 | - $criteria = new \CriteriaCompo(); |
|
94 | - // Если мы редактируем, то убрать текущую категорию из списка выбора родительской |
|
95 | - if (!$this->isNew()) { |
|
96 | - $criteria->add(new \Criteria('cid', $this->getVar('cid'), '<>')); |
|
97 | - } |
|
98 | - $criteria->setSort('weight ASC, title'); |
|
99 | - $criteria->setOrder('ASC'); |
|
100 | - |
|
101 | - $categoryHandler = new CategoryHandler; |
|
102 | - $instructioncat_arr = $categoryHandler->getall($criteria); |
|
103 | - unset($criteria); |
|
104 | - // Подключаем трей |
|
105 | - include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
106 | - $mytree = new \XoopsObjectTree($instructioncat_arr, 'cid', 'pid'); |
|
107 | - |
|
108 | - // $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_PCATC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
109 | - |
|
110 | - $helper = Helper::getInstance(); |
|
111 | - $module = $helper->getModule(); |
|
112 | - |
|
113 | - if (Utility::checkVerXoops($module, '2.5.9')) { |
|
114 | - $mytree_select = $mytree->makeSelectElement('pid', 'title', '--', $this->getVar('pid'), true, 0, '', _AM_INSTRUCTION_PCATC); |
|
115 | - $form->addElement($mytree_select); |
|
116 | - } else { |
|
117 | - $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_PCATC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
118 | - } |
|
119 | - |
|
120 | - // Вес |
|
121 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_WEIGHTC, 'weight', 5, 5, $this->getVar('weight')), true); |
|
122 | - // Мета-теги ключевых слов |
|
123 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false); |
|
124 | - // Мета-теги описания |
|
125 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
|
126 | - |
|
127 | - // ========================================================== |
|
128 | - // ========================================================== |
|
129 | - |
|
130 | - // Права |
|
131 | - $memberHandler = xoops_getHandler('member'); |
|
132 | - $group_list = $memberHandler->getGroupList(); |
|
133 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
134 | - $full_list = array_keys($group_list); |
|
135 | - |
|
136 | - // Права на просмотр |
|
137 | - $groups_ids = []; |
|
138 | - // Если мы редактируем |
|
139 | - if (!$this->isNew()) { |
|
140 | - $groups_ids = $gpermHandler->getGroupIds('instruction_view', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
141 | - $groups_ids = array_values($groups_ids); |
|
142 | - $groups_instr_view = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $groups_ids); |
|
143 | - } else { |
|
144 | - $groups_instr_view = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $full_list); |
|
145 | - } |
|
146 | - $groups_instr_view->addOptionArray($group_list); |
|
147 | - $form->addElement($groups_instr_view); |
|
148 | - |
|
149 | - // Права на отправку |
|
150 | - $groups_ids = []; |
|
151 | - if (!$this->isNew()) { |
|
152 | - $groups_ids = $gpermHandler->getGroupIds('instruction_submit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
153 | - $groups_ids = array_values($groups_ids); |
|
154 | - $groups_instr_submit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $groups_ids); |
|
155 | - } else { |
|
156 | - $groups_instr_submit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $full_list); |
|
157 | - } |
|
158 | - $groups_instr_submit->addOptionArray($group_list); |
|
159 | - $form->addElement($groups_instr_submit); |
|
160 | - |
|
161 | - // Права на редактирование |
|
162 | - $groups_ids = []; |
|
163 | - if (!$this->isNew()) { |
|
164 | - $groups_ids = $gpermHandler->getGroupIds('instruction_edit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
165 | - $groups_ids = array_values($groups_ids); |
|
166 | - $groups_instr_edit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $groups_ids); |
|
167 | - } else { |
|
168 | - $groups_instr_edit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $full_list); |
|
169 | - } |
|
170 | - $groups_instr_edit->addOptionArray($group_list); |
|
171 | - $form->addElement($groups_instr_edit); |
|
172 | - |
|
173 | - // ========================================================== |
|
174 | - // ========================================================== |
|
175 | - |
|
176 | - // Если мы редактируем категорию |
|
177 | - if (!$this->isNew()) { |
|
178 | - $form->addElement(new \XoopsFormHidden('cid', $this->getVar('cid'))); |
|
179 | - //$form->addElement( new \XoopsFormHidden( 'catmodify', true)); |
|
180 | - } |
|
181 | - // |
|
182 | - $form->addElement(new \XoopsFormHidden('op', 'savecat')); |
|
183 | - // Кнопка |
|
184 | - $button_tray = new \XoopsFormElementTray('', ''); |
|
185 | - $submit_btn = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
186 | - $button_tray->addElement($submit_btn); |
|
187 | - $cancel_btn = new \XoopsFormButton('', 'cancel', _CANCEL, 'cancel'); |
|
188 | - $cancel_btn->setExtra('onclick="javascript:history.go(-1);"'); |
|
189 | - $button_tray->addElement($cancel_btn); |
|
190 | - $form->addElement($button_tray); |
|
191 | - |
|
192 | - return $form; |
|
193 | - } |
|
91 | + // Родительская категория |
|
92 | + // $categoryHandler = xoops_getModuleHandler('category', 'instruction'); |
|
93 | + $criteria = new \CriteriaCompo(); |
|
94 | + // Если мы редактируем, то убрать текущую категорию из списка выбора родительской |
|
95 | + if (!$this->isNew()) { |
|
96 | + $criteria->add(new \Criteria('cid', $this->getVar('cid'), '<>')); |
|
97 | + } |
|
98 | + $criteria->setSort('weight ASC, title'); |
|
99 | + $criteria->setOrder('ASC'); |
|
100 | + |
|
101 | + $categoryHandler = new CategoryHandler; |
|
102 | + $instructioncat_arr = $categoryHandler->getall($criteria); |
|
103 | + unset($criteria); |
|
104 | + // Подключаем трей |
|
105 | + include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
106 | + $mytree = new \XoopsObjectTree($instructioncat_arr, 'cid', 'pid'); |
|
107 | + |
|
108 | + // $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_PCATC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
109 | + |
|
110 | + $helper = Helper::getInstance(); |
|
111 | + $module = $helper->getModule(); |
|
112 | + |
|
113 | + if (Utility::checkVerXoops($module, '2.5.9')) { |
|
114 | + $mytree_select = $mytree->makeSelectElement('pid', 'title', '--', $this->getVar('pid'), true, 0, '', _AM_INSTRUCTION_PCATC); |
|
115 | + $form->addElement($mytree_select); |
|
116 | + } else { |
|
117 | + $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_PCATC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
118 | + } |
|
119 | + |
|
120 | + // Вес |
|
121 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_WEIGHTC, 'weight', 5, 5, $this->getVar('weight')), true); |
|
122 | + // Мета-теги ключевых слов |
|
123 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false); |
|
124 | + // Мета-теги описания |
|
125 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
|
126 | + |
|
127 | + // ========================================================== |
|
128 | + // ========================================================== |
|
129 | + |
|
130 | + // Права |
|
131 | + $memberHandler = xoops_getHandler('member'); |
|
132 | + $group_list = $memberHandler->getGroupList(); |
|
133 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
134 | + $full_list = array_keys($group_list); |
|
135 | + |
|
136 | + // Права на просмотр |
|
137 | + $groups_ids = []; |
|
138 | + // Если мы редактируем |
|
139 | + if (!$this->isNew()) { |
|
140 | + $groups_ids = $gpermHandler->getGroupIds('instruction_view', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
141 | + $groups_ids = array_values($groups_ids); |
|
142 | + $groups_instr_view = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $groups_ids); |
|
143 | + } else { |
|
144 | + $groups_instr_view = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $full_list); |
|
145 | + } |
|
146 | + $groups_instr_view->addOptionArray($group_list); |
|
147 | + $form->addElement($groups_instr_view); |
|
148 | + |
|
149 | + // Права на отправку |
|
150 | + $groups_ids = []; |
|
151 | + if (!$this->isNew()) { |
|
152 | + $groups_ids = $gpermHandler->getGroupIds('instruction_submit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
153 | + $groups_ids = array_values($groups_ids); |
|
154 | + $groups_instr_submit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $groups_ids); |
|
155 | + } else { |
|
156 | + $groups_instr_submit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $full_list); |
|
157 | + } |
|
158 | + $groups_instr_submit->addOptionArray($group_list); |
|
159 | + $form->addElement($groups_instr_submit); |
|
160 | + |
|
161 | + // Права на редактирование |
|
162 | + $groups_ids = []; |
|
163 | + if (!$this->isNew()) { |
|
164 | + $groups_ids = $gpermHandler->getGroupIds('instruction_edit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
165 | + $groups_ids = array_values($groups_ids); |
|
166 | + $groups_instr_edit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $groups_ids); |
|
167 | + } else { |
|
168 | + $groups_instr_edit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $full_list); |
|
169 | + } |
|
170 | + $groups_instr_edit->addOptionArray($group_list); |
|
171 | + $form->addElement($groups_instr_edit); |
|
172 | + |
|
173 | + // ========================================================== |
|
174 | + // ========================================================== |
|
175 | + |
|
176 | + // Если мы редактируем категорию |
|
177 | + if (!$this->isNew()) { |
|
178 | + $form->addElement(new \XoopsFormHidden('cid', $this->getVar('cid'))); |
|
179 | + //$form->addElement( new \XoopsFormHidden( 'catmodify', true)); |
|
180 | + } |
|
181 | + // |
|
182 | + $form->addElement(new \XoopsFormHidden('op', 'savecat')); |
|
183 | + // Кнопка |
|
184 | + $button_tray = new \XoopsFormElementTray('', ''); |
|
185 | + $submit_btn = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
186 | + $button_tray->addElement($submit_btn); |
|
187 | + $cancel_btn = new \XoopsFormButton('', 'cancel', _CANCEL, 'cancel'); |
|
188 | + $cancel_btn->setExtra('onclick="javascript:history.go(-1);"'); |
|
189 | + $button_tray->addElement($cancel_btn); |
|
190 | + $form->addElement($button_tray); |
|
191 | + |
|
192 | + return $form; |
|
193 | + } |
|
194 | 194 | } |
@@ -33,48 +33,48 @@ |
||
33 | 33 | */ |
34 | 34 | class Breadcrumb |
35 | 35 | { |
36 | - public $dirname; |
|
37 | - private $bread = []; |
|
36 | + public $dirname; |
|
37 | + private $bread = []; |
|
38 | 38 | |
39 | - /** |
|
40 | - * |
|
41 | - */ |
|
42 | - public function __construct() |
|
43 | - { |
|
44 | - $this->dirname = basename(dirname(dirname(__DIR__))); |
|
45 | - } |
|
39 | + /** |
|
40 | + * |
|
41 | + */ |
|
42 | + public function __construct() |
|
43 | + { |
|
44 | + $this->dirname = basename(dirname(dirname(__DIR__))); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Add link to breadcrumb |
|
49 | - * |
|
50 | - * @param string $title |
|
51 | - * @param string $link |
|
52 | - */ |
|
53 | - public function addLink($title = '', $link = '') |
|
54 | - { |
|
55 | - $this->bread[] = [ |
|
56 | - 'link' => $link, |
|
57 | - 'title' => $title |
|
58 | - ]; |
|
59 | - } |
|
47 | + /** |
|
48 | + * Add link to breadcrumb |
|
49 | + * |
|
50 | + * @param string $title |
|
51 | + * @param string $link |
|
52 | + */ |
|
53 | + public function addLink($title = '', $link = '') |
|
54 | + { |
|
55 | + $this->bread[] = [ |
|
56 | + 'link' => $link, |
|
57 | + 'title' => $title |
|
58 | + ]; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Render BreadCrumb |
|
63 | - * |
|
64 | - */ |
|
65 | - public function render() |
|
66 | - { |
|
67 | - if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
68 | - require_once $GLOBALS['xoops']->path('class/theme.php'); |
|
69 | - $GLOBALS['xoTheme'] = new xos_opal_Theme(); |
|
70 | - } |
|
61 | + /** |
|
62 | + * Render BreadCrumb |
|
63 | + * |
|
64 | + */ |
|
65 | + public function render() |
|
66 | + { |
|
67 | + if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
68 | + require_once $GLOBALS['xoops']->path('class/theme.php'); |
|
69 | + $GLOBALS['xoTheme'] = new xos_opal_Theme(); |
|
70 | + } |
|
71 | 71 | |
72 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
73 | - $breadcrumbTpl = new \XoopsTpl(); |
|
74 | - $breadcrumbTpl->assign('breadcrumb', $this->bread); |
|
75 | - $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
|
76 | - unset($breadcrumbTpl); |
|
72 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
73 | + $breadcrumbTpl = new \XoopsTpl(); |
|
74 | + $breadcrumbTpl->assign('breadcrumb', $this->bread); |
|
75 | + $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
|
76 | + unset($breadcrumbTpl); |
|
77 | 77 | |
78 | - return $html; |
|
79 | - } |
|
78 | + return $html; |
|
79 | + } |
|
80 | 80 | } |