@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | interface Constants |
30 | 30 | { |
31 | - // Constants for tables |
|
31 | + // Constants for tables |
|
32 | 32 | public const TABLE_SETTINGS = 0; |
33 | 33 | public const TABLE_REPOSITORIES = 1; |
34 | 34 | public const TABLE_DIRECTORIES = 2; |
@@ -39,17 +39,17 @@ discard block |
||
39 | 39 | public const DIRECTORY_TYPE_USER = 1; |
40 | 40 | public const DIRECTORY_TYPE_ORG = 2; |
41 | 41 | |
42 | - // Constants for status |
|
43 | - public const STATUS_NONE = 0; |
|
42 | + // Constants for status |
|
43 | + public const STATUS_NONE = 0; |
|
44 | 44 | public const STATUS_NEW = 1; |
45 | 45 | public const STATUS_UPDATED = 2; |
46 | - public const STATUS_UPTODATE = 3; |
|
46 | + public const STATUS_UPTODATE = 3; |
|
47 | 47 | |
48 | - // Constants for permissions |
|
49 | - public const PERM_GLOBAL_NONE = 0; |
|
50 | - public const PERM_GLOBAL_VIEW = 1; |
|
51 | - public const PERM_GLOBAL_READ = 2; |
|
52 | - public const PERM_README_UPDATE = 3; |
|
48 | + // Constants for permissions |
|
49 | + public const PERM_GLOBAL_NONE = 0; |
|
50 | + public const PERM_GLOBAL_VIEW = 1; |
|
51 | + public const PERM_GLOBAL_READ = 2; |
|
52 | + public const PERM_README_UPDATE = 3; |
|
53 | 53 | |
54 | 54 | // Constants for log type |
55 | 55 | public const LOG_TYPE_NONE = 0; |
@@ -52,7 +52,7 @@ |
||
52 | 52 | public const PERM_README_UPDATE = 3; |
53 | 53 | |
54 | 54 | // Constants for log type |
55 | - public const LOG_TYPE_NONE = 0; |
|
55 | + public const LOG_TYPE_NONE = 0; |
|
56 | 56 | public const LOG_TYPE_UPDATE_START = 1; |
57 | 57 | public const LOG_TYPE_UPDATE_END = 2; |
58 | 58 | public const LOG_TYPE_REQUEST = 3; |
@@ -31,96 +31,96 @@ |
||
31 | 31 | */ |
32 | 32 | class LogsHandler extends \XoopsPersistableObjectHandler |
33 | 33 | { |
34 | - /** |
|
35 | - * Constructor |
|
36 | - * |
|
37 | - * @param \XoopsDatabase $db |
|
38 | - */ |
|
39 | - public function __construct(\XoopsDatabase $db) |
|
40 | - { |
|
41 | - parent::__construct($db, 'wggithub_logs', Logs::class, 'log_id', 'log_detail'); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * @param bool $isNew |
|
46 | - * |
|
47 | - * @return object |
|
48 | - */ |
|
49 | - public function create($isNew = true) |
|
50 | - { |
|
51 | - return parent::create($isNew); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * retrieve a field |
|
56 | - * |
|
57 | - * @param int $i field id |
|
58 | - * @param null fields |
|
59 | - * @return mixed reference to the {@link Get} object |
|
60 | - */ |
|
61 | - public function get($i = null, $fields = null) |
|
62 | - { |
|
63 | - return parent::get($i, $fields); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * get inserted id |
|
68 | - * |
|
69 | - * @param null |
|
70 | - * @return int reference to the {@link Get} object |
|
71 | - */ |
|
72 | - public function getInsertId() |
|
73 | - { |
|
74 | - return $this->db->getInsertId(); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Get Count Logs in the database |
|
79 | - * @param int $start |
|
80 | - * @param int $limit |
|
81 | - * @param string $sort |
|
82 | - * @param string $order |
|
83 | - * @return int |
|
84 | - */ |
|
85 | - public function getCountLogs($start = 0, $limit = 0, $sort = 'log_id', $order = 'ASC') |
|
86 | - { |
|
87 | - $crCountLogs = new \CriteriaCompo(); |
|
88 | - $crCountLogs = $this->getLogsCriteria($crCountLogs, $start, $limit, $sort, $order); |
|
89 | - return $this->getCount($crCountLogs); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Get All Logs in the database |
|
94 | - * @param int $start |
|
95 | - * @param int $limit |
|
96 | - * @param string $sort |
|
97 | - * @param string $order |
|
98 | - * @return array |
|
99 | - */ |
|
100 | - public function getAllLogs($start = 0, $limit = 0, $sort = 'log_id', $order = 'ASC') |
|
101 | - { |
|
102 | - $crAllLogs = new \CriteriaCompo(); |
|
103 | - $crAllLogs = $this->getLogsCriteria($crAllLogs, $start, $limit, $sort, $order); |
|
104 | - return $this->getAll($crAllLogs); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Get Criteria Logs |
|
109 | - * @param $crLogs |
|
110 | - * @param int $start |
|
111 | - * @param int $limit |
|
112 | - * @param string $sort |
|
113 | - * @param string $order |
|
114 | - * @return int |
|
115 | - */ |
|
116 | - private function getLogsCriteria($crLogs, $start, $limit, $sort, $order) |
|
117 | - { |
|
118 | - $crLogs->setStart($start); |
|
119 | - $crLogs->setLimit($limit); |
|
120 | - $crLogs->setSort($sort); |
|
121 | - $crLogs->setOrder($order); |
|
122 | - return $crLogs; |
|
123 | - } |
|
34 | + /** |
|
35 | + * Constructor |
|
36 | + * |
|
37 | + * @param \XoopsDatabase $db |
|
38 | + */ |
|
39 | + public function __construct(\XoopsDatabase $db) |
|
40 | + { |
|
41 | + parent::__construct($db, 'wggithub_logs', Logs::class, 'log_id', 'log_detail'); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * @param bool $isNew |
|
46 | + * |
|
47 | + * @return object |
|
48 | + */ |
|
49 | + public function create($isNew = true) |
|
50 | + { |
|
51 | + return parent::create($isNew); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * retrieve a field |
|
56 | + * |
|
57 | + * @param int $i field id |
|
58 | + * @param null fields |
|
59 | + * @return mixed reference to the {@link Get} object |
|
60 | + */ |
|
61 | + public function get($i = null, $fields = null) |
|
62 | + { |
|
63 | + return parent::get($i, $fields); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * get inserted id |
|
68 | + * |
|
69 | + * @param null |
|
70 | + * @return int reference to the {@link Get} object |
|
71 | + */ |
|
72 | + public function getInsertId() |
|
73 | + { |
|
74 | + return $this->db->getInsertId(); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Get Count Logs in the database |
|
79 | + * @param int $start |
|
80 | + * @param int $limit |
|
81 | + * @param string $sort |
|
82 | + * @param string $order |
|
83 | + * @return int |
|
84 | + */ |
|
85 | + public function getCountLogs($start = 0, $limit = 0, $sort = 'log_id', $order = 'ASC') |
|
86 | + { |
|
87 | + $crCountLogs = new \CriteriaCompo(); |
|
88 | + $crCountLogs = $this->getLogsCriteria($crCountLogs, $start, $limit, $sort, $order); |
|
89 | + return $this->getCount($crCountLogs); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Get All Logs in the database |
|
94 | + * @param int $start |
|
95 | + * @param int $limit |
|
96 | + * @param string $sort |
|
97 | + * @param string $order |
|
98 | + * @return array |
|
99 | + */ |
|
100 | + public function getAllLogs($start = 0, $limit = 0, $sort = 'log_id', $order = 'ASC') |
|
101 | + { |
|
102 | + $crAllLogs = new \CriteriaCompo(); |
|
103 | + $crAllLogs = $this->getLogsCriteria($crAllLogs, $start, $limit, $sort, $order); |
|
104 | + return $this->getAll($crAllLogs); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Get Criteria Logs |
|
109 | + * @param $crLogs |
|
110 | + * @param int $start |
|
111 | + * @param int $limit |
|
112 | + * @param string $sort |
|
113 | + * @param string $order |
|
114 | + * @return int |
|
115 | + */ |
|
116 | + private function getLogsCriteria($crLogs, $start, $limit, $sort, $order) |
|
117 | + { |
|
118 | + $crLogs->setStart($start); |
|
119 | + $crLogs->setLimit($limit); |
|
120 | + $crLogs->setSort($sort); |
|
121 | + $crLogs->setOrder($order); |
|
122 | + return $crLogs; |
|
123 | + } |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Update table requests |
@@ -142,7 +142,7 @@ |
||
142 | 142 | $logsObj->setVar('log_type', $type); |
143 | 143 | $logsObj->setVar('log_details', $detail); |
144 | 144 | $logsObj->setVar('log_result', $result); |
145 | - $logsObj->setVar('log_datecreated',time()); |
|
145 | + $logsObj->setVar('log_datecreated', time()); |
|
146 | 146 | $logsObj->setVar('log_submitter', $submitter); |
147 | 147 | // Insert Data |
148 | 148 | if ($logsHandler->insert($logsObj)) { |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | Github\GithubClient |
29 | 29 | }; |
30 | 30 | |
31 | -require __DIR__ . '/header.php'; |
|
31 | +require __DIR__.'/header.php'; |
|
32 | 32 | $GLOBALS['xoopsOption']['template_main'] = 'wggithub_index.tpl'; |
33 | -include_once \XOOPS_ROOT_PATH . '/header.php'; |
|
33 | +include_once \XOOPS_ROOT_PATH.'/header.php'; |
|
34 | 34 | |
35 | 35 | // Permissions |
36 | 36 | $permGlobalView = $permissionsHandler->getPermGlobalView(); |
37 | 37 | if (!$permGlobalView) { |
38 | 38 | $GLOBALS['xoopsTpl']->assign('error', _NOPERM); |
39 | - require __DIR__ . '/footer.php'; |
|
39 | + require __DIR__.'/footer.php'; |
|
40 | 40 | } |
41 | 41 | $permGlobalRead = $permissionsHandler->getPermGlobalRead(); |
42 | 42 | $permReadmeUpdate = $permissionsHandler->getPermReadmeUpdate(); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | // Define Stylesheet |
52 | 52 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
53 | -$GLOBALS['xoTheme']->addStylesheet(WGGITHUB_URL . '/assets/css/tabs.css', null); |
|
53 | +$GLOBALS['xoTheme']->addStylesheet(WGGITHUB_URL.'/assets/css/tabs.css', null); |
|
54 | 54 | $keywords = []; |
55 | 55 | // |
56 | 56 | $GLOBALS['xoopsTpl']->assign('xoops_icons32_url', XOOPS_ICONS32_URL); |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | foreach (\array_keys($directoriesAll) as $i) { |
121 | 121 | $directories[$i] = $directoriesAll[$i]->getValuesDirectories(); |
122 | 122 | $dirName = $directoriesAll[$i]->getVar('dir_name'); |
123 | - $dirFilterRelease = (bool)$directoriesAll[$i]->getVar('dir_filterrelease'); |
|
123 | + $dirFilterRelease = (bool) $directoriesAll[$i]->getVar('dir_filterrelease'); |
|
124 | 124 | $repos = []; |
125 | 125 | $crRepositories = new \CriteriaCompo(); |
126 | 126 | $crRepositories->add(new \Criteria('repo_user', $dirName)); |
127 | 127 | $repositoriesCountTotal = $repositoriesHandler->getCount($crRepositories); |
128 | 128 | if ('any' === $filterRelease && $dirFilterRelease) { |
129 | - $crRepositories->add(new \Criteria('repo_prerelease', 1) ); |
|
129 | + $crRepositories->add(new \Criteria('repo_prerelease', 1)); |
|
130 | 130 | $crRepositories->add(new \Criteria('repo_release', 1), 'OR'); |
131 | 131 | } |
132 | 132 | if ('final' === $filterRelease && $dirFilterRelease) { |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | } |
182 | 182 | $directories[$i]['repos'] = $repos; |
183 | 183 | $directories[$i]['previousRepos'] = $start > 0; |
184 | - $directories[$i]['previousOp'] = '&start=' . ($start - $limit) . '&limit=' . $limit . '&release=' . $filterRelease . '&sortby=' . $filterSortby; |
|
184 | + $directories[$i]['previousOp'] = '&start='.($start - $limit).'&limit='.$limit.'&release='.$filterRelease.'&sortby='.$filterSortby; |
|
185 | 185 | $directories[$i]['nextRepos'] = ($repositoriesCount - $start) > $limit; |
186 | - $directories[$i]['nextOp'] = '&start=' . ($start + $limit) . '&limit=' . $limit . '&release=' . $filterRelease . '&sortby=' . $filterSortby; |
|
186 | + $directories[$i]['nextOp'] = '&start='.($start + $limit).'&limit='.$limit.'&release='.$filterRelease.'&sortby='.$filterSortby; |
|
187 | 187 | $GLOBALS['xoopsTpl']->assign('start', $start); |
188 | 188 | $GLOBALS['xoopsTpl']->assign('limit', $limit); |
189 | 189 | $GLOBALS['xoopsTpl']->assign('menu', $menu); |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | unset($crDirectories, $directories); |
195 | 195 | // Display Navigation |
196 | 196 | if ($directoriesCount > $limit) { |
197 | - require_once \XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
198 | - $pagenav = new \XoopsPageNav($directoriesCount, $limit, $start, 'start', 'op=list&limit=' . $limit); |
|
197 | + require_once \XOOPS_ROOT_PATH.'/class/pagenav.php'; |
|
198 | + $pagenav = new \XoopsPageNav($directoriesCount, $limit, $start, 'start', 'op=list&limit='.$limit); |
|
199 | 199 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
200 | 200 | } |
201 | 201 | $GLOBALS['xoopsTpl']->assign('lang_thereare', \sprintf(\_MA_WGGITHUB_INDEX_THEREARE, $directoriesCount)); |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | // Permissions |
209 | 209 | if (!$permGlobalRead) { |
210 | 210 | $GLOBALS['xoopsTpl']->assign('error', \_NOPERM); |
211 | - require __DIR__ . '/footer.php'; |
|
211 | + require __DIR__.'/footer.php'; |
|
212 | 212 | } |
213 | 213 | $dirName = Request::getString('dir_name', ''); |
214 | 214 | $result = executeUpdate($dirName); |
215 | - $redir = 'index.php?op=list_afterupdate&start=' . $start . '&limit=' . $limit . '&release=' . $filterRelease . '&sortby=' . $filterSortby; |
|
215 | + $redir = 'index.php?op=list_afterupdate&start='.$start.'&limit='.$limit.'&release='.$filterRelease.'&sortby='.$filterSortby; |
|
216 | 216 | if ($result) { |
217 | 217 | \redirect_header($redir, 2, \_MA_WGGITHUB_READGH_SUCCESS); |
218 | 218 | } else { |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | // Permissions |
225 | 225 | if (!$permReadmeUpdate) { |
226 | 226 | $GLOBALS['xoopsTpl']->assign('error', \_NOPERM); |
227 | - require __DIR__ . '/footer.php'; |
|
227 | + require __DIR__.'/footer.php'; |
|
228 | 228 | } |
229 | 229 | $repoId = Request::getInt('repo_id', 0); |
230 | 230 | $repoUser = Request::getString('repo_user', 'none'); |
231 | 231 | $repoName = Request::getString('repo_name', 'none'); |
232 | 232 | $result = $helper->getHandler('Readmes')->updateReadmes($repoId, $repoUser, $repoName); |
233 | - $redir = 'index.php?op=list_afterupdate&start=' . $start . '&limit=' . $limit . '&release=' . $filterRelease . '&sortby=' . $filterSortby; |
|
233 | + $redir = 'index.php?op=list_afterupdate&start='.$start.'&limit='.$limit.'&release='.$filterRelease.'&sortby='.$filterSortby; |
|
234 | 234 | if ($result) { |
235 | 235 | \redirect_header($redir, 2, \_MA_WGGITHUB_READGH_SUCCESS); |
236 | 236 | } else { |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | // Breadcrumbs |
244 | 244 | $xoBreadcrumbs[] = ['title' => \_MA_WGGITHUB_INDEX]; |
245 | 245 | // Keywords |
246 | -wggithubMetaKeywords($helper->getConfig('keywords') . ', ' . \implode(',', $keywords)); |
|
246 | +wggithubMetaKeywords($helper->getConfig('keywords').', '.\implode(',', $keywords)); |
|
247 | 247 | unset($keywords); |
248 | 248 | // Description |
249 | 249 | wggithubMetaDescription(\_MA_WGGITHUB_INDEX_DESC); |
250 | 250 | $GLOBALS['xoopsTpl']->assign('xoops_mpageurl', WGGITHUB_URL.'/index.php'); |
251 | 251 | $GLOBALS['xoopsTpl']->assign('xoops_icons32_url', XOOPS_ICONS32_URL); |
252 | 252 | $GLOBALS['xoopsTpl']->assign('wggithub_upload_url', WGGITHUB_UPLOAD_URL); |
253 | -require __DIR__ . '/footer.php'; |
|
253 | +require __DIR__.'/footer.php'; |
|
254 | 254 | |
255 | 255 | |
256 | 256 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param string $dirName |
259 | 259 | * @return bool |
260 | 260 | */ |
261 | -function executeUpdate($dirName = ''){ |
|
261 | +function executeUpdate($dirName = '') { |
|
262 | 262 | |
263 | 263 | $githubClient = GithubClient::getInstance(); |
264 | 264 | $helper = Helper::getInstance(); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | public function testMilo($url) { |
83 | 83 | $api = new Github\Api; |
84 | - $response = $api->get(static::BASE_URL . $url); |
|
84 | + $response = $api->get(static::BASE_URL.$url); |
|
85 | 85 | $data = $api->decode($response); |
86 | 86 | |
87 | 87 | return $data; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | $token = new Github\OAuth\Token('{myKey}', 'bearer', ['repo', 'user', 'public_repo']); |
94 | 94 | $api->setToken($token); |
95 | - $response = $api->get(static::BASE_URL . $url); |
|
95 | + $response = $api->get(static::BASE_URL.$url); |
|
96 | 96 | |
97 | 97 | $data = $api->decode($response); |
98 | 98 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function getUserRepositories($username, $per_page = 100, $page = 1) |
119 | 119 | { |
120 | - $url = static::BASE_URL . 'users/' . \rawurlencode($username) . '/repos?per_page=' . $per_page . '&page=' . $page; |
|
120 | + $url = static::BASE_URL.'users/'.\rawurlencode($username).'/repos?per_page='.$per_page.'&page='.$page; |
|
121 | 121 | |
122 | 122 | return $this->_get($url); |
123 | 123 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function getOrgRepositories($org, $per_page = 100, $page = 1) |
134 | 134 | { |
135 | - $url = static::BASE_URL . 'orgs/' . \rawurlencode($org) . '/repos?per_page=' . $per_page . '&page=' . $page; |
|
135 | + $url = static::BASE_URL.'orgs/'.\rawurlencode($org).'/repos?per_page='.$per_page.'&page='.$page; |
|
136 | 136 | |
137 | 137 | return $this->_get($url); |
138 | 138 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function getReadme($username, $repository) |
148 | 148 | { |
149 | - $url = static::BASE_URL . 'repos/' . \rawurlencode($username) . '/' . \rawurlencode($repository) . '/readme'; |
|
149 | + $url = static::BASE_URL.'repos/'.\rawurlencode($username).'/'.\rawurlencode($repository).'/readme'; |
|
150 | 150 | |
151 | 151 | return $this->_get($url); |
152 | 152 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function getReleases($username, $repository) |
162 | 162 | { |
163 | - $url = static::BASE_URL . 'repos/' . $username . '/' . $repository . '/releases'; |
|
163 | + $url = static::BASE_URL.'repos/'.$username.'/'.$repository.'/releases'; |
|
164 | 164 | |
165 | 165 | return $this->_get($url); |
166 | 166 | } |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | public function getLatestRelease($username, $repository, $prerelease = false) |
177 | 177 | { |
178 | 178 | if ($prerelease) { |
179 | - $url = static::BASE_URL . 'repos/' . $username . '/' . $repository . '/releases'; |
|
179 | + $url = static::BASE_URL.'repos/'.$username.'/'.$repository.'/releases'; |
|
180 | 180 | } else { |
181 | - $url = static::BASE_URL . 'repos/' . $username . '/' . $repository . '/releases/latest'; |
|
181 | + $url = static::BASE_URL.'repos/'.$username.'/'.$repository.'/releases/latest'; |
|
182 | 182 | } |
183 | 183 | $result = $this->_get($url); |
184 | 184 | |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | } else { |
217 | 217 | $error = true; |
218 | 218 | $errMsg = $response->getContent(); |
219 | - $logsHandler->updateTableLogs(Constants::LOG_TYPE_ERROR, $errMsg, 'ERROR ' . $code); |
|
219 | + $logsHandler->updateTableLogs(Constants::LOG_TYPE_ERROR, $errMsg, 'ERROR '.$code); |
|
220 | 220 | } |
221 | 221 | if ($error) { |
222 | 222 | //catch common errors |
223 | 223 | switch ($code) { |
224 | 224 | case 401: |
225 | - throw new \RuntimeException('"' . \_MA_WGGITHUB_READGH_ERROR_API_401 . '"'); |
|
225 | + throw new \RuntimeException('"'.\_MA_WGGITHUB_READGH_ERROR_API_401.'"'); |
|
226 | 226 | break; |
227 | 227 | case 403: |
228 | 228 | /* |
@@ -230,21 +230,21 @@ discard block |
||
230 | 230 | $GLOBALS['xoopsTpl']->assign('apiexceed', true); |
231 | 231 | } |
232 | 232 | */ |
233 | - throw new \RuntimeException('"' . \_MA_WGGITHUB_READGH_ERROR_API_403 . '"'); |
|
233 | + throw new \RuntimeException('"'.\_MA_WGGITHUB_READGH_ERROR_API_403.'"'); |
|
234 | 234 | break; |
235 | 235 | case 404: |
236 | - throw new \RuntimeException('"' . \_MA_WGGITHUB_READGH_ERROR_API_404 . '"'); |
|
236 | + throw new \RuntimeException('"'.\_MA_WGGITHUB_READGH_ERROR_API_404.'"'); |
|
237 | 237 | break; |
238 | 238 | case 405: |
239 | - throw new \RuntimeException('"' . \_MA_WGGITHUB_READGH_ERROR_API_405 . '"'); |
|
239 | + throw new \RuntimeException('"'.\_MA_WGGITHUB_READGH_ERROR_API_405.'"'); |
|
240 | 240 | break; |
241 | 241 | case 0: |
242 | 242 | default: |
243 | - throw new \RuntimeException('"' . \_MA_WGGITHUB_READGH_ERROR_API . $errMsg . '"'); |
|
243 | + throw new \RuntimeException('"'.\_MA_WGGITHUB_READGH_ERROR_API.$errMsg.'"'); |
|
244 | 244 | break; |
245 | 245 | } |
246 | 246 | } |
247 | - $data = (array)$api->decode($response); |
|
247 | + $data = (array) $api->decode($response); |
|
248 | 248 | |
249 | 249 | return $data; |
250 | 250 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $setting = $settingsHandler->getPrimarySetting(); |
261 | 261 | |
262 | 262 | if (0 == \count($setting)) { |
263 | - \redirect_header(\XOOPS_URL . '/index.php', 3, \_AM_WGGITHUB_THEREARENT_SETTINGS); |
|
263 | + \redirect_header(\XOOPS_URL.'/index.php', 3, \_AM_WGGITHUB_THEREARENT_SETTINGS); |
|
264 | 264 | } |
265 | 265 | //$this->userAuth = $setting['user']; |
266 | 266 | $this->tokenAuth = $setting['token']; |
@@ -8,169 +8,169 @@ |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | namespace XoopsModules\Wggithub\Github { |
11 | - /** |
|
12 | - * Marker interface. |
|
13 | - */ |
|
14 | - interface IException |
|
15 | - {} |
|
11 | + /** |
|
12 | + * Marker interface. |
|
13 | + */ |
|
14 | + interface IException |
|
15 | + {} |
|
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * Wrong algorithm. API is used in wrong way. Application code should be changed. |
|
20 | - */ |
|
21 | - class LogicException extends \LogicException implements IException |
|
22 | - {} |
|
18 | + /** |
|
19 | + * Wrong algorithm. API is used in wrong way. Application code should be changed. |
|
20 | + */ |
|
21 | + class LogicException extends \LogicException implements IException |
|
22 | + {} |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Substitution is used in URL path but corresponding parameter is missing. |
|
27 | - */ |
|
28 | - class MissingParameterException extends LogicException |
|
29 | - {} |
|
25 | + /** |
|
26 | + * Substitution is used in URL path but corresponding parameter is missing. |
|
27 | + */ |
|
28 | + class MissingParameterException extends LogicException |
|
29 | + {} |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Unpredictable situation occurred. |
|
34 | - */ |
|
35 | - abstract class RuntimeException extends \RuntimeException implements IException |
|
36 | - {} |
|
32 | + /** |
|
33 | + * Unpredictable situation occurred. |
|
34 | + */ |
|
35 | + abstract class RuntimeException extends \RuntimeException implements IException |
|
36 | + {} |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Github API returned a non-success HTTP code or data are somehow wrong. See all following descendants. |
|
41 | - * |
|
42 | - * @see Api::decode() |
|
43 | - * @see https://developer.github.com/v3/#client-errors |
|
44 | - */ |
|
45 | - abstract class ApiException extends RuntimeException |
|
46 | - { |
|
47 | - /** @var Http\Response|NULL */ |
|
48 | - private $response; |
|
39 | + /** |
|
40 | + * Github API returned a non-success HTTP code or data are somehow wrong. See all following descendants. |
|
41 | + * |
|
42 | + * @see Api::decode() |
|
43 | + * @see https://developer.github.com/v3/#client-errors |
|
44 | + */ |
|
45 | + abstract class ApiException extends RuntimeException |
|
46 | + { |
|
47 | + /** @var Http\Response|NULL */ |
|
48 | + private $response; |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @param string |
|
53 | - * @param int |
|
54 | - */ |
|
55 | - public function __construct($message = '', $code = 0, \Exception $previous = NULL, Http\Response $response = NULL) |
|
56 | - { |
|
57 | - parent::__construct($message, $code, $previous); |
|
58 | - $this->response = clone $response; |
|
59 | - } |
|
51 | + /** |
|
52 | + * @param string |
|
53 | + * @param int |
|
54 | + */ |
|
55 | + public function __construct($message = '', $code = 0, \Exception $previous = NULL, Http\Response $response = NULL) |
|
56 | + { |
|
57 | + parent::__construct($message, $code, $previous); |
|
58 | + $this->response = clone $response; |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * @return Http\Response|NULL |
|
64 | - */ |
|
65 | - final public function getResponse() |
|
66 | - { |
|
67 | - return $this->response; |
|
68 | - } |
|
62 | + /** |
|
63 | + * @return Http\Response|NULL |
|
64 | + */ |
|
65 | + final public function getResponse() |
|
66 | + { |
|
67 | + return $this->response; |
|
68 | + } |
|
69 | 69 | |
70 | - } |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * Invalid credentials (e.g. revoked token). |
|
75 | - */ |
|
76 | - class UnauthorizedException extends ApiException |
|
77 | - {} |
|
73 | + /** |
|
74 | + * Invalid credentials (e.g. revoked token). |
|
75 | + */ |
|
76 | + class UnauthorizedException extends ApiException |
|
77 | + {} |
|
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * Invalid JSON sent to Github API. |
|
82 | - */ |
|
83 | - class BadRequestException extends ApiException |
|
84 | - {} |
|
80 | + /** |
|
81 | + * Invalid JSON sent to Github API. |
|
82 | + */ |
|
83 | + class BadRequestException extends ApiException |
|
84 | + {} |
|
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * Invalid structure sent to Github API (e.g. some required fields are missing). |
|
89 | - */ |
|
90 | - class UnprocessableEntityException extends ApiException |
|
91 | - {} |
|
87 | + /** |
|
88 | + * Invalid structure sent to Github API (e.g. some required fields are missing). |
|
89 | + */ |
|
90 | + class UnprocessableEntityException extends ApiException |
|
91 | + {} |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * Access denied. |
|
96 | - * @see https://developer.github.com/v3/#authentication |
|
97 | - */ |
|
98 | - class ForbiddenException extends ApiException |
|
99 | - {} |
|
94 | + /** |
|
95 | + * Access denied. |
|
96 | + * @see https://developer.github.com/v3/#authentication |
|
97 | + */ |
|
98 | + class ForbiddenException extends ApiException |
|
99 | + {} |
|
100 | 100 | |
101 | 101 | |
102 | - /** |
|
103 | - * Rate limit exceed. |
|
104 | - * @see https://developer.github.com/v3/#rate-limiting |
|
105 | - */ |
|
106 | - class RateLimitExceedException extends ForbiddenException |
|
107 | - {} |
|
102 | + /** |
|
103 | + * Rate limit exceed. |
|
104 | + * @see https://developer.github.com/v3/#rate-limiting |
|
105 | + */ |
|
106 | + class RateLimitExceedException extends ForbiddenException |
|
107 | + {} |
|
108 | 108 | |
109 | 109 | |
110 | - /** |
|
111 | - * Resource not found. |
|
112 | - * @see https://developer.github.com/v3/#authentication |
|
113 | - */ |
|
114 | - class NotFoundException extends ApiException |
|
115 | - {} |
|
110 | + /** |
|
111 | + * Resource not found. |
|
112 | + * @see https://developer.github.com/v3/#authentication |
|
113 | + */ |
|
114 | + class NotFoundException extends ApiException |
|
115 | + {} |
|
116 | 116 | |
117 | 117 | |
118 | - /** |
|
119 | - * Response cannot be classified. |
|
120 | - */ |
|
121 | - class UnexpectedResponseException extends ApiException |
|
122 | - {} |
|
118 | + /** |
|
119 | + * Response cannot be classified. |
|
120 | + */ |
|
121 | + class UnexpectedResponseException extends ApiException |
|
122 | + {} |
|
123 | 123 | |
124 | 124 | |
125 | - /** |
|
126 | - * Response from Github is somehow wrong (e.g. invalid JSON decoding). |
|
127 | - */ |
|
128 | - class InvalidResponseException extends ApiException |
|
129 | - {} |
|
125 | + /** |
|
126 | + * Response from Github is somehow wrong (e.g. invalid JSON decoding). |
|
127 | + */ |
|
128 | + class InvalidResponseException extends ApiException |
|
129 | + {} |
|
130 | 130 | |
131 | 131 | |
132 | - /** |
|
133 | - * JSON cannot be decoded, or value cannot be encoded to JSON. |
|
134 | - */ |
|
135 | - class JsonException extends RuntimeException |
|
136 | - { |
|
137 | - } |
|
132 | + /** |
|
133 | + * JSON cannot be decoded, or value cannot be encoded to JSON. |
|
134 | + */ |
|
135 | + class JsonException extends RuntimeException |
|
136 | + { |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
140 | 140 | |
141 | 141 | |
142 | 142 | namespace Milo\Github\Http { |
143 | - use Milo\Github; |
|
143 | + use Milo\Github; |
|
144 | 144 | |
145 | 145 | |
146 | - /** |
|
147 | - * HTTP response is somehow wrong and cannot be processed. |
|
148 | - */ |
|
149 | - class BadResponseException extends Github\RuntimeException |
|
150 | - {} |
|
146 | + /** |
|
147 | + * HTTP response is somehow wrong and cannot be processed. |
|
148 | + */ |
|
149 | + class BadResponseException extends Github\RuntimeException |
|
150 | + {} |
|
151 | 151 | |
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | 155 | namespace Milo\Github\OAuth { |
156 | - use Milo\Github; |
|
156 | + use Milo\Github; |
|
157 | 157 | |
158 | - /** |
|
159 | - * Something fails during the token obtaining. |
|
160 | - */ |
|
161 | - class LoginException extends Github\RuntimeException |
|
162 | - {} |
|
158 | + /** |
|
159 | + * Something fails during the token obtaining. |
|
160 | + */ |
|
161 | + class LoginException extends Github\RuntimeException |
|
162 | + {} |
|
163 | 163 | |
164 | 164 | } |
165 | 165 | |
166 | 166 | |
167 | 167 | namespace Milo\Github\Storages { |
168 | - use Milo\Github; |
|
168 | + use Milo\Github; |
|
169 | 169 | |
170 | - /** |
|
171 | - * Directory is missing and/or cannot be created. |
|
172 | - */ |
|
173 | - class MissingDirectoryException extends Github\RuntimeException |
|
174 | - {} |
|
170 | + /** |
|
171 | + * Directory is missing and/or cannot be created. |
|
172 | + */ |
|
173 | + class MissingDirectoryException extends Github\RuntimeException |
|
174 | + {} |
|
175 | 175 | |
176 | 176 | } |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | Github\GithubClient |
29 | 29 | }; |
30 | 30 | |
31 | -require __DIR__ . '/header.php'; |
|
31 | +require __DIR__.'/header.php'; |
|
32 | 32 | $GLOBALS['xoopsOption']['template_main'] = 'wggithub_index.tpl'; |
33 | -include_once \XOOPS_ROOT_PATH . '/header.php'; |
|
33 | +include_once \XOOPS_ROOT_PATH.'/header.php'; |
|
34 | 34 | // Define Stylesheet |
35 | 35 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
36 | 36 | $keywords = []; |
@@ -166,4 +166,4 @@ discard block |
||
166 | 166 | var_dump($result); |
167 | 167 | */ |
168 | 168 | |
169 | -require __DIR__ . '/footer.php'; |
|
169 | +require __DIR__.'/footer.php'; |
@@ -27,52 +27,52 @@ |
||
27 | 27 | $sysPathIcon32 = $moduleInfo->getInfo('sysicons32'); |
28 | 28 | |
29 | 29 | $adminmenu[] = [ |
30 | - 'title' => _MI_WGGITHUB_ADMENU1, |
|
31 | - 'link' => 'admin/index.php', |
|
32 | - 'icon' => 'assets/icons/32/dashboard.png', |
|
30 | + 'title' => _MI_WGGITHUB_ADMENU1, |
|
31 | + 'link' => 'admin/index.php', |
|
32 | + 'icon' => 'assets/icons/32/dashboard.png', |
|
33 | 33 | ]; |
34 | 34 | $adminmenu[] = [ |
35 | - 'title' => _MI_WGGITHUB_ADMENU2, |
|
36 | - 'link' => 'admin/settings.php', |
|
37 | - 'icon' => 'assets/icons/32/settings.png', |
|
35 | + 'title' => _MI_WGGITHUB_ADMENU2, |
|
36 | + 'link' => 'admin/settings.php', |
|
37 | + 'icon' => 'assets/icons/32/settings.png', |
|
38 | 38 | ]; |
39 | 39 | $adminmenu[] = [ |
40 | - 'title' => _MI_WGGITHUB_ADMENU3, |
|
41 | - 'link' => 'admin/directories.php', |
|
42 | - 'icon' => 'assets/icons/32/directories.png', |
|
40 | + 'title' => _MI_WGGITHUB_ADMENU3, |
|
41 | + 'link' => 'admin/directories.php', |
|
42 | + 'icon' => 'assets/icons/32/directories.png', |
|
43 | 43 | ]; |
44 | 44 | $adminmenu[] = [ |
45 | - 'title' => _MI_WGGITHUB_ADMENU4, |
|
46 | - 'link' => 'admin/logs.php', |
|
47 | - 'icon' => 'assets/icons/32/logs.png', |
|
45 | + 'title' => _MI_WGGITHUB_ADMENU4, |
|
46 | + 'link' => 'admin/logs.php', |
|
47 | + 'icon' => 'assets/icons/32/logs.png', |
|
48 | 48 | ]; |
49 | 49 | $adminmenu[] = [ |
50 | - 'title' => _MI_WGGITHUB_ADMENU5, |
|
51 | - 'link' => 'admin/repositories.php', |
|
52 | - 'icon' => 'assets/icons/32/repositories.png', |
|
50 | + 'title' => _MI_WGGITHUB_ADMENU5, |
|
51 | + 'link' => 'admin/repositories.php', |
|
52 | + 'icon' => 'assets/icons/32/repositories.png', |
|
53 | 53 | ]; |
54 | 54 | $adminmenu[] = [ |
55 | - 'title' => _MI_WGGITHUB_ADMENU6, |
|
56 | - 'link' => 'admin/readmes.php', |
|
57 | - 'icon' => 'assets/icons/32/readmes.png', |
|
55 | + 'title' => _MI_WGGITHUB_ADMENU6, |
|
56 | + 'link' => 'admin/readmes.php', |
|
57 | + 'icon' => 'assets/icons/32/readmes.png', |
|
58 | 58 | ]; |
59 | 59 | $adminmenu[] = [ |
60 | - 'title' => _MI_WGGITHUB_ADMENU7, |
|
61 | - 'link' => 'admin/releases.php', |
|
62 | - 'icon' => 'assets/icons/32/releases.png', |
|
60 | + 'title' => _MI_WGGITHUB_ADMENU7, |
|
61 | + 'link' => 'admin/releases.php', |
|
62 | + 'icon' => 'assets/icons/32/releases.png', |
|
63 | 63 | ]; |
64 | 64 | $adminmenu[] = [ |
65 | - 'title' => _MI_WGGITHUB_ADMENU8, |
|
66 | - 'link' => 'admin/permissions.php', |
|
67 | - 'icon' => 'assets/icons/32/permissions.png', |
|
65 | + 'title' => _MI_WGGITHUB_ADMENU8, |
|
66 | + 'link' => 'admin/permissions.php', |
|
67 | + 'icon' => 'assets/icons/32/permissions.png', |
|
68 | 68 | ]; |
69 | 69 | $adminmenu[] = [ |
70 | - 'title' => _MI_WGGITHUB_ADMENU9, |
|
71 | - 'link' => 'admin/feedback.php', |
|
72 | - 'icon' => 'assets/icons/32/feedback.png', |
|
70 | + 'title' => _MI_WGGITHUB_ADMENU9, |
|
71 | + 'link' => 'admin/feedback.php', |
|
72 | + 'icon' => 'assets/icons/32/feedback.png', |
|
73 | 73 | ]; |
74 | 74 | $adminmenu[] = [ |
75 | - 'title' => _MI_WGGITHUB_ABOUT, |
|
76 | - 'link' => 'admin/about.php', |
|
77 | - 'icon' => 'assets/icons/32/about.png', |
|
75 | + 'title' => _MI_WGGITHUB_ABOUT, |
|
76 | + 'link' => 'admin/about.php', |
|
77 | + 'icon' => 'assets/icons/32/about.png', |
|
78 | 78 | ]; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | use XoopsModules\Wggithub; |
31 | 31 | use XoopsModules\Wggithub\Github; |
32 | 32 | |
33 | -require __DIR__ . '/header.php'; |
|
33 | +require __DIR__.'/header.php'; |
|
34 | 34 | // It recovered the value of argument op in URL$ |
35 | 35 | |
36 | 36 | /* |
@@ -45,46 +45,46 @@ discard block |
||
45 | 45 | |
46 | 46 | $data = []; |
47 | 47 | $url = '/orgs/XoopsModules25x/repos?per_page=100&page=1'; |
48 | -echo "<br>Test read org repo:" . $url; |
|
48 | +echo "<br>Test read org repo:".$url; |
|
49 | 49 | $api = new XoopsModules\Wggithub\Github\GithubClient(); |
50 | 50 | $data = $api->testMilo($url); |
51 | 51 | $count = 0; |
52 | 52 | foreach ($data as $key => $repo) { |
53 | - echo "<br>key:" . $key . ' repo:' . $repo['name']; |
|
53 | + echo "<br>key:".$key.' repo:'.$repo['name']; |
|
54 | 54 | $count++; |
55 | - if ($count>5) {break;} |
|
55 | + if ($count > 5) {break; } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
59 | 59 | $data = []; |
60 | 60 | $url = '/users/ggoffy/repos?per_page=100&page=1'; |
61 | -echo "<br><br>Test read user repo:" . $url; |
|
61 | +echo "<br><br>Test read user repo:".$url; |
|
62 | 62 | $api = new XoopsModules\Wggithub\Github\GithubClient(); |
63 | 63 | $data = $api->testMilo($url); |
64 | 64 | $count = 0; |
65 | 65 | foreach ($data as $key => $repo) { |
66 | - echo "<br>key:" . $key . ' repo:' . $repo['name']; |
|
66 | + echo "<br>key:".$key.' repo:'.$repo['name']; |
|
67 | 67 | $count++; |
68 | - if ($count>5) {break;} |
|
68 | + if ($count > 5) {break; } |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
72 | 72 | $data = []; |
73 | 73 | $url = '/repos/XoopsModules25x/smallworld/readme'; |
74 | -echo "<br><br>test read readme orgs:" . $url; |
|
74 | +echo "<br><br>test read readme orgs:".$url; |
|
75 | 75 | $api = new XoopsModules\Wggithub\Github\GithubClient(); |
76 | 76 | $data = $api->testMilo($url); |
77 | -echo '<br>name:' . $data['name']; |
|
78 | -echo '<br>download_url:' . $data['download_url']; |
|
77 | +echo '<br>name:'.$data['name']; |
|
78 | +echo '<br>download_url:'.$data['download_url']; |
|
79 | 79 | |
80 | 80 | |
81 | 81 | $data = []; |
82 | 82 | $url = '/repos/ggoffy/wggithub/readme'; |
83 | -echo "<br><br>test read readme user:" . $url; |
|
83 | +echo "<br><br>test read readme user:".$url; |
|
84 | 84 | $api = new XoopsModules\Wggithub\Github\GithubClient(); |
85 | 85 | $data = $api->testMilo($url); |
86 | -echo '<br>name:' . $data['name']; |
|
87 | -echo '<br>download_url:' . $data['download_url']; |
|
86 | +echo '<br>name:'.$data['name']; |
|
87 | +echo '<br>download_url:'.$data['download_url']; |
|
88 | 88 | |
89 | 89 | |
90 | 90 | echo "<br><br><br>-----------------------------------"; |
@@ -93,45 +93,45 @@ discard block |
||
93 | 93 | |
94 | 94 | $data = []; |
95 | 95 | $url = '/orgs/XoopsModules25x/repos?per_page=100&page=1'; |
96 | -echo "<br>Test read org repo:" . $url; |
|
96 | +echo "<br>Test read org repo:".$url; |
|
97 | 97 | $api = new XoopsModules\Wggithub\Github\GithubClient(); |
98 | 98 | $data = $api->testMilo2($url); |
99 | 99 | $count = 0; |
100 | 100 | foreach ($data as $key => $repo) { |
101 | - echo "<br>key:" . $key . ' repo:' . $repo['name']; |
|
101 | + echo "<br>key:".$key.' repo:'.$repo['name']; |
|
102 | 102 | $count++; |
103 | - if ($count>5) {break;} |
|
103 | + if ($count > 5) {break; } |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
107 | 107 | $data = []; |
108 | 108 | $url = '/users/ggoffy/repos?per_page=100&page=1'; |
109 | -echo "<br><br>Test read user repo:" . $url; |
|
109 | +echo "<br><br>Test read user repo:".$url; |
|
110 | 110 | $api = new XoopsModules\Wggithub\Github\GithubClient(); |
111 | 111 | $data = $api->testMilo2($url); |
112 | 112 | $count = 0; |
113 | 113 | foreach ($data as $key => $repo) { |
114 | - echo "<br>key:" . $key . ' repo:' . $repo['name']; |
|
114 | + echo "<br>key:".$key.' repo:'.$repo['name']; |
|
115 | 115 | $count++; |
116 | - if ($count>5) {break;} |
|
116 | + if ($count > 5) {break; } |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | |
120 | 120 | $data = []; |
121 | 121 | $url = '/repos/XoopsModules25x/smallworld/readme'; |
122 | -echo "<br><br>test read readme orgs:" . $url; |
|
122 | +echo "<br><br>test read readme orgs:".$url; |
|
123 | 123 | $api = new XoopsModules\Wggithub\Github\GithubClient(); |
124 | 124 | $data = $api->testMilo2($url); |
125 | -echo '<br>name:' . $data['name']; |
|
126 | -echo '<br>download_url:' . $data['download_url']; |
|
125 | +echo '<br>name:'.$data['name']; |
|
126 | +echo '<br>download_url:'.$data['download_url']; |
|
127 | 127 | |
128 | 128 | |
129 | 129 | $data = []; |
130 | 130 | $url = '/repos/ggoffy/wggithub/readme'; |
131 | -echo "<br><br>test read readme user:" . $url; |
|
131 | +echo "<br><br>test read readme user:".$url; |
|
132 | 132 | $api = new XoopsModules\Wggithub\Github\GithubClient(); |
133 | 133 | $data = $api->testMilo2($url); |
134 | -echo '<br>name:' . $data['name']; |
|
135 | -echo '<br>download_url:' . $data['download_url']; |
|
134 | +echo '<br>name:'.$data['name']; |
|
135 | +echo '<br>download_url:'.$data['download_url']; |
|
136 | 136 | |
137 | 137 |