X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2Fbookmark%2FLinkDB.php;h=f01c7ee6cadaea8422baf7e650ee85e639e84172;hb=7ff3ed1d6377f5db0f63d4228707f69f89653539;hp=266632e30da3ed45a0015dbcfc278878809e80e1;hpb=015314f3c6a1ce0b2c45fdb2fb0d36a15cab10f5;p=github%2Fshaarli%2FShaarli.git diff --git a/application/bookmark/LinkDB.php b/application/bookmark/LinkDB.php index 266632e3..f01c7ee6 100644 --- a/application/bookmark/LinkDB.php +++ b/application/bookmark/LinkDB.php @@ -102,7 +102,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess $isLoggedIn, $hidePublicLinks ) { - + $this->datastore = $datastore; $this->loggedIn = $isLoggedIn; $this->hidePublicLinks = $hidePublicLinks; @@ -252,7 +252,8 @@ You use the community supported version of the original Shaarli project, by Seba ), 'private' => 0, 'created' => new DateTime(), - 'tags' => 'opensource software' + 'tags' => 'opensource software', + 'sticky' => false, ); $link['shorturl'] = link_small_hash($link['created'], $link['id']); $this->links[1] = $link; @@ -265,6 +266,7 @@ You use the community supported version of the original Shaarli project, by Seba 'private' => 1, 'created' => new DateTime('1 minute ago'), 'tags' => 'secretstuff', + 'sticky' => false, ); $link['shorturl'] = link_small_hash($link['created'], $link['id']); $this->links[0] = $link; @@ -306,6 +308,8 @@ You use the community supported version of the original Shaarli project, by Seba $link['real_url'] = $link['url']; + $link['sticky'] = isset($link['sticky']) ? $link['sticky'] : false; + // To be able to load links before running the update, and prepare the update if (!isset($link['created'])) { $link['id'] = $link['linkdate']; @@ -411,7 +415,7 @@ You use the community supported version of the original Shaarli project, by Seba $visibility = 'all', $untaggedonly = false ) { - + // Filter link database according to parameters. $searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : ''; $searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : ''; @@ -529,6 +533,9 @@ You use the community supported version of the original Shaarli project, by Seba if (isset($a['sticky']) && isset($b['sticky']) && $a['sticky'] !== $b['sticky']) { return $a['sticky'] ? -1 : 1; } + if ($a['created'] == $b['created']) { + return $a['id'] < $b['id'] ? 1 * $order : -1 * $order; + } return $a['created'] < $b['created'] ? 1 * $order : -1 * $order; });