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