aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-04-15 10:10:29 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-04-15 10:10:29 +0200
commit339a12698c07eb466c6a1ab8ffa856d8a8e1f506 (patch)
treed599dd61687b5b4ccd5aa07ae5c500533dc4bcef /app/Models
parent951a137f2d05594dd0b61b9d86567cf4e9a12f5a (diff)
parentbdd7b7b13e6fdcdb9110cbee3618bf2b5fc89b71 (diff)
Merge pull request #486 from aledeg/simple-layout
New toggle buttons to filter articles (was: Delete favorite button)
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/Configuration.php4
-rw-r--r--app/Models/Entry.php5
-rw-r--r--app/Models/EntryDAO.php39
-rw-r--r--app/Models/Themes.php1
4 files changed, 33 insertions, 16 deletions
diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php
index 80031369e..4b52fa05b 100644
--- a/app/Models/Configuration.php
+++ b/app/Models/Configuration.php
@@ -13,7 +13,7 @@ class FreshRSS_Configuration {
'apiPasswordHash' => '', //CRYPT_BLOWFISH
'posts_per_page' => 20,
'view_mode' => 'normal',
- 'default_view' => 'not_read',
+ 'default_view' => FreshRSS_Entry::STATE_NOT_READ,
'auto_load_more' => true,
'display_posts' => false,
'onread_jump_next' => true,
@@ -131,7 +131,7 @@ class FreshRSS_Configuration {
}
}
public function _default_view ($value) {
- $this->data['default_view'] = $value === 'all' ? 'all' : 'not_read';
+ $this->data['default_view'] = $value === FreshRSS_Entry::STATE_ALL ? FreshRSS_Entry::STATE_ALL : FreshRSS_Entry::STATE_NOT_READ;
}
public function _display_posts ($value) {
$this->data['display_posts'] = ((bool)$value) && $value !== 'no';
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index a6c67221b..fa9066d5b 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -1,6 +1,11 @@
<?php
class FreshRSS_Entry extends Minz_Model {
+ const STATE_ALL = 0;
+ const STATE_READ = 1;
+ const STATE_NOT_READ = 2;
+ const STATE_FAVORITE = 4;
+ const STATE_NOT_FAVORITE = 8;
private $id = 0;
private $guid;
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index 6d00967fc..285ad431f 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -406,7 +406,10 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
return isset ($entries[0]) ? $entries[0] : null;
}
- private function sqlListWhere($type = 'a', $id = '', $state = 'all', $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) {
+ private function sqlListWhere($type = 'a', $id = '', $state = null , $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) {
+ if (!$state) {
+ $state = FreshRSS_Entry::STATE_ALL;
+ }
$where = '';
$joinFeed = false;
$values = array();
@@ -416,6 +419,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
$joinFeed = true;
break;
case 's':
+ // This is deprecated. The favorite button does not exist anymore
$where .= 'e1.is_favorite = 1 ';
break;
case 'c':
@@ -433,21 +437,28 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
default:
throw new FreshRSS_EntriesGetter_Exception ('Bad type in Entry->listByType: [' . $type . ']!');
}
- switch ($state) {
- case 'all':
- break;
- case 'not_read':
+
+ if ($state & FreshRSS_Entry::STATE_NOT_READ) {
+ if (!($state & FreshRSS_Entry::STATE_READ)) {
$where .= 'AND e1.is_read = 0 ';
- break;
- case 'read':
+ }
+ }
+ if ($state & FreshRSS_Entry::STATE_READ) {
+ if (!($state & FreshRSS_Entry::STATE_NOT_READ)) {
$where .= 'AND e1.is_read = 1 ';
- break;
- case 'favorite':
+ }
+ }
+ if ($state & FreshRSS_Entry::STATE_NOT_FAVORITE) {
+ if (!($state & FreshRSS_Entry::STATE_FAVORITE)) {
+ $where .= 'AND e1.is_favorite = 0 ';
+ }
+ }
+ if ($state & FreshRSS_Entry::STATE_FAVORITE) {
+ if (!($state & FreshRSS_Entry::STATE_NOT_FAVORITE)) {
$where .= 'AND e1.is_favorite = 1 ';
- break;
- default:
- throw new FreshRSS_EntriesGetter_Exception ('Bad state in Entry->listByType: [' . $state . ']!');
+ }
}
+
switch ($order) {
case 'DESC':
case 'ASC':
@@ -528,7 +539,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
. ($limit > 0 ? ' LIMIT ' . $limit : '')); //TODO: See http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/
}
- public function listWhere($type = 'a', $id = '', $state = 'all', $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) {
+ public function listWhere($type = 'a', $id = '', $state = null, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) {
list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min, $showOlderUnreadsorFavorites, $keepHistoryDefault);
$sql = 'SELECT e.id, e.guid, e.title, e.author, UNCOMPRESS(e.content_bin) AS content, e.link, e.date, e.is_read, e.is_favorite, e.id_feed, e.tags '
@@ -544,7 +555,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
return self::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC));
}
- public function listIdsWhere($type = 'a', $id = '', $state = 'all', $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) { //For API
+ public function listIdsWhere($type = 'a', $id = '', $state = null, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) { //For API
list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min, $showOlderUnreadsorFavorites, $keepHistoryDefault);
$stm = $this->bd->prepare($sql);
diff --git a/app/Models/Themes.php b/app/Models/Themes.php
index ed746b7e9..17b95bb9e 100644
--- a/app/Models/Themes.php
+++ b/app/Models/Themes.php
@@ -85,6 +85,7 @@ class FreshRSS_Themes extends Minz_Model {
'non-starred' => '☆',
'prev' => '⏪',
'read' => '☑',
+ 'rss' => '☄',
'unread' => '☐',
'refresh' => '🔃', //↻
'search' => '🔍',