diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-03-21 21:40:49 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-03-25 19:17:59 +0100 |
commit | 528a6f8a232c060faf024008e4f8a09b4aa8dabc (patch) | |
tree | 86cac78b7f4d3998bedd923da83145c37ec88ff4 /application/FeedBuilder.php | |
parent | ee88a4bcc29da721cf43b750663aebeac4969517 (diff) | |
download | Shaarli-528a6f8a232c060faf024008e4f8a09b4aa8dabc.tar.gz Shaarli-528a6f8a232c060faf024008e4f8a09b4aa8dabc.tar.zst Shaarli-528a6f8a232c060faf024008e4f8a09b4aa8dabc.zip |
Refactor filter in LinkDB
* search type now carried by LinkDB in order to factorize code between different search sources.
* LinkDB->filter split in 3 method: filterSearch, filterHash, filterDay (we know what type of filter is needed).
* filterHash now throw a LinkNotFoundException if it doesn't exist: internal implementation choice, still displays a 404.
* Smallhash regex has been rewritten.
* Unit tests update
Diffstat (limited to 'application/FeedBuilder.php')
-rw-r--r-- | application/FeedBuilder.php | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/application/FeedBuilder.php b/application/FeedBuilder.php index 50e09831..ddefe6ce 100644 --- a/application/FeedBuilder.php +++ b/application/FeedBuilder.php | |||
@@ -103,23 +103,7 @@ class FeedBuilder | |||
103 | public function buildData() | 103 | public function buildData() |
104 | { | 104 | { |
105 | // Optionally filter the results: | 105 | // Optionally filter the results: |
106 | $searchtags = !empty($this->userInput['searchtags']) ? escape($this->userInput['searchtags']) : ''; | 106 | $linksToDisplay = $this->linkDB->filterSearch($this->userInput); |
107 | $searchterm = !empty($this->userInput['searchterm']) ? escape($this->userInput['searchterm']) : ''; | ||
108 | if (! empty($searchtags) && ! empty($searchterm)) { | ||
109 | $linksToDisplay = $this->linkDB->filter( | ||
110 | LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT, | ||
111 | array($searchtags, $searchterm) | ||
112 | ); | ||
113 | } | ||
114 | elseif ($searchtags) { | ||
115 | $linksToDisplay = $this->linkDB->filter(LinkFilter::$FILTER_TAG, $searchtags); | ||
116 | } | ||
117 | elseif ($searchterm) { | ||
118 | $linksToDisplay = $this->linkDB->filter(LinkFilter::$FILTER_TEXT, $searchterm); | ||
119 | } | ||
120 | else { | ||
121 | $linksToDisplay = $this->linkDB; | ||
122 | } | ||
123 | 107 | ||
124 | $nblinksToDisplay = $this->getNbLinks(count($linksToDisplay)); | 108 | $nblinksToDisplay = $this->getNbLinks(count($linksToDisplay)); |
125 | 109 | ||