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
Loading history...
|
|||
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
Loading history...
|
|||
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
Loading history...
|
|||
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', \DateTime::createFromFormat(_SHORTDATESTRING), '>=')); |
||
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
Loading history...
|
|||
60 | $crRepositories->add(new \Criteria('repo_datecreated', \DateTime::createFromFormat(_SHORTDATESTRING) + 86400, '<=')); |
||
61 | $crRepositories->setSort('repo_datecreated'); |
||
62 | $crRepositories->setOrder('ASC'); |
||
63 | break; |
||
64 | case 'hits': |
||
65 | // For the block: repositories hits |
||
66 | $crRepositories->setSort('repo_hits'); |
||
67 | $crRepositories->setOrder('DESC'); |
||
68 | break; |
||
69 | case 'top': |
||
70 | // For the block: repositories top |
||
71 | $crRepositories->setSort('repo_top'); |
||
72 | $crRepositories->setOrder('ASC'); |
||
73 | break; |
||
74 | case 'random': |
||
75 | // For the block: repositories random |
||
76 | $crRepositories->setSort('RAND()'); |
||
77 | break; |
||
78 | } |
||
79 | |||
80 | $crRepositories->setLimit($limit); |
||
81 | $repositoriesAll = $repositoriesHandler->getAll($crRepositories); |
||
82 | unset($crRepositories); |
||
83 | if (\count($repositoriesAll) > 0) { |
||
84 | foreach (\array_keys($repositoriesAll) as $i) { |
||
85 | $block[$i]['id'] = $repositoriesAll[$i]->getVar('repo_id'); |
||
86 | $block[$i]['name'] = $myts->htmlSpecialChars($repositoriesAll[$i]->getVar('repo_name')); |
||
87 | $block[$i]['htmlurl'] = $myts->htmlSpecialChars($repositoriesAll[$i]->getVar('repo_htmlurl')); |
||
88 | } |
||
89 | } |
||
90 | |||
91 | return $block; |
||
92 | |||
93 | } |
||
94 | |||
95 | /** |
||
96 | * Function edit block |
||
97 | * @param $options |
||
98 | * @return string |
||
99 | */ |
||
100 | function b_wggithub_repositories_edit($options) |
||
101 | { |
||
102 | include_once \XOOPS_ROOT_PATH . '/modules/wggithub/class/repositories.php'; |
||
0 ignored issues
–
show
|
|||
103 | $helper = Helper::getInstance(); |
||
104 | $repositoriesHandler = $helper->getHandler('Repositories'); |
||
105 | $GLOBALS['xoopsTpl']->assign('wggithub_upload_url', WGGITHUB_UPLOAD_URL); |
||
106 | $form = \_MB_WGGITHUB_DISPLAY; |
||
107 | $form .= "<input type='hidden' name='options[0]' value='".$options[0]."' />"; |
||
108 | $form .= "<input type='text' name='options[1]' size='5' maxlength='255' value='" . $options[1] . "' /> <br>"; |
||
109 | $form .= \_MB_WGGITHUB_TITLE_LENGTH . " : <input type='text' name='options[2]' size='5' maxlength='255' value='" . $options[2] . "' /><br><br>"; |
||
110 | \array_shift($options); |
||
111 | \array_shift($options); |
||
112 | \array_shift($options); |
||
113 | |||
114 | $crRepositories = new \CriteriaCompo(); |
||
115 | $crRepositories->add(new \Criteria('repo_id', 0, '!=')); |
||
116 | $crRepositories->setSort('repo_id'); |
||
117 | $crRepositories->setOrder('ASC'); |
||
118 | $repositoriesAll = $repositoriesHandler->getAll($crRepositories); |
||
119 | unset($crRepositories); |
||
120 | $form .= \_MB_WGGITHUB_REPOSITORIES_TO_DISPLAY . "<br><select name='options[]' multiple='multiple' size='5'>"; |
||
121 | $form .= "<option value='0' " . (\in_array(0, $options) == false ? '' : "selected='selected'") . '>' . \_MB_WGGITHUB_ALL_REPOSITORIES . '</option>'; |
||
122 | foreach (\array_keys($repositoriesAll) as $i) { |
||
123 | $repo_id = $repositoriesAll[$i]->getVar('repo_id'); |
||
124 | $form .= "<option value='" . $repo_id . "' " . (\in_array($repo_id, $options) == false ? '' : "selected='selected'") . '>' . $repositoriesAll[$i]->getVar('repo_name') . '</option>'; |
||
125 | } |
||
126 | $form .= '</select>'; |
||
127 | |||
128 | return $form; |
||
129 | |||
130 | } |
||
131 |