aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <github@ainw.org> 2014-05-04 08:57:19 -0400
committerGravatar Alexis Degrugillier <github@ainw.org> 2014-05-04 17:23:53 -0400
commit8521c876d4b2ce69ff5d4313493017f26aa2cd6b (patch)
tree36b2c4ee9f3237502a7f15c0a8e6c132ad7a53a7
parent2f51556f775045689abcde413c765cd08b85058a (diff)
Add user queries
It's an intermediary step to remove the favorite button. I add a button to store the current query as a favorite query. It redirects automatically to the configuration page where it is possible to name and remove user queries. To make the queries more straigtforward, I removed the default behavior when searching for a string. This way, when we search for a string, the filter is not defaulted to all articles.
-rwxr-xr-xapp/Controllers/configureController.php54
-rwxr-xr-xapp/Controllers/indexController.php3
-rw-r--r--app/Models/Configuration.php7
-rw-r--r--app/Models/Themes.php1
-rw-r--r--app/i18n/en.php22
-rw-r--r--app/i18n/fr.php22
-rw-r--r--app/layout/aside_configure.phtml3
-rw-r--r--app/layout/aside_flux.phtml17
-rw-r--r--app/layout/header.phtml1
-rw-r--r--app/layout/nav_menu.phtml8
-rw-r--r--app/views/configure/queries.phtml45
-rw-r--r--p/scripts/main.js8
-rw-r--r--p/themes/icons/bookmark-add.svg6
13 files changed, 194 insertions, 3 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index df5212041..573c42d64 100755
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -298,4 +298,58 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
$this->view->size_total = $entryDAO->size(true);
}
}
+
+ public function queriesAction () {
+ if (Minz_Request::isPost ()) {
+ $params = Minz_Request::params();
+ $this->view->conf->_queries ($params['queries']);
+ $this->view->conf->save();
+
+ $notif = array (
+ 'type' => 'good',
+ 'content' => Minz_Translate::t ('configuration_updated')
+ );
+ Minz_Session::_param ('notification', $notif);
+
+ Minz_Request::forward (array ('c' => 'configure', 'a' => 'queries'), true);
+ } else {
+ $this->view->query_get = array();
+ foreach ($this->view->conf->queries as $key => $query) {
+ if (isset($query['get'])) {
+ switch ($query['get'][0]) {
+ case 'c':
+ $dao = new FreshRSS_CategoryDAO();
+ $category = $dao->searchById(substr($query['get'], 2));
+ $this->view->query_get[$key] = array(
+ 'type' => 'category',
+ 'name' => $category->name(),
+ );
+ break;
+ case 'f':
+ $dao = new FreshRSS_FeedDAO();
+ $feed = $dao->searchById(substr($query['get'], 2));
+ $this->view->query_get[$key] = array(
+ 'type' => 'feed',
+ 'name' => $feed->name(),
+ );
+ break;
+ }
+ }
+ }
+ }
+
+ Minz_View::prependTitle (Minz_Translate::t ('queries') . ' · ');
+ }
+
+ public function addQueryAction () {
+ $queries = $this->view->conf->queries;
+ $query = Minz_Request::params();
+ unset($query['output']);
+ unset($query['token']);
+ $queries[] = $query;
+ $this->view->conf->_queries($queries);
+ $this->view->conf->save();
+
+ Minz_Request::forward(array('c' => 'configure', 'a' => 'queries'), true);
+ }
}
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index 3445c0bd4..d45ce5510 100755
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -84,9 +84,6 @@ class FreshRSS_index_Controller extends Minz_ActionController {
$this->view->state = $state = Minz_Request::param ('state', $this->view->conf->default_view);
$state_param = Minz_Request::param ('state', null);
$filter = Minz_Request::param ('search', '');
- if (!empty($filter)) {
- $state = FreshRSS_Entry::STATE_ALL; //Search always in read and unread articles
- }
$this->view->order = $order = Minz_Request::param ('order', $this->view->conf->sort_order);
$nb = Minz_Request::param ('nb', $this->view->conf->posts_per_page);
$first = Minz_Request::param ('next', '');
diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php
index 8d3e69a1c..deeae0826 100644
--- a/app/Models/Configuration.php
+++ b/app/Models/Configuration.php
@@ -52,6 +52,7 @@ class FreshRSS_Configuration {
'bottomline_date' => true,
'bottomline_link' => true,
'sharing' => array(),
+ 'queries' => array(),
);
private $available_languages = array(
@@ -218,6 +219,12 @@ class FreshRSS_Configuration {
$this->data['sharing'][] = $value;
}
}
+ public function _queries ($values) {
+ $this->data['queries'] = array();
+ foreach ($values as $value) {
+ $this->data['queries'][] = array_filter($value);
+ }
+ }
public function _theme($value) {
$this->data['theme'] = $value;
}
diff --git a/app/Models/Themes.php b/app/Models/Themes.php
index 17b95bb9e..5fcbe78e0 100644
--- a/app/Models/Themes.php
+++ b/app/Models/Themes.php
@@ -70,6 +70,7 @@ class FreshRSS_Themes extends Minz_Model {
'add' => '✚',
'all' => '☰',
'bookmark' => '★',
+ 'bookmark-add' => '✚',
'category' => '☷',
'category-white' => '☷',
'close' => '❌',
diff --git a/app/i18n/en.php b/app/i18n/en.php
index 21d37f475..57ca0985d 100644
--- a/app/i18n/en.php
+++ b/app/i18n/en.php
@@ -15,6 +15,28 @@ return array (
'feed' => 'Feed',
'feeds' => 'Feeds',
'shortcuts' => 'Shortcuts',
+ 'queries' => 'User queries',
+ 'query-search' => 'Search for "%s"',
+ 'query-order-asc' => 'Display oldest articles first',
+ 'query-order-desc' => 'Display newest articles first',
+ 'query-get-category'=> 'Display "%s" category',
+ 'query-get-feed' => 'Display "%s" feed',
+ 'query-state-0' => 'Display all articles',
+ 'query-state-1' => 'Display read articles',
+ 'query-state-2' => 'Display unread articles',
+ 'query-state-3' => 'Display all articles',
+ 'query-state-4' => 'Display favorite articles',
+ 'query-state-5' => 'Display read favorite articles',
+ 'query-state-6' => 'Display unread favorite articles',
+ 'query-state-7' => 'Display favorite articles',
+ 'query-state-8' => 'Display not favorite articles',
+ 'query-state-9' => 'Display read not favorite articles',
+ 'query-state-10' => 'Display unread not favorite articles',
+ 'query-state-11' => 'Display not favorite articles',
+ 'query-state-12' => 'Display all articles',
+ 'query-state-13' => 'Display read articles',
+ 'query-state-14' => 'Display unread articles',
+ 'query-state-15' => 'Display all articles',
'about' => 'About',
'stats' => 'Statistics',
diff --git a/app/i18n/fr.php b/app/i18n/fr.php
index f42115fcd..d99b8eb1d 100644
--- a/app/i18n/fr.php
+++ b/app/i18n/fr.php
@@ -15,6 +15,28 @@ return array (
'feed' => 'Flux',
'feeds' => 'Flux',
'shortcuts' => 'Raccourcis',
+ 'queries' => 'Filtres utilisateurs',
+ 'query-search' => 'Chercher "%s"',
+ 'query-order-asc' => 'Afficher les articles les plus anciens en premier',
+ 'query-order-desc' => 'Afficher les articles les plus récents en premier',
+ 'query-get-category'=> 'Afficher la catégorie "%s"',
+ 'query-get-feed' => 'Afficher le flux "%s"',
+ 'query-state-0' => 'Afficher tous les articles',
+ 'query-state-1' => 'Afficher les articles lus',
+ 'query-state-2' => 'Afficher les articles non lus',
+ 'query-state-3' => 'Afficher tous les articles',
+ 'query-state-4' => 'Afficher les articles favoris',
+ 'query-state-5' => 'Afficher les articles lus et favoris',
+ 'query-state-6' => 'Afficher les articles non lus et favoris',
+ 'query-state-7' => 'Afficher les articles favoris',
+ 'query-state-8' => 'Afficher les articles non favoris',
+ 'query-state-9' => 'Afficher les articles lus et non favoris',
+ 'query-state-10' => 'Afficher les articles non lus et non favoris',
+ 'query-state-11' => 'Afficher les articles non favoris',
+ 'query-state-12' => 'Afficher tous les articles',
+ 'query-state-13' => 'Afficher les articles lus',
+ 'query-state-14' => 'Afficher les articles non lus',
+ 'query-state-15' => 'Afficher tous les articles',
'about' => 'À propos',
'stats' => 'Statistiques',
diff --git a/app/layout/aside_configure.phtml b/app/layout/aside_configure.phtml
index 43adeb3c6..e66f2f64c 100644
--- a/app/layout/aside_configure.phtml
+++ b/app/layout/aside_configure.phtml
@@ -15,6 +15,9 @@
<li class="item<?php echo Minz_Request::actionName () == 'shortcut' ? ' active' : ''; ?>">
<a href="<?php echo _url ('configure', 'shortcut'); ?>"><?php echo Minz_Translate::t ('shortcuts'); ?></a>
</li>
+ <li class="item<?php echo Minz_Request::actionName () == 'queries' ? ' active' : ''; ?>">
+ <a href="<?php echo _url ('configure', 'queries'); ?>"><?php echo Minz_Translate::t ('queries'); ?></a>
+ </li>
<li class="separator"></li>
<li class="item<?php echo Minz_Request::actionName () == 'users' ? ' active' : ''; ?>">
<a href="<?php echo _url ('configure', 'users'); ?>"><?php echo Minz_Translate::t ('users'); ?></a>
diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml
index 817dae676..8f8d436e1 100644
--- a/app/layout/aside_flux.phtml
+++ b/app/layout/aside_flux.phtml
@@ -36,6 +36,23 @@
</a>
</div>
</li>
+
+ <?php
+ $count = 0;
+ foreach ($this->conf->queries as $query_conf):
+ $count++;
+ $name = $count;
+ if (isset($query_conf['name'])) {
+ $name = $query_conf['name'];
+ unset($query_conf['name']);
+ }
+ $url_user_query = array('c' => 'index', 'a' => 'index', 'params' => $query_conf); ?>
+ <li>
+ <div class="category">
+ <a data-unread="0" class="btn" href="<?php echo Minz_Url::display($url_user_query)?>"><?php echo $name?></a>
+ </div>
+ </li>
+ <?php endforeach; ?>
<?php
foreach ($this->cat_aside as $cat) {
diff --git a/app/layout/header.phtml b/app/layout/header.phtml
index 08aa7715d..3eedc8ea7 100644
--- a/app/layout/header.phtml
+++ b/app/layout/header.phtml
@@ -72,6 +72,7 @@ if (Minz_Configuration::canLogIn()) {
<li class="item"><a href="<?php echo _url ('configure', 'archiving'); ?>"><?php echo Minz_Translate::t ('archiving_configuration'); ?></a></li>
<li class="item"><a href="<?php echo _url ('configure', 'sharing'); ?>"><?php echo Minz_Translate::t ('sharing'); ?></a></li>
<li class="item"><a href="<?php echo _url ('configure', 'shortcut'); ?>"><?php echo Minz_Translate::t ('shortcuts'); ?></a></li>
+ <li class="item"><a href="<?php echo _url ('configure', 'queries'); ?>"><?php echo Minz_Translate::t ('queries'); ?></a></li>
<li class="separator"></li>
<li class="item"><a href="<?php echo _url ('configure', 'users'); ?>"><?php echo Minz_Translate::t ('users'); ?></a></li>
<li class="separator"></li>
diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml
index 9990448ba..6db172904 100644
--- a/app/layout/nav_menu.phtml
+++ b/app/layout/nav_menu.phtml
@@ -241,6 +241,14 @@
<?php echo FreshRSS_Themes::icon($icon); ?>
</a>
+ <?php if ($this->loginOk):
+ $url_query = $this->url;
+ $url_query['c'] = 'configure';
+ $url_query['a'] = 'addQuery';
+ ?>
+ <a id="save_query" class="btn" href="<?php echo Minz_Url::display ($url_query); ?>"><?php echo FreshRSS_Themes::icon('bookmark-add'); ?></a>
+ <?php endif; ?>
+
<?php $url_output['params']['output'] = 'rss'; ?>
<a class="btn view_rss" target="_blank" href="<?php echo Minz_Url::display ($url_output); ?>" title="<?php echo Minz_Translate::t ('rss_view'); ?>">
<?php echo FreshRSS_Themes::icon('rss'); ?>
diff --git a/app/views/configure/queries.phtml b/app/views/configure/queries.phtml
new file mode 100644
index 000000000..38755edc5
--- /dev/null
+++ b/app/views/configure/queries.phtml
@@ -0,0 +1,45 @@
+<?php $this->partial ('aside_configure'); ?>
+
+<div class="post">
+ <a href="<?php echo _url ('index', 'index'); ?>"><?php echo Minz_Translate::t ('back_to_rss_feeds'); ?></a>
+
+ <form method="post" action="<?php echo _url ('configure', 'queries'); ?>">
+ <legend><?php echo Minz_Translate::t ('queries'); ?></legend>
+
+ <?php foreach ($this->conf->queries as $key => $query):?>
+ <div class="form-group">
+ <label class="group-name"><?php echo $key + 1?></label>
+ <div class="group-controls">
+ <input type="hidden" id="queries_<?php echo $key; ?>_search" name="queries[<?php echo $key; ?>][search]" value="<?php echo $query['search']; ?>"/>
+ <input type="hidden" id="queries_<?php echo $key; ?>_state" name="queries[<?php echo $key; ?>][state]" value="<?php echo $query['state']; ?>"/>
+ <input type="hidden" id="queries_<?php echo $key; ?>_order" name="queries[<?php echo $key; ?>][order]" value="<?php echo $query['order']; ?>"/>
+ <input type="hidden" id="queries_<?php echo $key; ?>_get" name="queries[<?php echo $key; ?>][get]" value="<?php echo $query['get']; ?>"/>
+ <input type="text" id="queries_<?php echo $key; ?>_name" name="queries[<?php echo $key; ?>][name]" value="<?php echo $query['name']; ?>"/>
+ <a href='#' class='query remove'><?php echo FreshRSS_Themes::icon('close'); ?></a>
+ <ul>
+ <?php if (isset($query['search'])):?>
+ <li><?php echo Minz_Translate::t ('query-search', $query['search']); ?></li>
+ <?php endif; ?>
+ <?php if (isset($query['state'])):?>
+ <li><?php echo Minz_Translate::t ('query-state-' . $query['state']); ?></li>
+ <?php endif; ?>
+ <?php if (isset($query['order'])):?>
+ <li><?php echo Minz_Translate::t ('query-order-' . strtolower($query['order'])); ?></li>
+ <?php endif; ?>
+ <?php if (isset($query['get'])):?>
+ <li><?php echo Minz_Translate::t ('query-get-' . $this->query_get[$key]['type'], $this->query_get[$key]['name']); ?></li>
+ <?php endif; ?>
+ </ul>
+ </div>
+ </div>
+ <?php endforeach; ?>
+
+ <div class="form-group form-actions">
+ <div class="group-controls">
+ <button type="submit" class="btn btn-important"><?php echo Minz_Translate::t ('save'); ?></button>
+ <button type="reset" class="btn"><?php echo Minz_Translate::t ('cancel'); ?></button>
+ </div>
+ </div>
+ </form>
+
+</div> \ No newline at end of file
diff --git a/p/scripts/main.js b/p/scripts/main.js
index aeb044e88..0b3ebf735 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -992,6 +992,13 @@ function init_share_observers() {
});
}
+function init_queries_observers() {
+ $('.post').on('click', '.query.remove', function(e) {
+ e.preventDefault();
+ $(this).parents('.form-group').remove();
+ });
+}
+
function init_feed_observers() {
$('select[id="category"]').on('change', function() {
var detail = $('#new_category_name').parent();
@@ -1046,6 +1053,7 @@ function init_all() {
window.setInterval(refreshUnreads, 120000);
} else {
init_share_observers();
+ init_queries_observers();
init_feed_observers();
init_password_observers();
}
diff --git a/p/themes/icons/bookmark-add.svg b/p/themes/icons/bookmark-add.svg
new file mode 100644
index 000000000..51db9c498
--- /dev/null
+++ b/p/themes/icons/bookmark-add.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">
+<g transform="translate(-141.0002,-807)" fill="#bebebe">
+<path d="m143,807,0,13,4-4,4,4,0-4,0-1-2,0,0-4,2,0,0-4z"/>
+<path d="m152,810,0,2-2,0,0,2,2,0,0,2,2,0,0-2,2,0,0-2-2,0,0-2-2,0z"/>
+</g>
+</svg> \ No newline at end of file