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 |
|
|
|
|
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* Constructor |
38
|
|
|
* |
39
|
|
|
* @param null |
40
|
|
|
*/ |
41
|
|
|
public function __construct() |
42
|
|
|
{ |
43
|
|
|
$this->initVar('dir_id', \XOBJ_DTYPE_INT); |
|
|
|
|
44
|
|
|
$this->initVar('dir_name', \XOBJ_DTYPE_TXTBOX); |
|
|
|
|
45
|
|
|
$this->initVar('dir_descr', XOBJ_DTYPE_OTHER); |
|
|
|
|
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_datecreated', \XOBJ_DTYPE_INT); |
52
|
|
|
$this->initVar('dir_submitter', \XOBJ_DTYPE_INT); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @static function &getInstance |
57
|
|
|
* |
58
|
|
|
* @param null |
59
|
|
|
*/ |
60
|
|
|
public static function getInstance() |
61
|
|
|
{ |
62
|
|
|
static $instance = false; |
63
|
|
|
if (!$instance) { |
64
|
|
|
$instance = new self(); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* The new inserted $Id |
70
|
|
|
* @return inserted id |
|
|
|
|
71
|
|
|
*/ |
72
|
|
|
public function getNewInsertedIdDirectories() |
73
|
|
|
{ |
74
|
|
|
$newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
75
|
|
|
return $newInsertedId; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @public function getForm |
80
|
|
|
* @param bool $action |
81
|
|
|
* @param int $start |
82
|
|
|
* @param int $limit |
83
|
|
|
* @return \XoopsThemeForm |
84
|
|
|
*/ |
85
|
|
|
public function getFormDirectories($action = false, $start = 0, $limit = 0) |
86
|
|
|
{ |
87
|
|
|
$helper = \XoopsModules\Wggithub\Helper::getInstance(); |
88
|
|
|
if (!$action) { |
89
|
|
|
$action = $_SERVER['REQUEST_URI']; |
90
|
|
|
} |
91
|
|
|
$isAdmin = $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()); |
92
|
|
|
|
93
|
|
|
// Title |
94
|
|
|
$title = $this->isNew() ? \sprintf(\_AM_WGGITHUB_DIRECTORY_ADD) : \sprintf(\_AM_WGGITHUB_DIRECTORY_EDIT); |
95
|
|
|
// Get Theme Form |
96
|
|
|
\xoops_load('XoopsFormLoader'); |
|
|
|
|
97
|
|
|
$form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
|
|
|
98
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
99
|
|
|
// Form Text dirName |
100
|
|
|
$form->addElement(new \XoopsFormText(\_AM_WGGITHUB_DIRECTORY_NAME, 'dir_name', 50, 255, $this->getVar('dir_name')), true); |
|
|
|
|
101
|
|
|
// Form Editor DhtmlTextArea dirDescr |
102
|
|
|
$editorConfigs = []; |
103
|
|
|
if ($isAdmin) { |
104
|
|
|
$editor = $helper->getConfig('editor_admin'); |
105
|
|
|
} else { |
106
|
|
|
$editor = $helper->getConfig('editor_user'); |
107
|
|
|
} |
108
|
|
|
$editorConfigs['name'] = 'dir_descr'; |
109
|
|
|
$editorConfigs['value'] = $this->getVar('dir_descr', 'e'); |
110
|
|
|
$editorConfigs['rows'] = 5; |
111
|
|
|
$editorConfigs['cols'] = 40; |
112
|
|
|
$editorConfigs['width'] = '100%'; |
113
|
|
|
$editorConfigs['height'] = '400px'; |
114
|
|
|
$editorConfigs['editor'] = $editor; |
115
|
|
|
$form->addElement(new \XoopsFormEditor(_AM_WGGITHUB_DIRECTORY_DESCR, 'dir_descr', $editorConfigs)); |
|
|
|
|
116
|
|
|
// Form Select dirType |
117
|
|
|
$dirTypeSelect = new \XoopsFormSelect(\_AM_WGGITHUB_DIRECTORY_TYPE, 'dir_type', $this->getVar('dir_type'), 5); |
|
|
|
|
118
|
|
|
$dirTypeSelect->addOption(Constants::DIRECTORY_TYPE_USER, \_AM_WGGITHUB_DIRECTORY_TYPE_USER); |
119
|
|
|
$dirTypeSelect->addOption(Constants::DIRECTORY_TYPE_ORG, \_AM_WGGITHUB_DIRECTORY_TYPE_ORG); |
120
|
|
|
$form->addElement($dirTypeSelect, true); |
121
|
|
|
// Form Select dirContent |
122
|
|
|
$dirContentSelect = new \XoopsFormSelect(\_AM_WGGITHUB_DIRECTORY_CONTENT, 'dir_content', $this->getVar('dir_content'), 3); |
123
|
|
|
$dirContentSelect->addOption(Constants::DIRECTORY_CONTENT_ALL, \_AM_WGGITHUB_DIRECTORY_CONTENT_ALL); |
124
|
|
|
$dirContentSelect->addOption(Constants::DIRECTORY_CONTENT_OWN, \_AM_WGGITHUB_DIRECTORY_CONTENT_OWN); |
125
|
|
|
$form->addElement($dirContentSelect, true); |
126
|
|
|
// Form Radio Yes/No dirAutoupdate |
127
|
|
|
$dirAutoupdate = $this->isNew() ?: $this->getVar('dir_autoupdate'); |
128
|
|
|
$form->addElement(new \XoopsFormRadioYN(_AM_WGGITHUB_DIRECTORY_AUTOUPDATE, 'dir_autoupdate', $dirAutoupdate)); |
|
|
|
|
129
|
|
|
// Form Radio Yes/No dirOnline |
130
|
|
|
$dirOnline = $this->isNew() ?: $this->getVar('dir_online'); |
131
|
|
|
$form->addElement(new \XoopsFormRadioYN(_AM_WGGITHUB_DIRECTORY_ONLINE, 'dir_online', $dirOnline)); |
132
|
|
|
// Form Radio Yes/No dirFilterrelease |
133
|
|
|
$dirFilterrelease = $this->isNew() ?: $this->getVar('dir_filterrelease'); |
134
|
|
|
$form->addElement(new \XoopsFormRadioYN(_AM_WGGITHUB_DIRECTORY_FILTERRELEASE, 'dir_filterrelease', $dirFilterrelease)); |
135
|
|
|
// Form Text Date Select dirDatecreated |
136
|
|
|
$dirDatecreated = $this->isNew() ?: $this->getVar('dir_datecreated'); |
137
|
|
|
$form->addElement(new \XoopsFormTextDateSelect(\_AM_WGGITHUB_DIRECTORY_DATECREATED, 'dir_datecreated', '', $dirDatecreated)); |
|
|
|
|
138
|
|
|
// Form Select User dirSubmitter |
139
|
|
|
$form->addElement(new \XoopsFormSelectUser(\_AM_WGGITHUB_DIRECTORY_SUBMITTER, 'dir_submitter', false, $this->getVar('dir_submitter'))); |
|
|
|
|
140
|
|
|
// To Save |
141
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save')); |
|
|
|
|
142
|
|
|
$form->addElement(new \XoopsFormHidden('start', $start)); |
143
|
|
|
$form->addElement(new \XoopsFormHidden('limit', $limit)); |
144
|
|
|
$form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
|
|
|
145
|
|
|
return $form; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Get Values |
150
|
|
|
* @param null $keys |
|
|
|
|
151
|
|
|
* @param null $format |
|
|
|
|
152
|
|
|
* @param null $maxDepth |
|
|
|
|
153
|
|
|
* @return array |
154
|
|
|
*/ |
155
|
|
|
public function getValuesDirectories($keys = null, $format = null, $maxDepth = null) |
156
|
|
|
{ |
157
|
|
|
$ret = $this->getValues($keys, $format, $maxDepth); |
158
|
|
|
$ret['id'] = $this->getVar('dir_id'); |
159
|
|
|
$ret['name'] = $this->getVar('dir_name'); |
160
|
|
|
$ret['descr'] = $this->getVar('dir_descr'); |
161
|
|
|
$ret['type'] = $this->getVar('dir_type'); |
162
|
|
|
$ret['type_text'] = Constants::DIRECTORY_TYPE_USER == $this->getVar('dir_type') ? \_AM_WGGITHUB_DIRECTORY_TYPE_USER : \_AM_WGGITHUB_DIRECTORY_TYPE_ORG; |
163
|
|
|
$content = $this->getVar('dir_content'); |
164
|
|
|
$ret['content'] = $content; |
165
|
|
|
switch ($content) { |
166
|
|
|
case Constants::DIRECTORY_CONTENT_ALL: |
167
|
|
|
default: |
168
|
|
|
$content_text = \_AM_WGGITHUB_DIRECTORY_CONTENT_ALL; |
169
|
|
|
break; |
170
|
|
|
case Constants::DIRECTORY_CONTENT_OWN: |
171
|
|
|
$content_text = \_AM_WGGITHUB_DIRECTORY_CONTENT_OWN; |
172
|
|
|
break; |
173
|
|
|
} |
174
|
|
|
$ret['content_shorttext'] = Utility::truncateHtml($content_text); |
175
|
|
|
$ret['autoupdate'] = (int)$this->getVar('dir_autoupdate') > 0 ? _YES : _NO; |
|
|
|
|
176
|
|
|
$ret['online'] = (int)$this->getVar('dir_online') > 0 ? _YES : _NO; |
177
|
|
|
$ret['filterrelease'] = (int)$this->getVar('dir_filterrelease') > 0 ? _YES : _NO; |
178
|
|
|
$ret['datecreated'] = \formatTimestamp($this->getVar('dir_datecreated'), 's'); |
|
|
|
|
179
|
|
|
$ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('dir_submitter')); |
|
|
|
|
180
|
|
|
return $ret; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Returns an array representation of the object |
185
|
|
|
* |
186
|
|
|
* @return array |
187
|
|
|
*/ |
188
|
|
|
public function toArrayDirectories() |
189
|
|
|
{ |
190
|
|
|
$ret = []; |
191
|
|
|
$vars = $this->getVars(); |
192
|
|
|
foreach (\array_keys($vars) as $var) { |
193
|
|
|
$ret[$var] = $this->getVar('"{$var}"'); |
194
|
|
|
} |
195
|
|
|
return $ret; |
196
|
|
|
} |
197
|
|
|
} |
198
|
|
|
|
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