Browse Source

Add to search UI the user modification date (#8122)

* Add to search UI the user modification date
Follow-up of:
* https://github.com/FreshRSS/FreshRSS/pull/8103
* https://github.com/FreshRSS/FreshRSS/pull/8093

* Easier UI to cancel filtering by date

* Add blank <option> to ease deselection of <select>
Alexandre Alapetite 5 months ago
parent
commit
14fc3e9b64

+ 1 - 1
README.fr.md

@@ -231,7 +231,7 @@ Voir le [dépôt dédié à ces extensions](https://github.com/FreshRSS/Extensio
 | Ελληνικά (el) | ■■・・・・・・・・ 22% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fel+%2F%28TODO%7CDIRTY%29%24%2F) |
 | English (en) | ■■■■■■■■■■ 100% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fen+%2F%28TODO%7CDIRTY%29%24%2F) |
 | English (United States) (en-US) | ■■■■■■■■■■ 100% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fen-US+%2F%28TODO%7CDIRTY%29%24%2F) |
-| Español (es) | ■■■■■■■■・・ 89% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fes+%2F%28TODO%7CDIRTY%29%24%2F) |
+| Español (es) | ■■■■■■■■・・ 88% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fes+%2F%28TODO%7CDIRTY%29%24%2F) |
 | فارسی (fa) | ■■■■■■■■■・ 94% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffa+%2F%28TODO%7CDIRTY%29%24%2F) |
 | Suomi (fi) | ■■■■■■■■■・ 97% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffi+%2F%28TODO%7CDIRTY%29%24%2F) |
 | Français (fr) | ■■■■■■■■■■ 100% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffr+%2F%28TODO%7CDIRTY%29%24%2F) |

+ 1 - 1
README.md

@@ -127,7 +127,7 @@ See the [repository dedicated to those extensions](https://github.com/FreshRSS/E
 | Ελληνικά (el) | ■■・・・・・・・・ 22% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fel+%2F%28TODO%7CDIRTY%29%24%2F) |
 | English (en) | ■■■■■■■■■■ 100% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fen+%2F%28TODO%7CDIRTY%29%24%2F) |
 | English (United States) (en-US) | ■■■■■■■■■■ 100% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fen-US+%2F%28TODO%7CDIRTY%29%24%2F) |
-| Español (es) | ■■■■■■■■・・ 89% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fes+%2F%28TODO%7CDIRTY%29%24%2F) |
+| Español (es) | ■■■■■■■■・・ 88% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fes+%2F%28TODO%7CDIRTY%29%24%2F) |
 | فارسی (fa) | ■■■■■■■■■・ 94% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffa+%2F%28TODO%7CDIRTY%29%24%2F) |
 | Suomi (fi) | ■■■■■■■■■・ 97% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffi+%2F%28TODO%7CDIRTY%29%24%2F) |
 | Français (fr) | ■■■■■■■■■■ 100% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffr+%2F%28TODO%7CDIRTY%29%24%2F) |

+ 21 - 0
app/Controllers/searchController.php

@@ -149,6 +149,27 @@ class FreshRSS_search_Controller extends FreshRSS_ActionController {
 			}
 		}
 
