diff options
Diffstat (limited to 'application/feed')
-rw-r--r-- | application/feed/FeedBuilder.php | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/application/feed/FeedBuilder.php b/application/feed/FeedBuilder.php index ed62af26..d5d74fd1 100644 --- a/application/feed/FeedBuilder.php +++ b/application/feed/FeedBuilder.php | |||
@@ -102,22 +102,16 @@ class FeedBuilder | |||
102 | $userInput['searchtags'] = false; | 102 | $userInput['searchtags'] = false; |
103 | } | 103 | } |
104 | 104 | ||
105 | // Optionally filter the results: | 105 | $limit = $this->getLimit($userInput); |
106 | $linksToDisplay = $this->linkDB->search($userInput ?? [], null, false, false, true); | ||
107 | |||
108 | $nblinksToDisplay = $this->getNbLinks(count($linksToDisplay), $userInput); | ||
109 | 106 | ||
110 | // Can't use array_keys() because $link is a LinkDB instance and not a real array. | 107 | // Optionally filter the results: |
111 | $keys = []; | 108 | $searchResult = $this->linkDB->search($userInput ?? [], null, false, false, true, ['limit' => $limit]); |
112 | foreach ($linksToDisplay as $key => $value) { | ||
113 | $keys[] = $key; | ||
114 | } | ||
115 | 109 | ||
116 | $pageaddr = escape(index_url($this->serverInfo)); | 110 | $pageaddr = escape(index_url($this->serverInfo)); |
117 | $this->formatter->addContextData('index_url', $pageaddr); | 111 | $this->formatter->addContextData('index_url', $pageaddr); |
118 | $linkDisplayed = []; | 112 | $links = []; |
119 | for ($i = 0; $i < $nblinksToDisplay && $i < count($keys); $i++) { | 113 | foreach ($searchResult->getBookmarks() as $key => $bookmark) { |
120 | $linkDisplayed[$keys[$i]] = $this->buildItem($feedType, $linksToDisplay[$keys[$i]], $pageaddr); | 114 | $links[$key] = $this->buildItem($feedType, $bookmark, $pageaddr); |
121 | } | 115 | } |
122 | 116 | ||
123 | $data['language'] = $this->getTypeLanguage($feedType); | 117 | $data['language'] = $this->getTypeLanguage($feedType); |
@@ -128,7 +122,7 @@ class FeedBuilder | |||
128 | $data['self_link'] = $pageaddr . $requestUri; | 122 | $data['self_link'] = $pageaddr . $requestUri; |
129 | $data['index_url'] = $pageaddr; | 123 | $data['index_url'] = $pageaddr; |
130 | $data['usepermalinks'] = $this->usePermalinks === true; | 124 | $data['usepermalinks'] = $this->usePermalinks === true; |
131 | $data['links'] = $linkDisplayed; | 125 | $data['links'] = $links; |
132 | 126 | ||
133 | return $data; | 127 | return $data; |
134 | } | 128 | } |
@@ -268,19 +262,18 @@ class FeedBuilder | |||
268 | * If 'nb' not set or invalid, default value: $DEFAULT_NB_LINKS. | 262 | * If 'nb' not set or invalid, default value: $DEFAULT_NB_LINKS. |
269 | * If 'nb' is set to 'all', display all filtered bookmarks (max parameter). | 263 | * If 'nb' is set to 'all', display all filtered bookmarks (max parameter). |
270 | * | 264 | * |
271 | * @param int $max maximum number of bookmarks to display. | ||
272 | * @param array $userInput $_GET. | 265 | * @param array $userInput $_GET. |
273 | * | 266 | * |
274 | * @return int number of bookmarks to display. | 267 | * @return int number of bookmarks to display. |
275 | */ | 268 | */ |
276 | protected function getNbLinks($max, ?array $userInput) | 269 | protected function getLimit(?array $userInput) |
277 | { | 270 | { |
278 | if (empty($userInput['nb'])) { | 271 | if (empty($userInput['nb'])) { |
279 | return self::$DEFAULT_NB_LINKS; | 272 | return self::$DEFAULT_NB_LINKS; |
280 | } | 273 | } |
281 | 274 | ||
282 | if ($userInput['nb'] == 'all') { | 275 | if ($userInput['nb'] == 'all') { |
283 | return $max; | 276 | return null; |
284 | } | 277 | } |
285 | 278 | ||
286 | $intNb = intval($userInput['nb']); | 279 | $intNb = intval($userInput['nb']); |