Преглед изворни кода

Add a new configuration option

Before, when you selected the option to display only unread articles, it shows read articles if no unread article were found.
Now, this option is renamed to include information on fallback behavior and a new option is created to have the "only unread" behavior

See #551

It is missing the german translation
Alexis Degrugillier пре 11 година
родитељ
комит
83832a39c4
6 измењених фајлова са 32 додато и 9 уклоњено
  1. 12 1
      app/Models/Configuration.php
  2. 2 0
      app/Models/Entry.php
  3. 3 0
      app/Models/EntryDAO.php
  4. 2 0
      app/i18n/en.php
  5. 2 0
      app/i18n/fr.php
  6. 11 8
      app/views/configure/reading.phtml

+ 12 - 1
app/Models/Configuration.php

@@ -141,7 +141,18 @@ class FreshRSS_Configuration {
 		}
 		}
 	}
 	}
 	public function _default_view ($value) {
 	public function _default_view ($value) {
-		$this->data['default_view'] = $value === FreshRSS_Entry::STATE_ALL ? FreshRSS_Entry::STATE_ALL : FreshRSS_Entry::STATE_NOT_READ;
+		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_NOT_READ_STRICT:
+				$this->data['default_view'] = $value;
+				break;
+			default:
+				$this->data['default_view'] = FreshRSS_Entry::STATE_ALL;
+				break;
+		endswitch;
 	}
 	}
 	public function _display_posts ($value) {
 	public function _display_posts ($value) {
 		$this->data['display_posts'] = ((bool)$value) && $value !== 'no';
 		$this->data['display_posts'] = ((bool)$value) && $value !== 'no';

+ 2 - 0
app/Models/Entry.php

@@ -6,6 +6,8 @@ class FreshRSS_Entry extends Minz_Model {
 	const STATE_NOT_READ = 2;
 	const STATE_NOT_READ = 2;
 	const STATE_FAVORITE = 4;
 	const STATE_FAVORITE = 4;
 	const STATE_NOT_FAVORITE = 8;
 	const STATE_NOT_FAVORITE = 8;
+	const STATE_READ_STRICT = 16;
+	const STATE_NOT_READ_STRICT = 32;
 
 
 	private $id = 0;
 	private $id = 0;
 	private $guid;
 	private $guid;

+ 3 - 0
app/Models/EntryDAO.php

@@ -338,6 +338,9 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 		elseif ($state & FreshRSS_Entry::STATE_READ) {
 		elseif ($state & FreshRSS_Entry::STATE_READ) {
 			$where .= 'AND e1.is_read=1 ';
 			$where .= 'AND e1.is_read=1 ';
 		}
 		}
+		elseif ($state & FreshRSS_Entry::STATE_NOT_READ_STRICT) {
+			$where .= 'AND e1.is_read=0 ';
+		}
 		if ($state & FreshRSS_Entry::STATE_FAVORITE) {
 		if ($state & FreshRSS_Entry::STATE_FAVORITE) {
 			if (!($state & FreshRSS_Entry::STATE_NOT_FAVORITE)) {
 			if (!($state & FreshRSS_Entry::STATE_NOT_FAVORITE)) {
 				$where .= 'AND e1.is_favorite=1 ';
 				$where .= 'AND e1.is_favorite=1 ';

+ 2 - 0
app/i18n/en.php

@@ -92,6 +92,7 @@ return array (
 	'rss_view'			=> 'RSS feed',
 	'rss_view'			=> 'RSS feed',
 	'show_all_articles'		=> 'Show all articles',
 	'show_all_articles'		=> 'Show all articles',
 	'show_not_reads'		=> 'Show only unread',
 	'show_not_reads'		=> 'Show only unread',
+	'show_not_reads_with_fallback'	=> 'Show only unread or read if no unread',
 	'show_read'			=> 'Show only read',
 	'show_read'			=> 'Show only read',
 	'show_favorite'			=> 'Show only favorites',
 	'show_favorite'			=> 'Show only favorites',
 	'show_not_favorite'		=> 'Show all but favorites',
 	'show_not_favorite'		=> 'Show all but favorites',
@@ -267,6 +268,7 @@ return array (
 	'display_configuration'		=> 'Display',
 	'display_configuration'		=> 'Display',
 	'articles_per_page'		=> 'Number of articles per page',
 	'articles_per_page'		=> 'Number of articles per page',
 	'default_view'			=> 'Default view',
 	'default_view'			=> 'Default view',
+	'articles_to_display'		=> 'Articles to display',
 	'sort_order'			=> 'Sort order',
 	'sort_order'			=> 'Sort order',
 	'auto_load_more'		=> 'Load next articles at the page bottom',
 	'auto_load_more'		=> 'Load next articles at the page bottom',
 	'display_articles_unfolded'	=> 'Show articles unfolded by default',
 	'display_articles_unfolded'	=> 'Show articles unfolded by default',

+ 2 - 0
app/i18n/fr.php

@@ -92,6 +92,7 @@ return array (
 	'rss_view'			=> 'Flux RSS',
 	'rss_view'			=> 'Flux RSS',
 	'show_all_articles'		=> 'Afficher tous les articles',
 	'show_all_articles'		=> 'Afficher tous les articles',
 	'show_not_reads'		=> 'Afficher les non lus',
 	'show_not_reads'		=> 'Afficher les non lus',
+	'show_not_reads_with_fallback'	=> 'Afficher les non lus ou les lus si aucun non lus',
 	'show_read'			=> 'Afficher les lus',
 	'show_read'			=> 'Afficher les lus',
 	'show_favorite'			=> 'Afficher les favoris',
 	'show_favorite'			=> 'Afficher les favoris',
 	'show_not_favorite'		=> 'Afficher tout sauf les favoris',
 	'show_not_favorite'		=> 'Afficher tout sauf les favoris',
@@ -267,6 +268,7 @@ return array (
 	'display_configuration'		=> 'Affichage',
 	'display_configuration'		=> 'Affichage',
 	'articles_per_page'		=> 'Nombre d’articles par page',
 	'articles_per_page'		=> 'Nombre d’articles par page',
 	'default_view'			=> 'Vue par défaut',
 	'default_view'			=> 'Vue par défaut',
+	'articles_to_display'		=> 'Articles à afficher',
 	'sort_order'			=> 'Ordre de tri',
 	'sort_order'			=> 'Ordre de tri',
 	'auto_load_more'		=> 'Charger les articles suivants en bas de page',
 	'auto_load_more'		=> 'Charger les articles suivants en bas de page',
 	'display_articles_unfolded'	=> 'Afficher les articles dépliés par défaut',
 	'display_articles_unfolded'	=> 'Afficher les articles dépliés par défaut',

+ 11 - 8
app/views/configure/reading.phtml

@@ -31,14 +31,17 @@
 					<option value="reader"<?php echo $this->conf->view_mode === 'reader' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('reader_view'); ?></option>
 					<option value="reader"<?php echo $this->conf->view_mode === 'reader' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('reader_view'); ?></option>
 					<option value="global"<?php echo $this->conf->view_mode === 'global' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('global_view'); ?></option>
 					<option value="global"<?php echo $this->conf->view_mode === 'global' ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('global_view'); ?></option>
 				</select>
 				</select>
-				<label class="radio" for="radio_all">
-					<input type="radio" name="default_view" id="radio_all" value="<?php echo FreshRSS_Entry::STATE_ALL; ?>"<?php echo $this->conf->default_view === FreshRSS_Entry::STATE_ALL ? ' checked="checked"' : ''; ?> />
-					<?php echo Minz_Translate::t ('show_all_articles'); ?>
-				</label>
-				<label class="radio" for="radio_not_read">
-					<input type="radio" name="default_view" id="radio_not_read" value="<?php echo FreshRSS_Entry::STATE_NOT_READ; ?>"<?php echo $this->conf->default_view === FreshRSS_Entry::STATE_NOT_READ ? ' checked="checked"' : ''; ?> />
-					<?php echo Minz_Translate::t ('show_not_reads'); ?>
-				</label>
+			</div>
+		</div>
+
+		<div class="form-group">
+			<label class="group-name" for="view_mode"><?php echo Minz_Translate::t ('articles_to_display'); ?></label>
+			<div class="group-controls">
+				<select name="default_view" id="default_view">
+					<option value="<?php echo FreshRSS_Entry::STATE_ALL; ?>"<?php echo $this->conf->default_view === FreshRSS_Entry::STATE_ALL ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('show_all_articles'); ?></option>
+					<option value="<?php echo FreshRSS_Entry::STATE_NOT_READ; ?>"<?php echo $this->conf->default_view === FreshRSS_Entry::STATE_NOT_READ ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('show_not_reads_with_fallback'); ?></option>
+					<option value="<?php echo FreshRSS_Entry::STATE_NOT_READ_STRICT; ?>"<?php echo $this->conf->default_view === FreshRSS_Entry::STATE_NOT_READ_STRICT ? ' selected="selected"' : ''; ?>><?php echo Minz_Translate::t ('show_not_reads'); ?></option>
+				</select>
 			</div>
 			</div>
 		</div>
 		</div>