X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FLinkDB.php;h=a5b42727e8fbb8d9f0076d23708d7595fc8f574a;hb=a0c4dbd91c41b9ecdd5176c1ac33b55e240d2392;hp=cd0f29671f9b199c213b4333e8eeab23eedcadb7;hpb=0deaedeeaef088040fb015f5be3e270e3bae508e;p=github%2Fshaarli%2FShaarli.git diff --git a/application/LinkDB.php b/application/LinkDB.php index cd0f2967..a5b42727 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php @@ -1,4 +1,8 @@ datastore = $datastore; $this->loggedIn = $isLoggedIn; $this->hidePublicLinks = $hidePublicLinks; @@ -250,11 +253,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' @@ -317,8 +323,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 +408,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); } @@ -420,8 +426,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']) : ''; @@ -492,8 +502,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 +545,10 @@ 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; + } return $a['created'] < $b['created'] ? 1 * $order : -1 * $order; });