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 Releases
|
32
|
|
|
*/
|
33
|
|
|
class Releases extends \XoopsObject
|
|
|
|
|
34
|
|
|
{
|
35
|
|
|
/**
|
36
|
|
|
* Constructor
|
37
|
|
|
*
|
38
|
|
|
* @param null
|
39
|
|
|
*/
|
40
|
|
|
public function __construct()
|
41
|
|
|
{
|
42
|
|
|
$this->initVar('rel_id', \XOBJ_DTYPE_INT);
|
|
|
|
|
43
|
|
|
$this->initVar('rel_repoid', \XOBJ_DTYPE_INT);
|
44
|
|
|
$this->initVar('rel_type', \XOBJ_DTYPE_INT);
|
45
|
|
|
$this->initVar('rel_name', \XOBJ_DTYPE_TXTBOX);
|
|
|
|
|
46
|
|
|
$this->initVar('rel_prerelease', \XOBJ_DTYPE_INT);
|
47
|
|
|
$this->initVar('rel_publishedat', \XOBJ_DTYPE_INT);
|
48
|
|
|
$this->initVar('rel_tarballurl', \XOBJ_DTYPE_TXTBOX);
|
49
|
|
|
$this->initVar('rel_zipballurl', \XOBJ_DTYPE_TXTBOX);
|
50
|
|
|
$this->initVar('rel_datecreated', \XOBJ_DTYPE_INT);
|
51
|
|
|
$this->initVar('rel_submitter', \XOBJ_DTYPE_INT);
|
52
|
|
|
}
|
53
|
|
|
|
54
|
|
|
/**
|
55
|
|
|
* @static function &getInstance
|
56
|
|
|
*
|
57
|
|
|
* @param null
|
58
|
|
|
*/
|
59
|
|
|
public static function getInstance()
|
60
|
|
|
{
|
61
|
|
|
static $instance = false;
|
62
|
|
|
if (!$instance) {
|
63
|
|
|
$instance = new self();
|
64
|
|
|
}
|
65
|
|
|
}
|
66
|
|
|
|
67
|
|
|
/**
|
68
|
|
|
* The new inserted $Id
|
69
|
|
|
* @return inserted id
|
|
|
|
|
70
|
|
|
*/
|
71
|
|
|
public function getNewInsertedIdReleases()
|
72
|
|
|
{
|
73
|
|
|
$newInsertedId = $GLOBALS['xoopsDB']->getInsertId();
|
74
|
|
|
return $newInsertedId;
|
75
|
|
|
}
|
76
|
|
|
|
77
|
|
|
/**
|
78
|
|
|
* @public function getForm
|
79
|
|
|
* @param bool $action
|
80
|
|
|
* @param int $start
|
81
|
|
|
* @param int $limit
|
82
|
|
|
* @return \XoopsThemeForm
|
83
|
|
|
*/
|
84
|
|
|
public function getFormReleases($action = false, $start = 0, $limit = 0)
|
85
|
|
|
{
|
86
|
|
|
$helper = \XoopsModules\Wggithub\Helper::getInstance();
|
87
|
|
|
if (!$action) {
|
88
|
|
|
$action = $_SERVER['REQUEST_URI'];
|
89
|
|
|
}
|
90
|
|
|
|
91
|
|
|
// Get Theme Form
|
92
|
|
|
\xoops_load('XoopsFormLoader');
|
|
|
|
|
93
|
|
|
$form = new \XoopsThemeForm(\_AM_WGGITHUB_RELEASE_EDIT, 'form', $action, 'post', true);
|
|
|
|
|
94
|
|
|
$form->setExtra('enctype="multipart/form-data"');
|
95
|
|
|
// Form Table repositories
|
96
|
|
|
$repositoriesHandler = $helper->getHandler('Repositories');
|
97
|
|
|
$rmRepoidSelect = new \XoopsFormSelect(\_AM_WGGITHUB_README_REPOID, 'rel_repoid', $this->getVar('rel_repoid'));
|
|
|
|
|
98
|
|
|
$rmRepoidSelect->addOptionArray($repositoriesHandler->getList());
|
99
|
|
|
$form->addElement($rmRepoidSelect);
|
100
|
|
|
// Form Select relType
|
101
|
|
|
$relTypeSelect = new \XoopsFormSelect(\_AM_WGGITHUB_RELEASE_TYPE, 'rel_type', $this->getVar('rel_type'));
|
102
|
|
|
$relTypeSelect->addOption('file');
|
103
|
|
|
$form->addElement($relTypeSelect);
|
104
|
|
|
// Form Text relName
|
105
|
|
|
$form->addElement(new \XoopsFormText(\_AM_WGGITHUB_RELEASE_NAME, 'rel_name', 50, 255, $this->getVar('rel_name')), true);
|
|
|
|
|
106
|
|
|
// Form Radio Yes/No relPrerelease
|
107
|
|
|
$relPrerelease = $this->isNew() ?: $this->getVar('rel_prerelease');
|
108
|
|
|
$form->addElement(new \XoopsFormRadioYN(\_AM_WGGITHUB_RELEASE_PRERELEASE, 'rel_prerelease', $relPrerelease));
|
|
|
|
|
109
|
|
|
// Form Text Date Select relPublishedat
|
110
|
|
|
$relPublishedat = $this->isNew() ?: $this->getVar('rel_publishedat');
|
111
|
|
|
$form->addElement(new \XoopsFormTextDateSelect(\_AM_WGGITHUB_RELEASE_PUBLISHEDAT, 'rel_publishedat', '', $relPublishedat));
|
|
|
|
|
112
|
|
|
// Form Text relTarballurl
|
113
|
|
|
$form->addElement(new \XoopsFormText(\_AM_WGGITHUB_RELEASE_TARBALLURL, 'rel_tarballurl', 50, 255, $this->getVar('rel_tarballurl')));
|
114
|
|
|
// Form Text relZipballurl
|
115
|
|
|
$form->addElement(new \XoopsFormText(\_AM_WGGITHUB_RELEASE_ZIPBALLURL, 'rel_zipballurl', 50, 255, $this->getVar('rel_zipballurl')));
|
116
|
|
|
// Form Text Date Select relDatecreated
|
117
|
|
|
$relDatecreated = $this->isNew() ?: $this->getVar('rel_datecreated');
|
118
|
|
|
$form->addElement(new \XoopsFormTextDateSelect(\_AM_WGGITHUB_RELEASE_DATECREATED, 'rel_datecreated', '', $relDatecreated));
|
119
|
|
|
// Form Select User relSubmitter
|
120
|
|
|
$form->addElement(new \XoopsFormSelectUser(\_AM_WGGITHUB_RELEASE_SUBMITTER, 'rel_submitter', false, $this->getVar('rel_submitter')));
|
|
|
|
|
121
|
|
|
// To Save
|
122
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save'));
|
|
|
|
|
123
|
|
|
$form->addElement(new \XoopsFormHidden('start', $start));
|
124
|
|
|
$form->addElement(new \XoopsFormHidden('limit', $limit));
|
125
|
|
|
$form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', '', false));
|
|
|
|
|
126
|
|
|
return $form;
|
127
|
|
|
}
|
128
|
|
|
|
129
|
|
|
/**
|
130
|
|
|
* Get Values
|
131
|
|
|
* @param null $keys
|
|
|
|
|
132
|
|
|
* @param null $format
|
|
|
|
|
133
|
|
|
* @param null $maxDepth
|
|
|
|
|
134
|
|
|
* @return array
|
135
|
|
|
*/
|
136
|
|
|
public function getValuesReleases($keys = null, $format = null, $maxDepth = null)
|
137
|
|
|
{
|
138
|
|
|
$helper = \XoopsModules\Wggithub\Helper::getInstance();
|
139
|
|
|
$ret = $this->getValues($keys, $format, $maxDepth);
|
140
|
|
|
$ret['id'] = $this->getVar('rel_id');
|
141
|
|
|
$repositoriesHandler = $helper->getHandler('Repositories');
|
142
|
|
|
$repositoriesObj = $repositoriesHandler->get($this->getVar('rel_repoid'));
|
143
|
|
|
if (\is_object($repositoriesObj)) {
|
144
|
|
|
$ret['repoid'] = $repositoriesObj->getVar('repo_name');
|
145
|
|
|
} else {
|
146
|
|
|
$ret['repoid'] = '*****missing repo_name*****';
|
147
|
|
|
}
|
148
|
|
|
$ret['type'] = $this->getVar('rel_type');
|
149
|
|
|
$ret['name'] = $this->getVar('rel_name');
|
150
|
|
|
$ret['prerelease'] = (int)$this->getVar('rel_prerelease') > 0 ? _YES : _NO;
|
|
|
|
|
151
|
|
|
$ret['publishedat'] = \formatTimestamp($this->getVar('rel_publishedat'), 'm');
|
|
|
|
|
152
|
|
|
$ret['tarballurl'] = $this->getVar('rel_tarballurl');
|
153
|
|
|
$ret['zipballurl'] = $this->getVar('rel_zipballurl');
|
154
|
|
|
$ret['datecreated'] = \formatTimestamp($this->getVar('rel_datecreated'), 'm');
|
155
|
|
|
$ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('rel_submitter'));
|
|
|
|
|
156
|
|
|
return $ret;
|
157
|
|
|
}
|
158
|
|
|
|
159
|
|
|
/**
|
160
|
|
|
* Returns an array representation of the object
|
161
|
|
|
*
|
162
|
|
|
* @return array
|
163
|
|
|
*/
|
164
|
|
|
public function toArrayReleases()
|
165
|
|
|
{
|
166
|
|
|
$ret = [];
|
167
|
|
|
$vars = $this->getVars();
|
168
|
|
|
foreach (\array_keys($vars) as $var) {
|
169
|
|
|
$ret[$var] = $this->getVar('"{$var}"');
|
170
|
|
|
}
|
171
|
|
|
return $ret;
|
172
|
|
|
}
|
173
|
|
|
}
|
174
|
|
|
|
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