@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | // $categoryHandler = xoops_getModuleHandler('category', 'instruction'); |
| 93 | 93 | $criteria = new \CriteriaCompo(); |
| 94 | 94 | // Если мы редактируем, то убрать текущую категорию из списка выбора родительской |
| 95 | - if (!$this->isNew()) { |
|
| 95 | + if ( ! $this->isNew()) { |
|
| 96 | 96 | $criteria->add(new \Criteria('cid', $this->getVar('cid'), '<>')); |
| 97 | 97 | } |
| 98 | 98 | $criteria->setSort('weight ASC, title'); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | // Права на просмотр |
| 139 | 139 | $groups_ids = []; |
| 140 | 140 | // Если мы редактируем |
| 141 | - if (!$this->isNew()) { |
|
| 141 | + if ( ! $this->isNew()) { |
|
| 142 | 142 | $groups_ids = $gpermHandler->getGroupIds('instruction_view', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
| 143 | 143 | $groups_ids = array_values($groups_ids); |
| 144 | 144 | $groups_instr_view = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $groups_ids); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | // Права на отправку |
| 152 | 152 | $groups_ids = []; |
| 153 | - if (!$this->isNew()) { |
|
| 153 | + if ( ! $this->isNew()) { |
|
| 154 | 154 | $groups_ids = $gpermHandler->getGroupIds('instruction_submit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
| 155 | 155 | $groups_ids = array_values($groups_ids); |
| 156 | 156 | $groups_instr_submit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $groups_ids); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | // Права на редактирование |
| 164 | 164 | $groups_ids = []; |
| 165 | - if (!$this->isNew()) { |
|
| 165 | + if ( ! $this->isNew()) { |
|
| 166 | 166 | $groups_ids = $gpermHandler->getGroupIds('instruction_edit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
| 167 | 167 | $groups_ids = array_values($groups_ids); |
| 168 | 168 | $groups_instr_edit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $groups_ids); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | // ========================================================== |
| 177 | 177 | |
| 178 | 178 | // Если мы редактируем категорию |
| 179 | - if (!$this->isNew()) { |
|
| 179 | + if ( ! $this->isNew()) { |
|
| 180 | 180 | $form->addElement(new \XoopsFormHidden('cid', $this->getVar('cid'))); |
| 181 | 181 | //$form->addElement( new \XoopsFormHidden( 'catmodify', true)); |
| 182 | 182 | } |
@@ -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,108 +88,108 @@ 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 | } |
| 195 | 195 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | // Находим все страницы данной инструкции |
| 87 | 87 | $criteria->add(new \Criteria('instrid', $instrid_page, '=')); |
| 88 | 88 | // Если мы редактируем, то убрать текущую страницу из списка выбора родительской |
| 89 | - if (!$this->isNew()) { |
|
| 89 | + if ( ! $this->isNew()) { |
|
| 90 | 90 | $criteria->add(new \Criteria('pageid', $this->getVar('pageid'), '<>')); |
| 91 | 91 | } |
| 92 | 92 | $criteria->setSort('weight'); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $form->addElement($option_tray); |
| 152 | 152 | |
| 153 | 153 | // Если мы редактируем страницу |
| 154 | - if (!$this->isNew()) { |
|
| 154 | + if ( ! $this->isNew()) { |
|
| 155 | 155 | $form->addElement(new \XoopsFormHidden('pageid', $this->getVar('pageid'))); |
| 156 | 156 | } else { |
| 157 | 157 | $form->addElement(new \XoopsFormHidden('pageid', 0)); |
@@ -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 | } |
@@ -16,28 +16,28 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class CategoryHandler extends \XoopsPersistableObjectHandler |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @param null|mixed $db |
|
| 21 | - */ |
|
| 22 | - public function __construct(\XoopsDatabase $db = null) |
|
| 23 | - { |
|
| 24 | - parent::__construct($db, 'instruction_cat', Category::class, 'cid', 'title'); |
|
| 25 | - } |
|
| 19 | + /** |
|
| 20 | + * @param null|mixed $db |
|
| 21 | + */ |
|
| 22 | + public function __construct(\XoopsDatabase $db = null) |
|
| 23 | + { |
|
| 24 | + parent::__construct($db, 'instruction_cat', Category::class, 'cid', 'title'); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - // Обновление даты обновления категории |
|
| 27 | + // Обновление даты обновления категории |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @param int $cid |
|
| 31 | - * @param null|int $time |
|
| 32 | - * @return mixed |
|
| 33 | - */ |
|
| 34 | - public function updateDateupdated($cid = 0, $time = null) |
|
| 35 | - { |
|
| 36 | - // Если не передали время |
|
| 37 | - $time = null === $time ? time() : (int)$time; |
|
| 38 | - // |
|
| 39 | - $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid); |
|
| 40 | - // |
|
| 41 | - return $this->db->query($sql); |
|
| 42 | - } |
|
| 29 | + /** |
|
| 30 | + * @param int $cid |
|
| 31 | + * @param null|int $time |
|
| 32 | + * @return mixed |
|
| 33 | + */ |
|
| 34 | + public function updateDateupdated($cid = 0, $time = null) |
|
| 35 | + { |
|
| 36 | + // Если не передали время |
|
| 37 | + $time = null === $time ? time() : (int)$time; |
|
| 38 | + // |
|
| 39 | + $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid); |
|
| 40 | + // |
|
| 41 | + return $this->db->query($sql); |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -34,9 +34,9 @@ |
||
| 34 | 34 | public function updateDateupdated($cid = 0, $time = null) |
| 35 | 35 | { |
| 36 | 36 | // Если не передали время |
| 37 | - $time = null === $time ? time() : (int)$time; |
|
| 37 | + $time = null === $time ? time() : (int) $time; |
|
| 38 | 38 | // |
| 39 | - $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid); |
|
| 39 | + $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int) $cid); |
|
| 40 | 40 | // |
| 41 | 41 | return $this->db->query($sql); |
| 42 | 42 | } |
@@ -118,7 +118,7 @@ |
||
| 118 | 118 | $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
| 119 | 119 | |
| 120 | 120 | // Если мы редактируем категорию |
| 121 | - if (!$this->isNew()) { |
|
| 121 | + if ( ! $this->isNew()) { |
|
| 122 | 122 | $form->addElement(new \XoopsFormHidden('instrid', $this->getVar('instrid'))); |
| 123 | 123 | } |
| 124 | 124 | // |
@@ -12,115 +12,115 @@ |
||
| 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); |
|
| 30 | - |
|
| 31 | - // Нет в таблице |
|
| 32 | - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
|
| 33 | - $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @return mixed |
|
| 38 | - */ |
|
| 39 | - public function getNewInstertId() |
|
| 40 | - { |
|
| 41 | - $newEnreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
| 42 | - return $newEnreg; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - // Получаем форму |
|
| 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'); |
|
| 60 | - |
|
| 61 | - // Название формы |
|
| 62 | - $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDINSTR) : sprintf(_AM_INSTRUCTION_FORMEDITINSTR); |
|
| 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'); |
|
| 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(); |
|
| 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 | - } |
|
| 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); |
|
| 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 | - } |
|
| 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); |
|
| 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 | - } |
|
| 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 | + |
|
| 31 | + // Нет в таблице |
|
| 32 | + $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
|
| 33 | + $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @return mixed |
|
| 38 | + */ |
|
| 39 | + public function getNewInstertId() |
|
| 40 | + { |
|
| 41 | + $newEnreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
| 42 | + return $newEnreg; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + // Получаем форму |
|
| 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'); |
|
| 60 | + |
|
| 61 | + // Название формы |
|
| 62 | + $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDINSTR) : sprintf(_AM_INSTRUCTION_FORMEDITINSTR); |
|
| 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'); |
|
| 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(); |
|
| 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 | + } |
|
| 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); |
|
| 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 | + } |
|
| 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); |
|
| 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 | + } |
|
| 125 | 125 | } |
| 126 | 126 | |
@@ -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 | } |
@@ -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 | } |
@@ -7,14 +7,14 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | function instruction_tag_iteminfo(&$items) |
| 9 | 9 | { |
| 10 | - if (empty($items) || !is_array($items)) { |
|
| 10 | + if (empty($items) || ! is_array($items)) { |
|
| 11 | 11 | return false; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | $items_id = []; |
| 15 | 15 | foreach (array_keys($items) as $cat_id) { |
| 16 | 16 | foreach (array_keys($items[$cat_id]) as $item_id) { |
| 17 | - $items_id[] = (int)$item_id; |
|
| 17 | + $items_id[] = (int) $item_id; |
|
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | 20 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | . ' OR aa.status < 1' |
| 71 | 71 | . ' )'; |
| 72 | 72 | endif; |
| 73 | - if (!$result = $linkHandler->db->queryF($sql)) { |
|
| 73 | + if ( ! $result = $linkHandler->db->queryF($sql)) { |
|
| 74 | 74 | //xoops_error($linkHandler->db->error()); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -60,7 +60,8 @@ discard block |
||
| 60 | 60 | . " WHERE {$itemHandler->table}.status > 0" |
| 61 | 61 | . ' ) ' |
| 62 | 62 | . ' )'; |
| 63 | - else: |
|
| 63 | + else {
|
|
| 64 | + : |
|
| 64 | 65 | $sql = " DELETE {$linkHandler->table} FROM {$linkHandler->table}" |
| 65 | 66 | . " LEFT JOIN {$itemHandler->table} AS aa ON {$linkHandler->table}.tag_itemid = aa.{$itemHandler->keyName} " |
| 66 | 67 | . ' WHERE ' |
@@ -68,7 +69,8 @@ discard block |
||
| 68 | 69 | . ' AND ' |
| 69 | 70 | . " ( aa.{$itemHandler->keyName} IS NULL" |
| 70 | 71 | . ' OR aa.status < 1' |
| 71 | - . ' )'; |
|
| 72 | + . ' )'; |
|
| 73 | + } |
|
| 72 | 74 | endif; |
| 73 | 75 | if (!$result = $linkHandler->db->queryF($sql)) { |
| 74 | 76 | //xoops_error($linkHandler->db->error()); |
@@ -7,37 +7,37 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | function instruction_tag_iteminfo(&$items) |
| 9 | 9 | { |
| 10 | - if (empty($items) || !is_array($items)) { |
|
| 11 | - return false; |
|
| 12 | - } |
|
| 10 | + if (empty($items) || !is_array($items)) { |
|
| 11 | + return false; |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - $items_id = []; |
|
| 15 | - foreach (array_keys($items) as $cat_id) { |
|
| 16 | - foreach (array_keys($items[$cat_id]) as $item_id) { |
|
| 17 | - $items_id[] = (int)$item_id; |
|
| 18 | - } |
|
| 19 | - } |
|
| 14 | + $items_id = []; |
|
| 15 | + foreach (array_keys($items) as $cat_id) { |
|
| 16 | + foreach (array_keys($items[$cat_id]) as $item_id) { |
|
| 17 | + $items_id[] = (int)$item_id; |
|
| 18 | + } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - $itemHandler = xoops_getModuleHandler('instruction', 'instruction'); |
|
| 22 | - $items_obj = $itemHandler->getObjects(new \Criteria('instrid', '(' . implode(', ', $items_id) . ')', 'IN'), true); |
|
| 21 | + $itemHandler = xoops_getModuleHandler('instruction', 'instruction'); |
|
| 22 | + $items_obj = $itemHandler->getObjects(new \Criteria('instrid', '(' . implode(', ', $items_id) . ')', 'IN'), true); |
|
| 23 | 23 | |
| 24 | - foreach (array_keys($items) as $cat_id) { |
|
| 25 | - foreach (array_keys($items[$cat_id]) as $item_id) { |
|
| 26 | - if (isset($items_obj[$item_id])) { |
|
| 27 | - $item_obj = $items_obj[$item_id]; |
|
| 28 | - $items[$cat_id][$item_id] = [ |
|
| 29 | - 'title' => $item_obj->getVar('title'), |
|
| 30 | - 'uid' => $item_obj->getVar('uid'), |
|
| 31 | - 'link' => "instr.php?id={$item_id}", |
|
| 32 | - 'time' => $item_obj->getVar('datecreated'), |
|
| 33 | - 'tags' => '', |
|
| 34 | - 'content' => '', |
|
| 35 | - ]; |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - unset($items_obj); |
|
| 40 | - return ''; |
|
| 24 | + foreach (array_keys($items) as $cat_id) { |
|
| 25 | + foreach (array_keys($items[$cat_id]) as $item_id) { |
|
| 26 | + if (isset($items_obj[$item_id])) { |
|
| 27 | + $item_obj = $items_obj[$item_id]; |
|
| 28 | + $items[$cat_id][$item_id] = [ |
|
| 29 | + 'title' => $item_obj->getVar('title'), |
|
| 30 | + 'uid' => $item_obj->getVar('uid'), |
|
| 31 | + 'link' => "instr.php?id={$item_id}", |
|
| 32 | + 'time' => $item_obj->getVar('datecreated'), |
|
| 33 | + 'tags' => '', |
|
| 34 | + 'content' => '', |
|
| 35 | + ]; |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + unset($items_obj); |
|
| 40 | + return ''; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Синхронизация тегов |
@@ -46,32 +46,32 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | function instruction_tag_synchronization($mid) |
| 48 | 48 | { |
| 49 | - $itemHandler = xoops_getModuleHandler('instruction', 'instruction'); |
|
| 50 | - $linkHandler = xoops_getModuleHandler('link', 'tag'); |
|
| 49 | + $itemHandler = xoops_getModuleHandler('instruction', 'instruction'); |
|
| 50 | + $linkHandler = xoops_getModuleHandler('link', 'tag'); |
|
| 51 | 51 | |
| 52 | - /* clear tag-item links */ |
|
| 53 | - if (version_compare($GLOBALS['xoopsDB']->getServerVersion(), '4.1.0', 'ge')): |
|
| 54 | - $sql = " DELETE FROM {$linkHandler->table}" |
|
| 55 | - . ' WHERE ' |
|
| 56 | - . " tag_modid = {$mid}" |
|
| 57 | - . ' AND ' |
|
| 58 | - . ' ( tag_itemid NOT IN ' |
|
| 59 | - . " ( SELECT DISTINCT {$itemHandler->keyName} " |
|
| 60 | - . " FROM {$itemHandler->table} " |
|
| 61 | - . " WHERE {$itemHandler->table}.status > 0" |
|
| 62 | - . ' ) ' |
|
| 63 | - . ' )'; |
|
| 64 | - else: |
|
| 65 | - $sql = " DELETE {$linkHandler->table} FROM {$linkHandler->table}" |
|
| 66 | - . " LEFT JOIN {$itemHandler->table} AS aa ON {$linkHandler->table}.tag_itemid = aa.{$itemHandler->keyName} " |
|
| 67 | - . ' WHERE ' |
|
| 68 | - . " tag_modid = {$mid}" |
|
| 69 | - . ' AND ' |
|
| 70 | - . " ( aa.{$itemHandler->keyName} IS NULL" |
|
| 71 | - . ' OR aa.status < 1' |
|
| 72 | - . ' )'; |
|
| 73 | - endif; |
|
| 74 | - if (!$result = $linkHandler->db->queryF($sql)) { |
|
| 75 | - //xoops_error($linkHandler->db->error()); |
|
| 76 | - } |
|
| 52 | + /* clear tag-item links */ |
|
| 53 | + if (version_compare($GLOBALS['xoopsDB']->getServerVersion(), '4.1.0', 'ge')): |
|
| 54 | + $sql = " DELETE FROM {$linkHandler->table}" |
|
| 55 | + . ' WHERE ' |
|
| 56 | + . " tag_modid = {$mid}" |
|
| 57 | + . ' AND ' |
|
| 58 | + . ' ( tag_itemid NOT IN ' |
|
| 59 | + . " ( SELECT DISTINCT {$itemHandler->keyName} " |
|
| 60 | + . " FROM {$itemHandler->table} " |
|
| 61 | + . " WHERE {$itemHandler->table}.status > 0" |
|
| 62 | + . ' ) ' |
|
| 63 | + . ' )'; |
|
| 64 | + else: |
|
| 65 | + $sql = " DELETE {$linkHandler->table} FROM {$linkHandler->table}" |
|
| 66 | + . " LEFT JOIN {$itemHandler->table} AS aa ON {$linkHandler->table}.tag_itemid = aa.{$itemHandler->keyName} " |
|
| 67 | + . ' WHERE ' |
|
| 68 | + . " tag_modid = {$mid}" |
|
| 69 | + . ' AND ' |
|
| 70 | + . " ( aa.{$itemHandler->keyName} IS NULL" |
|
| 71 | + . ' OR aa.status < 1' |
|
| 72 | + . ' )'; |
|
| 73 | + endif; |
|
| 74 | + if (!$result = $linkHandler->db->queryF($sql)) { |
|
| 75 | + //xoops_error($linkHandler->db->error()); |
|
| 76 | + } |
|
| 77 | 77 | } |
@@ -9,9 +9,9 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | function instruction_com_update($pageid, $total_num) |
| 11 | 11 | { |
| 12 | - $db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 13 | - $sql = 'UPDATE ' . $db->prefix('instruction_page') . ' SET comments = ' . $total_num . ' WHERE pageid = ' . $pageid; |
|
| 14 | - $db->query($sql); |
|
| 12 | + $db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 13 | + $sql = 'UPDATE ' . $db->prefix('instruction_page') . ' SET comments = ' . $total_num . ' WHERE pageid = ' . $pageid; |
|
| 14 | + $db->query($sql); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -19,5 +19,5 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | function instruction_com_approve(&$comment) |
| 21 | 21 | { |
| 22 | - // notification mail here |
|
| 22 | + // notification mail here |
|
| 23 | 23 | } |
@@ -70,8 +70,8 @@ |
||
| 70 | 70 | $debug = false; |
| 71 | 71 | |
| 72 | 72 | if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) { |
| 73 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 74 | - $xoopsTpl = new \XoopsTpl(); |
|
| 73 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 74 | + $xoopsTpl = new \XoopsTpl(); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $moduleDirName = basename(dirname(__DIR__)); |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | |
| 70 | 70 | $debug = false; |
| 71 | 71 | |
| 72 | -if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) { |
|
| 72 | +if ( ! isset($GLOBALS['xoopsTpl']) || ! ($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) { |
|
| 73 | 73 | require_once $GLOBALS['xoops']->path('class/template.php'); |
| 74 | 74 | $xoopsTpl = new \XoopsTpl(); |
| 75 | 75 | } |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | $criteria->add(new \Criteria('pageid ', $pageid)); |
| 30 | 30 | $criteria->add(new \Criteria('status ', '0', '>')); |
| 31 | 31 | if (0 == $pageHandler->getCount($criteria)) { |
| 32 | - redirect_header('index.php', 3, _MD_INSTRUCTION_PAGENOTEXIST); |
|
| 33 | - exit(); |
|
| 32 | + redirect_header('index.php', 3, _MD_INSTRUCTION_PAGENOTEXIST); |
|
| 33 | + exit(); |
|
| 34 | 34 | } |
| 35 | 35 | // |
| 36 | 36 | unset($criteria); |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | // Если админ и ссылка на отключение кэша |
| 44 | 44 | if (($GLOBALS['xoopsUser'] instanceof \XoopsUser) && $GLOBALS['xoopsUser']->isAdmin() && $nocache) { |
| 45 | - // Отключаем кэш |
|
| 46 | - $GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0; |
|
| 45 | + // Отключаем кэш |
|
| 46 | + $GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // Задание тайтла |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | // Права на просмотр инструкции |
| 61 | 61 | $categories = Xoopsmodules\instruction\Utility::getItemIds(); |
| 62 | 62 | if (!in_array($objInsinstr->getVar('cid'), $categories)) { |
| 63 | - redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM); |
|
| 64 | - exit(); |
|
| 63 | + redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM); |
|
| 64 | + exit(); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // Массив данных о странице |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | $footnote = $objInspage->getVar('footnote'); |
| 79 | 79 | // Если есть сноски |
| 80 | 80 | if ($footnote) { |
| 81 | - $pages['footnotes'] = explode('|', $objInspage->getVar('footnote')); |
|
| 81 | + $pages['footnotes'] = explode('|', $objInspage->getVar('footnote')); |
|
| 82 | 82 | } else { |
| 83 | - $pages['footnotes'] = false; |
|
| 83 | + $pages['footnotes'] = false; |
|
| 84 | 84 | } |
| 85 | 85 | // Мета-теги ключевых слов |
| 86 | 86 | $pages['keywords'] = $objInspage->getVar('keywords'); |
@@ -89,39 +89,39 @@ discard block |
||
| 89 | 89 | // |
| 90 | 90 | // Если админ, рисуем админлинк |
| 91 | 91 | if (($GLOBALS['xoopsUser'] instanceof \XoopsUser) && $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid())) { |
| 92 | - $pages['adminlink'] = ' <a href="' |
|
| 93 | - . XOOPS_URL |
|
| 94 | - . '/modules/' |
|
| 95 | - . $moduleDirName |
|
| 96 | - . '/admin/instr.php?op=editpage&pageid=' |
|
| 97 | - . $pages['pageid'] |
|
| 98 | - . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' |
|
| 99 | - . _EDIT |
|
| 100 | - . ' title=' |
|
| 101 | - . _EDIT |
|
| 102 | - . '></a> <a href="' |
|
| 103 | - . XOOPS_URL |
|
| 104 | - . '/modules/' |
|
| 105 | - . $moduleDirName |
|
| 106 | - . '/admin/instr.php?op=delpage&pageid=' |
|
| 107 | - . $pages['pageid'] |
|
| 108 | - . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt=' |
|
| 109 | - . _DELETE |
|
| 110 | - . ' title=' |
|
| 111 | - . _DELETE |
|
| 112 | - . '></a> '; |
|
| 92 | + $pages['adminlink'] = ' <a href="' |
|
| 93 | + . XOOPS_URL |
|
| 94 | + . '/modules/' |
|
| 95 | + . $moduleDirName |
|
| 96 | + . '/admin/instr.php?op=editpage&pageid=' |
|
| 97 | + . $pages['pageid'] |
|
| 98 | + . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' |
|
| 99 | + . _EDIT |
|
| 100 | + . ' title=' |
|
| 101 | + . _EDIT |
|
| 102 | + . '></a> <a href="' |
|
| 103 | + . XOOPS_URL |
|
| 104 | + . '/modules/' |
|
| 105 | + . $moduleDirName |
|
| 106 | + . '/admin/instr.php?op=delpage&pageid=' |
|
| 107 | + . $pages['pageid'] |
|
| 108 | + . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt=' |
|
| 109 | + . _DELETE |
|
| 110 | + . ' title=' |
|
| 111 | + . _DELETE |
|
| 112 | + . '></a> '; |
|
| 113 | 113 | } else { |
| 114 | - $pages['adminlink'] = ' '; |
|
| 115 | - // Если можно редактировать |
|
| 116 | - if ($gpermHandler->checkRight($moduleDirName . '_edit', $objInsinstr->getVar('cid'), $groups, $GLOBALS['xoopsModule']->getVar('mid'))) { |
|
| 117 | - $pages['adminlink'] .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/submit.php?op=editpage&pageid=' . $pages['pageid'] . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' . _EDIT . ' title=' . _EDIT . '></a>'; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - $pages['adminlink'] .= ' '; |
|
| 121 | - // Если нет админлика |
|
| 122 | - if ('[ ]' === $pages['adminlink']) { |
|
| 123 | - $pages['adminlink'] = ''; |
|
| 124 | - } |
|
| 114 | + $pages['adminlink'] = ' '; |
|
| 115 | + // Если можно редактировать |
|
| 116 | + if ($gpermHandler->checkRight($moduleDirName . '_edit', $objInsinstr->getVar('cid'), $groups, $GLOBALS['xoopsModule']->getVar('mid'))) { |
|
| 117 | + $pages['adminlink'] .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/submit.php?op=editpage&pageid=' . $pages['pageid'] . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' . _EDIT . ' title=' . _EDIT . '></a>'; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + $pages['adminlink'] .= ' '; |
|
| 121 | + // Если нет админлика |
|
| 122 | + if ('[ ]' === $pages['adminlink']) { |
|
| 123 | + $pages['adminlink'] = ''; |
|
| 124 | + } |
|
| 125 | 125 | } |
| 126 | 126 | // Выводим в шаблон |
| 127 | 127 | $GLOBALS['xoopsTpl']->assign('insPage', $pages); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $nav_parent_id = array_reverse($nav_parent_id); |
| 141 | 141 | $navigation = '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/">' . $GLOBALS['xoopsModule']->name() . '</a> : '; |
| 142 | 142 | foreach (array_keys($nav_parent_id) as $i) { |
| 143 | - $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $nav_parent_id[$i]->getVar('cid') . '">' . $nav_parent_id[$i]->getVar('title') . '</a> : '; |
|
| 143 | + $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $nav_parent_id[$i]->getVar('cid') . '">' . $nav_parent_id[$i]->getVar('title') . '</a> : '; |
|
| 144 | 144 | } |
| 145 | 145 | $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $objInscat->getVar('cid') . '">' . $objInscat->getVar('title') . '</a> : '; |
| 146 | 146 | $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/instr.php?id=' . $pages['instrid'] . '">' . $objInsinstr->getVar('title') . '</a>'; |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | // Рейтинг |
| 174 | 174 | if (xoops_getModuleOption('userat', 'instruction')) { |
| 175 | - $xoopsTpl->assign('insUserat', true); |
|
| 175 | + $xoopsTpl->assign('insUserat', true); |
|
| 176 | 176 | } else { |
| 177 | - $xoopsTpl->assign('insUserat', false); |
|
| 177 | + $xoopsTpl->assign('insUserat', false); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | // Мета теги |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | |
| 60 | 60 | // Права на просмотр инструкции |
| 61 | 61 | $categories = Xoopsmodules\instruction\Utility::getItemIds(); |
| 62 | -if (!in_array($objInsinstr->getVar('cid'), $categories)) { |
|
| 62 | +if ( ! in_array($objInsinstr->getVar('cid'), $categories)) { |
|
| 63 | 63 | redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM); |
| 64 | 64 | exit(); |
| 65 | 65 | } |