aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/LinkDB.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2019-02-23 16:46:02 +0100
committerVirtualTam <virtualtam@flibidi.net>2019-02-23 16:46:02 +0100
commitaf22c1ae3adb7a0705814bb7c4d75c9e2aa26a0e (patch)
treee461ef309a15e9b9da6058892350c4275558d783 /application/LinkDB.php
parent1a3da5a5011fc79c2bf15a8d1f6c7dd9f87db715 (diff)
parent1c03b65e2ea722b39e54b22c46014f35e34b575b (diff)
downloadShaarli-af22c1ae3adb7a0705814bb7c4d75c9e2aa26a0e.tar.gz
Shaarli-af22c1ae3adb7a0705814bb7c4d75c9e2aa26a0e.tar.zst
Shaarli-af22c1ae3adb7a0705814bb7c4d75c9e2aa26a0e.zip
Merge tag 'v0.10.3' into latest
Release v0.10.3
Diffstat (limited to 'application/LinkDB.php')
-rw-r--r--application/LinkDB.php32
1 files changed, 20 insertions, 12 deletions
diff --git a/application/LinkDB.php b/application/LinkDB.php
index cd0f2967..4bbc2950 100644
--- a/application/LinkDB.php
+++ b/application/LinkDB.php
@@ -107,8 +107,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
107 $hidePublicLinks, 107 $hidePublicLinks,
108 $redirector = '', 108 $redirector = '',
109 $redirectorEncode = true 109 $redirectorEncode = true
110 ) 110 ) {
111 {
112 $this->datastore = $datastore; 111 $this->datastore = $datastore;
113 $this->loggedIn = $isLoggedIn; 112 $this->loggedIn = $isLoggedIn;
114 $this->hidePublicLinks = $hidePublicLinks; 113 $this->hidePublicLinks = $hidePublicLinks;
@@ -250,11 +249,14 @@ class LinkDB implements Iterator, Countable, ArrayAccess
250 'id' => 1, 249 'id' => 1,
251 'title'=> t('The personal, minimalist, super-fast, database free, bookmarking service'), 250 'title'=> t('The personal, minimalist, super-fast, database free, bookmarking service'),
252 'url'=>'https://shaarli.readthedocs.io', 251 'url'=>'https://shaarli.readthedocs.io',
253 'description'=>t('Welcome to Shaarli! This is your first public bookmark. To edit or delete me, you must first login. 252 'description'=>t(
253 'Welcome to Shaarli! This is your first public bookmark. '
254 .'To edit or delete me, you must first login.
254 255
255To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page. 256To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page.
256 257
257You use the community supported version of the original Shaarli project, by Sebastien Sauvage.'), 258You use the community supported version of the original Shaarli project, by Sebastien Sauvage.'
259 ),
258 'private'=>0, 260 'private'=>0,
259 'created'=> new DateTime(), 261 'created'=> new DateTime(),
260 'tags'=>'opensource software' 262 'tags'=>'opensource software'
@@ -317,8 +319,7 @@ You use the community supported version of the original Shaarli project, by Seba
317 } else { 319 } else {
318 $link['real_url'] .= $link['url']; 320 $link['real_url'] .= $link['url'];
319 } 321 }
320 } 322 } else {
321 else {
322 $link['real_url'] = $link['url']; 323 $link['real_url'] = $link['url'];
323 } 324 }
324 325
@@ -403,7 +404,8 @@ You use the community supported version of the original Shaarli project, by Seba
403 * 404 *
404 * @return array list of shaare found. 405 * @return array list of shaare found.
405 */ 406 */
406 public function filterDay($request) { 407 public function filterDay($request)
408 {
407 $linkFilter = new LinkFilter($this->links); 409 $linkFilter = new LinkFilter($this->links);
408 return $linkFilter->filter(LinkFilter::$FILTER_DAY, $request); 410 return $linkFilter->filter(LinkFilter::$FILTER_DAY, $request);
409 } 411 }
@@ -420,8 +422,12 @@ You use the community supported version of the original Shaarli project, by Seba
420 * 422 *
421 * @return array filtered links, all links if no suitable filter was provided. 423 * @return array filtered links, all links if no suitable filter was provided.
422 */ 424 */
423 public function filterSearch($filterRequest = array(), $casesensitive = false, $visibility = 'all', $untaggedonly = false) 425 public function filterSearch(
424 { 426 $filterRequest = array(),
427 $casesensitive = false,
428 $visibility = 'all',
429 $untaggedonly = false
430 ) {
425 // Filter link database according to parameters. 431 // Filter link database according to parameters.
426 $searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : ''; 432 $searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : '';
427 $searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : ''; 433 $searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : '';
@@ -492,8 +498,7 @@ You use the community supported version of the original Shaarli project, by Seba
492 $delete = empty($to); 498 $delete = empty($to);
493 // True for case-sensitive tag search. 499 // True for case-sensitive tag search.
494 $linksToAlter = $this->filterSearch(['searchtags' => $from], true); 500 $linksToAlter = $this->filterSearch(['searchtags' => $from], true);
495 foreach($linksToAlter as $key => &$value) 501 foreach ($linksToAlter as $key => &$value) {
496 {
497 $tags = preg_split('/\s+/', trim($value['tags'])); 502 $tags = preg_split('/\s+/', trim($value['tags']));
498 if (($pos = array_search($from, $tags)) !== false) { 503 if (($pos = array_search($from, $tags)) !== false) {
499 if ($delete) { 504 if ($delete) {
@@ -536,7 +541,10 @@ You use the community supported version of the original Shaarli project, by Seba
536 { 541 {
537 $order = $order === 'ASC' ? -1 : 1; 542 $order = $order === 'ASC' ? -1 : 1;
538 // Reorder array by dates. 543 // Reorder array by dates.
539 usort($this->links, function($a, $b) use ($order) { 544 usort($this->links, function ($a, $b) use ($order) {
545 if (isset($a['sticky']) && isset($b['sticky']) && $a['sticky'] !== $b['sticky']) {
546 return $a['sticky'] ? -1 : 1;
547 }
540 return $a['created'] < $b['created'] ? 1 * $order : -1 * $order; 548 return $a['created'] < $b['created'] ? 1 * $order : -1 * $order;
541 }); 549 });
542 550