From 8521c876d4b2ce69ff5d4313493017f26aa2cd6b Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sun, 4 May 2014 08:57:19 -0400 Subject: 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. --- app/Models/Configuration.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/Models/Configuration.php') 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; } -- cgit v1.2.3 From a7e833280954a537e12d5a3f4fa12a5b9e8412da Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 14 Jun 2014 08:58:33 +0200 Subject: Improve system of queries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Coding style - More checks server side - Default query name is "Query n°X" - List of queries is moved into nav_menu, in a dropdown - Better system to remove fields in JS (to a.remove elements, give an attibute data-remove="id_to_remove") - Fix a bug in lib/Mine/Request.php (htmlspecialchars_utf8 can be applied on arrays now) - Few theme improvements - Add an element .no-mobile to apply to elements which should not appear on mobiles See https://github.com/marienfressinaud/FreshRSS/pull/498 --- app/Controllers/configureController.php | 66 +++++++++++++------- app/Models/Configuration.php | 8 ++- app/i18n/en.php | 49 ++++++++------- app/i18n/fr.php | 49 ++++++++------- app/layout/aside_flux.phtml | 17 ------ app/layout/nav_menu.phtml | 63 +++++++++++++------ app/views/configure/queries.phtml | 105 +++++++++++++++++++++++--------- app/views/configure/sharing.phtml | 14 ++--- lib/Minz/Request.php | 5 +- p/scripts/main.js | 21 ++++--- p/themes/Origine/origine.css | 6 +- p/themes/Origine/template.css | 13 +++- 12 files changed, 263 insertions(+), 153 deletions(-) (limited to 'app/Models/Configuration.php') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 14cd65647..89130cae4 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -302,8 +302,14 @@ class FreshRSS_configure_Controller extends Minz_ActionController { public function queriesAction () { if (Minz_Request::isPost ()) { - $params = Minz_Request::params(); - $this->view->conf->_queries (isset($params['queries']) ? $params['queries'] : array()); + $queries = Minz_Request::param('queries', array()); + + foreach ($queries as $key => $query) { + if (!$query['name']) { + $query['name'] = Minz_Translate::t('query_number', $key + 1); + } + } + $this->view->conf->_queries($queries); $this->view->conf->save(); $notif = array ( @@ -316,25 +322,39 @@ class FreshRSS_configure_Controller extends Minz_ActionController { } 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; - } + if (!isset($query['get'])) { + continue; + } + + 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; + case 's': + $this->view->query_get[$key] = array( + 'type' => 'favorite', + 'name' => 'favorite', + ); + break; + case 'a': + $this->view->query_get[$key] = array( + 'type' => 'all', + 'name' => 'all', + ); + break; } } } @@ -345,12 +365,14 @@ class FreshRSS_configure_Controller extends Minz_ActionController { public function addQueryAction () { $queries = $this->view->conf->queries; $query = Minz_Request::params(); + $query['name'] = Minz_Translate::t('query_number', count($queries) + 1); unset($query['output']); unset($query['token']); $queries[] = $query; $this->view->conf->_queries($queries); $this->view->conf->save(); - + + // Minz_Request::forward(array('params' => $query), true); Minz_Request::forward(array('c' => 'configure', 'a' => 'queries'), true); } } diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index b0ce70000..ffd20deca 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -223,7 +223,13 @@ class FreshRSS_Configuration { public function _queries ($values) { $this->data['queries'] = array(); foreach ($values as $value) { - $this->data['queries'][] = array_filter($value); + $value = array_filter($value); + $params = $value; + unset($params['name']); + unset($params['url']); + $value['url'] = Minz_Url::display(array('params' => $params)); + + $this->data['queries'][] = $value; } } public function _theme($value) { diff --git a/app/i18n/en.php b/app/i18n/en.php index afcc4b7ec..223b74010 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -16,27 +16,34 @@ return array ( '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', + '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_get_all' => 'Display all articles', + 'query_get_favorite' => 'Display favorite articles', + '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', + 'query_number' => 'Query n°%d', + 'add_query' => 'Add a query', + 'no_query' => 'You have not create user query yet.', + 'query_filter' => 'Filter applied:', + 'no_query_filter' => 'No filter', 'about' => 'About', 'stats' => 'Statistics', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 9cd1725dd..e85e66723 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -16,27 +16,34 @@ return array ( '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', + 'query_search' => 'Recherche de "%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_get_all' => 'Afficher tous les articles', + 'query_get_favorite' => 'Afficher les articles favoris', + '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', + 'query_number' => 'Filtre n°%d', + 'add_query' => 'Créer un filtre', + 'no_query' => 'Vous n’avez pas encore créé de filtre.', + 'query_filter' => 'Filtres appliqués :', + 'no_query_filter' => 'Aucun filtre appliqué', 'about' => 'À propos', 'stats' => 'Statistiques', diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index 8f8d436e1..817dae676 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -36,23 +36,6 @@ - - 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); ?> -
  • -
    - -
    -
  • - cat_aside as $cat) { diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index aadaadff9..a9cf02388 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -7,18 +7,20 @@ loginOk) { ?> - url; - if ($this->state & FreshRSS_Entry::STATE_READ) { - $url_state['params']['state'] = $this->state & ~FreshRSS_Entry::STATE_READ; - $checked = 'true'; - $class = 'active'; - } else { - $url_state['params']['state'] = $this->state | FreshRSS_Entry::STATE_READ; - $checked = 'false'; - $class = ''; - } - ?>
    + url; + + if ($this->state & FreshRSS_Entry::STATE_READ) { + $url_state['params']['state'] = $this->state & ~FreshRSS_Entry::STATE_READ; + $checked = 'true'; + $class = 'active'; + } else { + $url_state['params']['state'] = $this->state | FreshRSS_Entry::STATE_READ; + $checked = 'false'; + $class = ''; + } + ?> + state & FreshRSS_Entry::STATE_NOT_READ) { $url_state['params']['state'] = $this->state & ~FreshRSS_Entry::STATE_NOT_READ; @@ -44,6 +47,7 @@ title=""> + state & FreshRSS_Entry::STATE_FAVORITE) { $url_state['params']['state'] = $this->state & ~FreshRSS_Entry::STATE_FAVORITE; @@ -62,6 +66,7 @@ title=""> + state & FreshRSS_Entry::STATE_NOT_FAVORITE) { $url_state['params']['state'] = $this->state & ~FreshRSS_Entry::STATE_NOT_FAVORITE; @@ -80,6 +85,34 @@ title=""> + +
    " title=""> - - loginOk) { - $url_query = $this->url; - $url_query['c'] = 'configure'; - $url_query['a'] = 'addQuery'; - ?> - - loginOk || Minz_Configuration::allowAnonymousRefresh()) { ?> diff --git a/app/views/configure/queries.phtml b/app/views/configure/queries.phtml index f0c551742..d0aec687b 100644 --- a/app/views/configure/queries.phtml +++ b/app/views/configure/queries.phtml @@ -1,45 +1,90 @@ -partial ('aside_configure'); ?> +partial('aside_configure'); ?>
    - - -
    - - - conf->queries as $key => $query):?> -
    - -
    - "/> - "/> - "/> - "/> - "/> - + + + + + + conf->queries as $key => $query) { ?> +
    + + +
    + "/> + "/> + "/> + "/> + +
    + + + + + + + + + +
    + + + + +
    +
    +
    + +
    +
    +
      - -
    • - - -
    • - - -
    • - - -
    • query_get[$key]['type'], $this->query_get[$key]['name']); ?>
    • - + +
    • + + + +
    • + + + +
    • + + + +
    • query_get[$key]['type'], $this->query_get[$key]['name']); ?>
    • +
    +
    - - +
    + + + conf->queries) > 0) { ?>
    + +

    +
    \ No newline at end of file diff --git a/app/views/configure/sharing.phtml b/app/views/configure/sharing.phtml index a952bc3b4..02ce331da 100644 --- a/app/views/configure/sharing.phtml +++ b/app/views/configure/sharing.phtml @@ -4,35 +4,35 @@
    + data-simple='
    ' - data-advanced='
    + data-advanced='
    -
    +
    '> conf->sharing as $key => $sharing): ?> conf->shares[$sharing['type']]; ?> -
    +
    ' /> - +
    - +
    - +
    diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index 7e3c59990..755784522 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -28,6 +28,9 @@ class Minz_Request { return self::$params; } static function htmlspecialchars_utf8 ($p) { + if (is_array($p)) { + return array_map('self::htmlspecialchars_utf8', $p); + } return htmlspecialchars($p, ENT_COMPAT, 'UTF-8'); } public static function param ($key, $default = false, $specialchars = false) { @@ -35,8 +38,6 @@ class Minz_Request { $p = self::$params[$key]; if(is_object($p) || $specialchars) { return $p; - } elseif(is_array($p)) { - return array_map('self::htmlspecialchars_utf8', $p); } else { return self::htmlspecialchars_utf8($p); } diff --git a/p/scripts/main.js b/p/scripts/main.js index 079ae0da4..5a3b25c3f 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -975,11 +975,6 @@ function init_print_action() { function init_share_observers() { shares = $('.form-group:not(".form-actions")').length; - $('.post').on('click', '.share.remove', function(e) { - e.preventDefault(); - $(this).parents('.form-group').remove(); - }); - $('.share.add').on('click', function(e) { var opt = $(this).siblings('select').find(':selected'); var row = $(this).parents('form').data(opt.data('form')); @@ -994,10 +989,16 @@ function init_share_observers() { }); } -function init_queries_observers() { - $('.post').on('click', '.query.remove', function(e) { - e.preventDefault(); - $(this).parents('.form-group').remove(); +function init_remove_observers() { + $('.post').on('click', 'a.remove', function(e) { + var remove_what = $(this).attr('data-remove'); + + if (remove_what !== undefined) { + var remove_obj = $('#' + remove_what); + remove_obj.remove(); + } + + return false; }); } @@ -1061,7 +1062,7 @@ function init_all() { window.setInterval(refreshUnreads, 120000); } else { init_share_observers(); - init_queries_observers(); + init_remove_observers(); init_feed_observers(); init_password_observers(); } diff --git a/p/themes/Origine/origine.css b/p/themes/Origine/origine.css index 1835e9ff9..cd40dc509 100644 --- a/p/themes/Origine/origine.css +++ b/p/themes/Origine/origine.css @@ -362,6 +362,10 @@ a.btn { padding: 0 25px; line-height: 2.5em; } +.dropdown-menu > .item > span { + padding: 0 25px; + line-height: 2em; +} .dropdown-menu > .item:hover { background: #0062BE; color: #fff; @@ -400,7 +404,7 @@ a.btn { font-size: 0.9em; } .alert-head { - font-size: 1.2em; + font-size: 1.15em; } .alert > a { color: inherit; diff --git a/p/themes/Origine/template.css b/p/themes/Origine/template.css index f68fdfca3..09ecaf685 100644 --- a/p/themes/Origine/template.css +++ b/p/themes/Origine/template.css @@ -180,7 +180,8 @@ a.btn { .dropdown-menu > .item { display: block; } -.dropdown-menu > .item > a { +.dropdown-menu > .item > a, +.dropdown-menu > .item > span { display: block; } .dropdown-menu > .item[aria-checked="true"] > a:before { @@ -220,10 +221,16 @@ a.btn { display: block; width: 90%; } +.group-controls .alert { + width: 100% +} .alert-head { margin: 0; font-weight: bold; } +.alert ul { + margin: 5px 20px; +} /*=== Icons */ .icon { @@ -587,7 +594,9 @@ a.btn { .aside .btn-important, .aside .feeds .dropdown, .flux_header .item.website span, - .item.date, .day .date { + .item.date, .day .date, + .dropdown-menu > .no-mobile, + .no-mobile { display: none; } .nav-login { -- cgit v1.2.3 From bc8eb560afd50290745ea6a500c0f930df2559eb Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 6 Jul 2014 00:09:31 +0200 Subject: Add TTL to control feed freshness https://github.com/marienfressinaud/FreshRSS/issues/250 --- app/Controllers/configureController.php | 3 + app/Controllers/entryController.php | 2 +- app/Controllers/feedController.php | 2 +- app/Controllers/javascriptController.php | 2 +- app/Models/Configuration.php | 5 ++ app/Models/Feed.php | 150 ++++++++++++++++--------------- app/Models/FeedDAO.php | 19 ++-- app/i18n/en.php | 3 +- app/i18n/fr.php | 1 + app/views/configure/archiving.phtml | 21 +++++ app/views/configure/feed.phtml | 21 +++++ lib/lib_rss.php | 2 +- 12 files changed, 150 insertions(+), 81 deletions(-) (limited to 'app/Models/Configuration.php') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index a608df162..5fd09a263 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -109,6 +109,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { 'priority' => intval(Minz_Request::param ('priority', 0)), 'httpAuth' => $httpAuth, 'keep_history' => intval(Minz_Request::param ('keep_history', -2)), + 'ttl' => intval(Minz_Request::param('ttl', -2)), ); if ($feedDAO->updateFeed ($id, $values)) { @@ -274,9 +275,11 @@ class FreshRSS_configure_Controller extends Minz_ActionController { if (Minz_Request::isPost()) { $old = Minz_Request::param('old_entries', 3); $keepHistoryDefault = Minz_Request::param('keep_history_default', 0); + $ttlDefault = Minz_Request::param('ttl_default', -2); $this->view->conf->_old_entries($old); $this->view->conf->_keep_history_default($keepHistoryDefault); + $this->view->conf->_ttl_default($ttlDefault); $this->view->conf->save(); invalidateHttpCache(); diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php index 2d7fa718a..ac43587ea 100755 --- a/app/Controllers/entryController.php +++ b/app/Controllers/entryController.php @@ -125,7 +125,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController { $date_min = time() - (3600 * 24 * 30 * $nb_month_old); $feedDAO = FreshRSS_Factory::createFeedDao(); - $feeds = $feedDAO->listFeedsOrderUpdate(); + $feeds = $feedDAO->listFeeds(); $nbTotal = 0; invalidateHttpCache(); diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index d30b60877..36425ca9b 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -233,7 +233,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feeds = array ($feed); } } else { - $feeds = $feedDAO->listFeedsOrderUpdate (); + $feeds = $feedDAO->listFeedsOrderUpdate($this->view->conf->ttl_default); } // on calcule la date des articles les plus anciens qu'on accepte diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php index 737908c91..67148350f 100755 --- a/app/Controllers/javascriptController.php +++ b/app/Controllers/javascriptController.php @@ -8,7 +8,7 @@ class FreshRSS_javascript_Controller extends Minz_ActionController { public function actualizeAction () { header('Content-Type: text/javascript; charset=UTF-8'); $feedDAO = FreshRSS_Factory::createFeedDao(); - $this->view->feeds = $feedDAO->listFeedsOrderUpdate(); + $this->view->feeds = $feedDAO->listFeedsOrderUpdate($this->view->conf->ttl_default); } public function nbUnreadsPerFeedAction() { diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index ffd20deca..f2084b833 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -7,6 +7,7 @@ class FreshRSS_Configuration { 'language' => 'en', 'old_entries' => 3, 'keep_history_default' => 0, + 'ttl_default' => 3600, 'mail_login' => '', 'token' => '', 'passwordHash' => '', //CRYPT_BLOWFISH @@ -159,6 +160,10 @@ class FreshRSS_Configuration { $value = intval($value); $this->data['keep_history_default'] = $value >= -1 ? $value : 0; } + public function _ttl_default($value) { + $value = intval($value); + $this->data['ttl_default'] = $value >= -1 ? $value : 3600; + } public function _shortcuts ($values) { foreach ($values as $key => $value) { if (isset($this->data['shortcuts'][$key])) { diff --git a/app/Models/Feed.php b/app/Models/Feed.php index c9f1230ad..576f37760 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -16,18 +16,19 @@ class FreshRSS_Feed extends Minz_Model { private $httpAuth = ''; private $error = false; private $keep_history = -2; + private $ttl = -2; private $hash = null; private $lockPath = ''; - public function __construct ($url, $validate=true) { + public function __construct($url, $validate=true) { if ($validate) { - $this->_url ($url); + $this->_url($url); } else { $this->url = $url; } } - public function id () { + public function id() { return $this->id; } @@ -38,72 +39,75 @@ class FreshRSS_Feed extends Minz_Model { return $this->hash; } - public function url () { + public function url() { return $this->url; } - public function category () { + public function category() { return $this->category; } - public function entries () { + public function entries() { return $this->entries === null ? array() : $this->entries; } - public function name () { + public function name() { return $this->name; } - public function website () { + public function website() { return $this->website; } - public function description () { + public function description() { return $this->description; } - public function lastUpdate () { + public function lastUpdate() { return $this->lastUpdate; } - public function priority () { + public function priority() { return $this->priority; } - public function pathEntries () { + public function pathEntries() { return $this->pathEntries; } - public function httpAuth ($raw = true) { + public function httpAuth($raw = true) { if ($raw) { return $this->httpAuth; } else { - $pos_colon = strpos ($this->httpAuth, ':'); - $user = substr ($this->httpAuth, 0, $pos_colon); - $pass = substr ($this->httpAuth, $pos_colon + 1); + $pos_colon = strpos($this->httpAuth, ':'); + $user = substr($this->httpAuth, 0, $pos_colon); + $pass = substr($this->httpAuth, $pos_colon + 1); - return array ( + return array( 'username' => $user, 'password' => $pass ); } } - public function inError () { + public function inError() { return $this->error; } - public function keepHistory () { + public function keepHistory() { return $this->keep_history; } - public function nbEntries () { + public function ttl() { + return $this->ttl; + } + public function nbEntries() { if ($this->nbEntries < 0) { $feedDAO = FreshRSS_Factory::createFeedDao(); - $this->nbEntries = $feedDAO->countEntries ($this->id ()); + $this->nbEntries = $feedDAO->countEntries($this->id()); } return $this->nbEntries; } - public function nbNotRead () { + public function nbNotRead() { if ($this->nbNotRead < 0) { $feedDAO = FreshRSS_Factory::createFeedDao(); - $this->nbNotRead = $feedDAO->countNotRead ($this->id ()); + $this->nbNotRead = $feedDAO->countNotRead($this->id()); } return $this->nbNotRead; } public function faviconPrepare() { $file = DATA_PATH . '/favicons/' . $this->hash() . '.txt'; - if (!file_exists ($file)) { + if (!file_exists($file)) { $t = $this->website; if ($t == '') { $t = $this->url; @@ -116,92 +120,98 @@ class FreshRSS_Feed extends Minz_Model { @unlink($path . '.ico'); @unlink($path . '.txt'); } - public function favicon () { - return Minz_Url::display ('/f.php?' . $this->hash()); + public function favicon() { + return Minz_Url::display('/f.php?' . $this->hash()); } - public function _id ($value) { + public function _id($value) { $this->id = $value; } - public function _url ($value, $validate=true) { + public function _url($value, $validate=true) { $this->hash = null; if ($validate) { $value = checkUrl($value); } - if (empty ($value)) { - throw new FreshRSS_BadUrl_Exception ($value); + if (empty($value)) { + throw new FreshRSS_BadUrl_Exception($value); } $this->url = $value; } - public function _category ($value) { + public function _category($value) { $value = intval($value); $this->category = $value >= 0 ? $value : 0; } - public function _name ($value) { + public function _name($value) { $this->name = $value === null ? '' : $value; } - public function _website ($value, $validate=true) { + public function _website($value, $validate=true) { if ($validate) { $value = checkUrl($value); } - if (empty ($value)) { + if (empty($value)) { $value = ''; } $this->website = $value; } - public function _description ($value) { + public function _description($value) { $this->description = $value === null ? '' : $value; } - public function _lastUpdate ($value) { + public function _lastUpdate($value) { $this->lastUpdate = $value; } - public function _priority ($value) { + public function _priority($value) { $value = intval($value); $this->priority = $value >= 0 ? $value : 10; } - public function _pathEntries ($value) { + public function _pathEntries($value) { $this->pathEntries = $value; } - public function _httpAuth ($value) { + public function _httpAuth($value) { $this->httpAuth = $value; } - public function _error ($value) { + public function _error($value) { $this->error = (bool)$value; } - public function _keepHistory ($value) { + public function _keepHistory($value) { $value = intval($value); $value = min($value, 1000000); $value = max($value, -2); $this->keep_history = $value; } - public function _nbNotRead ($value) { + public function _ttl($value) { + $value = intval($value); + $value = min($value, 100000000); + $value = max($value, -2); + $this->ttl = $value; + } + public function _nbNotRead($value) { $this->nbNotRead = intval($value); } - public function _nbEntries ($value) { + public function _nbEntries($value) { $this->nbEntries = intval($value); } - public function load ($loadDetails = false) { + public function load($loadDetails = false) { if ($this->url !== null) { if (CACHE_PATH === false) { - throw new Minz_FileNotExistException ( + throw new Minz_FileNotExistException( 'CACHE_PATH', Minz_Exception::ERROR ); } else { - $url = htmlspecialchars_decode ($this->url, ENT_QUOTES); + $url = htmlspecialchars_decode($this->url, ENT_QUOTES); if ($this->httpAuth != '') { - $url = preg_replace ('#((.+)://)(.+)#', '${1}' . $this->httpAuth . '@${3}', $url); + $url = preg_replace('#((.+)://)(.+)#', '${1}' . $this->httpAuth . '@${3}', $url); } $feed = customSimplePie(); - $feed->set_feed_url ($url); + $feed->set_feed_url($url); if (!$loadDetails) { //Only activates auto-discovery when adding a new feed $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE); } $mtime = $feed->init(); if ((!$mtime) || $feed->error()) { - throw new FreshRSS_Feed_Exception ($feed->error() . ' [' . $url . ']'); + throw new FreshRSS_Feed_Exception($feed->error() . ' [' . $url . ']'); } if ($loadDetails) { @@ -209,7 +219,7 @@ class FreshRSS_Feed extends Minz_Model { $subscribe_url = $feed->subscribe_url(false); $title = strtr(html_only_entity_decode($feed->get_title()), array('<' => '<', '>' => '>', '"' => '"')); //HTML to HTML-PRE //ENT_COMPAT except & - $this->_name ($title == '' ? $this->url : $title); + $this->_name($title == '' ? $this->url : $title); $this->_website(html_only_entity_decode($feed->get_link())); $this->_description(html_only_entity_decode($feed->get_description())); @@ -221,12 +231,12 @@ class FreshRSS_Feed extends Minz_Model { if ($subscribe_url !== null && $subscribe_url !== $this->url) { if ($this->httpAuth != '') { // on enlève les id si authentification HTTP - $subscribe_url = preg_replace ('#((.+)://)((.+)@)(.+)#', '${1}${5}', $subscribe_url); + $subscribe_url = preg_replace('#((.+)://)((.+)@)(.+)#', '${1}${5}', $subscribe_url); } - $this->_url ($subscribe_url); + $this->_url($subscribe_url); } - if (($mtime === true) || ($mtime > $this->lastUpdate)) { + if (($mtime === true) ||($mtime > $this->lastUpdate)) { syslog(LOG_DEBUG, 'FreshRSS no cache ' . $mtime . ' > ' . $this->lastUpdate . ' for ' . $subscribe_url); $this->loadEntries($feed); // et on charge les articles du flux } else { @@ -240,25 +250,25 @@ class FreshRSS_Feed extends Minz_Model { } } - private function loadEntries ($feed) { - $entries = array (); + private function loadEntries($feed) { + $entries = array(); - foreach ($feed->get_items () as $item) { - $title = html_only_entity_decode (strip_tags ($item->get_title ())); - $author = $item->get_author (); - $link = $item->get_permalink (); - $date = @strtotime ($item->get_date ()); + foreach ($feed->get_items() as $item) { + $title = html_only_entity_decode(strip_tags($item->get_title())); + $author = $item->get_author(); + $link = $item->get_permalink(); + $date = @strtotime($item->get_date()); // gestion des tags (catégorie == tag) - $tags_tmp = $item->get_categories (); - $tags = array (); + $tags_tmp = $item->get_categories(); + $tags = array(); if ($tags_tmp !== null) { foreach ($tags_tmp as $tag) { - $tags[] = html_only_entity_decode ($tag->get_label ()); + $tags[] = html_only_entity_decode($tag->get_label()); } } - $content = html_only_entity_decode ($item->get_content ()); + $content = html_only_entity_decode($item->get_content()); $elinks = array(); foreach ($item->get_enclosures() as $enclosure) { @@ -276,16 +286,16 @@ class FreshRSS_Feed extends Minz_Model { } } - $entry = new FreshRSS_Entry ( - $this->id (), - $item->get_id (), + $entry = new FreshRSS_Entry( + $this->id(), + $item->get_id(), $title === null ? '' : $title, - $author === null ? '' : html_only_entity_decode ($author->name), + $author === null ? '' : html_only_entity_decode($author->name), $content === null ? '' : $content, $link === null ? '' : $link, - $date ? $date : time () + $date ? $date : time() ); - $entry->_tags ($tags); + $entry->_tags($tags); // permet de récupérer le contenu des flux tronqués $entry->loadCompleteContent($this->pathEntries()); diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index 5281b371d..83f3a6231 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -2,7 +2,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { public function addFeed($valuesTmp) { - $sql = 'INSERT INTO `' . $this->prefix . 'feed` (url, category, name, website, description, lastUpdate, priority, httpAuth, error, keep_history) VALUES(?, ?, ?, ?, ?, ?, 10, ?, 0, -2)'; + $sql = 'INSERT INTO `' . $this->prefix . 'feed` (url, category, name, website, description, lastUpdate, priority, httpAuth, error, keep_history, ttl) VALUES(?, ?, ?, ?, ?, ?, 10, ?, 0, -2, -2)'; $stm = $this->bd->prepare($sql); $values = array( @@ -222,13 +222,19 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { return $feedCategoryNames; } - public function listFeedsOrderUpdate($cacheDuration = 1500) { - $sql = 'SELECT id, url, name, website, lastUpdate, pathEntries, httpAuth, keep_history ' + public function listFeedsOrderUpdate($defaultCacheDuration = 3600) { + $sql = 'SELECT id, url, name, website, lastUpdate, pathEntries, httpAuth, keep_history, ttl ' . 'FROM `' . $this->prefix . 'feed` ' - . 'WHERE lastUpdate < ' . (time() - intval($cacheDuration)) - . ' ORDER BY lastUpdate'; + . 'WHERE ttl <> -1 AND lastUpdate < (' . (time() + 60) . '-(CASE WHEN ttl=-2 THEN ' . intval($defaultCacheDuration) . ' ELSE ttl END)) ' + . 'ORDER BY lastUpdate'; $stm = $this->bd->prepare($sql); - $stm->execute(); + if (!($stm && $stm->execute())) { + $sql2 = 'ALTER TABLE `' . $this->prefix . 'feed` ADD COLUMN ttl INT NOT NULL DEFAULT -2'; //v0.7.3 + $stm = $this->bd->prepare($sql2); + $stm->execute(); + $stm = $this->bd->prepare($sql); + $stm->execute(); + } return self::daoToFeed($stm->fetchAll(PDO::FETCH_ASSOC)); } @@ -365,6 +371,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { $myFeed->_httpAuth(isset($dao['httpAuth']) ? base64_decode($dao['httpAuth']) : ''); $myFeed->_error(isset($dao['error']) ? $dao['error'] : 0); $myFeed->_keepHistory(isset($dao['keep_history']) ? $dao['keep_history'] : -2); + $myFeed->_ttl(isset($dao['ttl']) ? $dao['ttl'] : -2); $myFeed->_nbNotRead(isset($dao['cache_nbUnreads']) ? $dao['cache_nbUnreads'] : 0); $myFeed->_nbEntries(isset($dao['cache_nbEntries']) ? $dao['cache_nbEntries'] : 0); if (isset($dao['id'])) { diff --git a/app/i18n/en.php b/app/i18n/en.php index 19cf4a06d..569903782 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -41,7 +41,7 @@ return array ( 'query_state_15' => 'Display all articles', 'query_number' => 'Query n°%d', 'add_query' => 'Add a query', - 'no_query' => 'You haven’t created user queries yet.', + 'no_query' => 'You haven’t created any user query yet.', 'query_filter' => 'Filter applied:', 'no_query_filter' => 'No filter', 'about' => 'About', @@ -197,6 +197,7 @@ return array ( 'by_feed' => 'by feed', 'by_default' => 'By default', 'keep_history' => 'Minimum number of articles to keep', + 'ttl' => 'Do not automatically refresh more often than', 'categorize' => 'Store in a category', 'truncate' => 'Delete all articles', 'advanced' => 'Advanced', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 54fe55ea0..5fc60bd15 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -197,6 +197,7 @@ return array ( 'by_feed' => 'par flux', 'by_default' => 'Par défaut', 'keep_history' => 'Nombre minimum d’articles à conserver', + 'ttl' => 'Ne pas automatiquement rafraîchir plus souvent que', 'categorize' => 'Ranger dans une catégorie', 'truncate' => 'Supprimer tous les articles', 'advanced' => 'Avancé', diff --git a/app/views/configure/archiving.phtml b/app/views/configure/archiving.phtml index e144d0f45..04fa19b0d 100644 --- a/app/views/configure/archiving.phtml +++ b/app/views/configure/archiving.phtml @@ -24,6 +24,27 @@ ?> ()
    +
    + +
    + () +
    +
    diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index 27b0990ff..a8dd9a8cb 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -103,6 +103,27 @@ ?>
    +
    + +
    + +
    +
    diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 1b1e4b021..7ca611b04 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -109,7 +109,7 @@ function customSimplePie() { $simplePie = new SimplePie(); $simplePie->set_useragent(Minz_Translate::t('freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION); $simplePie->set_cache_location(CACHE_PATH); - $simplePie->set_cache_duration(1500); + $simplePie->set_cache_duration(800); $simplePie->strip_htmltags(array( 'base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', -- cgit v1.2.3 From 21d8c03ac969d93b9a0d29ee5cb8cd2f5630bdb8 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Mon, 7 Jul 2014 19:21:57 -0400 Subject: Add a configuration parameter Add a parameter to choose wether or not the user want to display a confirmation dialog when clicking on "mark all as read" actions. --- app/Controllers/configureController.php | 5 +++-- app/Models/Configuration.php | 4 ++++ app/i18n/en.php | 1 + app/i18n/fr.php | 1 + app/layout/nav_menu.phtml | 2 +- app/views/configure/reading.phtml | 10 ++++++++++ app/views/helpers/pagination.phtml | 2 +- 7 files changed, 21 insertions(+), 4 deletions(-) (limited to 'app/Models/Configuration.php') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index f016e1fbf..9c143508e 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -185,8 +185,9 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $this->view->conf->_auto_load_more(Minz_Request::param('auto_load_more', false)); $this->view->conf->_display_posts(Minz_Request::param('display_posts', false)); $this->view->conf->_onread_jump_next(Minz_Request::param('onread_jump_next', false)); - $this->view->conf->_lazyload(Minz_Request::param('lazyload', false)); - $this->view->conf->_sticky_post(Minz_Request::param('sticky_post', false)); + $this->view->conf->_lazyload (Minz_Request::param('lazyload', false)); + $this->view->conf->_sticky_post (Minz_Request::param('sticky_post', false)); + $this->view->conf->_reading_confirm (Minz_Request::param('reading_confirm', false)); $this->view->conf->_sort_order(Minz_Request::param('sort_order', 'DESC')); $this->view->conf->_mark_when(array( 'article' => Minz_Request::param('mark_open_article', false), diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index f2084b833..7596c54cd 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -20,6 +20,7 @@ class FreshRSS_Configuration { 'onread_jump_next' => true, 'lazyload' => true, 'sticky_post' => true, + 'reading_confirm' => false, 'sort_order' => 'DESC', 'anon_access' => false, 'mark_when' => array( @@ -149,6 +150,9 @@ class FreshRSS_Configuration { public function _sticky_post($value) { $this->data['sticky_post'] = ((bool)$value) && $value !== 'no'; } + public function _reading_confirm($value) { + $this->data['reading_confirm'] = ((bool)$value) && $value !== 'no'; + } public function _sort_order ($value) { $this->data['sort_order'] = $value === 'ASC' ? 'ASC' : 'DESC'; } diff --git a/app/i18n/en.php b/app/i18n/en.php index b9aff9d73..8634f99b5 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -264,6 +264,7 @@ return array ( 'bottom_line' => 'Bottom line', 'img_with_lazyload' => 'Use "lazy load" mode to load pictures', 'sticky_post' => 'Stick the article to the top when opened', + 'reading_confirm' => 'Display a confirmation dialog on “mark all as read” actions', 'auto_read_when' => 'Mark article as read…', 'article_viewed' => 'when article is viewed', 'article_open_on_website' => 'when article is opened on its original website', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index c43e2611b..e04078dba 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -264,6 +264,7 @@ return array ( 'bottom_line' => 'Ligne du bas', 'img_with_lazyload' => 'Utiliser le mode “chargement différé” pour les images', 'sticky_post' => 'Aligner l’article en haut quand il est ouvert', + 'reading_confirm' => 'Afficher une confirmation lors des actions “marquer tout comme lu”', 'auto_read_when' => 'Marquer un article comme lu…', 'article_viewed' => 'lorsque l’article est affiché', 'article_open_on_website' => 'lorsque l’article est ouvert sur le site d’origine', diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index b7eee664a..29ea9032c 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -181,7 +181,7 @@ ?> +
    +
    + +
    +
    +
    diff --git a/app/views/helpers/pagination.phtml b/app/views/helpers/pagination.phtml index d43c664e5..f38913c06 100755 --- a/app/views/helpers/pagination.phtml +++ b/app/views/helpers/pagination.phtml @@ -12,7 +12,7 @@ nextId; ?> - + conf->reading_confirm) { echo ' class="confirm"';} ?>>

    -- cgit v1.2.3