diff --git a/blocks/repositories.php b/blocks/repositories.php index 32709f2..1b71c21 100644 --- a/blocks/repositories.php +++ b/blocks/repositories.php @@ -83,7 +83,11 @@ function b_wggithub_repositories_show($options) if (\count($repositoriesAll) > 0) { foreach (\array_keys($repositoriesAll) as $i) { $block[$i]['id'] = $repositoriesAll[$i]->getVar('repo_id'); - $block[$i]['name'] = $myts->htmlSpecialChars($repositoriesAll[$i]->getVar('repo_name')); + $repoName = $myts->htmlSpecialChars($repositoriesAll[$i]->getVar('repo_name')); + if ($lenghtTitle > 0) { + $repoName = \substr($repoName, 0, $lenghtTitle); + } + $block[$i]['name'] = $repoName; $block[$i]['htmlurl'] = $myts->htmlSpecialChars($repositoriesAll[$i]->getVar('repo_htmlurl')); } } diff --git a/class/Common/XoopsConfirm.php b/class/Common/XoopsConfirm.php index 000e43a..cc3f374 100644 --- a/class/Common/XoopsConfirm.php +++ b/class/Common/XoopsConfirm.php @@ -62,19 +62,19 @@ public function __construct($hiddens, $action, $object, $title = '', $label = '' public function getFormXoopsConfirm() { //in order to be accessable from user and admin area this should be place in language common.php - \define('CO__\WGGITHUB_DELETE_CONFIRM', 'Confirm delete'); - \define('CO__\WGGITHUB_DELETE_LABEL', 'Do you really want to delete:'); + \define('CO_WGGITHUB_DELETE_CONFIRM', 'Confirm delete'); + \define('CO_WGGITHUB_DELETE_LABEL', 'Do you really want to delete:'); // Get Theme Form if ('' === $this->action) { $this->action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER'); } if ('' === $this->title) { - $this->title = CO__\WGGITHUB_DELETE_CONFIRM; + $this->title = CO_WGGITHUB_DELETE_CONFIRM; } if ('' === $this->label) { - $this->label = CO__\WGGITHUB_DELETE_LABEL; + $this->label = CO_WGGITHUB_DELETE_LABEL; } \xoops_load('XoopsFormLoader'); @@ -87,8 +87,8 @@ public function getFormXoopsConfirm() } $form->addElement(new \XoopsFormHidden('ok', 1)); $buttonTray = new \XoopsFormElementTray(''); - $buttonTray->addElement(new \XoopsFormButton('', 'confirm_submit', _YES, 'submit')); - $buttonBack = new \XoopsFormButton('', 'confirm_back', _NO, 'button'); + $buttonTray->addElement(new \XoopsFormButton('', 'confirm_submit', \_YES, 'submit')); + $buttonBack = new \XoopsFormButton('', 'confirm_back', \_NO, 'button'); $buttonBack->setExtra('onclick="history.go(-1);return true;"'); $buttonTray->addElement($buttonBack); $form->addElement($buttonTray); diff --git a/class/Github/Api.php b/class/Github/Api.php index 9021fe3..0b3bfee 100644 --- a/class/Github/Api.php +++ b/class/Github/Api.php @@ -35,6 +35,7 @@ public function __construct(Http\IClient $client = NULL) /** + * @param OAuth\Token|null $token * @return self */ public function setToken(OAuth\Token $token = NULL) @@ -98,9 +99,10 @@ public function getDefaultAccept() * @see request() * * @param string + * @param array $parameters + * @param array $headers * @return Http\Response * - * @throws MissingParameterException */ public function delete($urlPath, array $parameters = [], array $headers = []) { @@ -115,9 +117,10 @@ public function delete($urlPath, array $parameters = [], array $headers = []) * @see request() * * @param string + * @param array $parameters + * @param array $headers * @return Http\Response * - * @throws MissingParameterException */ public function get($urlPath, array $parameters = [], array $headers = []) { @@ -132,9 +135,10 @@ public function get($urlPath, array $parameters = [], array $headers = []) * @see request() * * @param string + * @param array $parameters + * @param array $headers * @return Http\Response * - * @throws MissingParameterException */ public function head($urlPath, array $parameters = [], array $headers = []) { @@ -148,12 +152,12 @@ public function head($urlPath, array $parameters = [], array $headers = []) * @see createRequest() * @see request() * - * @param string - * @param mixed + * @param $urlPath + * @param $content + * @param array $parameters + * @param array $headers * @return Http\Response * - * @throws MissingParameterException - * @throws JsonException */ public function patch($urlPath, $content, array $parameters = [], array $headers = []) { @@ -167,12 +171,12 @@ public function patch($urlPath, $content, array $parameters = [], array $headers * @see createRequest() * @see request() * - * @param string - * @param mixed + * @param $urlPath + * @param $content + * @param array $parameters + * @param array $headers * @return Http\Response * - * @throws MissingParameterException - * @throws JsonException */ public function post($urlPath, $content, array $parameters = [], array $headers = []) { @@ -186,12 +190,12 @@ public function post($urlPath, $content, array $parameters = [], array $headers * @see createRequest() * @see request() * - * @param string - * @param mixed + * @param $urlPath + * @param null $content + * @param array $parameters + * @param array $headers * @return Http\Response * - * @throws MissingParameterException - * @throws JsonException */ public function put($urlPath, $content = NULL, array $parameters = [], array $headers = []) { @@ -202,9 +206,9 @@ public function put($urlPath, $content = NULL, array $parameters = [], array $he /** + * @param Http\Request $request * @return Http\Response * - * @throws Http\BadResponseException */ public function request(Http\Request $request) { @@ -324,9 +328,10 @@ public function decode(Http\Response $response, array $okCodes = NULL) * @see get() * * @param string + * @param array $parameters + * @param array $headers * @return Paginator * - * @throws MissingParameterException */ public function paginator($urlPath, array $parameters = [], array $headers = []) { @@ -380,9 +385,10 @@ public function getUrl() /** * @param string + * @param array $parameters + * @param array $defaultParameters * @return string * - * @throws MissingParameterException */ protected function expandColonParameters($url, array $parameters, array $defaultParameters) { @@ -414,6 +420,8 @@ protected function expandColonParameters($url, array $parameters, array $default * @todo Inject remaining default parameters into query string? * * @param string + * @param array $parameters + * @param array $defaultParameters * @return string */ protected function expandUriTemplate($url, array $parameters, array $defaultParameters) diff --git a/class/Github/Github.php b/class/Github/Github.php index 576b143..8d51611 100644 --- a/class/Github/Github.php +++ b/class/Github/Github.php @@ -105,13 +105,6 @@ public function readOrgRepositories($org) */ private function getSetting($user = false) { - - $this->user = 'ggoffy'; - $this->token = 'effca620d3b6a14813e53086c5477646743073aa'; - - return true; - - $helper = Helper::getInstance(); $settingsHandler = $helper->getHandler('Settings'); if ($user) { diff --git a/class/Github/Helpers.php b/class/Github/Helpers.php index 1d80b6e..c8bc799 100644 --- a/class/Github/Helpers.php +++ b/class/Github/Helpers.php @@ -61,10 +61,10 @@ public static function jsonEncode($value) /** - * @param mixed + * @param $json + * @param bool $assoc * @return string * - * @throws JsonException */ public static function jsonDecode($json, $assoc = false) { diff --git a/class/Github/Http/AbstractClient.php b/class/Github/Http/AbstractClient.php index 3f1a492..534927f 100644 --- a/class/Github/Http/AbstractClient.php +++ b/class/Github/Http/AbstractClient.php @@ -32,9 +32,9 @@ abstract class AbstractClient extends Github\Sanity implements IClient /** * @see https://developer.github.com/v3/#http-redirects * + * @param Request $request * @return Response * - * @throws BadResponseException */ public function request(Request $request) { @@ -100,9 +100,9 @@ protected function setupRequest(Request $request) /** + * @param Request $request * @return Response * - * @throws BadResponseException */ abstract protected function process(Request $request); diff --git a/class/Github/Http/CachedClient.php b/class/Github/Http/CachedClient.php index 7a3c840..ce4813d 100644 --- a/class/Github/Http/CachedClient.php +++ b/class/Github/Http/CachedClient.php @@ -27,7 +27,7 @@ class CachedClient extends Github\Sanity implements IClient /** - * @param Storages\ICache + * @param Storages\ICache $cache * @param IClient * @param bool forbid checking Github for new data; more or less development purpose only */ @@ -49,9 +49,9 @@ public function getInnerClient() /** + * @param Request $request * @return Response * - * @throws BadResponseException */ public function request(Request $request) { @@ -126,6 +126,7 @@ public function onResponse($callback) /** + * @param Response $response * @return bool */ protected function isCacheable(Response $response) diff --git a/class/Github/Http/CurlClient.php b/class/Github/Http/CurlClient.php index f69f71e..1a888a8 100644 --- a/class/Github/Http/CurlClient.php +++ b/class/Github/Http/CurlClient.php @@ -42,9 +42,9 @@ protected function setupRequest(Request $request) /** + * @param Request $request * @return Response * - * @throws BadResponseException */ protected function process(Request $request) { diff --git a/class/Github/Http/IClient.php b/class/Github/Http/IClient.php index f35de8b..697d555 100644 --- a/class/Github/Http/IClient.php +++ b/class/Github/Http/IClient.php @@ -11,6 +11,7 @@ interface IClient { /** + * @param Request $request * @return Response */ function request(Request $request); diff --git a/class/Github/Http/Response.php b/class/Github/Http/Response.php index 214f4a6..1c747ae 100644 --- a/class/Github/Http/Response.php +++ b/class/Github/Http/Response.php @@ -74,9 +74,9 @@ public function getPrevious() /** + * @param Response|null $previous * @return self * - * @throws Github\LogicException */ public function setPrevious(Response $previous = NULL) { diff --git a/class/Github/Http/StreamClient.php b/class/Github/Http/StreamClient.php index 13ffae7..f2eea20 100644 --- a/class/Github/Http/StreamClient.php +++ b/class/Github/Http/StreamClient.php @@ -31,9 +31,9 @@ protected function setupRequest(Request $request) /** + * @param Request $request * @return Response * - * @throws BadResponseException */ protected function process(Request $request) { @@ -102,6 +102,7 @@ protected function fileGetContents($url, array $contextOptions) unset($http_response_header[0]); $headers = []; + $last = ''; foreach ($http_response_header as $header) { if (\in_array(\substr($header, 0, 1), [' ', "\t"], TRUE)) { $headers[$last] .= ' ' . \trim($header); # RFC2616, 2.2 diff --git a/class/Github/OAuth/Configuration.php b/class/Github/OAuth/Configuration.php index 873af99..5d6d6c7 100644 --- a/class/Github/OAuth/Configuration.php +++ b/class/Github/OAuth/Configuration.php @@ -36,6 +36,7 @@ public function __construct($clientId, $clientSecret, array $scopes = []) /** + * @param array $conf * @return Configuration */ public static function fromArray(array $conf) diff --git a/class/Github/OAuth/Token.php b/class/Github/OAuth/Token.php index cb0208c..63602a5 100644 --- a/class/Github/OAuth/Token.php +++ b/class/Github/OAuth/Token.php @@ -99,7 +99,10 @@ public function toArray() } - /** @internal */ + /** @internal + * @param array $data + * @return Token + */ public static function createFromArray(array $data) { return new static($data['value'], $data['type'], $data['scopes']); diff --git a/class/Github/Sanity.php b/class/Github/Sanity.php index 36b0563..b542c17 100644 --- a/class/Github/Sanity.php +++ b/class/Github/Sanity.php @@ -9,7 +9,7 @@ abstract class Sanity { /** - * @throws LogicException + * @param $name */ public function & __get($name) { @@ -18,7 +18,8 @@ public function & __get($name) /** - * @throws LogicException + * @param $name + * @param $value */ public function __set($name, $value) { diff --git a/class/Github/Storages/FileCache.php b/class/Github/Storages/FileCache.php index 6c19d3b..570720e 100644 --- a/class/Github/Storages/FileCache.php +++ b/class/Github/Storages/FileCache.php @@ -82,6 +82,8 @@ public function load($key) return $cached; } } + + return false; } diff --git a/class/Github/exceptions.php b/class/Github/exceptions.php index 9403ac0..a981d28 100644 --- a/class/Github/exceptions.php +++ b/class/Github/exceptions.php @@ -51,6 +51,8 @@ abstract class ApiException extends RuntimeException /** * @param string * @param int + * @param \Exception|null $previous + * @param Http\Response|null $response */ public function __construct($message = '', $code = 0, \Exception $previous = NULL, Http\Response $response = NULL) { diff --git a/class/MDParser/Parsedown.php b/class/MDParser/Parsedown.php index e374a42..8e95e71 100644 --- a/class/MDParser/Parsedown.php +++ b/class/MDParser/Parsedown.php @@ -1789,6 +1789,10 @@ protected function li($lines) /** * Replace occurrences $regexp with $Elements in $text. Return an array of * elements representing the replacement. + * @param $regexp + * @param $Elements + * @param $text + * @return array */ protected static function pregReplaceElements($regexp, $Elements, $text) { diff --git a/class/Requests.php b/class/Requests.php index fa16cbd..b59d348 100644 --- a/class/Requests.php +++ b/class/Requests.php @@ -3,12 +3,12 @@ namespace XoopsModules\Wggithub; /* - You may not change or alter any portion of this comment or credits - of supporting developers from this source code or any supporting source code - which is considered copyrighted (c) material of the original comment or credit authors. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ @@ -76,11 +76,9 @@ public function getNewInsertedIdRequests() */ public function getFormRequests($action = false) { - $helper = \XoopsModules\Wggithub\Helper::getInstance(); if (!$action) { $action = $_SERVER['REQUEST_URI']; } - $isAdmin = $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()); // Title $title = $this->isNew() ? \sprintf(\_AM_WGGITHUB_REQUEST_ADD) : \sprintf(\_AM_WGGITHUB_REQUEST_EDIT); // Get Theme Form diff --git a/class/SettingsHandler.php b/class/SettingsHandler.php index 790341d..afae7fd 100644 --- a/class/SettingsHandler.php +++ b/class/SettingsHandler.php @@ -143,7 +143,7 @@ public function getPrimarySetting() /** * Set given setting as primary - * @param int $asId + * @param $setId * @return bool */ public function setPrimarySetting($setId) diff --git a/include/functions.php b/include/functions.php index 74bf16a..00a853f 100644 --- a/include/functions.php +++ b/include/functions.php @@ -206,6 +206,6 @@ function wggithub_Filter($url, $type = '') { $url .= htmlentities($url, ENT_COMPAT, 'utf-8'); $url .= \preg_replace('`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig);`i', "\1", $url); $url .= \preg_replace([$regular_expression, '`[-]+`'], '-', $url); - $url = ($url == '') ? $type : strtolower( rim($url, '-')); + $url = ($url == '') ? $type : strtolower(\trim($url, '-')); return $url; } \ No newline at end of file diff --git a/include/update.php b/include/update.php index a6622c9..2290834 100644 --- a/include/update.php +++ b/include/update.php @@ -31,79 +31,20 @@ */ function xoops_module_update_wggithub($module, $prev_version = null) { - $ret = null; - if ($prev_version < 10) { - $ret = update_wggithub_v10($module); - } - - $ret = wggithub_check_db($module); + //wggithub_check_db($module); //check upload directory include_once __DIR__ . '/install.php'; - $ret = xoops_module_install_wggithub($module); + xoops_module_install_wggithub($module); $errors = $module->getErrors(); if (!empty($errors)) { print_r($errors); } - return $ret; - -} - -// irmtfan bug fix: solve templates duplicate issue -/** - * @param $module - * - * @return bool - */ -function update_wggithub_v10($module) -{ - global $xoopsDB; - $result = $xoopsDB->query( - 'SELECT t1.tpl_id FROM ' . $xoopsDB->prefix('tplfile') . ' t1, ' . $xoopsDB->prefix('tplfile') . ' t2 WHERE t1.tpl_refid = t2.tpl_refid AND t1.tpl_module = t2.tpl_module AND t1.tpl_tplset=t2.tpl_tplset AND t1.tpl_file = t2.tpl_file AND t1.tpl_type = t2.tpl_type AND t1.tpl_id > t2.tpl_id' - ); - $tplids = []; - while (false !== (list($tplid) = $xoopsDB->fetchRow($result))) { - $tplids[] = $tplid; - } - if (\count($tplids) > 0) { - $tplfileHandler = \xoops_getHandler('tplfile'); - $duplicate_files = $tplfileHandler->getObjects(new \Criteria('tpl_id', '(' . \implode(',', $tplids) . ')', 'IN')); - - if (\count($duplicate_files) > 0) { - foreach (\array_keys($duplicate_files) as $i) { - $tplfileHandler->delete($duplicate_files[$i]); - } - } - } - $sql = 'SHOW INDEX FROM ' . $xoopsDB->prefix('tplfile') . " WHERE KEY_NAME = 'tpl_refid_module_set_file_type'"; - if (!$result = $xoopsDB->queryF($sql)) { - xoops_error($xoopsDB->error() . '
' . $sql); - - return false; - } - $ret = []; - while (false !== ($myrow = $xoopsDB->fetchArray($result))) { - $ret[] = $myrow; - } - if (!empty($ret)) { - $module->setErrors("'tpl_refid_module_set_file_type' unique index is exist. Note: check 'tplfile' table to be sure this index is UNIQUE because XOOPS CORE need it."); - - return true; - } - $sql = 'ALTER TABLE ' . $xoopsDB->prefix('tplfile') . ' ADD UNIQUE tpl_refid_module_set_file_type ( tpl_refid, tpl_module, tpl_tplset, tpl_file, tpl_type )'; - if (!$result = $xoopsDB->queryF($sql)) { - xoops_error($xoopsDB->error() . '
' . $sql); - $module->setErrors("'tpl_refid_module_set_file_type' unique index is not added to 'tplfile' table. Warning: do not use XOOPS until you add this unique index."); - - return false; - } - return true; -} -// irmtfan bug fix: solve templates duplicate issue +} /** * @param $module