1 | <?php |
||
2 | /* |
||
3 | You may not change or alter any portion of this comment or credits |
||
4 | of supporting developers from this source code or any supporting source code |
||
5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
6 | |||
7 | This program is distributed in the hope that it will be useful, |
||
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
10 | */ |
||
11 | |||
12 | /** |
||
13 | * wgGitHub module for xoops |
||
14 | * |
||
15 | * @copyright 2020 XOOPS Project (https://xooops.org) |
||
16 | * @license GPL 2.0 or later |
||
17 | * @package wggithub |
||
18 | * @since 1.0 |
||
19 | * @min_xoops 2.5.10 |
||
20 | * @author Goffy - XOOPS Development Team - Email:<[email protected]> - Website:<https://wedega.com> |
||
21 | */ |
||
22 | |||
23 | use XoopsModules\Wggithub; |
||
24 | use XoopsModules\Wggithub\Helper; |
||
25 | use XoopsModules\Wggithub\Constants; |
||
26 | |||
27 | include_once \XOOPS_ROOT_PATH . '/modules/wggithub/include/common.php'; |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
28 | |||
29 | /** |
||
30 | * Function show block |
||
31 | * @param $options |
||
32 | * @return array |
||
33 | */ |
||
34 | function b_wggithub_repositories_show($options) |
||
35 | { |
||
36 | include_once \XOOPS_ROOT_PATH . '/modules/wggithub/class/repositories.php'; |
||
0 ignored issues
–
show
|
|||
37 | $myts = MyTextSanitizer::getInstance(); |
||
0 ignored issues
–
show
The type
MyTextSanitizer 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 ![]() |
|||
38 | $GLOBALS['xoopsTpl']->assign('wggithub_upload_url', \WGGITHUB_UPLOAD_URL); |
||
39 | $block = []; |
||
40 | $typeBlock = $options[0]; |
||
41 | $limit = $options[1]; |
||
42 | $lenghtTitle = $options[2]; |
||
43 | $helper = Helper::getInstance(); |
||
44 | $repositoriesHandler = $helper->getHandler('Repositories'); |
||
45 | $crRepositories = new \CriteriaCompo(); |
||
0 ignored issues
–
show
The type
CriteriaCompo 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 ![]() |
|||
46 | \array_shift($options); |
||
47 | \array_shift($options); |
||
48 | \array_shift($options); |
||
49 | |||
50 | switch ($typeBlock) { |
||
51 | case 'last': |
||
52 | default: |
||
53 | // For the block: repositories last |
||
54 | $crRepositories->setSort('repo_datecreated'); |
||
55 | $crRepositories->setOrder('DESC'); |
||
56 | break; |
||
57 | case 'new': |
||
58 | // For the block: repositories new |
||
59 | $crRepositories->add(new \Criteria('repo_datecreated', \time() - 604800, '>=')); |
||
0 ignored issues
–
show
The type
Criteria 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 ![]() |
|||
60 | $crRepositories->add(new \Criteria('repo_datecreated', \time(), '<=')); |
||
61 | $crRepositories->setSort('repo_datecreated'); |
||
62 | $crRepositories->setOrder('ASC'); |
||
63 | break; |
||
64 | case 'random': |
||
65 | // For the block: repositories random |
||
66 | $crRepositories->setSort('RAND()'); |
||
67 | break; |
||
68 | } |
||
69 | |||
70 | $crRepositories->setLimit($limit); |
||
71 | $repositoriesAll = $repositoriesHandler->getAll($crRepositories); |
||
72 | unset($crRepositories); |
||
73 | if (\count($repositoriesAll) > 0) { |
||
74 | foreach (\array_keys($repositoriesAll) as $i) { |
||
75 | $block[$i]['id'] = $repositoriesAll[$i]->getVar('repo_id'); |
||
76 | $repoName = $myts->htmlSpecialChars($repositoriesAll[$i]->getVar('repo_name')); |
||
77 | if ($lenghtTitle > 0) { |
||
78 | $repoName = \substr($repoName, 0, $lenghtTitle); |
||
79 | } |
||
80 | $block[$i]['name'] = $repoName; |
||
81 | $block[$i]['htmlurl'] = $myts->htmlSpecialChars($repositoriesAll[$i]->getVar('repo_htmlurl')); |
||
82 | } |
||
83 | } |
||
84 | |||
85 | return $block; |
||
86 | |||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Function edit block |
||
91 | * @param $options |
||
92 | * @return string |
||
93 | */ |
||
94 | function b_wggithub_repositories_edit($options) |
||
95 | { |
||
96 | include_once \XOOPS_ROOT_PATH . '/modules/wggithub/class/repositories.php'; |
||
0 ignored issues
–
show
|
|||
97 | $helper = Helper::getInstance(); |
||
98 | $repositoriesHandler = $helper->getHandler('Repositories'); |
||
99 | $GLOBALS['xoopsTpl']->assign('wggithub_upload_url', \WGGITHUB_UPLOAD_URL); |
||
100 | $form = \_MB_WGGITHUB_DISPLAY; |
||
101 | $form .= "<input type='hidden' name='options[0]' value='".$options[0]."' />"; |
||
102 | $form .= "<input type='text' name='options[1]' size='5' maxlength='255' value='" . $options[1] . "' /> <br>"; |
||
103 | $form .= \_MB_WGGITHUB_TITLE_LENGTH . " : <input type='text' name='options[2]' size='5' maxlength='255' value='" . $options[2] . "' /><br><br>"; |
||
104 | \array_shift($options); |
||
105 | \array_shift($options); |
||
106 | \array_shift($options); |
||
107 | |||
108 | $crRepositories = new \CriteriaCompo(); |
||
109 | $crRepositories->add(new \Criteria('repo_id', 0, '!=')); |
||
110 | $crRepositories->setSort('repo_id'); |
||
111 | $crRepositories->setOrder('ASC'); |
||
112 | $repositoriesAll = $repositoriesHandler->getAll($crRepositories); |
||
113 | unset($crRepositories); |
||
114 | $form .= \_MB_WGGITHUB_REPOSITORIES_TO_DISPLAY . "<br><select name='options[]' multiple='multiple' size='5'>"; |
||
115 | $form .= "<option value='0' " . (\in_array(0, $options) == false ? '' : "selected='selected'") . '>' . \_MB_WGGITHUB_ALL_REPOSITORIES . '</option>'; |
||
0 ignored issues
–
show
|
|||
116 | foreach (\array_keys($repositoriesAll) as $i) { |
||
117 | $repo_id = $repositoriesAll[$i]->getVar('repo_id'); |
||
118 | $form .= "<option value='" . $repo_id . "' " . (\in_array($repo_id, $options) == false ? '' : "selected='selected'") . '>' . $repositoriesAll[$i]->getVar('repo_name') . '</option>'; |
||
0 ignored issues
–
show
|
|||
119 | } |
||
120 | $form .= '</select>'; |
||
121 | |||
122 | return $form; |
||
123 | |||
124 | } |
||
125 |