ggoffy /
wggithub
| 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 |
||||
|
0 ignored issues
–
show
|
|||||
| 34 | {
|
||||
| 35 | /** |
||||
| 36 | * Constructor |
||||
| 37 | * |
||||
| 38 | * @param null |
||||
| 39 | */ |
||||
| 40 | public function __construct() |
||||
| 41 | {
|
||||
| 42 | $this->initVar('repo_id', \XOBJ_DTYPE_INT);
|
||||
|
0 ignored issues
–
show
|
|||||
| 43 | $this->initVar('repo_nodeid', \XOBJ_DTYPE_TXTBOX);
|
||||
|
0 ignored issues
–
show
|
|||||
| 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 |
||||
|
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 Loading history...
|
|||||
| 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 | |||||
| 95 | // Get Theme Form |
||||
| 96 | \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
Loading history...
|
|||||
| 97 | $form = new \XoopsThemeForm(\_AM_WGGITHUB_REPOSITORY_EDIT, '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 Loading history...
|
|||||
| 98 | $form->setExtra('enctype="multipart/form-data"');
|
||||
| 99 | // Form Text repoNodeid |
||||
| 100 | $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REPOSITORY_NODEID, 'repo_nodeid', 50, 255, $this->getVar('repo_nodeid')));
|
||||
|
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 Loading history...
|
|||||
| 101 | // Form Text repoUser |
||||
| 102 | $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REPOSITORY_USER, 'repo_user', 50, 255, $this->getVar('repo_user')), true);
|
||||
| 103 | // Form Text repoName |
||||
| 104 | $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REPOSITORY_NAME, 'repo_name', 50, 255, $this->getVar('repo_name')), true);
|
||||
| 105 | // Form Text repoFullname |
||||
| 106 | $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REPOSITORY_FULLNAME, 'repo_fullname', 50, 255, $this->getVar('repo_fullname')));
|
||||
| 107 | // Form Text Date Select repoCreatedat |
||||
| 108 | $repoCreatedat = $this->isNew() ?: $this->getVar('repo_createdat');
|
||||
| 109 | $form->addElement(new \XoopsFormTextDateSelect(\_AM_WGGITHUB_REPOSITORY_CREATEDAT, 'repo_createdat', '', $repoCreatedat)); |
||||
|
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 Loading history...
|
|||||
| 110 | // Form Text Date Select repoUpdatedat |
||||
| 111 | $repoUpdatedat = $this->isNew() ?: $this->getVar('repo_updatedat');
|
||||
| 112 | $form->addElement(new \XoopsFormTextDateSelect(\_AM_WGGITHUB_REPOSITORY_UPDATEDAT, 'repo_updatedat', '', $repoUpdatedat)); |
||||
| 113 | // Form Text repoHtmlurl |
||||
| 114 | $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REPOSITORY_HTMLURL, 'repo_htmlurl', 50, 255, $this->getVar('repo_htmlurl')));
|
||||
| 115 | // Form Text repoReadme |
||||
| 116 | $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REPOSITORY_README, 'repo_readme', 50, 255, $this->getVar('repo_readme')));
|
||||
| 117 | // Form Text repoPrerelease |
||||
| 118 | $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REPOSITORY_PRERELEASE, 'repo_prerelease', 50, 255, $this->getVar('repo_prerelease')));
|
||||
| 119 | // Form Text repoRelease |
||||
| 120 | $form->addElement(new \XoopsFormText(\_AM_WGGITHUB_REPOSITORY_RELEASE, 'repo_release', 50, 255, $this->getVar('repo_prelease')));
|
||||
| 121 | // Form Radio Yes/No repoApproved |
||||
| 122 | $repoApproved = $this->isNew() ?: $this->getVar('repo_approved');
|
||||
| 123 | $form->addElement(new \XoopsFormRadioYN(\_AM_WGGITHUB_REPOSITORY_APPROVED, 'repo_approved', $repoApproved)); |
||||
|
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 Loading history...
|
|||||
| 124 | // Form Select Status repoStatus |
||||
| 125 | $repoStatusSelect = new \XoopsFormSelect(\_AM_WGGITHUB_REPOSITORY_STATUS, 'repo_status', $this->getVar('repo_status'));
|
||||
|
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 Loading history...
|
|||||
| 126 | $repoStatusSelect->addOption(Constants::STATUS_NONE, \_AM_WGGITHUB_STATUS_NONE); |
||||
| 127 | $repoStatusSelect->addOption(Constants::STATUS_UPTODATE, \_AM_WGGITHUB_STATUS_UPTODATE); |
||||
| 128 | $repoStatusSelect->addOption(Constants::STATUS_UPDATED, \_AM_WGGITHUB_STATUS_UPDATED); |
||||
| 129 | $repoStatusSelect->addOption(Constants::STATUS_OFFLINE, \_AM_WGGITHUB_STATUS_OFFLINE); |
||||
| 130 | $form->addElement($repoStatusSelect); |
||||
| 131 | // Form Text Date Select repoDatecreated |
||||
| 132 | $repoDatecreated = $this->isNew() ?: $this->getVar('repo_datecreated');
|
||||
| 133 | $form->addElement(new \XoopsFormTextDateSelect(\_AM_WGGITHUB_REPOSITORY_DATECREATED, 'repo_datecreated', '', $repoDatecreated)); |
||||
| 134 | // Form Select User repoSubmitter |
||||
| 135 | $form->addElement(new \XoopsFormSelectUser(\_AM_WGGITHUB_REPOSITORY_SUBMITTER, 'repo_submitter', false, $this->getVar('repo_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 Loading history...
|
|||||
| 136 | // To Save |
||||
| 137 | $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 Loading history...
|
|||||
| 138 | $form->addElement(new \XoopsFormHidden('start', $start));
|
||||
| 139 | $form->addElement(new \XoopsFormHidden('limit', $limit));
|
||||
| 140 | $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 Loading history...
|
|||||
| 141 | return $form; |
||||
| 142 | } |
||||
| 143 | |||||
| 144 | /** |
||||
| 145 | * Get Values |
||||
| 146 | * @param null $keys |
||||
|
0 ignored issues
–
show
|
|||||
| 147 | * @param null $format |
||||
|
0 ignored issues
–
show
|
|||||
| 148 | * @param null $maxDepth |
||||
|
0 ignored issues
–
show
|
|||||
| 149 | * @return array |
||||
| 150 | */ |
||||
| 151 | public function getValuesRepositories($keys = null, $format = null, $maxDepth = null) |
||||
| 152 | {
|
||||
| 153 | $ret = $this->getValues($keys, $format, $maxDepth); |
||||
| 154 | $ret['id'] = $this->getVar('repo_id');
|
||||
| 155 | $ret['nodeid'] = $this->getVar('repo_nodeid');
|
||||
| 156 | $ret['user'] = $this->getVar('repo_user');
|
||||
| 157 | $ret['name'] = $this->getVar('repo_name');
|
||||
| 158 | $ret['fullname'] = $this->getVar('repo_fullname');
|
||||
| 159 | $ret['createdat'] = \formatTimestamp($this->getVar('repo_createdat'), 'm');
|
||||
|
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
Loading history...
|
|||||
| 160 | $ret['updatedat'] = \formatTimestamp($this->getVar('repo_updatedat'), 'm');
|
||||
| 161 | $ret['htmlurl'] = $this->getVar('repo_htmlurl');
|
||||
| 162 | $ret['readme'] = $this->getVar('repo_readme');
|
||||
| 163 | $ret['prerelease'] = $this->getVar('repo_prerelease');
|
||||
| 164 | $ret['release'] = $this->getVar('repo_release');
|
||||
| 165 | $ret['approved'] = (int)$this->getVar('repo_approved') > 0 ? \_YES : \_NO;
|
||||
|
0 ignored issues
–
show
|
|||||
| 166 | $status = $this->getVar('repo_status');
|
||||
| 167 | $ret['status'] = $status; |
||||
| 168 | switch ($status) {
|
||||
| 169 | case Constants::STATUS_NONE: |
||||
| 170 | default: |
||||
| 171 | $status_text = \_AM_WGGITHUB_STATUS_NONE; |
||||
| 172 | break; |
||||
| 173 | case Constants::STATUS_NEW: |
||||
| 174 | $status_text = \_AM_WGGITHUB_STATUS_NEW; |
||||
| 175 | break; |
||||
| 176 | case Constants::STATUS_UPTODATE: |
||||
| 177 | $status_text = \_AM_WGGITHUB_STATUS_UPTODATE; |
||||
| 178 | break; |
||||
| 179 | case Constants::STATUS_UPDATED: |
||||
| 180 | $status_text = \_AM_WGGITHUB_STATUS_UPDATED; |
||||
| 181 | break; |
||||
| 182 | case Constants::STATUS_OFFLINE: |
||||
| 183 | $status_text = \_AM_WGGITHUB_STATUS_OFFLINE; |
||||
| 184 | break; |
||||
| 185 | } |
||||
| 186 | $ret['status_text'] = $status_text; |
||||
| 187 | $ret['datecreated'] = \formatTimestamp($this->getVar('repo_datecreated'), 'm');
|
||||
| 188 | $ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('repo_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 Loading history...
|
|||||
| 189 | return $ret; |
||||
| 190 | } |
||||
| 191 | |||||
| 192 | /** |
||||
| 193 | * Returns an array representation of the object |
||||
| 194 | * |
||||
| 195 | * @return array |
||||
| 196 | */ |
||||
| 197 | public function toArrayRepositories() |
||||
| 198 | {
|
||||
| 199 | $ret = []; |
||||
| 200 | $vars = $this->getVars(); |
||||
| 201 | foreach (\array_keys($vars) as $var) {
|
||||
| 202 | $ret[$var] = $this->getVar('"{$var}"');
|
||||
| 203 | } |
||||
| 204 | return $ret; |
||||
| 205 | } |
||||
| 206 | } |
||||
| 207 |
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