mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-05-06 14:15:40 -04:00
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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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', '');
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ class FreshRSS_Themes extends Minz_Model {
|
||||
'add' => '✚',
|
||||
'all' => '☰',
|
||||
'bookmark' => '★',
|
||||
'bookmark-add' => '✚',
|
||||
'category' => '☷',
|
||||
'category-white' => '☷',
|
||||
'close' => '❌',
|
||||
|
||||
@@ -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',
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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'); ?>
|
||||
|
||||
45
app/views/configure/queries.phtml
Normal file
45
app/views/configure/queries.phtml
Normal file
@@ -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>
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
6
p/themes/icons/bookmark-add.svg
Normal file
6
p/themes/icons/bookmark-add.svg
Normal file
@@ -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>
|
||||
|
After Width: | Height: | Size: 261 B |
Reference in New Issue
Block a user