summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-22 18:21:36 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-22 18:21:36 +0200
commit9551145200b61717fdeb11007e1da541ddf93f0f (patch)
treef5d09af281d20e7df05a08193bcb959ef6b17369
parenteb60b82959d768b199985523e7d4e05ba4055591 (diff)
Better view mode
- Seperate view mode from default state in conf - Load read articles if no unread articles only if view is adaptive See https://github.com/marienfressinaud/FreshRSS/issues/634
-rwxr-xr-xapp/Controllers/configureController.php2
-rwxr-xr-xapp/Controllers/indexController.php6
-rw-r--r--app/Models/Configuration.php21
-rw-r--r--app/views/configure/reading.phtml6
4 files changed, 20 insertions, 15 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index 8a9dcdc62..9a7870000 100755
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -104,7 +104,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
if (Minz_Request::isPost()) {
FreshRSS_Context::$conf->_posts_per_page(Minz_Request::param('posts_per_page', 10));
FreshRSS_Context::$conf->_view_mode(Minz_Request::param('view_mode', 'normal'));
- FreshRSS_Context::$conf->_default_view((int)Minz_Request::param('default_view', FreshRSS_Entry::STATE_ALL));
+ FreshRSS_Context::$conf->_default_view(Minz_Request::param('default_view', 'adaptive'));
FreshRSS_Context::$conf->_auto_load_more(Minz_Request::param('auto_load_more', false));
FreshRSS_Context::$conf->_display_posts(Minz_Request::param('display_posts', false));
FreshRSS_Context::$conf->_display_categories(Minz_Request::param('display_categories', false));
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index f9af2d0bb..2dd4c3068 100755
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -126,13 +126,13 @@ class FreshRSS_index_Controller extends Minz_ActionController {
private function updateContext() {
FreshRSS_Context::_get(Minz_Request::param('get', 'a'));
- // TODO: change default_view by default_state.
FreshRSS_Context::$state = Minz_Request::param(
- 'state', FreshRSS_Context::$conf->default_view
+ 'state', FreshRSS_Context::$conf->default_state
);
$state_forced_by_user = Minz_Request::param('state', false) !== false;
- if (FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) &&
+ if (FreshRSS_Context::$conf->default_view === 'adaptive' &&
FreshRSS_Context::$get_unread <= 0 &&
+ !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ) &&
!$state_forced_by_user) {
FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ;
}
diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php
index 2f208e509..53f136513 100644
--- a/app/Models/Configuration.php
+++ b/app/Models/Configuration.php
@@ -14,7 +14,8 @@ class FreshRSS_Configuration {
'apiPasswordHash' => '', //CRYPT_BLOWFISH
'posts_per_page' => 20,
'view_mode' => 'normal',
- 'default_view' => FreshRSS_Entry::STATE_NOT_READ,
+ 'default_view' => 'adaptive',
+ 'default_state' => FreshRSS_Entry::STATE_NOT_READ,
'auto_load_more' => true,
'display_posts' => false,
'display_categories' => false,
@@ -153,18 +154,22 @@ class FreshRSS_Configuration {
}
public function _default_view($value) {
switch ($value) {
- case FreshRSS_Entry::STATE_ALL:
- // left blank on purpose
- case FreshRSS_Entry::STATE_NOT_READ:
- // left blank on purpose
- case FreshRSS_Entry::STATE_STRICT + FreshRSS_Entry::STATE_NOT_READ:
+ case 'all':
$this->data['default_view'] = $value;
+ $this->data['default_state'] = (FreshRSS_Entry::STATE_READ +
+ FreshRSS_Entry::STATE_NOT_READ);
break;
+ case 'adaptive':
+ case 'unread':
default:
- $this->data['default_view'] = FreshRSS_Entry::STATE_ALL;
- break;
+ $this->data['default_view'] = $value;
+ $this->data['default_state'] = FreshRSS_Entry::STATE_NOT_READ;
}
}
+ public function _default_state($value) {
+ $this->data['default_state'] = (int)$value;
+ }
+
public function _display_posts($value) {
$this->data['display_posts'] = ((bool)$value) && $value !== 'no';
}
diff --git a/app/views/configure/reading.phtml b/app/views/configure/reading.phtml
index ef775b4b1..b8f673466 100644
--- a/app/views/configure/reading.phtml
+++ b/app/views/configure/reading.phtml
@@ -39,9 +39,9 @@
<label class="group-name" for="view_mode"><?php echo _t('articles_to_display'); ?></label>
<div class="group-controls">
<select name="default_view" id="default_view">
- <option value="<?php echo FreshRSS_Entry::STATE_NOT_READ; ?>"<?php echo FreshRSS_Context::$conf->default_view === FreshRSS_Entry::STATE_NOT_READ ? ' selected="selected"' : ''; ?>><?php echo _t('show_adaptive'); ?></option>
- <option value="<?php echo FreshRSS_Entry::STATE_ALL; ?>"<?php echo FreshRSS_Context::$conf->default_view === FreshRSS_Entry::STATE_ALL ? ' selected="selected"' : ''; ?>><?php echo _t('show_all_articles'); ?></option>
- <option value="<?php echo FreshRSS_Entry::STATE_STRICT + FreshRSS_Entry::STATE_NOT_READ; ?>"<?php echo FreshRSS_Context::$conf->default_view === FreshRSS_Entry::STATE_STRICT + FreshRSS_Entry::STATE_NOT_READ ? ' selected="selected"' : ''; ?>><?php echo _t('show_not_reads'); ?></option>
+ <option value="adaptive"<?php echo FreshRSS_Context::$conf->default_view === 'adaptive' ? ' selected="selected"' : ''; ?>><?php echo _t('show_adaptive'); ?></option>
+ <option value="all"<?php echo FreshRSS_Context::$conf->default_view === 'all' ? ' selected="selected"' : ''; ?>><?php echo _t('show_all_articles'); ?></option>
+ <option value="unread"<?php echo FreshRSS_Context::$conf->default_view === 'unread' ? ' selected="selected"' : ''; ?>><?php echo _t('show_not_reads'); ?></option>
</select>
</div>
</div>