X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2Fbookmark%2FLinkFilter.php;fp=application%2FLinkFilter.php;h=9b96630737008cb2075886e339b85d6b2bbeb109;hb=ff3b5dc5542ec150f0d9b447394364a15e9156d0;hp=8f147974e9d5cf232f3cf3f509b3401fcf5e6b84;hpb=1826e383ecf501302974132fd443cf1ca06e10f6;p=github%2Fshaarli%2FShaarli.git diff --git a/application/LinkFilter.php b/application/bookmark/LinkFilter.php similarity index 93% rename from application/LinkFilter.php rename to application/bookmark/LinkFilter.php index 8f147974..9b966307 100644 --- a/application/LinkFilter.php +++ b/application/bookmark/LinkFilter.php @@ -1,5 +1,10 @@ links as $key => $value) { if ($value['private'] && $visibility === 'private') { $out[$key] = $value; - } elseif (! $value['private'] && $visibility === 'public') { + } elseif (!$value['private'] && $visibility === 'public') { $out[$key] = $value; } } @@ -132,7 +137,7 @@ class LinkFilter * * @return array $filtered array containing permalink data. * - * @throws LinkNotFoundException if the smallhash doesn't match any link. + * @throws \Shaarli\Bookmark\Exception\LinkNotFoundException if the smallhash doesn't match any link. */ private function filterSmallHash($smallHash) { @@ -169,7 +174,7 @@ class LinkFilter * - see https://github.com/shaarli/Shaarli/issues/75 for examples * * @param string $searchterms search query. - * @param string $visibility Optional: return only all/private/public links. + * @param string $visibility Optional: return only all/private/public links. * * @return array search results. */ @@ -207,7 +212,7 @@ class LinkFilter foreach ($this->links as $id => $link) { // ignore non private links when 'privatonly' is on. if ($visibility !== 'all') { - if (! $link['private'] && $visibility === 'private') { + if (!$link['private'] && $visibility === 'private') { continue; } elseif ($link['private'] && $visibility === 'public') { continue; @@ -250,7 +255,9 @@ class LinkFilter /** * generate a regex fragment out of a tag + * * @param string $tag to to generate regexs from. may start with '-' to negate, contain '*' as wildcard + * * @return string generated regex fragment */ private static function tag2regex($tag) @@ -334,7 +341,7 @@ class LinkFilter // check level of visibility // ignore non private links when 'privateonly' is on. if ($visibility !== 'all') { - if (! $link['private'] && $visibility === 'private') { + if (!$link['private'] && $visibility === 'private') { continue; } elseif ($link['private'] && $visibility === 'public') { continue; @@ -377,7 +384,7 @@ class LinkFilter $filtered = []; foreach ($this->links as $key => $link) { if ($visibility !== 'all') { - if (! $link['private'] && $visibility === 'private') { + if (!$link['private'] && $visibility === 'private') { continue; } elseif ($link['private'] && $visibility === 'public') { continue; @@ -406,7 +413,7 @@ class LinkFilter */ public function filterDay($day) { - if (! checkDateFormat('Ymd', $day)) { + if (!checkDateFormat('Ymd', $day)) { throw new Exception('Invalid date format'); } @@ -440,14 +447,3 @@ class LinkFilter return preg_split('/\s+/', $tagsOut, -1, PREG_SPLIT_NO_EMPTY); } } - -class LinkNotFoundException extends Exception -{ - /** - * LinkNotFoundException constructor. - */ - public function __construct() - { - $this->message = t('The link you are trying to reach does not exist or has been deleted.'); - } -}