Add a new status for 'ALL'

I made the conversion in every file I can think of.
It should not have any reference to the string 'all' for the state context
This commit is contained in:
Alexis Degrugillier
2014-04-13 07:28:41 -04:00
parent d25afa9def
commit 86066b1659
6 changed files with 19 additions and 15 deletions

View File

@@ -370,7 +370,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
$this->view->type = 'starred';
$unread_fav = $this->entryDAO->countUnreadReadFavorites();
$this->view->entries = $this->entryDAO->listWhere(
's', '', 'all', 'ASC',
's', '', FreshRSS_Configuration::STATE_ALL, 'ASC',
$unread_fav['all']
);
} elseif ($type == 'feed' && !is_null($feed)) {
@@ -379,7 +379,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
);
$this->view->type = 'feed/' . $feed->id();
$this->view->entries = $this->entryDAO->listWhere(
'f', $feed->id(), 'all', 'ASC',
'f', $feed->id(), FreshRSS_Configuration::STATE_ALL, 'ASC',
$this->view->conf->posts_per_page
);
$this->view->feed = $feed;

View File

@@ -85,7 +85,7 @@ class FreshRSS_index_Controller extends Minz_ActionController {
$state_param = Minz_Request::param ('state', null);
$filter = Minz_Request::param ('search', '');
if (!empty($filter)) {
$state = 'all'; //Search always in read and unread articles
$state = FreshRSS_Configuration::STATE_ALL; //Search always in read and unread articles
}
$this->view->order = $order = Minz_Request::param ('order', $this->view->conf->sort_order);
$nb = Minz_Request::param ('nb', $this->view->conf->posts_per_page);
@@ -108,7 +108,7 @@ class FreshRSS_index_Controller extends Minz_ActionController {
break;
}
if (!$hasUnread && ($state_param === null)) {
$this->view->state = $state = 'all';
$this->view->state = $state = FreshRSS_Configuration::STATE_ALL;
}
}
@@ -127,8 +127,8 @@ class FreshRSS_index_Controller extends Minz_ActionController {
// on essaye de récupérer tous les articles
if ($state === FreshRSS_Configuration::STATE_NOT_READ && empty($entries) && ($state_param === null)) {
Minz_Log::record ('Conflicting information about nbNotRead!', Minz_Log::DEBUG);
$this->view->state = 'all';
$entries = $entryDAO->listWhere($getType, $getId, 'all', $order, $nb, $first, $filter, $date_min, true, $keepHistoryDefault);
$this->view->state = FreshRSS_Configuration::STATE_ALL;
$entries = $entryDAO->listWhere($getType, $getId, $this->view->state, $order, $nb, $first, $filter, $date_min, true, $keepHistoryDefault);
}
if (count($entries) <= $nb) {

View File

@@ -1,6 +1,7 @@
<?php
class FreshRSS_Configuration {
const STATE_ALL = 0;
const STATE_READ = 1;
const STATE_NOT_READ = 2;
const STATE_FAVORITE = 4;
@@ -136,7 +137,7 @@ class FreshRSS_Configuration {
}
}
public function _default_view ($value) {
$this->data['default_view'] = $value === 'all' ? 'all' : self::STATE_NOT_READ;
$this->data['default_view'] = $value === self::STATE_ALL ? self::STATE_ALL : self::STATE_NOT_READ;
}
public function _display_posts ($value) {
$this->data['display_posts'] = ((bool)$value) && $value !== 'no';

View File

@@ -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_Configuration::STATE_ALL;
}
$where = '';
$joinFeed = false;
$values = array();
@@ -532,7 +535,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 '
@@ -548,7 +551,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);

View File

@@ -32,7 +32,7 @@
<option value="global"<?php echo $this->conf->view_mode === 'global' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('global_view'); ?></option>
</select>
<label class="radio" for="radio_all">
<input type="radio" name="default_view" id="radio_all" value="all"<?php echo $this->conf->default_view === 'all' ? ' checked="checked"' : ''; ?> />
<input type="radio" name="default_view" id="radio_all" value="<?php echo FreshRSS_Configuration::STATE_ALL; ?>"<?php echo $this->conf->default_view === FreshRSS_Configuration::STATE_ALL ? ' checked="checked"' : ''; ?> />
<?php echo Minz_Translate::t ('show_all_articles'); ?>
</label>
<label class="radio" for="radio_not_read">

View File

@@ -353,10 +353,10 @@ function streamContents($path, $include_target, $start_time, $count, $order, $ex
switch ($exclude_target) {
case 'user/-/state/com.google/read':
$state = 'not_read';
$state = FreshRSS_Configuration::STATE_NOT_READ;
break;
default:
$state = 'all';
$state = FreshRSS_Configuration::STATE_ALL;
break;
}
@@ -451,10 +451,10 @@ function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude
switch ($exclude_target) {
case 'user/-/state/com.google/read':
$state = 'not_read';
$state = FreshRSS_Configuration::STATE_NOT_READ;
break;
default:
$state = 'all';
$state = FreshRSS_Configuration::STATE_ALL;
break;
}