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
|
|
|
|
28
|
|
|
\defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Class Object Repositories |
32
|
|
|
*/ |
33
|
|
|
class Repositories extends \XoopsObject |
|
|
|
|
34
|
|
|
{ |
35
|
|
|
/** |
36
|
|
|
* Constructor |
37
|
|
|
* |
38
|
|
|
* @param null |
39
|
|
|
*/ |
40
|
|
|
public function __construct() |
41
|
|
|
{ |
42
|
|
|
$this->initVar('repo_id', XOBJ_DTYPE_INT); |
|
|
|
|
43
|
|
|
$this->initVar('repo_nodeid', XOBJ_DTYPE_TXTBOX); |
|
|
|
|
44
|
|
|
$this->initVar('repo_user', XOBJ_DTYPE_TXTBOX); |
45
|
|
|
$this->initVar('repo_name', XOBJ_DTYPE_TXTBOX); |
46
|
|
|
$this->initVar('repo_fullname', XOBJ_DTYPE_TXTBOX); |
47
|
|
|
$this->initVar('repo_createdat', XOBJ_DTYPE_INT); |
48
|
|
|
$this->initVar('repo_updatedat', XOBJ_DTYPE_INT); |
49
|
|
|
$this->initVar('repo_htmlurl', XOBJ_DTYPE_TXTBOX); |
50
|
|
|
$this->initVar('repo_readme', XOBJ_DTYPE_TXTBOX); |
51
|
|
|
$this->initVar('repo_prerelease', XOBJ_DTYPE_TXTBOX); |
52
|
|
|
$this->initVar('repo_release', XOBJ_DTYPE_TXTBOX); |
53
|
|
|
$this->initVar('repo_status', XOBJ_DTYPE_INT); |
54
|
|
|
$this->initVar('repo_datecreated', XOBJ_DTYPE_INT); |
55
|
|
|
$this->initVar('repo_submitter', XOBJ_DTYPE_INT); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @static function &getInstance |
60
|
|
|
* |
61
|
|
|
* @param null |
62
|
|
|
*/ |
63
|
|
|
public static function getInstance() |
64
|
|
|
{ |
65
|
|
|
static $instance = false; |
66
|
|
|
if (!$instance) { |
67
|
|
|
$instance = new self(); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* The new inserted $Id |
73
|
|
|
* @return inserted id |
|
|
|
|
74
|
|
|
*/ |
75
|
|
|
public function getNewInsertedIdRepositories() |
76
|
|
|
{ |
77
|
|
|
$newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
78
|
|
|
return $newInsertedId; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @public function getForm |
83
|
|
|
* @param bool $action |
84
|
|
|
* @return \XoopsThemeForm |
85
|
|
|
*/ |
86
|
|
|
public function getFormRepositories($action = false) |
87
|
|
|
{ |
88
|
|
|
$helper = \XoopsModules\Wggithub\Helper::getInstance(); |
|
|
|
|
89
|
|
|
if (!$action) { |
90
|
|
|
$action = $_SERVER['REQUEST_URI']; |
91
|
|
|
} |
92
|
|
|
// Title |
93
|
|
|
$title = $this->isNew() ? \sprintf(_AM_WGGITHUB_REPOSITORY_ADD) : \sprintf(_AM_WGGITHUB_REPOSITORY_EDIT); |
94
|
|
|
// Get Theme Form |
95
|
|
|
\xoops_load('XoopsFormLoader'); |
|
|
|
|
96
|
|
|
$form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
|
|
|
97
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
98
|
|
|
// Form Text repoNodeid |
99
|
|
|
$form->addElement(new \XoopsFormText(_AM_WGGITHUB_REPOSITORY_NODEID, 'repo_nodeid', 50, 255, $this->getVar('repo_nodeid'))); |
|
|
|
|
100
|
|
|
// Form Text repoUser |
101
|
|
|
$form->addElement(new \XoopsFormText(_AM_WGGITHUB_REPOSITORY_USER, 'repo_user', 50, 255, $this->getVar('repo_user')), true); |
102
|
|
|
// Form Text repoName |
103
|
|
|
$form->addElement(new \XoopsFormText(_AM_WGGITHUB_REPOSITORY_NAME, 'repo_name', 50, 255, $this->getVar('repo_name')), true); |
104
|
|
|
// Form Text repoFullname |
105
|
|
|
$form->addElement(new \XoopsFormText(_AM_WGGITHUB_REPOSITORY_FULLNAME, 'repo_fullname', 50, 255, $this->getVar('repo_fullname'))); |
106
|
|
|
// Form Text Date Select repoCreatedat |
107
|
|
|
$repoCreatedat = $this->isNew() ?: $this->getVar('repo_createdat'); |
108
|
|
|
$form->addElement(new \XoopsFormTextDateSelect(_AM_WGGITHUB_REPOSITORY_CREATEDAT, 'repo_createdat', '', $repoCreatedat)); |
|
|
|
|
109
|
|
|
// Form Text Date Select repoUpdatedat |
110
|
|
|
$repoUpdatedat = $this->isNew() ?: $this->getVar('repo_updatedat'); |
111
|
|
|
$form->addElement(new \XoopsFormTextDateSelect(_AM_WGGITHUB_REPOSITORY_UPDATEDAT, 'repo_updatedat', '', $repoUpdatedat)); |
112
|
|
|
// Form Text repoHtmlurl |
113
|
|
|
$form->addElement(new \XoopsFormText(_AM_WGGITHUB_REPOSITORY_HTMLURL, 'repo_htmlurl', 50, 255, $this->getVar('repo_htmlurl'))); |
114
|
|
|
// Form Text repoReadme |
115
|
|
|
$form->addElement(new \XoopsFormText(_AM_WGGITHUB_REPOSITORY_README, 'repo_readme', 50, 255, $this->getVar('repo_readme'))); |
116
|
|
|
// Form Text repoPrerelease |
117
|
|
|
$form->addElement(new \XoopsFormText(_AM_WGGITHUB_REPOSITORY_PRERELEASE, 'repo_prerelease', 50, 255, $this->getVar('repo_prerelease'))); |
118
|
|
|
// Form Text repoRelease |
119
|
|
|
$form->addElement(new \XoopsFormText(_AM_WGGITHUB_REPOSITORY_RELEASE, 'repo_release', 50, 255, $this->getVar('repo_prelease'))); |
120
|
|
|
// Form Select Status repoStatus |
121
|
|
|
$repoStatusSelect = new \XoopsFormSelect(_AM_WGGITHUB_REPOSITORY_STATUS, 'repo_status', $this->getVar('repo_status')); |
|
|
|
|
122
|
|
|
$repoStatusSelect->addOption(Constants::STATUS_NONE, _AM_WGGITHUB_STATUS_NONE); |
123
|
|
|
$repoStatusSelect->addOption(Constants::STATUS_UPTODATE, _AM_WGGITHUB_STATUS_UPTODATE); |
124
|
|
|
$repoStatusSelect->addOption(Constants::STATUS_UPDATED, _AM_WGGITHUB_STATUS_UPDATED); |
125
|
|
|
$repoStatusSelect->addOption(Constants::STATUS_OFFLINE, _AM_WGGITHUB_STATUS_OFFLINE); |
126
|
|
|
$form->addElement($repoStatusSelect); |
127
|
|
|
// Form Text Date Select repoDatecreated |
128
|
|
|
$repoDatecreated = $this->isNew() ?: $this->getVar('repo_datecreated'); |
129
|
|
|
$form->addElement(new \XoopsFormTextDateSelect(_AM_WGGITHUB_REPOSITORY_DATECREATED, 'repo_datecreated', '', $repoDatecreated)); |
130
|
|
|
// Form Select User repoSubmitter |
131
|
|
|
$form->addElement(new \XoopsFormSelectUser(_AM_WGGITHUB_REPOSITORY_SUBMITTER, 'repo_submitter', false, $this->getVar('repo_submitter'))); |
|
|
|
|
132
|
|
|
// To Save |
133
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save')); |
|
|
|
|
134
|
|
|
$form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
|
|
|
135
|
|
|
return $form; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Get Values |
140
|
|
|
* @param null $keys |
|
|
|
|
141
|
|
|
* @param null $format |
|
|
|
|
142
|
|
|
* @param null $maxDepth |
|
|
|
|
143
|
|
|
* @return array |
144
|
|
|
*/ |
145
|
|
|
public function getValuesRepositories($keys = null, $format = null, $maxDepth = null) |
146
|
|
|
{ |
147
|
|
|
$ret = $this->getValues($keys, $format, $maxDepth); |
148
|
|
|
$ret['id'] = $this->getVar('repo_id'); |
149
|
|
|
$ret['nodeid'] = $this->getVar('repo_nodeid'); |
150
|
|
|
$ret['user'] = $this->getVar('repo_user'); |
151
|
|
|
$ret['name'] = $this->getVar('repo_name'); |
152
|
|
|
$ret['fullname'] = $this->getVar('repo_fullname'); |
153
|
|
|
$ret['createdat'] = \formatTimestamp($this->getVar('repo_createdat'), 'm'); |
|
|
|
|
154
|
|
|
$ret['updatedat'] = \formatTimestamp($this->getVar('repo_updatedat'), 'm'); |
155
|
|
|
$ret['htmlurl'] = $this->getVar('repo_htmlurl'); |
156
|
|
|
$ret['readme'] = $this->getVar('repo_readme'); |
157
|
|
|
$ret['prerelease'] = $this->getVar('repo_prerelease'); |
158
|
|
|
$ret['release'] = $this->getVar('repo_release'); |
159
|
|
|
$status = $this->getVar('repo_status'); |
160
|
|
|
$ret['status'] = $status; |
161
|
|
|
switch ($status) { |
162
|
|
|
case Constants::STATUS_NONE: |
163
|
|
|
default: |
164
|
|
|
$status_text = \_AM_WGGITHUB_STATUS_NONE; |
165
|
|
|
break; |
166
|
|
|
case Constants::STATUS_NEW: |
167
|
|
|
$status_text = \_AM_WGGITHUB_STATUS_NEW; |
168
|
|
|
break; |
169
|
|
|
case Constants::STATUS_UPTODATE: |
170
|
|
|
$status_text = \_AM_WGGITHUB_STATUS_UPTODATE; |
171
|
|
|
break; |
172
|
|
|
case Constants::STATUS_UPDATED: |
173
|
|
|
$status_text = \_AM_WGGITHUB_STATUS_UPDATED; |
174
|
|
|
break; |
175
|
|
|
case Constants::STATUS_OFFLINE: |
176
|
|
|
$status_text = _AM_WGGITHUB_STATUS_OFFLINE; |
177
|
|
|
break; |
178
|
|
|
} |
179
|
|
|
$ret['status_text'] = $status_text; |
180
|
|
|
$ret['datecreated'] = \formatTimestamp($this->getVar('repo_datecreated'), 'm'); |
181
|
|
|
$ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('repo_submitter')); |
|
|
|
|
182
|
|
|
return $ret; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* Returns an array representation of the object |
187
|
|
|
* |
188
|
|
|
* @return array |
189
|
|
|
*/ |
190
|
|
|
public function toArrayRepositories() |
191
|
|
|
{ |
192
|
|
|
$ret = []; |
193
|
|
|
$vars = $this->getVars(); |
194
|
|
|
foreach (\array_keys($vars) as $var) { |
195
|
|
|
$ret[$var] = $this->getVar('"{$var}"'); |
196
|
|
|
} |
197
|
|
|
return $ret; |
198
|
|
|
} |
199
|
|
|
} |
200
|
|
|
|
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