From 1b7cc49d2253caf6f2ea9e3bbc5d380aeaff4ea1 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Sun, 10 Dec 2017 15:04:01 +0100 Subject: refactored ReadingModes to Model --- app/Models/ReadingMode.php | 136 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 app/Models/ReadingMode.php (limited to 'app/Models') diff --git a/app/Models/ReadingMode.php b/app/Models/ReadingMode.php new file mode 100644 index 000000000..06170a468 --- /dev/null +++ b/app/Models/ReadingMode.php @@ -0,0 +1,136 @@ +name = $name; + $this->title = $title; + $this->urlParams = $urlParams; + $this->isActive = $active; + } + + /** + * @return string + */ + public function getName() { + return $this->name; + } + + /** + * @param string $name + * @return FreshRSS_ReadingMode + */ + public function setName($name) { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getTitle() { + return $this->title; + } + + /** + * @param string $title + * @return FreshRSS_ReadingMode + */ + public function setTitle($title) { + $this->title = $title; + return $this; + } + + /** + * @return string + */ + public function getUrlParams() { + return $this->urlParams; + } + + /** + * @param string $urlParams + * @return FreshRSS_ReadingMode + */ + public function setUrlParams($urlParams) { + $this->urlParams = $urlParams; + return $this; + } + + /** + * @return bool + */ + public function isActive() { + return $this->isActive; + } + + /** + * @param bool $isActive + * @return FreshRSS_ReadingMode + */ + public function setIsActive($isActive) { + $this->isActive = $isActive; + return $this; + } + + /** + * Returns the built-in reading modes. + * return ReadingMode[] + */ + public static function getReadingModes() { + $actualView = Minz_Request::actionName(); + $defaultCtrl = Minz_Request::defaultControllerName(); + $isDefaultCtrl = Minz_Request::controllerName() == $defaultCtrl; + $urlOutput = Minz_Request::currentRequest(); + + $readingModes = array( + new FreshRSS_ReadingMode( + _i("view-normal"), + _t('index.menu.normal_view'), + array_merge($urlOutput, array('c' => $defaultCtrl, 'a' => 'normal')), + ($isDefaultCtrl && $actualView === 'normal') + ), + new FreshRSS_ReadingMode( + _i("view-global"), + _t('index.menu.global_view'), + array_merge($urlOutput, array('c' => $defaultCtrl, 'a' => 'global')), + ($isDefaultCtrl && $actualView === 'global') + ), + new FreshRSS_ReadingMode( + _i("view-reader"), + _t('index.menu.reader_view'), + array_merge($urlOutput, array('c' => $defaultCtrl, 'a' => 'reader')), + ($isDefaultCtrl && $actualView === 'reader') + ), + ); + + return $readingModes; + } +} -- cgit v1.2.3 From 8c2113f9e6eb86b630a4e861513229d7abf219b8 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Mon, 1 Jan 2018 20:34:06 +0100 Subject: Add mute strategy configuration (#1750) --- app/Controllers/configureController.php | 7 ++---- app/Controllers/feedController.php | 15 +++++++++-- app/Controllers/subscriptionController.php | 14 ++++++++--- app/Models/CategoryDAO.php | 5 ++-- app/Models/EntryDAO.php | 40 +++++++++++++++++++++--------- app/Models/Feed.php | 23 +++++++++++------ app/Models/FeedDAO.php | 33 ++++++++++++++++-------- app/SQL/install.sql.mysql.php | 2 +- app/SQL/install.sql.pgsql.php | 2 +- app/SQL/install.sql.sqlite.php | 2 +- app/i18n/cz/sub.php | 8 +++++- app/i18n/de/sub.php | 8 +++++- app/i18n/en/sub.php | 8 +++++- app/i18n/es/sub.php | 8 +++++- app/i18n/fr/sub.php | 8 +++++- app/i18n/he/sub.php | 8 +++++- app/i18n/it/sub.php | 8 +++++- app/i18n/kr/sub.php | 8 +++++- app/i18n/nl/sub.php | 8 +++++- app/i18n/pt-br/sub.php | 8 +++++- app/i18n/ru/sub.php | 8 +++++- app/i18n/tr/sub.php | 8 +++++- app/i18n/zh-cn/sub.php | 8 +++++- app/layout/aside_feed.phtml | 2 +- app/views/helpers/feed/update.phtml | 19 ++++++++------ app/views/index/global.phtml | 2 +- app/views/subscription/index.phtml | 2 +- p/api/greader.php | 4 +-- p/themes/base-theme/template.css | 3 +++ 29 files changed, 210 insertions(+), 69 deletions(-) (limited to 'app/Models') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index de70e475b..2c7739c55 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -204,16 +204,13 @@ class FreshRSS_configure_Controller extends Minz_ActionController { * The options available on that page are: * - duration to retain old article (default: 3) * - number of article to retain per feed (default: 0) - * - refresh frequency (default: -2) - * - * @todo explain why the default value is -2 but this value does not - * exist in the drop-down list + * - refresh frequency (default: 0) */ public function archivingAction() { if (Minz_Request::isPost()) { FreshRSS_Context::$user_conf->old_entries = Minz_Request::param('old_entries', 3); FreshRSS_Context::$user_conf->keep_history_default = Minz_Request::param('keep_history_default', 0); - FreshRSS_Context::$user_conf->ttl_default = Minz_Request::param('ttl_default', -2); + FreshRSS_Context::$user_conf->ttl_default = Minz_Request::param('ttl_default', FreshRSS_Feed::TTL_DEFAULT); FreshRSS_Context::$user_conf->save(); invalidateHttpCache(); diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index fff20f798..2793577d5 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -24,6 +24,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { Minz_Error::error(403); } } + $this->updateTTL(); } /** @@ -282,11 +283,11 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $mtime = 0; $ttl = $feed->ttl(); - if ($ttl == -1) { + if ($ttl < FreshRSS_Feed::TTL_DEFAULT) { continue; //Feed refresh is disabled } if ((!$simplePiePush) && (!$feed_id) && - ($feed->lastUpdate() + 10 >= time() - ($ttl == -2 ? FreshRSS_Context::$user_conf->ttl_default : $ttl))) { + ($feed->lastUpdate() + 10 >= time() - ($ttl == FreshRSS_Feed::TTL_DEFAULT ? FreshRSS_Context::$user_conf->ttl_default : $ttl))) { //Too early to refresh from source, but check whether the feed was updated by another user $mtime = $feed->cacheModifiedTime(); if ($feed->lastUpdate() + 10 >= $mtime) { @@ -639,4 +640,14 @@ class FreshRSS_feed_Controller extends Minz_ActionController { Minz_Request::bad(_t('feedback.sub.feed.error'), $redirect_url); } } + + /** + * This method update TTL values for feeds if needed. + * It changes the old default value (-2) to the new default value (0). + * It changes the old disabled value (-1) to the default disabled value. + */ + private function updateTTL() { + $feedDAO = FreshRSS_Factory::createFeedDao(); + $feedDAO->updateTTL(); + } } diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php index 6af048b84..b3f3df46e 100644 --- a/app/Controllers/subscriptionController.php +++ b/app/Controllers/subscriptionController.php @@ -15,8 +15,10 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { } $catDAO = new FreshRSS_CategoryDAO(); + $feedDAO = new FreshRSS_FeedDAO(); $catDAO->checkDefault(); + $feedDAO->updateTTL(); $this->view->categories = $catDAO->listCategories(false); $this->view->default_category = $catDAO->getDefault(); } @@ -55,7 +57,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { * - display in main stream (default: 0) * - HTTP authentication * - number of article to retain (default: -2) - * - refresh frequency (default: -2) + * - refresh frequency (default: 0) * Default values are empty strings unless specified. */ public function feedAction() { @@ -87,6 +89,12 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { $cat = intval(Minz_Request::param('category', 0)); + $mute = Minz_Request::param('mute', false); + $ttl = intval(Minz_Request::param('ttl', FreshRSS_Feed::TTL_DEFAULT)); + if ($mute && FreshRSS_Feed::TTL_DEFAULT === $ttl) { + $ttl = FreshRSS_Context::$user_conf->ttl_default; + } + $values = array( 'name' => Minz_Request::param('name', ''), 'description' => sanitizeHTML(Minz_Request::param('description', '', true)), @@ -94,10 +102,10 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { 'url' => checkUrl(Minz_Request::param('url', '')), 'category' => $cat, 'pathEntries' => Minz_Request::param('path_entries', ''), - 'priority' => intval(Minz_Request::param('priority', 0)), + 'priority' => intval(Minz_Request::param('priority', FreshRSS_Feed::PRIORITY_MAIN_STREAM)), 'httpAuth' => $httpAuth, 'keep_history' => intval(Minz_Request::param('keep_history', -2)), - 'ttl' => intval(Minz_Request::param('ttl', -2)), + 'ttl' => $ttl * ($mute ? -1 : 1), ); invalidateHttpCache(); diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index f219c275f..68db17db3 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -106,13 +106,14 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable public function listCategories($prePopulateFeeds = true, $details = false) { if ($prePopulateFeeds) { $sql = 'SELECT c.id AS c_id, c.name AS c_name, ' - . ($details ? 'f.* ' : 'f.id, f.name, f.url, f.website, f.priority, f.error, f.`cache_nbEntries`, f.`cache_nbUnreads` ') + . ($details ? 'f.* ' : 'f.id, f.name, f.url, f.website, f.priority, f.error, f.`cache_nbEntries`, f.`cache_nbUnreads`, f.ttl ') . 'FROM `' . $this->prefix . 'category` c ' . 'LEFT OUTER JOIN `' . $this->prefix . 'feed` f ON f.category=c.id ' + . 'WHERE f.priority >= :priority_normal ' . 'GROUP BY f.id, c_id ' . 'ORDER BY c.name, f.name'; $stm = $this->bd->prepare($sql); - $stm->execute(); + $stm->execute(array(':priority_normal' => FreshRSS_Feed::PRIORITY_NORMAL)); return self::daoToCategoryPrepopulated($stm->fetchAll(PDO::FETCH_ASSOC)); } else { $sql = 'SELECT * FROM `' . $this->prefix . 'category` ORDER BY name'; diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index e8b6dcdae..9e291f4ed 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -726,23 +726,23 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $values = array(); switch ($type) { case 'a': - $where .= 'f.priority > 0 '; - $joinFeed = true; + $where .= 'f.priority > ' . FreshRSS_Feed::PRIORITY_NORMAL . ' '; break; case 's': //Deprecated: use $state instead - $where .= 'e.is_favorite=1 '; + $where .= 'f.priority >= ' . FreshRSS_Feed::PRIORITY_NORMAL . ' '; + $where .= 'AND e.is_favorite=1 '; break; case 'c': - $where .= 'f.category=? '; + $where .= 'f.priority >= ' . FreshRSS_Feed::PRIORITY_NORMAL . ' '; + $where .= 'AND f.category=? '; $values[] = intval($id); - $joinFeed = true; break; case 'f': $where .= 'e.id_feed=? '; $values[] = intval($id); break; case 'A': - $where .= '1=1 '; + $where .= 'f.priority >= ' . FreshRSS_Feed::PRIORITY_NORMAL . ' '; break; default: throw new FreshRSS_EntriesGetter_Exception('Bad type in Entry->listByType: [' . $type . ']!'); @@ -752,7 +752,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return array(array_merge($values, $searchValues), 'SELECT e.id FROM `' . $this->prefix . 'entry` e ' - . ($joinFeed ? 'INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed=f.id ' : '') + . 'INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id ' . 'WHERE ' . $where . $search . 'ORDER BY e.id ' . $order @@ -873,12 +873,28 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { } public function countUnreadReadFavorites() { - $sql = 'SELECT c FROM (' - . 'SELECT COUNT(id) AS c, 1 as o FROM `' . $this->prefix . 'entry` WHERE is_favorite=1 ' - . 'UNION SELECT COUNT(id) AS c, 2 AS o FROM `' . $this->prefix . 'entry` WHERE is_favorite=1 AND is_read=0' - . ') u ORDER BY o'; + $sql = <<prefix}entry` AS e1 + JOIN `{$this->prefix}feed` AS f1 ON e1.id_feed = f1.id + WHERE e1.is_favorite = 1 + AND f1.priority >= :priority_normal + UNION + SELECT COUNT(e2.id) AS c + , 2 AS o + FROM `{$this->prefix}entry` AS e2 + JOIN `{$this->prefix}feed` AS f2 ON e2.id_feed = f2.id + WHERE e2.is_favorite = 1 + AND e2.is_read = 0 + AND f2.priority >= :priority_normal + ) u +ORDER BY o +SQL; $stm = $this->bd->prepare($sql); - $stm->execute(); + $stm->execute(array(':priority_normal' => FreshRSS_Feed::PRIORITY_NORMAL)); $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0); $all = empty($res[0]) ? 0 : $res[0]; $unread = empty($res[1]) ? 0 : $res[1]; diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 560f7415d..216a26d44 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -1,6 +1,12 @@ ttl; } + public function mute() { + return $this->mute; + } // public function ttlExpire() { // $ttl = $this->ttl; - // if ($ttl == -2) { //Default + // if ($ttl == self::TTL_DEFAULT) { //Default // $ttl = FreshRSS_Context::$user_conf->ttl_default; // } // if ($ttl == -1) { //Never @@ -198,8 +208,7 @@ class FreshRSS_Feed extends Minz_Model { $this->lastUpdate = $value; } public function _priority($value) { - $value = intval($value); - $this->priority = $value >= 0 ? $value : 10; + $this->priority = intval($value); } public function _pathEntries($value) { $this->pathEntries = $value; @@ -219,8 +228,8 @@ class FreshRSS_Feed extends Minz_Model { public function _ttl($value) { $value = intval($value); $value = min($value, 100000000); - $value = max($value, -2); - $this->ttl = $value; + $this->ttl = abs($value); + $this->mute = $value < self::TTL_DEFAULT; } public function _nbNotRead($value) { $this->nbNotRead = intval($value); diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index 0de6d98be..deda02c63 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -18,7 +18,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { ttl ) VALUES - (?, ?, ?, ?, ?, ?, 10, ?, 0, -2, -2)'; + (?, ?, ?, ?, ?, ?, 10, ?, 0, -2, ?)'; $stm = $this->bd->prepare($sql); $valuesTmp['url'] = safe_ascii($valuesTmp['url']); @@ -32,6 +32,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { substr($valuesTmp['description'], 0, 1023), $valuesTmp['lastUpdate'], base64_encode($valuesTmp['httpAuth']), + FreshRSS_Feed::TTL_DEFAULT, ); if ($stm && $stm->execute($values)) { @@ -249,18 +250,14 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { * Use $defaultCacheDuration == -1 to return all feeds, without filtering them by TTL. */ public function listFeedsOrderUpdate($defaultCacheDuration = 3600) { + $this->updateTTL(); $sql = 'SELECT id, url, name, website, `lastUpdate`, `pathEntries`, `httpAuth`, keep_history, ttl ' . 'FROM `' . $this->prefix . 'feed` ' - . ($defaultCacheDuration < 0 ? '' : 'WHERE ttl <> -1 AND `lastUpdate` < (' . (time() + 60) . '-(CASE WHEN ttl=-2 THEN ' . intval($defaultCacheDuration) . ' ELSE ttl END)) ') + . ($defaultCacheDuration < 0 ? '' : 'WHERE ttl >= ' . FreshRSS_Feed::TTL_DEFAULT + . ' AND `lastUpdate` < (' . (time() + 60) . '-(CASE WHEN ttl=' . FreshRSS_Feed::TTL_DEFAULT . ' THEN ' . intval($defaultCacheDuration) . ' ELSE ttl END)) ') . 'ORDER BY `lastUpdate`'; $stm = $this->bd->prepare($sql); - 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(); - } + $stm->execute(); return self::daoToFeed($stm->fetchAll(PDO::FETCH_ASSOC)); } @@ -410,7 +407,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $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->_ttl(isset($dao['ttl']) ? $dao['ttl'] : FreshRSS_Feed::TTL_DEFAULT); $myFeed->_nbNotRead(isset($dao['cache_nbUnreads']) ? $dao['cache_nbUnreads'] : 0); $myFeed->_nbEntries(isset($dao['cache_nbEntries']) ? $dao['cache_nbEntries'] : 0); if (isset($dao['id'])) { @@ -421,4 +418,20 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return $list; } + + public function updateTTL() { + $sql = <<prefix}feed` + SET ttl = :new_value + WHERE ttl = :old_value +SQL; + $stm = $this->bd->prepare($sql); + if (!($stm && $stm->execute(array(':new_value' => FreshRSS_Feed::TTL_DEFAULT, ':old_value' => -2)))) { + $sql2 = 'ALTER TABLE `' . $this->prefix . 'feed` ADD COLUMN ttl INT NOT NULL DEFAULT ' . FreshRSS_Feed::TTL_DEFAULT; //v0.7.3 + $stm = $this->bd->prepare($sql2); + $stm->execute(); + } else { + $stm->execute(array(':new_value' => -3600, ':old_value' => -1)); + } + } } diff --git a/app/SQL/install.sql.mysql.php b/app/SQL/install.sql.mysql.php index 09defd452..b94a24298 100644 --- a/app/SQL/install.sql.mysql.php +++ b/app/SQL/install.sql.mysql.php @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS `%1$sfeed` ( `httpAuth` varchar(511) DEFAULT NULL, `error` boolean DEFAULT 0, `keep_history` MEDIUMINT NOT NULL DEFAULT -2, -- v0.7 - `ttl` INT NOT NULL DEFAULT -2, -- v0.7.3 + `ttl` INT NOT NULL DEFAULT 0, -- v0.7.3 `cache_nbEntries` int DEFAULT 0, -- v0.7 `cache_nbUnreads` int DEFAULT 0, -- v0.7 PRIMARY KEY (`id`), diff --git a/app/SQL/install.sql.pgsql.php b/app/SQL/install.sql.pgsql.php index 4cfeb2517..23afdb783 100644 --- a/app/SQL/install.sql.pgsql.php +++ b/app/SQL/install.sql.pgsql.php @@ -21,7 +21,7 @@ $SQL_CREATE_TABLES = array( "httpAuth" VARCHAR(511) DEFAULT NULL, "error" smallint DEFAULT 0, "keep_history" INT NOT NULL DEFAULT -2, - "ttl" INT NOT NULL DEFAULT -2, + "ttl" INT NOT NULL DEFAULT 0, "cache_nbEntries" INT DEFAULT 0, "cache_nbUnreads" INT DEFAULT 0, FOREIGN KEY ("category") REFERENCES "%1$scategory" ("id") ON DELETE SET NULL ON UPDATE CASCADE diff --git a/app/SQL/install.sql.sqlite.php b/app/SQL/install.sql.sqlite.php index d485e2120..d8e670bc8 100644 --- a/app/SQL/install.sql.sqlite.php +++ b/app/SQL/install.sql.sqlite.php @@ -20,7 +20,7 @@ $SQL_CREATE_TABLES = array( `httpAuth` varchar(511) DEFAULT NULL, `error` boolean DEFAULT 0, `keep_history` MEDIUMINT NOT NULL DEFAULT -2, - `ttl` INT NOT NULL DEFAULT -2, + `ttl` INT NOT NULL DEFAULT 0, `cache_nbEntries` int DEFAULT 0, `cache_nbUnreads` int DEFAULT 0, FOREIGN KEY (`category`) REFERENCES `category`(`id`) ON DELETE SET NULL ON UPDATE CASCADE, diff --git a/app/i18n/cz/sub.php b/app/i18n/cz/sub.php index 807c249d3..ec77be317 100644 --- a/app/i18n/cz/sub.php +++ b/app/i18n/cz/sub.php @@ -32,12 +32,18 @@ return array( 'description' => 'Popis', 'empty' => 'Kanál je prázdný. Ověřte prosím zda je ještě autorem udržován.', 'error' => 'Vyskytl se problém s kanálem. Ověřte že je vždy dostupný, prosím, a poté jej aktualizujte.', - 'in_main_stream' => 'Zobrazit ve “Všechny kanály”', 'informations' => 'Informace', 'keep_history' => 'Zachovat tento minimální počet článků', 'moved_category_deleted' => 'Po smazání kategorie budou v ní obsažené kanály automaticky přesunuty do %s.', + 'mute' => 'mute', // TODO 'no_selected' => 'Nejsou označeny žádné kanály.', 'number_entries' => '%d článků', + 'priority' => array( + '_' => 'Visibility', // TODO + 'archived' => 'Do not show (archived)', // TODO + 'main_stream' => 'Zobrazit ve “Všechny kanály”', + 'normal' => 'Show in its category', // TODO + ), 'stats' => 'Statistika', 'think_to_add' => 'Můžete přidat kanály.', 'title' => 'Název', diff --git a/app/i18n/de/sub.php b/app/i18n/de/sub.php index 4ffef4302..6d41d0e5a 100644 --- a/app/i18n/de/sub.php +++ b/app/i18n/de/sub.php @@ -32,12 +32,18 @@ return array( 'description' => 'Beschreibung', 'empty' => 'Dieser Feed ist leer. Bitte stellen Sie sicher, dass er noch gepflegt wird.', 'error' => 'Dieser Feed ist auf ein Problem gestoßen. Bitte stellen Sie sicher, dass er immer lesbar ist und aktualisieren Sie ihn dann.', - 'in_main_stream' => 'In Haupt-Feeds zeigen', 'informations' => 'Information', 'keep_history' => 'Minimale Anzahl an Artikeln, die behalten wird', 'moved_category_deleted' => 'Wenn Sie eine Kategorie entfernen, werden deren Feeds automatisch in die Kategorie %s eingefügt.', + 'mute' => 'mute', // TODO 'no_selected' => 'Kein Feed ausgewählt.', 'number_entries' => '%d Artikel', + 'priority' => array( + '_' => 'Visibility', // TODO + 'archived' => 'Do not show (archived)', // TODO + 'main_stream' => 'In Haupt-Feeds zeigen', + 'normal' => 'Show in its category', // TODO + ), 'stats' => 'Statistiken', 'think_to_add' => 'Sie können Feeds hinzufügen.', 'title' => 'Titel', diff --git a/app/i18n/en/sub.php b/app/i18n/en/sub.php index 47b15ae7a..b9bae7955 100644 --- a/app/i18n/en/sub.php +++ b/app/i18n/en/sub.php @@ -32,12 +32,18 @@ return array( 'description' => 'Description', 'empty' => 'This feed is empty. Please verify that it is still maintained.', 'error' => 'This feed has encountered a problem. Please verify that it is always reachable then update it.', - 'in_main_stream' => 'Show in main stream', 'informations' => 'Information', 'keep_history' => 'Minimum number of articles to keep', 'moved_category_deleted' => 'When you delete a category, its feeds are automatically classified under %s.', + 'mute' => 'mute', 'no_selected' => 'No feed selected.', 'number_entries' => '%d articles', + 'priority' => array( + '_' => 'Visibility', + 'archived' => 'Do not show (archived)', + 'main_stream' => 'Show in main stream', + 'normal' => 'Show in its category', + ), 'stats' => 'Statistics', 'think_to_add' => 'You may add some feeds.', 'title' => 'Title', diff --git a/app/i18n/es/sub.php b/app/i18n/es/sub.php index 72eb06eb7..091c1e3e3 100755 --- a/app/i18n/es/sub.php +++ b/app/i18n/es/sub.php @@ -27,12 +27,18 @@ return array( 'description' => 'Descripción', 'empty' => 'La fuente está vacía. Por favor, verifica que siga activa.', 'error' => 'Hay un problema con esta fuente. Por favor, veritica que esté disponible y prueba de nuevo.', - 'in_main_stream' => 'Mostrar en salida principal', 'informations' => 'Información', 'keep_history' => 'Número mínimo de artículos a conservar', 'moved_category_deleted' => 'Al borrar una categoría todas sus fuentes pasan automáticamente a la categoría %s.', + 'mute' => 'mute', // TODO 'no_selected' => 'No hay funentes seleccionadas.', 'number_entries' => '%d artículos', + 'priority' => array( + '_' => 'Visibility', // TODO + 'archived' => 'Do not show (archived)', // TODO + 'main_stream' => 'Mostrar en salida principal', + 'normal' => 'Show in its category', // TODO + ), 'stats' => 'Estadísticas', 'think_to_add' => 'Puedes añadir fuentes.', 'title' => 'Título', diff --git a/app/i18n/fr/sub.php b/app/i18n/fr/sub.php index 607863c8f..04be55aa5 100644 --- a/app/i18n/fr/sub.php +++ b/app/i18n/fr/sub.php @@ -32,12 +32,18 @@ return array( 'description' => 'Description', 'empty' => 'Ce flux est vide. Veuillez vérifier qu’il est toujours maintenu.', 'error' => 'Ce flux a rencontré un problème. Veuillez vérifier qu’il est toujours accessible puis actualisez-le.', - 'in_main_stream' => 'Afficher dans le flux principal', 'informations' => 'Informations', 'keep_history' => 'Nombre minimum d’articles à conserver', 'moved_category_deleted' => 'Lors de la suppression d’une catégorie, ses flux seront automatiquement classés dans %s.', + 'mute' => 'muet', 'no_selected' => 'Aucun flux sélectionné.', 'number_entries' => '%d articles', + 'priority' => array( + '_' => 'Visibilité', + 'archived' => 'Ne pas afficher (archivé)', + 'main_stream' => 'Afficher dans le flux principal', + 'normal' => 'Afficher dans sa catégorie', + ), 'stats' => 'Statistiques', 'think_to_add' => 'Vous pouvez ajouter des flux.', 'title' => 'Titre', diff --git a/app/i18n/he/sub.php b/app/i18n/he/sub.php index 333de0edf..849a1d5bd 100644 --- a/app/i18n/he/sub.php +++ b/app/i18n/he/sub.php @@ -32,12 +32,18 @@ return array( 'description' => 'תיאור', 'empty' => 'הזנה זו ריקה. אנא ודאו שהיא עדיין מתוחזקת.', 'error' => 'הזנה זו נתקלה בשגיאה, אנא ודאו שהיא תקינה ואז נסו שנית.', - 'in_main_stream' => 'הצגה בזרם המרכזי', 'informations' => 'מידע', 'keep_history' => 'מסםר מינימלי של מאמרים לשמור', 'moved_category_deleted' => 'כאשר הקטגוריה נמחקת ההזנות שבתוכה אוטומטית מקוטלגות תחת %s.', + 'mute' => 'mute', // TODO 'no_selected' => 'אף הזנה לא נבחרה.', 'number_entries' => '%d מאמרים', + 'priority' => array( + '_' => 'Visibility', // TODO + 'archived' => 'Do not show (archived)', // TODO + 'main_stream' => 'הצגה בזרם המרכזי', + 'normal' => 'Show in its category', // TODO + ), 'stats' => 'סטטיסטיקות', 'think_to_add' => 'ניתן להוסיף הזנות חדשות.', 'title' => 'כותרת', diff --git a/app/i18n/it/sub.php b/app/i18n/it/sub.php index fe18855fb..698e64481 100644 --- a/app/i18n/it/sub.php +++ b/app/i18n/it/sub.php @@ -32,12 +32,18 @@ return array( 'description' => 'Descrizione', 'empty' => 'Questo feed non contiene articoli. Per favore verifica il sito direttamente.', 'error' => 'Questo feed ha generato un errore. Per favore verifica se ancora disponibile.', - 'in_main_stream' => 'Mostra in homepage', 'informations' => 'Informazioni', 'keep_history' => 'Numero minimo di articoli da mantenere', 'moved_category_deleted' => 'Cancellando una categoria i feed al suo interno verranno classificati automaticamente come %s.', + 'mute' => 'mute', // TODO 'no_selected' => 'Nessun feed selezionato.', 'number_entries' => '%d articoli', + 'priority' => array( + '_' => 'Visibility', // TODO + 'archived' => 'Do not show (archived)', // TODO + 'main_stream' => 'Mostra in homepage', // TODO + 'normal' => 'Show in its category', // TODO + ), 'stats' => 'Statistiche', 'think_to_add' => 'Aggiungi feed.', 'title' => 'Titolo', diff --git a/app/i18n/kr/sub.php b/app/i18n/kr/sub.php index b8f2385b3..d290dd635 100644 --- a/app/i18n/kr/sub.php +++ b/app/i18n/kr/sub.php @@ -32,12 +32,18 @@ return array( 'description' => '설명', 'empty' => '이 피드는 비어있습니다. 피드가 계속 운영되고 있는지 확인하세요.', 'error' => '이 피드에 문제가 발생했습니다. 이 피드에 접근 권한이 있는지 확인하세요.', - 'in_main_stream' => '메인 스트림에 표시하기', 'informations' => '정보', 'keep_history' => '최소 유지 글 개수', 'moved_category_deleted' => '카테고리를 삭제하면, 해당 카테고리 아래에 있던 피드들은 자동적으로 %s 아래로 분류됩니다.', + 'mute' => 'mute', // TODO 'no_selected' => '선택된 피드가 없습니다.', 'number_entries' => '%d 개의 글', + 'priority' => array( + '_' => 'Visibility', // TODO + 'archived' => 'Do not show (archived)', // TODO + 'main_stream' => '메인 스트림에 표시하기', // TODO + 'normal' => 'Show in its category', // TODO + ), 'stats' => '통계', 'think_to_add' => '피드를 추가할 수 있습니다.', 'title' => '제목', diff --git a/app/i18n/nl/sub.php b/app/i18n/nl/sub.php index ce446778c..4b699d894 100644 --- a/app/i18n/nl/sub.php +++ b/app/i18n/nl/sub.php @@ -32,12 +32,18 @@ return array( 'description' => 'Omschrijving', 'empty' => 'Deze feed is leeg. Controleer of deze nog actueel is.', 'error' => 'Deze feed heeft problemen. Verifieer a.u.b het doeladres en actualiseer het.', - 'in_main_stream' => 'Zichtbaar in het overzicht', 'informations' => 'Informatie', 'keep_history' => 'Minimum aantal artikelen om te houden', 'moved_category_deleted' => 'Als u een categorie verwijderd, worden de feeds automatisch geclassificeerd onder %s.', + 'mute' => 'mute', // TODO 'no_selected' => 'Geen feed geselecteerd.', 'number_entries' => '%d artikelen', + 'priority' => array( + '_' => 'Visibility', // TODO + 'archived' => 'Do not show (archived)', // TODO + 'main_stream' => 'Zichtbaar in het overzicht', + 'normal' => 'Show in its category', // TODO + ), 'pubsubhubbub' => 'Directe notificaties met PubSubHubbub', 'stats' => 'Statistieken', 'think_to_add' => 'Voeg wat feeds toe.', diff --git a/app/i18n/pt-br/sub.php b/app/i18n/pt-br/sub.php index 4249dcabf..09dde718f 100644 --- a/app/i18n/pt-br/sub.php +++ b/app/i18n/pt-br/sub.php @@ -32,12 +32,18 @@ return array( 'description' => 'Descrição', 'empty' => 'Este feed está vazio. Por favor verifique ele ainda é mantido.', 'error' => 'Este feed encontra-se com problema. Por favor verifique se ele ainda está disponível e atualize-o.', - 'in_main_stream' => 'Mostrar na tela principal', 'informations' => 'Informações', 'keep_history' => 'Número mínimo de artigos para manter', 'moved_category_deleted' => 'Quando você deleta uma categoria, seus feeds são automaticamente classificados como %s.', + 'mute' => 'mute', // TODO 'no_selected' => 'Nenhum feed selecionado.', 'number_entries' => '%d artigos', + 'priority' => array( + '_' => 'Visibility', // TODO + 'archived' => 'Do not show (archived)', // TODO + 'main_stream' => 'Mostrar na tela principal', + 'normal' => 'Show in its category', // TODO + ), 'stats' => 'Estatísticas', 'think_to_add' => 'Você deve adicionar alguns feeds.', 'title' => 'Título', diff --git a/app/i18n/ru/sub.php b/app/i18n/ru/sub.php index 6a5530de0..9e360630a 100644 --- a/app/i18n/ru/sub.php +++ b/app/i18n/ru/sub.php @@ -32,12 +32,18 @@ return array( 'description' => 'Description',// TODO 'empty' => 'This feed is empty. Please verify that it is still maintained.',// TODO 'error' => 'This feed has encountered a problem. Please verify that it is always reachable then actualize it.',// TODO - 'in_main_stream' => 'Show in main stream',// TODO 'informations' => 'Information',// TODO 'keep_history' => 'Minimum number of articles to keep',// TODO 'moved_category_deleted' => 'When you delete a category, its feeds are automatically classified under %s.',// TODO + 'mute' => 'mute', // TODO 'no_selected' => 'No feed selected.',// TODO 'number_entries' => '%d articles',// TODO + 'priority' => array( + '_' => 'Visibility', // TODO + 'archived' => 'Do not show (archived)', // TODO + 'main_stream' => 'Show in main stream', // TODO + 'normal' => 'Show in its category', // TODO + ), 'stats' => 'Statistics',// TODO 'think_to_add' => 'You may add some feeds.',// TODO 'title' => 'Title',// TODO diff --git a/app/i18n/tr/sub.php b/app/i18n/tr/sub.php index 0bbaeec5b..871731158 100644 --- a/app/i18n/tr/sub.php +++ b/app/i18n/tr/sub.php @@ -32,12 +32,18 @@ return array( 'description' => 'Tanım', 'empty' => 'Bu akış boş. Lütfen akışın aktif olduğuna emin olun.', 'error' => 'Bu akışda bir hatayla karşılaşıldı. Lütfen akışın sürekli ulaşılabilir olduğuna emin olun.', - 'in_main_stream' => 'Ana akışda göster', 'informations' => 'Bilgi', 'keep_history' => 'En az tutulacak makale sayısı', 'moved_category_deleted' => 'Bir kategoriyi silerseniz, içerisindeki akışlar %s içerisine yerleşir.', + 'mute' => 'mute', // TODO 'no_selected' => 'Hiçbir akış seçilmedi.', 'number_entries' => '%d makale', + 'priority' => array( + '_' => 'Visibility', // TODO + 'archived' => 'Do not show (archived)', // TODO + 'main_stream' => 'Ana akışda göster', + 'normal' => 'Show in its category', // TODO + ), 'stats' => 'İstatistikler', 'think_to_add' => 'Akış ekleyebilirsiniz.', 'title' => 'Başlık', diff --git a/app/i18n/zh-cn/sub.php b/app/i18n/zh-cn/sub.php index 026f436d7..c25875b41 100644 --- a/app/i18n/zh-cn/sub.php +++ b/app/i18n/zh-cn/sub.php @@ -32,12 +32,18 @@ return array( 'description' => '描述', 'empty' => '此源为空。请确认它是否正常更新。', 'error' => '此源遇到一些问题。请在确认是否能正常访问后重试。', - 'in_main_stream' => '在首页中显示', 'informations' => '信息', 'keep_history' => '至少保存的文章数', 'moved_category_deleted' => '删除分类时,其中的 RSS 源会自动归类到 %s', + 'mute' => 'mute', // TODO 'no_selected' => '未选择 RSS 源。', 'number_entries' => '%d 篇文章', + 'priority' => array( + '_' => 'Visibility', // TODO + 'archived' => 'Do not show (archived)', // TODO + 'main_stream' => '在首页中显示', + 'normal' => 'Show in its category', // TODO + ), 'stats' => '统计', 'think_to_add' => '你可以添加一些 RSS 源。', 'title' => '标题', diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml index 3e1ee44dd..97c0fb0d9 100644 --- a/app/layout/aside_feed.phtml +++ b/app/layout/aside_feed.phtml @@ -53,7 +53,7 @@ foreach ($feeds as $feed) { $f_active = FreshRSS_Context::isCurrentGet('f_' . $feed->id()); ?> -
  • +
  • - +
    - +
    @@ -111,11 +112,11 @@
    +
    diff --git a/app/views/index/global.phtml b/app/views/index/global.phtml index f35732c8f..2f25b6dc2 100644 --- a/app/views/index/global.phtml +++ b/app/views/index/global.phtml @@ -37,7 +37,7 @@ $empty = $feed->nbEntries() === 0 ? ' empty' : ''; $url_base['params']['get'] = 'f_' . $feed->id(); ?> -
  • +
  • ✇ name(); ?>
  • diff --git a/app/views/subscription/index.phtml b/app/views/subscription/index.phtml index 48f760d3e..26af0bd7c 100644 --- a/app/views/subscription/index.phtml +++ b/app/views/subscription/index.phtml @@ -125,7 +125,7 @@ $error = $feed->inError() ? ' error' : ''; $empty = $feed->nbEntries() == 0 ? ' empty' : ''; ?> -
  • diff --git a/p/api/greader.php b/p/api/greader.php index 99304f4ec..72f886190 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -261,8 +261,8 @@ function subscriptionList() { $pdo = new MyPDO(); $stm = $pdo->prepare('SELECT f.id, f.name, f.url, f.website, c.id as c_id, c.name as c_name FROM `%_feed` f - INNER JOIN `%_category` c ON c.id = f.category'); - $stm->execute(); + INNER JOIN `%_category` c ON c.id = f.category AND f.priority >= :priority_normal'); + $stm->execute(array(':priority_normal' => FreshRSS_Feed::PRIORITY_NORMAL)); $res = $stm->fetchAll(PDO::FETCH_ASSOC); $salt = FreshRSS_Context::$system_conf->salt; diff --git a/p/themes/base-theme/template.css b/p/themes/base-theme/template.css index e5e1bca05..72487ca17 100644 --- a/p/themes/base-theme/template.css +++ b/p/themes/base-theme/template.css @@ -71,6 +71,9 @@ img.favicon { width: 16px; vertical-align: middle; } +.feed.mute::before { + content: '🔇'; +} /*=== Videos */ iframe, embed, object, video { -- cgit v1.2.3 From 97d4250bd308175b72785f784d5b15e41ed7b04f Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 1 Jan 2018 20:48:33 +0100 Subject: Minor syntax --- app/Models/ReadingMode.php | 2 +- app/layout/nav_menu.phtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/Models') diff --git a/app/Models/ReadingMode.php b/app/Models/ReadingMode.php index 06170a468..1e97e228a 100644 --- a/app/Models/ReadingMode.php +++ b/app/Models/ReadingMode.php @@ -107,7 +107,7 @@ class FreshRSS_ReadingMode { public static function getReadingModes() { $actualView = Minz_Request::actionName(); $defaultCtrl = Minz_Request::defaultControllerName(); - $isDefaultCtrl = Minz_Request::controllerName() == $defaultCtrl; + $isDefaultCtrl = Minz_Request::controllerName() === $defaultCtrl; $urlOutput = Minz_Request::currentRequest(); $readingModes = array( diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index 403ac5cd6..a018a7185 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -136,7 +136,7 @@ $readingModes = Minz_ExtensionManager::callHook('nav_reading_modes', $readingModes); /** @var FreshRSS_ReadingMode $mode */ - foreach($readingModes as $mode) { + foreach ($readingModes as $mode) { ?> getName(); ?> -- cgit v1.2.3 From ebe7be4e6b41a115688bc52350470e7f64f949f7 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 1 Jan 2018 22:11:15 +0100 Subject: Fix login bug when HTTP REMOTE_USER changes https://github.com/YunoHost-Apps/freshrss_ynh/issues/33 --- app/Models/Auth.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/Models') diff --git a/app/Models/Auth.php b/app/Models/Auth.php index 4de058999..32b673b6d 100644 --- a/app/Models/Auth.php +++ b/app/Models/Auth.php @@ -13,6 +13,11 @@ class FreshRSS_Auth { * This method initializes authentication system. */ public static function init() { + if (Minz_Session::param('REMOTE_USER', '') !== httpAuthUser()) { + //HTTP REMOTE_USER has changed + self::removeAccess(); + } + self::$login_ok = Minz_Session::param('loginOk', false); $current_user = Minz_Session::param('currentUser', ''); if ($current_user === '') { @@ -58,6 +63,7 @@ class FreshRSS_Auth { $login_ok = $current_user != ''; if ($login_ok) { Minz_Session::_param('currentUser', $current_user); + Minz_Session::_param('REMOTE_USER', $current_user); } return $login_ok; case 'none': -- cgit v1.2.3 From 7642d334f827d1c077bb1444dfc4e79acf022891 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Tue, 2 Jan 2018 23:53:35 +0100 Subject: Replace "keep history" magic value by a constant (#1759) I think the use of a magic value repeated many times in the code is prone to have some errors made by people not knowing its meaning. Using a constant is a bit more safe. Judging by some comments in the code, I am not the only one. --- app/Controllers/entryController.php | 4 +--- app/Controllers/feedController.php | 6 ++---- app/Controllers/subscriptionController.php | 2 +- app/Models/ConfigurationSetter.php | 4 ++-- app/Models/Feed.php | 7 +++++-- app/Models/FeedDAO.php | 5 +++-- app/views/configure/archiving.phtml | 4 ++-- app/views/helpers/feed/update.phtml | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) (limited to 'app/Models') diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php index bd8b65b2b..9c6b248a9 100755 --- a/app/Controllers/entryController.php +++ b/app/Controllers/entryController.php @@ -177,9 +177,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController { foreach ($feeds as $feed) { $feed_history = $feed->keepHistory(); - if ($feed_history == -2) { - // TODO: -2 must be a constant! - // -2 means we take the default value from configuration + if (FreshRSS_Feed::KEEP_HISTORY_DEFAULT === $feed_history) { $feed_history = FreshRSS_Context::$user_conf->keep_history_default; } diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 2793577d5..884172112 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -317,10 +317,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feed_history = $feed->keepHistory(); if ($isNewFeed) { - $feed_history = -1; //∞ - } elseif ($feed_history == -2) { - // TODO: -2 must be a constant! - // -2 means we take the default value from configuration + $feed_history = FreshRSS_Feed::KEEP_HISTORY_INFINITE; + } elseif (FreshRSS_Feed::KEEP_HISTORY_DEFAULT === $feed_history) { $feed_history = FreshRSS_Context::$user_conf->keep_history_default; } $needFeedCacheRefresh = false; diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php index b3f3df46e..37efd3b57 100644 --- a/app/Controllers/subscriptionController.php +++ b/app/Controllers/subscriptionController.php @@ -104,7 +104,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { 'pathEntries' => Minz_Request::param('path_entries', ''), 'priority' => intval(Minz_Request::param('priority', FreshRSS_Feed::PRIORITY_MAIN_STREAM)), 'httpAuth' => $httpAuth, - 'keep_history' => intval(Minz_Request::param('keep_history', -2)), + 'keep_history' => intval(Minz_Request::param('keep_history', FreshRSS_Feed::KEEP_HISTORY_DEFAULT)), 'ttl' => $ttl * ($mute ? -1 : 1), ); diff --git a/app/Models/ConfigurationSetter.php b/app/Models/ConfigurationSetter.php index ca4709903..645ef644e 100644 --- a/app/Models/ConfigurationSetter.php +++ b/app/Models/ConfigurationSetter.php @@ -81,7 +81,7 @@ class FreshRSS_ConfigurationSetter { private function _keep_history_default(&$data, $value) { $value = intval($value); - $data['keep_history_default'] = $value >= -1 ? $value : 0; + $data['keep_history_default'] = $value >= FreshRSS_Feed::KEEP_HISTORY_INFINITE ? $value : 0; } // It works for system config too! @@ -154,7 +154,7 @@ class FreshRSS_ConfigurationSetter { private function _ttl_default(&$data, $value) { $value = intval($value); - $data['ttl_default'] = $value >= -1 ? $value : 3600; + $data['ttl_default'] = $value > FreshRSS_Feed::TTL_DEFAULT ? $value : 3600; } private function _view_mode(&$data, $value) { diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 216a26d44..13ab13df9 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -7,6 +7,9 @@ class FreshRSS_Feed extends Minz_Model { const TTL_DEFAULT = 0; + const KEEP_HISTORY_DEFAULT = -2; + const KEEP_HISTORY_INFINITE = -1; + private $id = 0; private $url; private $category = 1; @@ -21,7 +24,7 @@ class FreshRSS_Feed extends Minz_Model { private $pathEntries = ''; private $httpAuth = ''; private $error = false; - private $keep_history = -2; + private $keep_history = self::KEEP_HISTORY_DEFAULT; private $ttl = self::TTL_DEFAULT; private $mute = false; private $hash = null; @@ -222,7 +225,7 @@ class FreshRSS_Feed extends Minz_Model { public function _keepHistory($value) { $value = intval($value); $value = min($value, 1000000); - $value = max($value, -2); + $value = max($value, self::KEEP_HISTORY_DEFAULT); $this->keep_history = $value; } public function _ttl($value) { diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index deda02c63..011b3d112 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -18,7 +18,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { ttl ) VALUES - (?, ?, ?, ?, ?, ?, 10, ?, 0, -2, ?)'; + (?, ?, ?, ?, ?, ?, 10, ?, 0, ?, ?)'; $stm = $this->bd->prepare($sql); $valuesTmp['url'] = safe_ascii($valuesTmp['url']); @@ -32,6 +32,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { substr($valuesTmp['description'], 0, 1023), $valuesTmp['lastUpdate'], base64_encode($valuesTmp['httpAuth']), + FreshRSS_Feed::KEEP_HISTORY_DEFAULT, FreshRSS_Feed::TTL_DEFAULT, ); @@ -406,7 +407,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $myFeed->_pathEntries(isset($dao['pathEntries']) ? $dao['pathEntries'] : ''); $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->_keepHistory(isset($dao['keep_history']) ? $dao['keep_history'] : FreshRSS_Feed::KEEP_HISTORY_DEFAULT); $myFeed->_ttl(isset($dao['ttl']) ? $dao['ttl'] : FreshRSS_Feed::TTL_DEFAULT); $myFeed->_nbNotRead(isset($dao['cache_nbUnreads']) ? $dao['cache_nbUnreads'] : 0); $myFeed->_nbEntries(isset($dao['cache_nbEntries']) ? $dao['cache_nbEntries'] : 0); diff --git a/app/views/configure/archiving.phtml b/app/views/configure/archiving.phtml index 2254f5dba..09be55fd9 100644 --- a/app/views/configure/archiving.phtml +++ b/app/views/configure/archiving.phtml @@ -19,7 +19,7 @@
    () @@ -34,7 +34,7 @@ 3600 => '1h', 5400 => '1.5h', 7200 => '2h', 10800 => '3h', 14400 => '4h', 18800 => '5h', 21600 => '6h', 25200 => '7h', 28800 => '8h', 36000 => '10h', 43200 => '12h', 64800 => '18h', 86400 => '1d', 129600 => '1.5d', 172800 => '2d', 259200 => '3d', 345600 => '4d', 432000 => '5d', 518400 => '6d', - 604800 => '1wk', -1 => '∞') as $v => $t) { + 604800 => '1wk') as $v => $t) { echo ''; if (FreshRSS_Context::$user_conf->ttl_default == $v) { $found = true; diff --git a/app/views/helpers/feed/update.phtml b/app/views/helpers/feed/update.phtml index 595309f49..d379c5df8 100644 --- a/app/views/helpers/feed/update.phtml +++ b/app/views/helpers/feed/update.phtml @@ -101,7 +101,7 @@
    -- cgit v1.2.3 From 047fa17aeb65dfb6b551bf73e610057e8d78142c Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Wed, 24 Jan 2018 19:37:24 +0100 Subject: fixed css classes for reading mode buttons #1714 --- app/Models/ReadingMode.php | 24 ++++++++++++++++++------ app/layout/nav_menu.phtml | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'app/Models') diff --git a/app/Models/ReadingMode.php b/app/Models/ReadingMode.php index 1e97e228a..06af1704c 100644 --- a/app/Models/ReadingMode.php +++ b/app/Models/ReadingMode.php @@ -5,6 +5,10 @@ */ class FreshRSS_ReadingMode { + /** + * @var string + */ + protected $id; /** * @var string */ @@ -24,18 +28,26 @@ class FreshRSS_ReadingMode { /** * ReadingMode constructor. - * @param string $name + * @param string $id * @param string $title * @param string[] $urlParams * @param bool $active */ - public function __construct($name, $title, $urlParams, $active) { - $this->name = $name; + public function __construct($id, $title, $urlParams, $active) { + $this->id = $id; + $this->name = _i($id); $this->title = $title; $this->urlParams = $urlParams; $this->isActive = $active; } + /** + * @return string + */ + public function getId() { + return $this->id; + } + /** * @return string */ @@ -112,19 +124,19 @@ class FreshRSS_ReadingMode { $readingModes = array( new FreshRSS_ReadingMode( - _i("view-normal"), + "view-normal", _t('index.menu.normal_view'), array_merge($urlOutput, array('c' => $defaultCtrl, 'a' => 'normal')), ($isDefaultCtrl && $actualView === 'normal') ), new FreshRSS_ReadingMode( - _i("view-global"), + "view-global", _t('index.menu.global_view'), array_merge($urlOutput, array('c' => $defaultCtrl, 'a' => 'global')), ($isDefaultCtrl && $actualView === 'global') ), new FreshRSS_ReadingMode( - _i("view-reader"), + "view-reader", _t('index.menu.reader_view'), array_merge($urlOutput, array('c' => $defaultCtrl, 'a' => 'reader')), ($isDefaultCtrl && $actualView === 'reader') diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index 7632b944c..e9128d44a 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -138,7 +138,7 @@ /** @var FreshRSS_ReadingMode $mode */ foreach ($readingModes as $mode) { ?> - + getName(); ?> Date: Thu, 8 Feb 2018 20:11:05 +0100 Subject: API /reader/api/0/stream/items/contents (#1774) * API /reader/api/0/stream/items/contents For FeedMe * Fix continuation * Continuation in stream/items/ids * Fix multiple continuations * Allow empty POST tokens For FeedMe. This token is not used by e.g. The Old Reader API. There is the Authorization header anyway. TODO: Check security consequences * API compatibility FeedMe: add/remove feed FeedMe uses GET for some parameters typically given by POST * A bit of sanitization * Links to FeedMe * API favicons more robust when base_url is not set * Changelog FeedMe --- CHANGELOG.md | 4 +- README.fr.md | 1 + README.md | 1 + app/Models/EntryDAO.php | 23 ++++- docs/en/users/06_Mobile_access.md | 1 + docs/fr/users/06_Mobile_access.md | 1 + p/api/greader.php | 179 ++++++++++++++++++++++++++------------ 7 files changed, 149 insertions(+), 61 deletions(-) (limited to 'app/Models') diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ed835205..2908cd616 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ # FreshRSS changelog -## 2018-XX-XX FreshRSS 1.9.1-dev +## 2018-02-XX FreshRSS 1.9.1-dev +* API + * Add compatibility with FeedMe 3.5.3+ on Android [#1774](https://github.com/FreshRSS/FreshRSS/pull/1774) * Features * Ability to pause feeds, and to hide them from categories [#1750](https://github.com/FreshRSS/FreshRSS/pull/1750) * Security diff --git a/README.fr.md b/README.fr.md index b888f7738..4421f92f0 100644 --- a/README.fr.md +++ b/README.fr.md @@ -177,6 +177,7 @@ Tout client supportant une API de type Google Reader. Sélection : * Android * [News+](https://play.google.com/store/apps/details?id=com.noinnion.android.newsplus) avec [News+ Google Reader extension](https://play.google.com/store/apps/details?id=com.noinnion.android.newsplus.extension.google_reader) (Propriétaire) + * [FeedMe 3.5.3+](https://play.google.com/store/apps/details?id=com.seazon.feedme) (Propriétaire) * [EasyRSS](https://github.com/Alkarex/EasyRSS) (Libre, [F-Droid](https://f-droid.org/fr/packages/org.freshrss.easyrss/)) * GNU/Linux * [FeedReader 2.0+](https://jangernert.github.io/FeedReader/) (Libre) diff --git a/README.md b/README.md index c971675fa..a95593651 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ Any client supporting a Google Reader-like API. Selection: * Android * [News+](https://play.google.com/store/apps/details?id=com.noinnion.android.newsplus) with [News+ Google Reader extension](https://play.google.com/store/apps/details?id=com.noinnion.android.newsplus.extension.google_reader) (Closed source) + * [FeedMe 3.5.3+](https://play.google.com/store/apps/details?id=com.seazon.feedme) (Closed source) * [EasyRSS](https://github.com/Alkarex/EasyRSS) (Open source, [F-Droid](https://f-droid.org/packages/org.freshrss.easyrss/)) * GNU/Linux * [FeedReader 2.0+](https://jangernert.github.io/FeedReader/) (Open source) diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 9e291f4ed..70135e7a0 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -628,10 +628,12 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $firstId = $order === 'DESC' ? '9000000000'. '000000' : '0'; }*/ if ($firstId !== '') { - $search .= 'AND ' . $alias . 'id ' . ($order === 'DESC' ? '<=' : '>=') . $firstId . ' '; + $search .= 'AND ' . $alias . 'id ' . ($order === 'DESC' ? '<=' : '>=') . ' ? '; + $values[] = $firstId; } if ($date_min > 0) { - $search .= 'AND ' . $alias . 'id >= ' . $date_min . '000000 '; + $search .= 'AND ' . $alias . 'id >= ? '; + $values[] = $date_min . '000000'; } if ($filter) { if ($filter->getMinDate()) { @@ -781,6 +783,23 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return self::daoToEntries($stm->fetchAll(PDO::FETCH_ASSOC)); } + public function listByIds($ids, $order = 'DESC') { + if (count($ids) < 1) { + return array(); + } + + $sql = 'SELECT id, guid, title, author, ' + . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content') + . ', link, date, is_read, is_favorite, id_feed, tags ' + . 'FROM `' . $this->prefix . 'entry` ' + . 'WHERE id IN (' . str_repeat('?,', count($ids) - 1). '?) ' + . 'ORDER BY id ' . $order; + + $stm = $this->bd->prepare($sql); + $stm->execute($ids); + return self::daoToEntries($stm->fetchAll(PDO::FETCH_ASSOC)); + } + public function listIdsWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0) { //For API list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min); diff --git a/docs/en/users/06_Mobile_access.md b/docs/en/users/06_Mobile_access.md index 3472172b0..166985585 100644 --- a/docs/en/users/06_Mobile_access.md +++ b/docs/en/users/06_Mobile_access.md @@ -46,6 +46,7 @@ This page assumes you have completed the [server setup](../admins/02_Installatio 7. Pick a client supporting a Google Reader-like API. Selection: * Android * [News+](https://play.google.com/store/apps/details?id=com.noinnion.android.newsplus) with [News+ Google Reader extension](https://play.google.com/store/apps/details?id=com.noinnion.android.newsplus.extension.google_reader) (Closed source) + * [FeedMe 3.5.3+](https://play.google.com/store/apps/details?id=com.seazon.feedme) (Closed source) * [EasyRSS](https://github.com/Alkarex/EasyRSS) (Open source, [F-Droid](https://f-droid.org/packages/org.freshrss.easyrss/)) * Linux * [FeedReader 2.0+](https://jangernert.github.io/FeedReader/) (Open source) diff --git a/docs/fr/users/06_Mobile_access.md b/docs/fr/users/06_Mobile_access.md index 185c94098..8ef3d038a 100644 --- a/docs/fr/users/06_Mobile_access.md +++ b/docs/fr/users/06_Mobile_access.md @@ -44,6 +44,7 @@ Tout client supportant une API de type Google Reader. Sélection : * Android * [News+](https://play.google.com/store/apps/details?id=com.noinnion.android.newsplus) avec [News+ Google Reader extension](https://play.google.com/store/apps/details?id=com.noinnion.android.newsplus.extension.google_reader) (Propriétaire) + * [FeedMe 3.5.3+](https://play.google.com/store/apps/details?id=com.seazon.feedme) (Propriétaire) * [EasyRSS](https://github.com/Alkarex/EasyRSS) (Libre, F-Droid) * Linux * [FeedReader 2.0+](https://jangernert.github.io/FeedReader/) (Libre) diff --git a/p/api/greader.php b/p/api/greader.php index 72f886190..4add26bd8 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -216,9 +216,13 @@ function token($conf) { function checkToken($conf, $token) { //http://code.google.com/p/google-reader-api/wiki/ActionToken $user = Minz_Session::param('currentUser', '_'); + if ($user !== '_' && $token == '') { + return true; //FeedMe //TODO: Check security consequences + } if ($token === str_pad(sha1(FreshRSS_Context::$system_conf->salt . $user . $conf->apiPasswordHash), 57, 'Z')) { return true; } + Minz_Log::warning('Invalid POST token: ' . $token, API_LOG); unauthorized(); } @@ -266,6 +270,8 @@ function subscriptionList() { $res = $stm->fetchAll(PDO::FETCH_ASSOC); $salt = FreshRSS_Context::$system_conf->salt; + $faviconsUrl = Minz_Url::display('/f.php?', '', true); + $faviconsUrl = str_replace('/api/greader.php/reader/api/0/subscription', '', $faviconsUrl); //Security if base_url is not set properly $subscriptions = array(); foreach ($res as $line) { @@ -282,7 +288,7 @@ function subscriptionList() { //'firstitemmsec' => 0, 'url' => $line['url'], 'htmlUrl' => $line['website'], - 'iconUrl' => Minz_Url::display('/f.php?' . hash('crc32b', $salt . $line['url']), '', true), + 'iconUrl' => $faviconsUrl . hash('crc32b', $salt . $line['url']), ); } @@ -324,6 +330,9 @@ function subscriptionEdit($streamNames, $titles, $action, $add = '', $remove = ' $addCatId = 1; //Default category } $feedDAO = FreshRSS_Factory::createFeedDao(); + if (!is_array($streamNames) || count($streamNames) < 1) { + badRequest(); + } for ($i = count($streamNames) - 1; $i >= 0; $i--) { $streamName = $streamNames[$i]; //feed/http://example.net/sample.xml ; feed/338 if (strpos($streamName, 'feed/') === 0) { @@ -435,6 +444,51 @@ function unreadCount() { //http://blog.martindoms.com/2009/10/16/using-the-googl exit(); } +function entriesToArray($entries) { + $items = array(); + foreach ($entries as $entry) { + $f_id = $entry->feed(); + if (isset($arrayFeedCategoryNames[$f_id])) { + $c_name = $arrayFeedCategoryNames[$f_id]['c_name']; + $f_name = $arrayFeedCategoryNames[$f_id]['name']; + } else { + $c_name = '_'; + $f_name = '_'; + } + $item = array( + 'id' => /*'tag:google.com,2005:reader/item/' .*/ dec2hex($entry->id()), //64-bit hexa http://code.google.com/p/google-reader-api/wiki/ItemId + 'crawlTimeMsec' => substr($entry->id(), 0, -3), + 'timestampUsec' => '' . $entry->id(), //EasyRSS + 'published' => $entry->date(true), + 'title' => $entry->title(), + 'summary' => array('content' => $entry->content()), + 'alternate' => array( + array('href' => htmlspecialchars_decode($entry->link(), ENT_QUOTES)), + ), + 'categories' => array( + 'user/-/state/com.google/reading-list', + 'user/-/label/' . $c_name, + ), + 'origin' => array( + 'streamId' => 'feed/' . $f_id, + 'title' => $f_name, //EasyRSS + //'htmlUrl' => $line['f_website'], + ), + ); + if ($entry->author() != '') { + $item['author'] = $entry->author(); + } + if ($entry->isRead()) { + $item['categories'][] = 'user/-/state/com.google/read'; + } + if ($entry->isFavorite()) { + $item['categories'][] = 'user/-/state/com.google/starred'; + } + $items[] = $item; + } + return $items; +} + function streamContents($path, $include_target, $start_time, $count, $order, $exclude_target, $continuation) { //http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI //http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#feed @@ -476,57 +530,18 @@ function streamContents($path, $include_target, $start_time, $count, $order, $ex break; } - if (!empty($continuation)) { + if ($continuation != '') { $count++; //Shift by one element } $entryDAO = FreshRSS_Factory::createEntryDao(); $entries = $entryDAO->listWhere($type, $include_target, $state, $order === 'o' ? 'ASC' : 'DESC', $count, $continuation, new FreshRSS_Search(''), $start_time); - $items = array(); - foreach ($entries as $entry) { - $f_id = $entry->feed(); - if (isset($arrayFeedCategoryNames[$f_id])) { - $c_name = $arrayFeedCategoryNames[$f_id]['c_name']; - $f_name = $arrayFeedCategoryNames[$f_id]['name']; - } else { - $c_name = '_'; - $f_name = '_'; - } - $item = array( - 'id' => /*'tag:google.com,2005:reader/item/' .*/ dec2hex($entry->id()), //64-bit hexa http://code.google.com/p/google-reader-api/wiki/ItemId - 'crawlTimeMsec' => substr($entry->id(), 0, -3), - 'timestampUsec' => '' . $entry->id(), //EasyRSS - 'published' => $entry->date(true), - 'title' => $entry->title(), - 'summary' => array('content' => $entry->content()), - 'alternate' => array( - array('href' => htmlspecialchars_decode($entry->link(), ENT_QUOTES)), - ), - 'categories' => array( - 'user/-/state/com.google/reading-list', - 'user/-/label/' . $c_name, - ), - 'origin' => array( - 'streamId' => 'feed/' . $f_id, - 'title' => $f_name, //EasyRSS - //'htmlUrl' => $line['f_website'], - ), - ); - if ($entry->author() != '') { - $item['author'] = $entry->author(); - } - if ($entry->isRead()) { - $item['categories'][] = 'user/-/state/com.google/read'; - } - if ($entry->isFavorite()) { - $item['categories'][] = 'user/-/state/com.google/starred'; - } - $items[] = $item; - } + $items = entriesToArray($entries); - if (!empty($continuation)) { + if ($continuation != '') { array_shift($items); //Discard first element that was already sent in the previous response + $count--; } $response = array( @@ -534,15 +549,18 @@ function streamContents($path, $include_target, $start_time, $count, $order, $ex 'updated' => time(), 'items' => $items, ); - if ((count($entries) >= $count) && (!empty($entry))) { - $response['continuation'] = $entry->id(); + if (count($entries) >= $count) { + $entry = end($entries); + if ($entry != false) { + $response['continuation'] = $entry->id(); + } } echo json_encode($response), "\n"; exit(); } -function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target) { +function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target, $continuation) { //http://code.google.com/p/google-reader-api/wiki/ApiStreamItemsIds //http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI //http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#feed @@ -572,8 +590,17 @@ function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude break; } + if ($continuation != '') { + $count++; //Shift by one element + } + $entryDAO = FreshRSS_Factory::createEntryDao(); - $ids = $entryDAO->listIdsWhere($type, $id, $state, $order === 'o' ? 'ASC' : 'DESC', $count, '', new FreshRSS_Search(''), $start_time); + $ids = $entryDAO->listIdsWhere($type, $id, $state, $order === 'o' ? 'ASC' : 'DESC', $count, $continuation, new FreshRSS_Search(''), $start_time); + + if ($continuation != '') { + array_shift($ids); //Discard first element that was already sent in the previous response + $count--; + } if (empty($ids)) { //For News+ bug https://github.com/noinnion/newsplus/issues/84#issuecomment-57834632 $ids[] = 0; @@ -585,9 +612,39 @@ function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude ); } - echo json_encode(array( + $response = array( 'itemRefs' => $itemRefs, - )), "\n"; + ); + if (count($ids) >= $count) { + $id = end($ids); + if ($id != false) { + $response['continuation'] = $id; + } + } + + echo json_encode($response), "\n"; + exit(); +} + +function streamContentsItems($e_ids, $order) { + header('Content-Type: application/json; charset=UTF-8'); + + foreach ($e_ids as $i => $e_id) { + $e_ids[$i] = hex2dec(basename($e_id)); //Strip prefix 'tag:google.com,2005:reader/item/' + } + + $entryDAO = FreshRSS_Factory::createEntryDao(); + $entries = $entryDAO->listByIds($e_ids, $order === 'o' ? 'ASC' : 'DESC'); + + $items = entriesToArray($entries); + + $response = array( + 'id' => 'user/-/state/com.google/reading-list', + 'updated' => time(), + 'items' => $items, + ); + + echo json_encode($response), "\n"; exit(); } @@ -726,7 +783,10 @@ if (count($pathInfos) < 3) { * all items in a timestamp range, it will have a continuation attribute. * The same request can be re-issued with the value of that attribute put * in this parameter to get more items */ - $continuation = isset($_GET['c']) ? $_GET['c'] : ''; + $continuation = isset($_GET['c']) ? trim($_GET['c']) : ''; + if (!ctype_digit($continuation)) { + $continuation = ''; + } if (isset($pathInfos[5]) && $pathInfos[5] === 'contents' && isset($pathInfos[6])) { if (isset($pathInfos[7])) { if ($pathInfos[6] === 'feed') { @@ -755,7 +815,10 @@ if (count($pathInfos) < 3) { * be repeated to fetch the item IDs from multiple streams at once * (more efficient from a backend perspective than multiple requests). */ $streamId = $_GET['s']; - streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target); + streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target, $continuation); + } else if ($pathInfos[6] === 'contents' && isset($_POST['i'])) { //FeedMe + $e_ids = multiplePosts('i'); //item IDs + streamContentsItems($e_ids, $order); } } break; @@ -775,16 +838,16 @@ if (count($pathInfos) < 3) { subscriptionList($_GET['output']); break; case 'edit': - if (isset($_POST['s']) && isset($_POST['ac'])) { + if (isset($_REQUEST['s']) && isset($_REQUEST['ac'])) { //StreamId to operate on. The parameter may be repeated to edit multiple subscriptions at once - $streamNames = multiplePosts('s'); + $streamNames = empty($_POST['s']) && isset($_GET['s']) ? array($_GET['s']) : multiplePosts('s'); /* Title to use for the subscription. For the `subscribe` action, * if not specified then the feed's current title will be used. Can * be used with the `edit` action to rename a subscription */ - $titles = multiplePosts('t'); - $action = $_POST['ac']; //Action to perform on the given StreamId. Possible values are `subscribe`, `unsubscribe` and `edit` - $add = isset($_POST['a']) ? $_POST['a'] : ''; //StreamId to add the subscription to (generally a user label) - $remove = isset($_POST['r']) ? $_POST['r'] : ''; //StreamId to remove the subscription from (generally a user label) + $titles = empty($_POST['t']) && isset($_GET['t']) ? array($_GET['t']) : multiplePosts('t'); + $action = $_REQUEST['ac']; //Action to perform on the given StreamId. Possible values are `subscribe`, `unsubscribe` and `edit` + $add = isset($_REQUEST['a']) ? $_REQUEST['a'] : ''; //StreamId to add the subscription to (generally a user label) + $remove = isset($_REQUEST['r']) ? $_REQUEST['r'] : ''; //StreamId to remove the subscription from (generally a user label) subscriptionEdit($streamNames, $titles, $action, $add, $remove); } break; -- cgit v1.2.3 From 0936a6cdb2005e325d3be98e42897eb7a42541c7 Mon Sep 17 00:00:00 2001 From: Matt DeMoss Date: Mon, 19 Feb 2018 09:36:18 -0500 Subject: Option to hide nav_entries (#1764) * put nav_entries in a div so they can be hidden, add config option, no labels yet * add English text for hide_nav_entries, choose better name * Update conf.php add comma to last item * hide nav_entries by optionally not rendering in normal.phtml * fix logic, remove containing div * apply phpcbf to ConfigurationSetter.php * Make navigation buttons options positive And add TODOs for i18n, and add default config. --- app/Controllers/configureController.php | 1 + app/Models/ConfigurationSetter.php | 4 ++++ app/i18n/cz/conf.php | 1 + app/i18n/de/conf.php | 1 + app/i18n/en/conf.php | 1 + app/i18n/es/conf.php | 1 + app/i18n/fr/conf.php | 1 + app/i18n/he/conf.php | 1 + app/i18n/it/conf.php | 1 + app/i18n/kr/conf.php | 1 + app/i18n/nl/conf.php | 1 + app/i18n/pt-br/conf.php | 1 + app/i18n/ru/conf.php | 1 + app/i18n/tr/conf.php | 1 + app/i18n/zh-cn/conf.php | 1 + app/views/configure/display.phtml | 11 ++++++++++- app/views/index/normal.phtml | 2 +- config-user.default.php | 1 + 18 files changed, 30 insertions(+), 2 deletions(-) (limited to 'app/Models') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 2c7739c55..d34b5d59d 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -55,6 +55,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { FreshRSS_Context::$user_conf->bottomline_date = Minz_Request::param('bottomline_date', false); FreshRSS_Context::$user_conf->bottomline_link = Minz_Request::param('bottomline_link', false); FreshRSS_Context::$user_conf->html5_notif_timeout = Minz_Request::param('html5_notif_timeout', 0); + FreshRSS_Context::$user_conf->show_nav_buttons = Minz_Request::param('show_nav_buttons', false); FreshRSS_Context::$user_conf->save(); Minz_Session::_param('language', FreshRSS_Context::$user_conf->language); diff --git a/app/Models/ConfigurationSetter.php b/app/Models/ConfigurationSetter.php index 645ef644e..ad703dfc5 100644 --- a/app/Models/ConfigurationSetter.php +++ b/app/Models/ConfigurationSetter.php @@ -184,6 +184,10 @@ class FreshRSS_ConfigurationSetter { $data['mark_updated_article_unread'] = $this->handleBool($value); } + private function _show_nav_buttons(&$data, $value) { + $data['show_nav_buttons'] = $this->handleBool($value); + } + private function _display_categories(&$data, $value) { $data['display_categories'] = $this->handleBool($value); } diff --git a/app/i18n/cz/conf.php b/app/i18n/cz/conf.php index 8193b9575..649724e80 100644 --- a/app/i18n/cz/conf.php +++ b/app/i18n/cz/conf.php @@ -37,6 +37,7 @@ return array( 'no_limit' => 'Bez limitu', 'thin' => 'Tenká', ), + 'show_nav_buttons' => 'Show the navigation buttons', //TODO ), 'query' => array( '_' => 'Uživatelské dotazy', diff --git a/app/i18n/de/conf.php b/app/i18n/de/conf.php index 86c738dd1..9f1edffb9 100644 --- a/app/i18n/de/conf.php +++ b/app/i18n/de/conf.php @@ -37,6 +37,7 @@ return array( 'no_limit' => 'Keine Begrenzung', 'thin' => 'Klein', ), + 'show_nav_buttons' => 'Show the navigation buttons', //TODO ), 'query' => array( '_' => 'Benutzerabfragen', diff --git a/app/i18n/en/conf.php b/app/i18n/en/conf.php index 5e3b723fe..60231b825 100644 --- a/app/i18n/en/conf.php +++ b/app/i18n/en/conf.php @@ -37,6 +37,7 @@ return array( 'no_limit' => 'No limit', 'thin' => 'Thin', ), + 'show_nav_buttons' => 'Show the navigation buttons', ), 'query' => array( '_' => 'User queries', diff --git a/app/i18n/es/conf.php b/app/i18n/es/conf.php index 2d9a476cb..65858fefe 100755 --- a/app/i18n/es/conf.php +++ b/app/i18n/es/conf.php @@ -37,6 +37,7 @@ return array( 'no_limit' => 'Sin límite', 'thin' => 'Estrecho', ), + 'show_nav_buttons' => 'Show the navigation buttons', //TODO ), 'query' => array( '_' => 'Consultas de usuario', diff --git a/app/i18n/fr/conf.php b/app/i18n/fr/conf.php index b126a77c9..b4c39e1ca 100644 --- a/app/i18n/fr/conf.php +++ b/app/i18n/fr/conf.php @@ -37,6 +37,7 @@ return array( 'no_limit' => 'Pas de limite', 'thin' => 'Fine', ), + 'show_nav_buttons' => 'Afficher les boutons de navigation', ), 'query' => array( '_' => 'Filtres utilisateurs', diff --git a/app/i18n/he/conf.php b/app/i18n/he/conf.php index 0dd277d78..50d1936a8 100644 --- a/app/i18n/he/conf.php +++ b/app/i18n/he/conf.php @@ -37,6 +37,7 @@ return array( 'no_limit' => 'ללא הגבלה', 'thin' => 'צר', ), + 'show_nav_buttons' => 'Show the navigation buttons', //TODO ), 'query' => array( '_' => 'שאילתות', diff --git a/app/i18n/it/conf.php b/app/i18n/it/conf.php index 25cfbb7bf..9e20236f1 100644 --- a/app/i18n/it/conf.php +++ b/app/i18n/it/conf.php @@ -37,6 +37,7 @@ return array( 'no_limit' => 'Nessun limite', 'thin' => 'Stretto', ), + 'show_nav_buttons' => 'Show the navigation buttons', //TODO ), 'query' => array( '_' => 'Ricerche personali', diff --git a/app/i18n/kr/conf.php b/app/i18n/kr/conf.php index dbd902062..31b042f57 100644 --- a/app/i18n/kr/conf.php +++ b/app/i18n/kr/conf.php @@ -37,6 +37,7 @@ return array( 'no_limit' => '제한 없음', 'thin' => '얇음', ), + 'show_nav_buttons' => 'Show the navigation buttons', //TODO ), 'query' => array( '_' => '사용자 쿼리', diff --git a/app/i18n/nl/conf.php b/app/i18n/nl/conf.php index 0d1d9b70d..360e1c5e7 100644 --- a/app/i18n/nl/conf.php +++ b/app/i18n/nl/conf.php @@ -37,6 +37,7 @@ return array( 'no_limit' => 'Geen limiet', 'thin' => 'Smal', ), + 'show_nav_buttons' => 'Show the navigation buttons', //TODO ), 'query' => array( '_' => 'Gebruikers queries (informatie aanvragen)', diff --git a/app/i18n/pt-br/conf.php b/app/i18n/pt-br/conf.php index a5a0a9197..71b6afb20 100644 --- a/app/i18n/pt-br/conf.php +++ b/app/i18n/pt-br/conf.php @@ -37,6 +37,7 @@ return array( 'no_limit' => 'Sem lmite', 'thin' => 'Fino', ), + 'show_nav_buttons' => 'Show the navigation buttons', //TODO ), 'query' => array( '_' => 'Queries do usuário', diff --git a/app/i18n/ru/conf.php b/app/i18n/ru/conf.php index 0265ede9c..15109dd15 100644 --- a/app/i18n/ru/conf.php +++ b/app/i18n/ru/conf.php @@ -37,6 +37,7 @@ return array( 'no_limit' => 'No limit', 'thin' => 'Thin', ), + 'show_nav_buttons' => 'Show the navigation buttons', //TODO ), 'query' => array( '_' => 'User queries', diff --git a/app/i18n/tr/conf.php b/app/i18n/tr/conf.php index 424c030c5..596adaf9a 100644 --- a/app/i18n/tr/conf.php +++ b/app/i18n/tr/conf.php @@ -37,6 +37,7 @@ return array( 'no_limit' => 'Sınırsız', 'thin' => 'Zayıf', ), + 'show_nav_buttons' => 'Show the navigation buttons', //TODO ), 'query' => array( '_' => 'Kullanıcı sorguları', diff --git a/app/i18n/zh-cn/conf.php b/app/i18n/zh-cn/conf.php index 599f42234..2e068be42 100644 --- a/app/i18n/zh-cn/conf.php +++ b/app/i18n/zh-cn/conf.php @@ -37,6 +37,7 @@ return array( 'no_limit' => '无限制', 'thin' => '小', ), + 'show_nav_buttons' => 'Show the navigation buttons', //TODO ), 'query' => array( '_' => '自定义查询', diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index 62ecc1080..414fd2cd6 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -106,7 +106,7 @@
    - +
    @@ -114,6 +114,15 @@
    +
    +
    + +
    +
    +
    diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index ba48b2501..c7cab2d3f 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -83,7 +83,7 @@ if (!empty($this->entries)) { $this->renderHelper('pagination'); ?>
    -partial('nav_entries'); ?> +show_nav_buttons) $this->partial('nav_entries'); ?>
    diff --git a/config-user.default.php b/config-user.default.php index 2e4a96239..5e67d8d9b 100644 --- a/config-user.default.php +++ b/config-user.default.php @@ -76,5 +76,6 @@ return array ( 'queries' => array ( ), 'html5_notif_timeout' => 0, + 'show_nav_buttons' => true, 'extensions_enabled' => array(), ); -- cgit v1.2.3