1 | <?php |
||||||
2 | |||||||
3 | namespace XoopsModules\Wggithub; |
||||||
4 | |||||||
5 | /* |
||||||
6 | You may not change or alter any portion of this comment or credits |
||||||
7 | of supporting developers from this source code or any supporting source code |
||||||
8 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
9 | |||||||
10 | This program is distributed in the hope that it will be useful, |
||||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
13 | */ |
||||||
14 | |||||||
15 | /** |
||||||
16 | * wgGitHub module for xoops |
||||||
17 | * |
||||||
18 | * @copyright 2020 XOOPS Project (https://xooops.org) |
||||||
19 | * @license GPL 2.0 or later |
||||||
20 | * @package wggithub |
||||||
21 | * @since 1.0 |
||||||
22 | * @min_xoops 2.5.10 |
||||||
23 | * @author Goffy - XOOPS Development Team - Email:<[email protected]> - Website:<https://wedega.com> |
||||||
24 | */ |
||||||
25 | |||||||
26 | use XoopsModules\Wggithub; |
||||||
27 | use XoopsModules\Wggithub\Constants; |
||||||
28 | |||||||
29 | \defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||||||
30 | |||||||
31 | /** |
||||||
32 | * Class Object Directories |
||||||
33 | */ |
||||||
34 | class Directories extends \XoopsObject |
||||||
0 ignored issues
–
show
|
|||||||
35 | { |
||||||
36 | /** |
||||||
37 | * Constructor |
||||||
38 | * |
||||||
39 | * @param null |
||||||
40 | */ |
||||||
41 | public function __construct() |
||||||
42 | { |
||||||
43 | $this->initVar('dir_id', \XOBJ_DTYPE_INT); |
||||||
0 ignored issues
–
show
|
|||||||
44 | $this->initVar('dir_name', \XOBJ_DTYPE_TXTBOX); |
||||||
0 ignored issues
–
show
|
|||||||
45 | $this->initVar('dir_descr', \XOBJ_DTYPE_OTHER); |
||||||
0 ignored issues
–
show
|
|||||||
46 | $this->initVar('dir_type', \XOBJ_DTYPE_INT); |
||||||
47 | $this->initVar('dir_content', \XOBJ_DTYPE_INT); |
||||||
48 | $this->initVar('dir_autoupdate', \XOBJ_DTYPE_INT); |
||||||
49 | $this->initVar('dir_online', \XOBJ_DTYPE_INT); |
||||||
50 | $this->initVar('dir_filterrelease', \XOBJ_DTYPE_INT); |
||||||
51 | $this->initVar('dir_weight', \XOBJ_DTYPE_INT); |
||||||
52 | $this->initVar('dir_datecreated', \XOBJ_DTYPE_INT); |
||||||
53 | $this->initVar('dir_submitter', \XOBJ_DTYPE_INT); |
||||||
54 | } |
||||||
55 | |||||||
56 | /** |
||||||
57 | * @static function &getInstance |
||||||
58 | * |
||||||
59 | * @param null |
||||||
60 | */ |
||||||
61 | public static function getInstance() |
||||||
62 | { |
||||||
63 | static $instance = false; |
||||||
64 | if (!$instance) { |
||||||
65 | $instance = new self(); |
||||||
66 | } |
||||||
67 | } |
||||||
68 | |||||||
69 | /** |
||||||
70 | * The new inserted $Id |
||||||
71 | * @return inserted id |
||||||
0 ignored issues
–
show
The type
XoopsModules\Wggithub\inserted was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
72 | */ |
||||||
73 | public function getNewInsertedIdDirectories() |
||||||
74 | { |
||||||
75 | $newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
||||||
76 | return $newInsertedId; |
||||||
77 | } |
||||||
78 | |||||||
79 | /** |
||||||
80 | * @public function getForm |
||||||
81 | * @param bool $action |
||||||
82 | * @param int $start |
||||||
83 | * @param int $limit |
||||||
84 | * @return \XoopsThemeForm |
||||||
85 | */ |
||||||
86 | public function getFormDirectories($action = false, $start = 0, $limit = 0) |
||||||
87 | { |
||||||
88 | $helper = \XoopsModules\Wggithub\Helper::getInstance(); |
||||||
89 | if (!$action) { |
||||||
90 | $action = $_SERVER['REQUEST_URI']; |
||||||
91 | } |
||||||
92 | $isAdmin = $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()); |
||||||
93 | |||||||
94 | // Title |
||||||
95 | $title = $this->isNew() ? \sprintf(\_AM_WGGITHUB_DIRECTORY_ADD) : \sprintf(\_AM_WGGITHUB_DIRECTORY_EDIT); |
||||||
96 | // Get Theme Form |
||||||
97 | \xoops_load('XoopsFormLoader'); |
||||||
0 ignored issues
–
show
The function
xoops_load was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
98 | $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
||||||
0 ignored issues
–
show
The type
XoopsThemeForm was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
99 | $form->setExtra('enctype="multipart/form-data"'); |
||||||
100 | // Form Text dirName |
||||||
101 | $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_DIRECTORY_NAME, 'dir_name', 50, 255, $this->getVar('dir_name')), true); |
||||||
0 ignored issues
–
show
The type
XoopsFormText was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
102 | // Form Editor DhtmlTextArea dirDescr |
||||||
103 | $editorConfigs = []; |
||||||
104 | if ($isAdmin) { |
||||||
105 | $editor = $helper->getConfig('editor_admin'); |
||||||
106 | } else { |
||||||
107 | $editor = $helper->getConfig('editor_user'); |
||||||
108 | } |
||||||
109 | $editorConfigs['name'] = 'dir_descr'; |
||||||
110 | $editorConfigs['value'] = $this->getVar('dir_descr', 'e'); |
||||||
111 | $editorConfigs['rows'] = 5; |
||||||
112 | $editorConfigs['cols'] = 40; |
||||||
113 | $editorConfigs['width'] = '100%'; |
||||||
114 | $editorConfigs['height'] = '400px'; |
||||||
115 | $editorConfigs['editor'] = $editor; |
||||||
116 | $form->addElement(new \XoopsFormEditor(\_AM_WGGITHUB_DIRECTORY_DESCR, 'dir_descr', $editorConfigs)); |
||||||
0 ignored issues
–
show
The type
XoopsFormEditor was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
117 | // Form Select dirType |
||||||
118 | $dirTypeSelect = new \XoopsFormSelect(\_AM_WGGITHUB_DIRECTORY_TYPE, 'dir_type', $this->getVar('dir_type'), 5); |
||||||
0 ignored issues
–
show
The type
XoopsFormSelect was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
119 | $dirTypeSelect->addOption(Constants::DIRECTORY_TYPE_USER, \_AM_WGGITHUB_DIRECTORY_TYPE_USER); |
||||||
120 | $dirTypeSelect->addOption(Constants::DIRECTORY_TYPE_ORG, \_AM_WGGITHUB_DIRECTORY_TYPE_ORG); |
||||||
121 | $form->addElement($dirTypeSelect, true); |
||||||
122 | // Form Select dirContent |
||||||
123 | $dirContentSelect = new \XoopsFormSelect(\_AM_WGGITHUB_DIRECTORY_CONTENT, 'dir_content', $this->getVar('dir_content'), 3); |
||||||
124 | $dirContentSelect->addOption(Constants::DIRECTORY_CONTENT_ALL, \_AM_WGGITHUB_DIRECTORY_CONTENT_ALL); |
||||||
125 | $dirContentSelect->addOption(Constants::DIRECTORY_CONTENT_OWN, \_AM_WGGITHUB_DIRECTORY_CONTENT_OWN); |
||||||
126 | $form->addElement($dirContentSelect, true); |
||||||
127 | // Form Radio Yes/No dirAutoupdate |
||||||
128 | $dirAutoupdate = $this->isNew() ?: $this->getVar('dir_autoupdate'); |
||||||
129 | $form->addElement(new \XoopsFormRadioYN(\_AM_WGGITHUB_DIRECTORY_AUTOUPDATE, 'dir_autoupdate', $dirAutoupdate)); |
||||||
0 ignored issues
–
show
The type
XoopsFormRadioYN was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
130 | // Form Radio Yes/No dirOnline |
||||||
131 | $dirOnline = $this->isNew() ?: $this->getVar('dir_online'); |
||||||
132 | $form->addElement(new \XoopsFormRadioYN(\_AM_WGGITHUB_DIRECTORY_ONLINE, 'dir_online', $dirOnline)); |
||||||
133 | // Form Select dirFilterrelease |
||||||
134 | $dirFilterrelease = $this->isNew() ?: $this->getVar('dir_filterrelease'); |
||||||
135 | $form->addElement(new \XoopsFormRadioYN(\_AM_WGGITHUB_DIRECTORY_FILTERRELEASE, 'dir_filterrelease', $dirFilterrelease)); |
||||||
136 | // Form Text dirWeight |
||||||
137 | $dirWeight = $this->isNew() ? 0 : $this->getVar('dir_weight'); |
||||||
138 | $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_DIRECTORY_WEIGHT, 'dir_weight', 50, 255, $dirWeight), true); |
||||||
139 | // Form Text Date Select dirDatecreated |
||||||
140 | $dirDatecreated = $this->isNew() ?: $this->getVar('dir_datecreated'); |
||||||
141 | $form->addElement(new \XoopsFormTextDateSelect(\_AM_WGGITHUB_DIRECTORY_DATECREATED, 'dir_datecreated', '', $dirDatecreated)); |
||||||
0 ignored issues
–
show
The type
XoopsFormTextDateSelect was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
142 | // Form Select User dirSubmitter |
||||||
143 | $form->addElement(new \XoopsFormSelectUser(\_AM_WGGITHUB_DIRECTORY_SUBMITTER, 'dir_submitter', false, $this->getVar('dir_submitter'))); |
||||||
0 ignored issues
–
show
The type
XoopsFormSelectUser was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
144 | // To Save |
||||||
145 | $form->addElement(new \XoopsFormHidden('op', 'save')); |
||||||
0 ignored issues
–
show
The type
XoopsFormHidden was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
146 | $form->addElement(new \XoopsFormHidden('start', $start)); |
||||||
147 | $form->addElement(new \XoopsFormHidden('limit', $limit)); |
||||||
148 | $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', '', false)); |
||||||
0 ignored issues
–
show
The type
XoopsFormButtonTray was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
149 | return $form; |
||||||
150 | } |
||||||
151 | |||||||
152 | /** |
||||||
153 | * Get Values |
||||||
154 | * @param null $keys |
||||||
0 ignored issues
–
show
|
|||||||
155 | * @param null $format |
||||||
0 ignored issues
–
show
|
|||||||
156 | * @param null $maxDepth |
||||||
0 ignored issues
–
show
|
|||||||
157 | * @return array |
||||||
158 | */ |
||||||
159 | public function getValuesDirectories($keys = null, $format = null, $maxDepth = null) |
||||||
160 | { |
||||||
161 | $ret = $this->getValues($keys, $format, $maxDepth); |
||||||
162 | $ret['id'] = $this->getVar('dir_id'); |
||||||
163 | $ret['name'] = $this->getVar('dir_name'); |
||||||
164 | $ret['descr'] = $this->getVar('dir_descr'); |
||||||
165 | $ret['type'] = $this->getVar('dir_type'); |
||||||
166 | $ret['type_text'] = Constants::DIRECTORY_TYPE_USER == $this->getVar('dir_type') ? \_AM_WGGITHUB_DIRECTORY_TYPE_USER : \_AM_WGGITHUB_DIRECTORY_TYPE_ORG; |
||||||
167 | $content = $this->getVar('dir_content'); |
||||||
168 | $ret['content'] = $content; |
||||||
169 | switch ($content) { |
||||||
170 | case Constants::DIRECTORY_CONTENT_ALL: |
||||||
171 | default: |
||||||
172 | $content_text = \_AM_WGGITHUB_DIRECTORY_CONTENT_ALL; |
||||||
173 | break; |
||||||
174 | case Constants::DIRECTORY_CONTENT_OWN: |
||||||
175 | $content_text = \_AM_WGGITHUB_DIRECTORY_CONTENT_OWN; |
||||||
176 | break; |
||||||
177 | } |
||||||
178 | $ret['content_shorttext'] = Utility::truncateHtml($content_text); |
||||||
179 | $ret['autoupdate'] = (int)$this->getVar('dir_autoupdate') > 0 ? _YES : _NO; |
||||||
0 ignored issues
–
show
|
|||||||
180 | $ret['online'] = (int)$this->getVar('dir_online') > 0 ? _YES : _NO; |
||||||
181 | $ret['filterrelease'] = (int)$this->getVar('dir_filterrelease') > 0 ? _YES : _NO; |
||||||
182 | $ret['weight'] = (int)$this->getVar('dir_weight'); |
||||||
183 | $ret['datecreated'] = \formatTimestamp($this->getVar('dir_datecreated'), 's'); |
||||||
0 ignored issues
–
show
The function
formatTimestamp was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
184 | $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('dir_submitter')); |
||||||
0 ignored issues
–
show
The type
XoopsUser was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
185 | return $ret; |
||||||
186 | } |
||||||
187 | |||||||
188 | /** |
||||||
189 | * Returns an array representation of the object |
||||||
190 | * |
||||||
191 | * @return array |
||||||
192 | */ |
||||||
193 | public function toArrayDirectories() |
||||||
194 | { |
||||||
195 | $ret = []; |
||||||
196 | $vars = $this->getVars(); |
||||||
197 | foreach (\array_keys($vars) as $var) { |
||||||
198 | $ret[$var] = $this->getVar('"{$var}"'); |
||||||
199 | } |
||||||
200 | return $ret; |
||||||
201 | } |
||||||
202 | } |
||||||
203 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths