aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/bookmark/BookmarkFileService.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-10-16 11:50:53 +0200
committerArthurHoaro <arthur@hoa.ro>2020-10-27 19:45:02 +0100
commit36e6d88dbfd753665224664d5214f39ccfbbf6a5 (patch)
tree7a4a8a7ec50d571d0de554cd80bb74750ae24569 /application/bookmark/BookmarkFileService.php
parentc2cd15dac2bfaebe6d32f7649fbdedc07400fa08 (diff)
downloadShaarli-36e6d88dbfd753665224664d5214f39ccfbbf6a5.tar.gz
Shaarli-36e6d88dbfd753665224664d5214f39ccfbbf6a5.tar.zst
Shaarli-36e6d88dbfd753665224664d5214f39ccfbbf6a5.zip
Feature: add weekly and monthly view/RSS feed for daily page
- Heavy refactoring of DailyController - Add a banner like in tag cloud to display monthly and weekly links - Translations: t() now supports variables with optional first letter uppercase Fixes #160
Diffstat (limited to 'application/bookmark/BookmarkFileService.php')
-rw-r--r--application/bookmark/BookmarkFileService.php38
1 files changed, 27 insertions, 11 deletions
diff --git a/application/bookmark/BookmarkFileService.php b/application/bookmark/BookmarkFileService.php
index 14b3d620..0df2f47f 100644
--- a/application/bookmark/BookmarkFileService.php
+++ b/application/bookmark/BookmarkFileService.php
@@ -343,26 +343,42 @@ class BookmarkFileService implements BookmarkServiceInterface
343 /** 343 /**
344 * @inheritDoc 344 * @inheritDoc
345 */ 345 */
346 public function days(): array 346 public function findByDate(
347 { 347 \DateTimeInterface $from,
348 $bookmarkDays = []; 348 \DateTimeInterface $to,
349 foreach ($this->search() as $bookmark) { 349 ?\DateTimeInterface &$previous,
350 $bookmarkDays[$bookmark->getCreated()->format('Ymd')] = 0; 350 ?\DateTimeInterface &$next
351 ): array {
352 $out = [];
353 $previous = null;
354 $next = null;
355
356 foreach ($this->search([], null, false, false, true) as $bookmark) {
357 if ($to < $bookmark->getCreated()) {
358 $next = $bookmark->getCreated();
359 } else if ($from < $bookmark->getCreated() && $to > $bookmark->getCreated()) {
360 $out[] = $bookmark;
361 } else {
362 if ($previous !== null) {
363 break;
364 }
365 $previous = $bookmark->getCreated();
366 }
351 } 367 }
352 $bookmarkDays = array_keys($bookmarkDays);
353 sort($bookmarkDays);
354 368
355 return array_map('strval', $bookmarkDays); 369 return $out;
356 } 370 }
357 371
358 /** 372 /**
359 * @inheritDoc 373 * @inheritDoc
360 */ 374 */
361 public function filterDay(string $request) 375 public function getLatest(): ?Bookmark
362 { 376 {
363 $visibility = $this->isLoggedIn ? BookmarkFilter::$ALL : BookmarkFilter::$PUBLIC; 377 foreach ($this->search([], null, false, false, true) as $bookmark) {
378 return $bookmark;
379 }
364 380
365 return $this->bookmarkFilter->filter(BookmarkFilter::$FILTER_DAY, $request, false, $visibility); 381 return null;
366 } 382 }
367 383
368 /** 384 /**