1
|
|
|
<?php namespace Xoopsmodules\instruction; |
2
|
|
|
|
3
|
|
|
//if (!defined("XOOPS_ROOT_PATH")) { |
|
|
|
|
4
|
|
|
// die("XOOPS root path not defined"); |
5
|
|
|
//} |
6
|
|
|
|
7
|
|
|
include_once $GLOBALS['xoops']->path('include/common.php'); |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class Instruction |
11
|
|
|
* @package Xoopsmodules\instruction |
12
|
|
|
*/ |
13
|
|
|
class Instruction extends \XoopsObject |
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
|
|
|
public function Instruction() |
37
|
|
|
{ |
38
|
|
|
$this->__construct(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return mixed |
43
|
|
|
*/ |
44
|
|
|
public function get_new_enreg() |
45
|
|
|
{ |
46
|
|
|
$new_enreg = $GLOBALS['xoopsDB']->getInsertId(); |
47
|
|
|
return $new_enreg; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
// Получаем форму |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param bool|null|string $action |
54
|
|
|
* @return \XoopsThemeForm |
55
|
|
|
*/ |
56
|
|
|
public function getForm($action = false) |
57
|
|
|
{ |
58
|
|
|
global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
59
|
|
|
// Если нет $action |
60
|
|
|
if (false === $action) { |
61
|
|
|
$action = xoops_getenv('REQUEST_URI'); |
62
|
|
|
} |
63
|
|
|
// Подключаем формы |
64
|
|
|
include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
65
|
|
|
|
66
|
|
|
// Название формы |
67
|
|
|
$title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDINSTR) : sprintf(_AM_INSTRUCTION_FORMEDITINSTR); |
68
|
|
|
|
69
|
|
|
// Форма |
70
|
|
|
$form = new \XoopsThemeForm($title, 'forminstr', $action, 'post', true); |
71
|
|
|
//$form->setExtra('enctype="multipart/form-data"'); |
|
|
|
|
72
|
|
|
// Название инструкции |
73
|
|
|
$form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
74
|
|
|
// Категория |
75
|
|
|
$categoryHandler = new CategoryHandler; |
76
|
|
|
$criteria = new \CriteriaCompo(); |
77
|
|
|
$criteria->setSort('weight ASC, title'); |
78
|
|
|
$criteria->setOrder('ASC'); |
79
|
|
|
$instructioncat_arr = $categoryHandler->getall($criteria); |
80
|
|
|
unset($criteria); |
81
|
|
|
// Подключаем трей |
82
|
|
|
include_once $GLOBALS['xoops']->path('class/tree.php'); |
83
|
|
|
$mytree = new \XoopsObjectTree($instructioncat_arr, 'cid', 'pid'); |
84
|
|
|
|
85
|
|
|
// $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
|
|
|
|
86
|
|
|
$helper = Helper::getInstance(); |
87
|
|
|
$module = $helper->getModule(); |
88
|
|
|
|
89
|
|
View Code Duplication |
if (Utility::checkVerXoops($module, '2.5.9')) { |
|
|
|
|
90
|
|
|
$mytree_select = $mytree->makeSelectElement('cid', 'title', '--', $this->getVar('cid'), true, 0, '', _AM_INSTRUCTION_CATC); |
91
|
|
|
$form->addElement($mytree_select); |
92
|
|
|
} else { |
93
|
|
|
$form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
// Описание |
97
|
|
|
$form->addElement(Utility::getWysiwygForm(_AM_INSTRUCTION_DESCRIPTIONC, 'description', $this->getVar('description', 'e')), true); |
98
|
|
|
// Статус |
99
|
|
|
$form->addElement(new \XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false); |
100
|
|
|
|
101
|
|
|
// Теги |
102
|
|
|
$dir_tag_ok = false; |
103
|
|
|
if (is_dir('../../tag') || is_dir('../tag')) { |
104
|
|
|
$dir_tag_ok = true; |
105
|
|
|
} |
106
|
|
|
// Если влючена поддержка тегов и есть модуль tag |
107
|
|
|
if (xoops_getModuleOption('usetag', 'instruction') && $dir_tag_ok) { |
108
|
|
|
$itemIdForTag = $this->isNew() ? 0 : $this->getVar('instrid'); |
109
|
|
|
// Подключаем форму тегов |
110
|
|
|
include_once $GLOBALS['xoops']->path('modules/tag/include/formtag.php'); |
111
|
|
|
// Добавляем элемент в форму |
112
|
|
|
$form->addElement(new \XoopsFormTag('tag', 60, 255, $itemIdForTag, 0)); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
// Мета-теги ключевых слов |
116
|
|
|
$form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false); |
117
|
|
|
// Мета-теги описания |
118
|
|
|
$form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
119
|
|
|
|
120
|
|
|
// Если мы редактируем категорию |
121
|
|
|
if (!$this->isNew()) { |
122
|
|
|
$form->addElement(new \XoopsFormHidden('instrid', $this->getVar('instrid'))); |
123
|
|
|
} |
124
|
|
|
// |
125
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'saveinstr')); |
126
|
|
|
// Кнопка |
127
|
|
|
$form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
128
|
|
|
return $form; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.