aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/bookmark/BookmarkArray.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-08-29 10:06:40 +0200
committerArthurHoaro <arthur@hoa.ro>2020-08-29 10:06:40 +0200
commita8e210faa624517ee8b8978b7e659a0b3c689297 (patch)
tree68a1d7671210ac39bc556ee6a54cf969ca7a605f /application/bookmark/BookmarkArray.php
parentbea062149ebcb4663861edb1cc0a32faf85b273f (diff)
downloadShaarli-a8e210faa624517ee8b8978b7e659a0b3c689297.tar.gz
Shaarli-a8e210faa624517ee8b8978b7e659a0b3c689297.tar.zst
Shaarli-a8e210faa624517ee8b8978b7e659a0b3c689297.zip
Fixed: Pinned bookmarks are displayed first in ATOM/RSS feeds
Fixes #1485
Diffstat (limited to 'application/bookmark/BookmarkArray.php')
-rw-r--r--application/bookmark/BookmarkArray.php9
1 files changed, 5 insertions, 4 deletions
diff --git a/application/bookmark/BookmarkArray.php b/application/bookmark/BookmarkArray.php
index d87d43b4..3bd5eb20 100644
--- a/application/bookmark/BookmarkArray.php
+++ b/application/bookmark/BookmarkArray.php
@@ -234,16 +234,17 @@ class BookmarkArray implements \Iterator, \Countable, \ArrayAccess
234 * 234 *
235 * Also update the urls and ids mapping arrays. 235 * Also update the urls and ids mapping arrays.
236 * 236 *
237 * @param string $order ASC|DESC 237 * @param string $order ASC|DESC
238 * @param bool $ignoreSticky If set to true, sticky bookmarks won't be first
238 */ 239 */
239 public function reorder($order = 'DESC') 240 public function reorder(string $order = 'DESC', bool $ignoreSticky = false): void
240 { 241 {
241 $order = $order === 'ASC' ? -1 : 1; 242 $order = $order === 'ASC' ? -1 : 1;
242 // Reorder array by dates. 243 // Reorder array by dates.
243 usort($this->bookmarks, function ($a, $b) use ($order) { 244 usort($this->bookmarks, function ($a, $b) use ($order, $ignoreSticky) {
244 /** @var $a Bookmark */ 245 /** @var $a Bookmark */
245 /** @var $b Bookmark */ 246 /** @var $b Bookmark */
246 if ($a->isSticky() !== $b->isSticky()) { 247 if (false === $ignoreSticky && $a->isSticky() !== $b->isSticky()) {
247 return $a->isSticky() ? -1 : 1; 248 return $a->isSticky() ? -1 : 1;
248 } 249 }
249 return $a->getCreated() < $b->getCreated() ? 1 * $order : -1 * $order; 250 return $a->getCreated() < $b->getCreated() ? 1 * $order : -1 * $order;