use Shaarli\History;
use Shaarli\Legacy\LegacyLinkDB;
use Shaarli\Legacy\LegacyUpdater;
+use Shaarli\Plugin\PluginManager;
use Shaarli\Render\PageCacheManager;
use Shaarli\Updater\UpdaterUtils;
/** @var ConfigManager instance */
protected $conf;
+ /** @var PluginManager */
+ protected $pluginManager;
+
/** @var History instance */
protected $history;
/**
* @inheritDoc
*/
- public function __construct(ConfigManager $conf, History $history, Mutex $mutex, bool $isLoggedIn)
- {
+ public function __construct(
+ ConfigManager $conf,
+ PluginManager $pluginManager,
+ History $history,
+ Mutex $mutex,
+ bool $isLoggedIn
+ ) {
$this->conf = $conf;
$this->history = $history;
$this->mutex = $mutex;
}
}
- $this->bookmarkFilter = new BookmarkFilter($this->bookmarks, $this->conf);
+ $this->pluginManager = $pluginManager;
+ $this->bookmarkFilter = new BookmarkFilter($this->bookmarks, $this->conf, $this->pluginManager);
}
/**
string $visibility = null,
bool $caseSensitive = false,
bool $untaggedOnly = false,
- bool $ignoreSticky = false
- ) {
+ bool $ignoreSticky = false,
+ array $pagination = []
+ ): SearchResult {
if ($visibility === null) {
$visibility = $this->isLoggedIn ? BookmarkFilter::$ALL : BookmarkFilter::$PUBLIC;
}
$this->bookmarks->reorder('DESC', true);
}
- return $this->bookmarkFilter->filter(
+ $bookmarks = $this->bookmarkFilter->filter(
BookmarkFilter::$FILTER_TAG | BookmarkFilter::$FILTER_TEXT,
[$searchTags, $searchTerm],
$caseSensitive,
$visibility,
$untaggedOnly
);
+
+ return SearchResult::getSearchResult(
+ $bookmarks,
+ $pagination['offset'] ?? 0,
+ $pagination['limit'] ?? null,
+ $pagination['allowOutOfBounds'] ?? false
+ );
}
/**
*/
public function count(string $visibility = null): int
{
- return count($this->search([], $visibility));
+ return $this->search([], $visibility)->getResultCount();
}
/**
*/
public function bookmarksCountPerTag(array $filteringTags = [], string $visibility = null): array
{
- $bookmarks = $this->search(['searchtags' => $filteringTags], $visibility);
+ $searchResult = $this->search(['searchtags' => $filteringTags], $visibility);
$tags = [];
$caseMapping = [];
- foreach ($bookmarks as $bookmark) {
+ foreach ($searchResult->getBookmarks() as $bookmark) {
foreach ($bookmark->getTags() as $tag) {
if (
empty($tag)
$previous = null;
$next = null;
- foreach ($this->search([], null, false, false, true) as $bookmark) {
+ foreach ($this->search([], null, false, false, true)->getBookmarks() as $bookmark) {
if ($to < $bookmark->getCreated()) {
$next = $bookmark->getCreated();
} elseif ($from < $bookmark->getCreated() && $to > $bookmark->getCreated()) {
*/
public function getLatest(): ?Bookmark
{
- foreach ($this->search([], null, false, false, true) as $bookmark) {
+ foreach ($this->search([], null, false, false, true)->getBookmarks() as $bookmark) {
return $bookmark;
}
false
);
$updater = new LegacyUpdater(
- UpdaterUtils::read_updates_file($this->conf->get('resource.updates')),
+ UpdaterUtils::readUpdatesFile($this->conf->get('resource.updates')),
$bookmarkDb,
$this->conf,
true
);
$newUpdates = $updater->update();
if (! empty($newUpdates)) {
- UpdaterUtils::write_updates_file(
+ UpdaterUtils::writeUpdatesFile(
$this->conf->get('resource.updates'),
$updater->getDoneUpdates()
);