diff options
| author | 2014-06-13 20:20:43 +0200 | |
|---|---|---|
| committer | 2014-06-13 20:20:43 +0200 | |
| commit | 2b8dc666345d334f50bf2f4f32f0b127edb40c3a (patch) | |
| tree | 0802e16f4fc2c98a706b8d68cea0bcf89549a18d | |
| parent | 61f4d5457818204eb28ed394d4f1b97160542baa (diff) | |
| parent | a61180032f6c663ed3946fe0bbdb70ac3b8ec96a (diff) | |
Merge branch 'user-queries' of https://github.com/aledeg/FreshRSS into aledeg-user-queries
Conflicts:
app/layout/nav_menu.phtml
| -rwxr-xr-x | app/Controllers/configureController.php | 54 | ||||
| -rwxr-xr-x | app/Controllers/indexController.php | 3 | ||||
| -rw-r--r-- | app/Models/Configuration.php | 7 | ||||
| -rw-r--r-- | app/Models/Themes.php | 1 | ||||
| -rw-r--r-- | app/i18n/en.php | 22 | ||||
| -rw-r--r-- | app/i18n/fr.php | 22 | ||||
| -rw-r--r-- | app/layout/aside_configure.phtml | 3 | ||||
| -rw-r--r-- | app/layout/aside_flux.phtml | 17 | ||||
| -rw-r--r-- | app/layout/header.phtml | 1 | ||||
| -rw-r--r-- | app/layout/nav_menu.phtml | 8 | ||||
| -rw-r--r-- | app/views/configure/queries.phtml | 45 | ||||
| -rw-r--r-- | p/scripts/main.js | 8 | ||||
| -rw-r--r-- | p/themes/icons/bookmark-add.svg | 6 |
13 files changed, 194 insertions, 3 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index a117e0f9c..14cd65647 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -299,4 +299,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 (isset($params['queries']) ? $params['queries'] : array()); + $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 c843748c3..4fcc3176f 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -82,9 +82,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 0d6666297..b0ce70000 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -53,6 +53,7 @@ class FreshRSS_Configuration { 'bottomline_date' => true, 'bottomline_link' => true, 'sharing' => array(), + 'queries' => array(), ); private $available_languages = array( @@ -219,6 +220,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 620149934..2e2c3f9cd 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 a3c1dfeb7..afcc4b7ec 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 4acf5b397..9cd1725dd 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 b42f816b4..aadaadff9 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -233,6 +233,14 @@ <a class="btn" href="<?php echo Minz_Url::display ($url_order); ?>" title="<?php echo Minz_Translate::t ($title); ?>"> <?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 } ?> <?php if ($this->loginOk || Minz_Configuration::allowAnonymousRefresh()) { ?> <a id="actualize" class="btn" href="<?php echo _url ('feed', 'actualize'); ?>"><?php echo FreshRSS_Themes::icon('refresh'); ?></a> diff --git a/app/views/configure/queries.phtml b/app/views/configure/queries.phtml new file mode 100644 index 000000000..f0c551742 --- /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 isset($query['search']) ? $query['search'] : ""; ?>"/> + <input type="hidden" id="queries_<?php echo $key; ?>_state" name="queries[<?php echo $key; ?>][state]" value="<?php echo isset($query['state']) ? $query['state'] : ""; ?>"/> + <input type="hidden" id="queries_<?php echo $key; ?>_order" name="queries[<?php echo $key; ?>][order]" value="<?php echo isset($query['order']) ? $query['order'] : ""; ?>"/> + <input type="hidden" id="queries_<?php echo $key; ?>_get" name="queries[<?php echo $key; ?>][get]" value="<?php echo isset($query['get']) ? $query['get'] : ""; ?>"/> + <input type="text" id="queries_<?php echo $key; ?>_name" name="queries[<?php echo $key; ?>][name]" value="<?php echo isset($query['name']) ? $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 f1dd7117c..079ae0da4 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -994,6 +994,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(); @@ -1054,6 +1061,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 |
