From a120fb2977331e0f7d7ffe05861ba179fdae8764 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Mon, 13 Aug 2018 10:42:27 +0200 Subject: Add OpenGraph meta tags on permalink page Includes: - og:title - og:type -> article - og:image -> if there is a thumbnail - og:url -> permalink - og:description -> first 300 chars of raw description - article:published_time - article:modified_time - article:tag -> one OG meta tag for each shaare tag Fixes #258 --- application/PageBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'application') diff --git a/application/PageBuilder.php b/application/PageBuilder.php index b1abe0d0..0efd24c3 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php @@ -101,7 +101,7 @@ class PageBuilder 'version_hash', ApplicationUtils::getVersionHash(SHAARLI_VERSION, $this->conf->get('credentials.salt')) ); - $this->tpl->assign('scripturl', index_url($_SERVER)); + $this->tpl->assign('index_url', index_url($_SERVER)); $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : ''; $this->tpl->assign('visibility', $visibility); $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly'])); -- cgit v1.2.3 From 4154c25b5f2f8044a37d7f84e04173bb54f2375b Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 22 May 2018 22:44:38 +0200 Subject: Add a button to set links as sticky Meaning that they always appear on top of all links Fixes #186 --- application/LinkDB.php | 3 +++ application/Router.php | 6 ++++++ application/Updater.php | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+) (limited to 'application') diff --git a/application/LinkDB.php b/application/LinkDB.php index cd0f2967..cdd68cfb 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php @@ -537,6 +537,9 @@ You use the community supported version of the original Shaarli project, by Seba $order = $order === 'ASC' ? -1 : 1; // Reorder array by dates. usort($this->links, function($a, $b) use ($order) { + if (isset($a['sticky']) && isset($b['sticky']) && $a['sticky'] !== $b['sticky']) { + return $a['sticky'] ? -1 : 1; + } return $a['created'] < $b['created'] ? 1 * $order : -1 * $order; }); diff --git a/application/Router.php b/application/Router.php index bf86b884..beb3165b 100644 --- a/application/Router.php +++ b/application/Router.php @@ -37,6 +37,8 @@ class Router public static $PAGE_DELETELINK = 'delete_link'; + public static $PAGE_PINLINK = 'pin'; + public static $PAGE_EXPORT = 'export'; public static $PAGE_IMPORT = 'import'; @@ -146,6 +148,10 @@ class Router return self::$PAGE_DELETELINK; } + if (startsWith($query, 'do='. self::$PAGE_PINLINK)) { + return self::$PAGE_PINLINK; + } + if (startsWith($query, 'do='. self::$PAGE_EXPORT)) { return self::$PAGE_EXPORT; } diff --git a/application/Updater.php b/application/Updater.php index 480bff82..5dde47cb 100644 --- a/application/Updater.php +++ b/application/Updater.php @@ -517,6 +517,26 @@ class Updater return true; } + + /** + * Set sticky = false on all links + * + * @return bool true if the update is successful, false otherwise. + */ + public function updateMethodSetSticky() + { + foreach ($this->linkDB as $key => $link) { + if (isset($link['sticky'])) { + return true; + } + $link['sticky'] = false; + $this->linkDB[$key] = $link; + } + + $this->linkDB->save($this->conf->get('resource.page_cache')); + + return true; + } } /** -- cgit v1.2.3 From f211e417bf637b8a83988175c29ee072c69f7642 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sat, 13 Oct 2018 00:19:03 +0200 Subject: lint: apply phpcbf to application/ Signed-off-by: VirtualTam --- application/ApplicationUtils.php | 17 +++++++------- application/Base64Url.php | 7 +++--- application/FeedBuilder.php | 4 ++-- application/HttpUtils.php | 26 +++++++++++----------- application/Languages.php | 11 +++++---- application/LinkDB.php | 14 +++++------- application/LinkFilter.php | 25 ++++++++++----------- application/LinkUtils.php | 5 +++-- application/NetscapeBookmarkUtils.php | 11 +++++---- application/PageBuilder.php | 3 +-- application/PluginManager.php | 3 +-- application/Updater.php | 2 +- application/Url.php | 19 +++++++++------- application/Utils.php | 16 ++++++++----- application/api/ApiMiddleware.php | 5 +++-- application/api/controllers/ApiController.php | 2 +- application/api/controllers/History.php | 3 +-- application/api/controllers/Info.php | 4 ++-- application/api/exceptions/ApiException.php | 8 ++++--- .../api/exceptions/ApiLinkNotFoundException.php | 1 - .../api/exceptions/ApiTagNotFoundException.php | 1 - application/config/ConfigPlugin.php | 3 +-- application/security/LoginManager.php | 1 - 23 files changed, 98 insertions(+), 93 deletions(-) (limited to 'application') diff --git a/application/ApplicationUtils.php b/application/ApplicationUtils.php index 911873a0..a3b2dcb1 100644 --- a/application/ApplicationUtils.php +++ b/application/ApplicationUtils.php @@ -24,7 +24,7 @@ class ApplicationUtils * * @return mixed the version code from the repository if available, else 'false' */ - public static function getLatestGitVersionCode($url, $timeout=2) + public static function getLatestGitVersionCode($url, $timeout = 2) { list($headers, $data) = get_http_response($url, $timeout); @@ -86,13 +86,14 @@ class ApplicationUtils * * @return mixed the new version code if available and greater, else 'false' */ - public static function checkUpdate($currentVersion, - $updateFile, - $checkInterval, - $enableCheck, - $isLoggedIn, - $branch='stable') - { + public static function checkUpdate( + $currentVersion, + $updateFile, + $checkInterval, + $enableCheck, + $isLoggedIn, + $branch = 'stable' + ) { // Do not check versions for visitors // Do not check if the user doesn't want to // Do not check with dev version diff --git a/application/Base64Url.php b/application/Base64Url.php index 61590e43..54d0fcd5 100644 --- a/application/Base64Url.php +++ b/application/Base64Url.php @@ -2,7 +2,6 @@ namespace Shaarli; - /** * URL-safe Base64 operations * @@ -17,7 +16,8 @@ class Base64Url * * @return string Base64Url-encoded data */ - public static function encode($data) { + public static function encode($data) + { return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); } @@ -28,7 +28,8 @@ class Base64Url * * @return string Decoded data */ - public static function decode($data) { + public static function decode($data) + { return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); } } diff --git a/application/FeedBuilder.php b/application/FeedBuilder.php index ebae18b4..73fafcbe 100644 --- a/application/FeedBuilder.php +++ b/application/FeedBuilder.php @@ -163,7 +163,8 @@ class FeedBuilder $upDate = $link['updated']; $link['up_iso_date'] = $this->getIsoDate($upDate, DateTime::ATOM); } else { - $link['up_iso_date'] = $this->getIsoDate($pubDate, DateTime::ATOM);; + $link['up_iso_date'] = $this->getIsoDate($pubDate, DateTime::ATOM); + ; } // Save the more recent item. @@ -261,7 +262,6 @@ class FeedBuilder } if ($this->feedType == self::$FEED_RSS) { return $date->format(DateTime::RSS); - } return $date->format(DateTime::ATOM); } diff --git a/application/HttpUtils.php b/application/HttpUtils.php index e9282506..ef6f3264 100644 --- a/application/HttpUtils.php +++ b/application/HttpUtils.php @@ -64,29 +64,30 @@ function get_http_response($url, $timeout = 30, $maxBytes = 4194304, $curlWriteF } // General cURL settings - curl_setopt($ch, CURLOPT_AUTOREFERER, true); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_HEADER, true); + curl_setopt($ch, CURLOPT_AUTOREFERER, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Accept-Language: ' . $acceptLanguage) ); - curl_setopt($ch, CURLOPT_MAXREDIRS, $maxRedirs); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); - curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); + curl_setopt($ch, CURLOPT_MAXREDIRS, $maxRedirs); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); + curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); if (is_callable($curlWriteFunction)) { curl_setopt($ch, CURLOPT_WRITEFUNCTION, $curlWriteFunction); } // Max download size management - curl_setopt($ch, CURLOPT_BUFFERSIZE, 1024*16); - curl_setopt($ch, CURLOPT_NOPROGRESS, false); - curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, - function($arg0, $arg1, $arg2, $arg3, $arg4 = 0) use ($maxBytes) - { + curl_setopt($ch, CURLOPT_BUFFERSIZE, 1024*16); + curl_setopt($ch, CURLOPT_NOPROGRESS, false); + curl_setopt( + $ch, + CURLOPT_PROGRESSFUNCTION, + function ($arg0, $arg1, $arg2, $arg3, $arg4 = 0) use ($maxBytes) { if (version_compare(phpversion(), '5.5', '<')) { // PHP version lower than 5.5 // Callback has 4 arguments @@ -232,7 +233,6 @@ function get_redirected_headers($url, $redirectionLimit = 3) && !empty($headers) && (strpos($headers[0], '301') !== false || strpos($headers[0], '302') !== false) && !empty($headers['Location'])) { - $redirection = is_array($headers['Location']) ? end($headers['Location']) : $headers['Location']; if ($redirection != $url) { $redirection = getAbsoluteUrl($url, $redirection); diff --git a/application/Languages.php b/application/Languages.php index 4fa32426..6a6247c7 100644 --- a/application/Languages.php +++ b/application/Languages.php @@ -92,7 +92,7 @@ class Languages /** * Initialize the translator using php gettext extension (gettext dependency act as a wrapper). */ - protected function initGettextTranslator () + protected function initGettextTranslator() { $this->translator = new GettextTranslator(); $this->translator->setLanguage($this->language); @@ -125,7 +125,8 @@ class Languages $translations = $translations->addFromPoFile('inc/languages/'. $this->language .'/LC_MESSAGES/shaarli.po'); $translations->setDomain('shaarli'); $this->translator->loadTranslations($translations); - } catch (\InvalidArgumentException $e) {} + } catch (\InvalidArgumentException $e) { + } // Default extension translation from the current theme $theme = $this->conf->get('theme'); @@ -137,7 +138,8 @@ class Languages ); $translations->setDomain($theme); $this->translator->loadTranslations($translations); - } catch (\InvalidArgumentException $e) {} + } catch (\InvalidArgumentException $e) { + } } // Extension translations (plugins, themes, etc.). @@ -150,7 +152,8 @@ class Languages $extension = Translations::fromPoFile($translationPath . $this->language .'/LC_MESSAGES/'. $domain .'.po'); $extension->setDomain($domain); $this->translator->loadTranslations($extension); - } catch (\InvalidArgumentException $e) {} + } catch (\InvalidArgumentException $e) { + } } } diff --git a/application/LinkDB.php b/application/LinkDB.php index cdd68cfb..1f7c28cd 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php @@ -107,8 +107,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess $hidePublicLinks, $redirector = '', $redirectorEncode = true - ) - { + ) { $this->datastore = $datastore; $this->loggedIn = $isLoggedIn; $this->hidePublicLinks = $hidePublicLinks; @@ -317,8 +316,7 @@ You use the community supported version of the original Shaarli project, by Seba } else { $link['real_url'] .= $link['url']; } - } - else { + } else { $link['real_url'] = $link['url']; } @@ -403,7 +401,8 @@ You use the community supported version of the original Shaarli project, by Seba * * @return array list of shaare found. */ - public function filterDay($request) { + public function filterDay($request) + { $linkFilter = new LinkFilter($this->links); return $linkFilter->filter(LinkFilter::$FILTER_DAY, $request); } @@ -492,8 +491,7 @@ You use the community supported version of the original Shaarli project, by Seba $delete = empty($to); // True for case-sensitive tag search. $linksToAlter = $this->filterSearch(['searchtags' => $from], true); - foreach($linksToAlter as $key => &$value) - { + foreach ($linksToAlter as $key => &$value) { $tags = preg_split('/\s+/', trim($value['tags'])); if (($pos = array_search($from, $tags)) !== false) { if ($delete) { @@ -536,7 +534,7 @@ You use the community supported version of the original Shaarli project, by Seba { $order = $order === 'ASC' ? -1 : 1; // Reorder array by dates. - usort($this->links, function($a, $b) use ($order) { + usort($this->links, function ($a, $b) use ($order) { if (isset($a['sticky']) && isset($b['sticky']) && $a['sticky'] !== $b['sticky']) { return $a['sticky'] ? -1 : 1; } diff --git a/application/LinkFilter.php b/application/LinkFilter.php index e52239b8..8f147974 100644 --- a/application/LinkFilter.php +++ b/application/LinkFilter.php @@ -62,7 +62,7 @@ class LinkFilter $visibility = 'all'; } - switch($type) { + switch ($type) { case self::$FILTER_HASH: return $this->filterSmallHash($request); case self::$FILTER_TAG | self::$FILTER_TEXT: // == "vuotext" @@ -205,7 +205,6 @@ class LinkFilter // Iterate over every stored link. foreach ($this->links as $id => $link) { - // ignore non private links when 'privatonly' is on. if ($visibility !== 'all') { if (! $link['private'] && $visibility === 'private') { @@ -257,11 +256,11 @@ class LinkFilter private static function tag2regex($tag) { $len = strlen($tag); - if(!$len || $tag === "-" || $tag === "*"){ + if (!$len || $tag === "-" || $tag === "*") { // nothing to search, return empty regex return ''; } - if($tag[0] === "-") { + if ($tag[0] === "-") { // query is negated $i = 1; // use offset to start after '-' character $regex = '(?!'; // create negative lookahead @@ -271,14 +270,14 @@ class LinkFilter } $regex .= '.*(?:^| )'; // before tag may only be a space or the beginning // iterate over string, separating it into placeholder and content - for(; $i < $len; $i++){ - if($tag[$i] === '*'){ + for (; $i < $len; $i++) { + if ($tag[$i] === '*') { // placeholder found $regex .= '[^ ]*?'; } else { // regular characters $offset = strpos($tag, '*', $i); - if($offset === false){ + if ($offset === false) { // no placeholder found, set offset to end of string $offset = $len; } @@ -310,19 +309,19 @@ class LinkFilter { // get single tags (we may get passed an array, even though the docs say different) $inputTags = $tags; - if(!is_array($tags)) { + if (!is_array($tags)) { // we got an input string, split tags $inputTags = preg_split('/(?:\s+)|,/', $inputTags, -1, PREG_SPLIT_NO_EMPTY); } - if(!count($inputTags)){ + if (!count($inputTags)) { // no input tags return $this->noFilter($visibility); } // build regex from all tags $re = '/^' . implode(array_map("self::tag2regex", $inputTags)) . '.*$/'; - if(!$casesensitive) { + if (!$casesensitive) { // make regex case insensitive $re .= 'i'; } @@ -342,7 +341,7 @@ class LinkFilter } } $search = $link['tags']; // build search string, start with tags of current link - if(strlen(trim($link['description'])) && strpos($link['description'], '#') !== false){ + if (strlen(trim($link['description'])) && strpos($link['description'], '#') !== false) { // description given and at least one possible tag found $descTags = array(); // find all tags in the form of #tag in the description @@ -351,13 +350,13 @@ class LinkFilter $link['description'], $descTags ); - if(count($descTags[1])){ + if (count($descTags[1])) { // there were some tags in the description, add them to the search string $search .= ' ' . implode(' ', $descTags[1]); } }; // match regular expression with search string - if(!preg_match($re, $search)){ + if (!preg_match($re, $search)) { // this entry does _not_ match our regex continue; } diff --git a/application/LinkUtils.php b/application/LinkUtils.php index 4df5c0ca..d56e019f 100644 --- a/application/LinkUtils.php +++ b/application/LinkUtils.php @@ -23,7 +23,7 @@ function get_curl_download_callback(&$charset, &$title, $curlGetInfo = 'curl_get * * @return int|bool length of $data or false if we need to stop the download */ - return function(&$ch, $data) use ($curlGetInfo, &$charset, &$title, &$isRedirected) { + return function (&$ch, $data) use ($curlGetInfo, &$charset, &$title, &$isRedirected) { $responseCode = $curlGetInfo($ch, CURLINFO_RESPONSE_CODE); if (!empty($responseCode) && in_array($responseCode, [301, 302])) { $isRedirected = true; @@ -201,7 +201,8 @@ function space2nbsp($text) * @return string formatted description. */ -function format_description($description, $redirector = '', $urlEncode = true, $indexUrl = '') { +function format_description($description, $redirector = '', $urlEncode = true, $indexUrl = '') +{ return nl2br(space2nbsp(hashtag_autolink(text2clickable($description, $redirector, $urlEncode), $indexUrl))); } diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php index b4d16d00..e147d326 100644 --- a/application/NetscapeBookmarkUtils.php +++ b/application/NetscapeBookmarkUtils.php @@ -72,12 +72,11 @@ class NetscapeBookmarkUtils private static function importStatus( $filename, $filesize, - $importCount=0, - $overwriteCount=0, - $skipCount=0, - $duration=0 - ) - { + $importCount = 0, + $overwriteCount = 0, + $skipCount = 0, + $duration = 0 + ) { $status = sprintf(t('File %s (%d bytes) '), $filename, $filesize); if ($importCount == 0 && $overwriteCount == 0 && $skipCount == 0) { $status .= t('has an unknown file format. Nothing was imported.'); diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 0efd24c3..2ca95832 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php @@ -78,7 +78,6 @@ class PageBuilder ); $this->tpl->assign('newVersion', escape($version)); $this->tpl->assign('versionError', ''); - } catch (Exception $exc) { logm($this->conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage()); $this->tpl->assign('newVersion', ''); @@ -163,7 +162,7 @@ class PageBuilder $this->initialize(); } - if (empty($data) || !is_array($data)){ + if (empty($data) || !is_array($data)) { return false; } diff --git a/application/PluginManager.php b/application/PluginManager.php index cf603845..1ed4db4b 100644 --- a/application/PluginManager.php +++ b/application/PluginManager.php @@ -75,8 +75,7 @@ class PluginManager try { $this->loadPlugin($dirs[$index], $plugin); - } - catch (PluginFileNotFoundException $e) { + } catch (PluginFileNotFoundException $e) { error_log($e->getMessage()); } } diff --git a/application/Updater.php b/application/Updater.php index 5dde47cb..6b94c5e3 100644 --- a/application/Updater.php +++ b/application/Updater.php @@ -183,7 +183,7 @@ class Updater } } - try{ + try { $this->conf->write($this->isLoggedIn); return true; } catch (IOException $e) { diff --git a/application/Url.php b/application/Url.php index 6b9870f0..3b7f19c2 100644 --- a/application/Url.php +++ b/application/Url.php @@ -34,8 +34,8 @@ function unparse_url($parsedUrl) */ function cleanup_url($url) { - $obj_url = new Url($url); - return $obj_url->cleanup(); + $obj_url = new Url($url); + return $obj_url->cleanup(); } /** @@ -47,8 +47,8 @@ function cleanup_url($url) */ function get_url_scheme($url) { - $obj_url = new Url($url); - return $obj_url->getScheme(); + $obj_url = new Url($url); + return $obj_url->getScheme(); } /** @@ -217,7 +217,7 @@ class Url } $this->parts['query'] = implode('&', $queryParams); - } + } /** * Removes undesired fragments @@ -269,7 +269,8 @@ class Url * * @return string the URL scheme or false if none is provided. */ - public function getScheme() { + public function getScheme() + { if (!isset($this->parts['scheme'])) { return false; } @@ -281,7 +282,8 @@ class Url * * @return string the URL host or false if none is provided. */ - public function getHost() { + public function getHost() + { if (empty($this->parts['host'])) { return false; } @@ -293,7 +295,8 @@ class Url * * @return true is HTTP, false otherwise. */ - public function isHttp() { + public function isHttp() + { return strpos(strtolower($this->parts['scheme']), 'http') !== false; } } diff --git a/application/Utils.php b/application/Utils.php index 97b12fcf..925e1a22 100644 --- a/application/Utils.php +++ b/application/Utils.php @@ -97,7 +97,7 @@ function escape($input) if (is_array($input)) { $out = array(); - foreach($input as $key => $value) { + foreach ($input as $key => $value) { $out[$key] = escape($value); } return $out; @@ -355,10 +355,13 @@ function return_bytes($val) $val = trim($val); $last = strtolower($val[strlen($val)-1]); $val = intval(substr($val, 0, -1)); - switch($last) { - case 'g': $val *= 1024; - case 'm': $val *= 1024; - case 'k': $val *= 1024; + switch ($last) { + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; } return $val; } @@ -452,6 +455,7 @@ function alphabetical_sort(&$data, $reverse = false, $byKeys = false) * * @return string Text translated. */ -function t($text, $nText = '', $nb = 1, $domain = 'shaarli') { +function t($text, $nText = '', $nb = 1, $domain = 'shaarli') +{ return dn__($domain, $text, $nText, $nb); } diff --git a/application/api/ApiMiddleware.php b/application/api/ApiMiddleware.php index ff209393..66eac133 100644 --- a/application/api/ApiMiddleware.php +++ b/application/api/ApiMiddleware.php @@ -65,7 +65,7 @@ class ApiMiddleware try { $this->checkRequest($request); $response = $next($request, $response); - } catch(ApiException $e) { + } catch (ApiException $e) { $e->setResponse($response); $e->setDebug($this->conf->get('dev.debug', false)); $response = $e->getApiResponse(); @@ -98,7 +98,8 @@ class ApiMiddleware * * @throws ApiAuthorizationException The token couldn't be validated. */ - protected function checkToken($request) { + protected function checkToken($request) + { if (! $request->hasHeader('Authorization')) { throw new ApiAuthorizationException('JWT token not provided'); } diff --git a/application/api/controllers/ApiController.php b/application/api/controllers/ApiController.php index 3be85b98..9edefcf6 100644 --- a/application/api/controllers/ApiController.php +++ b/application/api/controllers/ApiController.php @@ -41,7 +41,7 @@ abstract class ApiController /** * ApiController constructor. - * + * * Note: enabling debug mode displays JSON with readable formatting. * * @param Container $ci Slim container. diff --git a/application/api/controllers/History.php b/application/api/controllers/History.php index 5cc453bf..4582e8b2 100644 --- a/application/api/controllers/History.php +++ b/application/api/controllers/History.php @@ -35,8 +35,7 @@ class History extends ApiController $offset = $request->getParam('offset'); if (empty($offset)) { $offset = 0; - } - elseif (ctype_digit($offset)) { + } elseif (ctype_digit($offset)) { $offset = (int) $offset; } else { throw new ApiBadParametersException('Invalid offset'); diff --git a/application/api/controllers/Info.php b/application/api/controllers/Info.php index 25433f72..f37dcae5 100644 --- a/application/api/controllers/Info.php +++ b/application/api/controllers/Info.php @@ -7,7 +7,7 @@ use Slim\Http\Response; /** * Class Info - * + * * REST API Controller: /info * * @package Api\Controllers @@ -17,7 +17,7 @@ class Info extends ApiController { /** * Service providing various information about Shaarli instance. - * + * * @param Request $request Slim request. * @param Response $response Slim response. * diff --git a/application/api/exceptions/ApiException.php b/application/api/exceptions/ApiException.php index c8490e0c..d6b66323 100644 --- a/application/api/exceptions/ApiException.php +++ b/application/api/exceptions/ApiException.php @@ -10,7 +10,8 @@ use Slim\Http\Response; * Parent Exception related to the API, able to generate a valid Response (ResponseInterface). * Also can include various information in debug mode. */ -abstract class ApiException extends \Exception { +abstract class ApiException extends \Exception +{ /** * @var Response instance from Slim. @@ -27,7 +28,7 @@ abstract class ApiException extends \Exception { * * @return Response Final response to give. */ - public abstract function getApiResponse(); + abstract public function getApiResponse(); /** * Creates ApiResponse body. @@ -36,7 +37,8 @@ abstract class ApiException extends \Exception { * * @return array|string response body */ - protected function getApiResponseBody() { + protected function getApiResponseBody() + { if ($this->debug !== true) { return $this->getMessage(); } diff --git a/application/api/exceptions/ApiLinkNotFoundException.php b/application/api/exceptions/ApiLinkNotFoundException.php index de7e14f5..c727f4f0 100644 --- a/application/api/exceptions/ApiLinkNotFoundException.php +++ b/application/api/exceptions/ApiLinkNotFoundException.php @@ -2,7 +2,6 @@ namespace Shaarli\Api\Exceptions; - use Slim\Http\Response; /** diff --git a/application/api/exceptions/ApiTagNotFoundException.php b/application/api/exceptions/ApiTagNotFoundException.php index eed5afa5..eee152fe 100644 --- a/application/api/exceptions/ApiTagNotFoundException.php +++ b/application/api/exceptions/ApiTagNotFoundException.php @@ -2,7 +2,6 @@ namespace Shaarli\Api\Exceptions; - use Slim\Http\Response; /** diff --git a/application/config/ConfigPlugin.php b/application/config/ConfigPlugin.php index b3d9752b..dbb24937 100644 --- a/application/config/ConfigPlugin.php +++ b/application/config/ConfigPlugin.php @@ -34,8 +34,7 @@ function save_plugin_config($formData) // If there is no order, it means a disabled plugin has been enabled. if (isset($formData['order_' . $key])) { $plugins[(int) $formData['order_' . $key]] = $key; - } - else { + } else { $newEnabledPlugins[] = $key; } } diff --git a/application/security/LoginManager.php b/application/security/LoginManager.php index d6784d6d..0f315483 100644 --- a/application/security/LoginManager.php +++ b/application/security/LoginManager.php @@ -95,7 +95,6 @@ class LoginManager // The user client has a valid stay-signed-in cookie // Session information is updated with the current client information $this->sessionManager->storeLoginInfo($clientIpId); - } elseif ($this->sessionManager->hasSessionExpired() || $this->sessionManager->hasClientIpChanged($clientIpId) ) { -- cgit v1.2.3 From 9d9f6d75b94aab51067bdfbe50b58b66d1194f6d Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sat, 13 Oct 2018 01:40:04 +0200 Subject: lint: fix line-length warnings Signed-off-by: VirtualTam --- application/HttpUtils.php | 3 ++- application/Languages.php | 4 +++- application/LinkDB.php | 15 +++++++++++---- application/NetscapeBookmarkUtils.php | 5 ++++- application/Thumbnailer.php | 5 ++++- application/config/ConfigPhp.php | 12 ++++++++++-- 6 files changed, 34 insertions(+), 10 deletions(-) (limited to 'application') diff --git a/application/HttpUtils.php b/application/HttpUtils.php index ef6f3264..9c438160 100644 --- a/application/HttpUtils.php +++ b/application/HttpUtils.php @@ -7,7 +7,8 @@ * @param int $timeout network timeout (in seconds) * @param int $maxBytes maximum downloaded bytes (default: 4 MiB) * @param callable|string $curlWriteFunction Optional callback called during the download (cURL CURLOPT_WRITEFUNCTION). - * Can be used to add download conditions on the headers (response code, content type, etc.). + * Can be used to add download conditions on the + * headers (response code, content type, etc.). * * @return array HTTP response headers, downloaded content * diff --git a/application/Languages.php b/application/Languages.php index 6a6247c7..b9c5d0e8 100644 --- a/application/Languages.php +++ b/application/Languages.php @@ -149,7 +149,9 @@ class Languages } try { - $extension = Translations::fromPoFile($translationPath . $this->language .'/LC_MESSAGES/'. $domain .'.po'); + $extension = Translations::fromPoFile( + $translationPath . $this->language .'/LC_MESSAGES/'. $domain .'.po' + ); $extension->setDomain($domain); $this->translator->loadTranslations($extension); } catch (\InvalidArgumentException $e) { diff --git a/application/LinkDB.php b/application/LinkDB.php index 1f7c28cd..4bbc2950 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php @@ -249,11 +249,14 @@ class LinkDB implements Iterator, Countable, ArrayAccess 'id' => 1, 'title'=> t('The personal, minimalist, super-fast, database free, bookmarking service'), 'url'=>'https://shaarli.readthedocs.io', - 'description'=>t('Welcome to Shaarli! This is your first public bookmark. To edit or delete me, you must first login. + 'description'=>t( + 'Welcome to Shaarli! This is your first public bookmark. ' + .'To edit or delete me, you must first login. To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page. -You use the community supported version of the original Shaarli project, by Sebastien Sauvage.'), +You use the community supported version of the original Shaarli project, by Sebastien Sauvage.' + ), 'private'=>0, 'created'=> new DateTime(), 'tags'=>'opensource software' @@ -419,8 +422,12 @@ You use the community supported version of the original Shaarli project, by Seba * * @return array filtered links, all links if no suitable filter was provided. */ - public function filterSearch($filterRequest = array(), $casesensitive = false, $visibility = 'all', $untaggedonly = false) - { + public function filterSearch( + $filterRequest = array(), + $casesensitive = false, + $visibility = 'all', + $untaggedonly = false + ) { // Filter link database according to parameters. $searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : ''; $searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : ''; diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php index e147d326..84dd2b20 100644 --- a/application/NetscapeBookmarkUtils.php +++ b/application/NetscapeBookmarkUtils.php @@ -82,7 +82,10 @@ class NetscapeBookmarkUtils $status .= t('has an unknown file format. Nothing was imported.'); } else { $status .= vsprintf( - t('was successfully processed in %d seconds: %d links imported, %d links overwritten, %d links skipped.'), + t( + 'was successfully processed in %d seconds: ' + .'%d links imported, %d links overwritten, %d links skipped.' + ), [$duration, $importCount, $overwriteCount, $skipCount] ); } diff --git a/application/Thumbnailer.php b/application/Thumbnailer.php index 7d0d9c33..37ed97a1 100644 --- a/application/Thumbnailer.php +++ b/application/Thumbnailer.php @@ -58,7 +58,10 @@ class Thumbnailer $this->conf->set('thumbnails.enabled', false); $this->conf->write(true); // TODO: create a proper error handling system able to catch exceptions... - die(t('php-gd extension must be loaded to use thumbnails. Thumbnails are now disabled. Please reload the page.')); + die(t( + 'php-gd extension must be loaded to use thumbnails. ' + .'Thumbnails are now disabled. Please reload the page.' + )); } $this->wt = new WebThumbnailer(); diff --git a/application/config/ConfigPhp.php b/application/config/ConfigPhp.php index 8add8bcd..9625fe1a 100644 --- a/application/config/ConfigPhp.php +++ b/application/config/ConfigPhp.php @@ -104,12 +104,20 @@ class ConfigPhp implements ConfigIO // Store all $conf['config'] foreach ($conf['config'] as $key => $value) { - $configStr .= '$GLOBALS[\'config\'][\''. $key .'\'] = '.var_export($conf['config'][$key], true).';'. PHP_EOL; + $configStr .= '$GLOBALS[\'config\'][\'' + . $key + .'\'] = ' + .var_export($conf['config'][$key], true).';' + . PHP_EOL; } if (isset($conf['plugins'])) { foreach ($conf['plugins'] as $key => $value) { - $configStr .= '$GLOBALS[\'plugins\'][\''. $key .'\'] = '.var_export($conf['plugins'][$key], true).';'. PHP_EOL; + $configStr .= '$GLOBALS[\'plugins\'][\'' + . $key + .'\'] = ' + .var_export($conf['plugins'][$key], true).';' + . PHP_EOL; } } -- cgit v1.2.3