+		// User modification date
+		$userDateFrom = trim(Minz_Request::paramString('userdate_from'));
+		$userDateTo = trim(Minz_Request::paramString('userdate_to'));
+		$userDateNumber = Minz_Request::paramInt('userdate_number');
+		$userDateUnit = trim(Minz_Request::paramString('userdate_unit'));
+
+		if ($userDateNumber > 0 && $userDateUnit !== '') {
+			// Convert to ISO 8601 duration format: P1D, P1W, P1M, PT1H, etc.
+			// Time units (H, M, S) require a T separator
+			$prefix = ($userDateUnit === 'H' || $userDateUnit === 'M' || $userDateUnit === 'S') ? 'PT' : 'P';
+			$searchTerms[] = "userdate:{$prefix}{$userDateNumber}{$userDateUnit}";
+		} elseif ($userDateFrom !== '' || $userDateTo !== '') {
+			if ($userDateFrom !== '' && $userDateTo !== '') {
+				$searchTerms[] = "userdate:$userDateFrom/$userDateTo";
+			} elseif ($userDateFrom !== '') {
+				$searchTerms[] = "userdate:$userDateFrom/";
+			} elseif ($userDateTo !== '') {
+				$searchTerms[] = "userdate:/$userDateTo";
+			}
+		}
+
 		$feedIds = Minz_Request::paramArrayInt('feed_ids');
 		if (!empty($feedIds)) {
 			$searchTerms[] = 'f:' . implode(',', $feedIds);

+ 1 - 0
app/i18n/cs/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/de/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/el/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/en-US/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// IGNORE
 		'date_received' => 'Received Date',	// IGNORE
 		'date_to' => 'To',	// IGNORE
+		'date_user' => 'User Modification Date',	// IGNORE
 		'feeds' => 'Feeds',	// IGNORE
 		'free_text' => 'Free Text',	// IGNORE
 		'free_text_help' => 'Search both in title and content',	// IGNORE

+ 1 - 0
app/i18n/en/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',
 		'date_received' => 'Received Date',
 		'date_to' => 'To',
+		'date_user' => 'User Modification Date',
 		'feeds' => 'Feeds',
 		'free_text' => 'Free Text',
 		'free_text_help' => 'Search both in title and content',

+ 1 - 0
app/i18n/es/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/fa/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/fi/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/fr/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Plage de dates',
 		'date_received' => 'Date de réception',
 		'date_to' => 'À',
+		'date_user' => 'Date de modification par l’utilisateur',
 		'feeds' => 'Flux',
 		'free_text' => 'Texte libre',
 		'free_text_help' => 'Rechercher dans le titre et le contenu',

+ 1 - 0
app/i18n/he/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/hu/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/id/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/it/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/ja/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/ko/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/lv/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/nl/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/oc/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/pl/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/pt-BR/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/pt-PT/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/ru/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/sk/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/tr/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/uk/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/zh-CN/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 1 - 0
app/i18n/zh-TW/gen.php

@@ -233,6 +233,7 @@ return array(
 		'date_range' => 'Date Range',	// TODO
 		'date_received' => 'Received Date',	// TODO
 		'date_to' => 'To',	// TODO
+		'date_user' => 'User Modification Date',	// TODO
 		'feeds' => 'Feeds',	// TODO
 		'free_text' => 'Free Text',	// TODO
 		'free_text_help' => 'Search both in title and content',	// TODO

+ 38 - 2
app/views/search/index.phtml

@@ -67,7 +67,7 @@
 				<div class="group-controls">
 					<div>
 						<label for="date_number"><?= _t('gen.search.date_past') ?>
-							<input id="date_number" name="date_number" type="number" min="1" placeholder="1" />
+							<input id="date_number" name="date_number" type="number" min="0" placeholder="0" />
 							<select id="date_unit" name="date_unit">
 								<option value="H"><?= _t('gen.period.hours') ?></option>
 								<option value="D"><?= _t('gen.period.days') ?></option>
@@ -85,7 +85,7 @@
 				<div class="group-controls">
 					<div>
 						<label for="pubdate_number"><?= _t('gen.search.date_past') ?>
-							<input id="pubdate_number" name="pubdate_number" type="number" min="1" placeholder="1" />
+							<input id="pubdate_number" name="pubdate_number" type="number" min="0" placeholder="0" />
 							<select id="pubdate_unit" name="pubdate_unit">
 								<option value="H"><?= _t('gen.period.hours') ?></option>
 								<option value="D"><?= _t('gen.period.days') ?></option>
@@ -97,6 +97,24 @@
 					</div>
 				</div>
 			</div>
+
+			<div class="form-group">
+				<label class="group-name"><?= _t('gen.search.date_user') ?></label>
+				<div class="group-controls">
+					<div>
+						<label for="userdate_number"><?= _t('gen.search.date_past') ?>
+							<input id="userdate_number" name="userdate_number" type="number" min="0" placeholder="0" />
+							<select id="userdate_unit" name="userdate_unit">
+								<option value="H"><?= _t('gen.period.hours') ?></option>
+								<option value="D"><?= _t('gen.period.days') ?></option>
+								<option value="W"><?= _t('gen.period.weeks') ?></option>
+								<option value="M"><?= _t('gen.period.months') ?></option>
+								<option value="Y"><?= _t('gen.period.years') ?></option>
+							</select>
+						</label>
+					</div>
+				</div>
+			</div>
 		</fieldset>
 
 		<fieldset>
@@ -129,6 +147,20 @@
 					</div>
 				</div>
 			</div>
+
+			<div class="form-group">
+				<label class="group-name"><?= _t('gen.search.date_user') ?></label>
+				<div class="group-controls">
+					<div>
+						<label for="userdate_from"><?= _t('gen.search.date_from') ?>
+							<input id="userdate_from" name="userdate_from" type="date" />
+						</label>
+						<label for="userdate_to"><?= _t('gen.search.date_to') ?>
+							<input id="userdate_to" name="userdate_to" type="date" />
+						</label>
+					</div>
+				</div>
+			</div>
 		</fieldset>
 
 		<fieldset>
@@ -138,6 +170,7 @@
 				<label class="group-name" for="feed_ids"><?= _t('gen.search.feeds') ?></label>
 				<div class="group-controls">
 					<select name="feed_ids[]" id="feed_ids" size="<?= min(8, count($this->feeds) + 1) ?>" multiple="multiple">
+						<option value=""></option>
 						<?php foreach ($this->feeds as $feed): ?>
 						<option value="<?= $feed->id() ?>"><?= $feed->name() ?></option>
 						<?php endforeach; ?>
@@ -149,6 +182,7 @@
 				<label class="group-name" for="category_ids"><?= _t('gen.search.categories') ?></label>
 				<div class="group-controls">
 					<select name="category_ids[]" id="category_ids" size="<?= min(8, count($this->categories) + 1) ?>" multiple="multiple">
+						<option value=""></option>
 						<?php foreach ($this->categories as $category): ?>
 						<option value="<?= $category->id() ?>"><?= $category->name() ?></option>
 						<?php endforeach; ?>
@@ -165,6 +199,7 @@
 				<label class="group-name" for="label_ids"><?= _t('gen.search.labels') ?></label>
 				<div class="group-controls">
 					<select name="label_ids[]" id="label_ids" size="<?= min(8, count($this->labels) + 1) ?>" multiple="multiple">
+						<option value=""></option>
 						<?php foreach ($this->labels as $label): ?>
 						<option value="<?= $label->id() ?>"><?= $label->name() ?></option>
 						<?php endforeach; ?>
@@ -181,6 +216,7 @@
 				<label class="group-name" for="user_query_ids"><?= _t('gen.search.user_queries') ?></label>
 				<div class="group-controls">
 					<select name="user_query_ids[]" id="user_query_ids" size="<?= min(8, count($this->queries) + 1) ?>" multiple="multiple">
+						<option value=""></option>
 						<?php foreach ($this->queries as $key => $query): ?>
 						<option value="<?= $key ?>"><?= $query->getName() ?></option>
 						<?php endforeach; ?>