소스 검색

"Show all" option on labels (#3472)

It uses the favorite option to keep a similar experience through out the application and also to limit the number of options.

See #3263
Alexis Degrugillier 5 년 전
부모
커밋
449fee7a2c

+ 2 - 1
app/Models/Context.php

@@ -292,9 +292,10 @@ class FreshRSS_Context {
 			self::$get_unread = $tag->nbUnread();
 			break;
 		case 'T':
+			$tagDAO = FreshRSS_Factory::createTagDao();
 			self::$current_get['tags'] = true;
 			self::$name = _t('index.menu.tags');
-			self::$get_unread = 0;
+			self::$get_unread = $tagDAO->countNotRead();
 			break;
 		default:
 			throw new FreshRSS_Context_Exception('Invalid getter: ' . $get);

+ 10 - 3
app/Models/TagDAO.php

@@ -259,12 +259,19 @@ class FreshRSS_TagDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
 		return $res[0]['count'];
 	}
 
-	public function countNotRead($id) {
+	public function countNotRead($id = null) {
 		$sql = 'SELECT COUNT(*) AS count FROM `_entrytag` et '
 			 . 'INNER JOIN `_entry` e ON et.id_entry=e.id '
-			 . 'WHERE et.id_tag=? AND e.is_read=0';
+			 . 'WHERE e.is_read=0';
+		$values = null;
+
+		if (null !== $id) {
+			$sql .= ' AND et.id_tag=?';
+			$values = [$id];
+		}
+
 		$stm = $this->pdo->prepare($sql);
-		$values = array($id);
+
 		$stm->execute($values);
 		$res = $stm->fetchAll(PDO::FETCH_ASSOC);
 		return $res[0]['count'];

+ 1 - 0
app/i18n/cz/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Remember open categories',	// TODO - Translation
 			'unread' => 'Zobrazit jen nepřečtené',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => 'Clicking outside of article text area closes the article',	// TODO - Translation
 		'sort' => array(
 			'_' => 'Řazení',

+ 1 - 0
app/i18n/de/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Geöffnete Kategorien merken',
 			'unread' => 'Nur ungelesene zeigen',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => 'Klick außerhalb des Artikel-Textes schließt den Artikel',
 		'sort' => array(
 			'_' => 'Sortierreihenfolge',

+ 1 - 0
app/i18n/en-us/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Remember open categories',
 			'unread' => 'Show only unread',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',
 		'sides_close_article' => 'Clicking outside of article text area closes the article',
 		'sort' => array(
 			'_' => 'Sort order',

+ 1 - 0
app/i18n/en/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Remember open categories',
 			'unread' => 'Show only unread',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',
 		'sides_close_article' => 'Clicking outside of article text area closes the article',
 		'sort' => array(
 			'_' => 'Sort order',

+ 1 - 0
app/i18n/es/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Remember open categories',	// TODO - Translation
 			'unread' => 'Mostrar solo pendientes',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => 'Pinchar fuera del área de texto del artículo lo cerrará',
 		'sort' => array(
 			'_' => 'Orden',

+ 1 - 0
app/i18n/fr/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Se souvenir des catégories dépliées',
 			'unread' => 'Afficher les non lus',
 		),
+		'show_fav_unread_help' => 'S’applique aussi aux étiquettes',
 		'sides_close_article' => 'Cliquer hors de la zone de texte ferme l’article',
 		'sort' => array(
 			'_' => 'Ordre de tri',

+ 1 - 0
app/i18n/he/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Remember open categories',	// TODO - Translation
 			'unread' => 'הצגת מאמרים שלא נקראו בלבד',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => 'Clicking outside of article text area closes the article',	// TODO - Translation
 		'sort' => array(
 			'_' => 'סדר המיון',

+ 1 - 0
app/i18n/it/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Remember open categories',	// TODO - Translation
 			'unread' => 'Mostra solo non letti',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => 'Clicking outside of article text area closes the article',	// TODO - Translation
 		'sort' => array(
 			'_' => 'Ordinamento',

+ 1 - 0
app/i18n/kr/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Remember open categories',	// TODO - Translation
 			'unread' => '읽지 않은 글만 표시',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => '글 영역 바깥을 클릭하면 글 접기',
 		'sort' => array(
 			'_' => '정렬 순서',

+ 1 - 0
app/i18n/nl/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Open categorieën herinneren',
 			'unread' => 'Bekijk alleen ongelezen',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => 'Sluit het artikel door buiten de artikeltekst te klikken',
 		'sort' => array(
 			'_' => 'Sorteer volgorde',

+ 1 - 0
app/i18n/oc/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Se remembrar de las categorias dobèrtas',
 			'unread' => 'Mostrar pas que los pas legits',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => 'Clicar fòra de la zòna de tèxte tampa l’article',
 		'sort' => array(
 			'_' => 'Òrdre de tria',

+ 1 - 0
app/i18n/pl/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Remember open categories',	// TODO - Translation
 			'unread' => 'Tylko nieprzeczytane',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => 'Kliknięcie poza zawartością wiadomości zamyka widok wiadomości',
 		'sort' => array(
 			'_' => 'Porządek sortowania',

+ 1 - 0
app/i18n/pt-br/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Remember open categories',	// TODO - Translation
 			'unread' => 'Exibir apenas não lido',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => 'Clicando fora da área do texto do artigo fecha o mesmo',
 		'sort' => array(
 			'_' => 'Ordem de visualização',

+ 1 - 0
app/i18n/ru/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Remember open categories',	// TODO - Translation
 			'unread' => 'Show only unread',	// TODO - Translation
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => 'Clicking outside of article text area closes the article',	// TODO - Translation
 		'sort' => array(
 			'_' => 'Sort order',	// TODO - Translation

+ 1 - 0
app/i18n/sk/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Remember open categories',	// TODO - Translation
 			'unread' => 'Zobraziť iba neprečítané',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => 'Po kliknutí mimo textu článku sa článok zatvorí',
 		'sort' => array(
 			'_' => 'Poradie',

+ 1 - 0
app/i18n/tr/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => 'Remember open categories',	// TODO - Translation
 			'unread' => 'Sadece okunmamış makaleleri göster',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => 'Clicking outside of article text area closes the article',	// TODO - Translation
 		'sort' => array(
 			'_' => 'Sıralama',

+ 1 - 0
app/i18n/zh-cn/conf.php

@@ -138,6 +138,7 @@ return array(
 			'remember_categories' => '记住打开的分类',
 			'unread' => '只显示未读',
 		),
+		'show_fav_unread_help' => 'Applies also on labels',	// TODO - Translation
 		'sides_close_article' => '点击文章区域外以关闭',
 		'sort' => array(
 			'_' => '排列顺序',

+ 5 - 9
app/layout/aside_feed.phtml

@@ -6,6 +6,8 @@
 			!FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ)) {
 		$class = ' state_unread';
 	}
+
+	$state_filter = FreshRSS_Context::$user_conf->show_fav_unread ? '&state=3' : '';
 ?>
 
 <div class="aside aside_feed<?= $class ?>" id="aside_feed">
@@ -31,14 +33,8 @@
 
 		<li class="tree-folder category favorites<?= FreshRSS_Context::isCurrentGet('s') ? ' active' : '' ?>">
 			<div class="tree-folder-title">
-				<?php
-					$url_starred = _url('index', $actual_view, 'get', 's');
-					if (FreshRSS_Context::$user_conf->show_fav_unread) {
-						$url_starred = $url_starred . '&state=3';
-					}
-				?>
 				<?= _i('bookmark') ?>
-				<a class="title" data-unread="<?= format_number(FreshRSS_Context::$total_starred['unread']) ?>" href="<?= $url_starred ?>">
+				<a class="title" data-unread="<?= format_number(FreshRSS_Context::$total_starred['unread']) ?>" href="<?= _url('index', $actual_view, 'get', 's') . $state_filter ?>">
 					<?= _t('index.menu.favorites', format_number(FreshRSS_Context::$total_starred['all'])) ?>
 				</a>
 			</div>
@@ -51,7 +47,7 @@
 		<li id="tags" class="tree-folder category tags<?= $t_active ? ' active' : '' ?>">
 			<div class="tree-folder-title">
 				<a class="dropdown-toggle" href="#"><?= _i($t_active ? 'up' : 'down') ?></a>
-				<a class="title" data-unread="<?= format_number($this->nbUnreadTags) ?>" href="<?= _url('index', $actual_view, 'get', 'T') ?>"><?= _t('index.menu.tags') ?></a>
+				<a class="title" data-unread="<?= format_number($this->nbUnreadTags) ?>" href="<?= _url('index', $actual_view, 'get', 'T') . $state_filter ?>"><?= _t('index.menu.tags') ?></a>
 			</div>
 			<ul class="tree-folder-items<?= $t_show ? ' active' : '' ?>">
 				<?php
@@ -63,7 +59,7 @@
 						<a class="dropdown-toggle"><?= _i('configure') ?></a>
 						<?php /* tag_config_template */ ?>
 					</div>
-					<?= FreshRSS_Themes::alt('label') ?> <a class="item-title" data-unread="<?= format_number($tag->nbUnread()) ?>" href="<?= _url('index', $actual_view, 'get', 't_' . $tag->id()) ?>"><?= $tag->name() ?></a>
+					<?= FreshRSS_Themes::alt('label') ?> <a class="item-title" data-unread="<?= format_number($tag->nbUnread()) ?>" href="<?= _url('index', $actual_view, 'get', 't_' . $tag->id()) . $state_filter ?>"><?= $tag->name() ?></a>
 				</li>
 				<?php endforeach; ?>
 			</ul>

+ 1 - 0
app/views/configure/reading.phtml

@@ -73,6 +73,7 @@
 				<label class="checkbox" for="show_fav_unread">
 					<input type="checkbox" name="show_fav_unread" id="show_fav_unread" value="1"<?= FreshRSS_Context::$user_conf->show_fav_unread ? ' checked="checked"' : '' ?> data-leave-validation="<?= FreshRSS_Context::$user_conf->show_fav_unread ?>"/>
 					<?= _t('conf.reading.always_show_favorites') ?>
+					<p class="help"><?= _i('help') ?> <?= _t('conf.reading.show_fav_unread_help') ?></p>
 				</label>
 			</div>
 		</div>

+ 1 - 0
cli/i18n/ignore/en-us.php

@@ -244,6 +244,7 @@ return array(
 	'conf.reading.show.no_category',
 	'conf.reading.show.remember_categories',
 	'conf.reading.show.unread',
+	'conf.reading.show_fav_unread_help',
 	'conf.reading.sides_close_article',
 	'conf.reading.sort._',
 	'conf.reading.sort.newer_first',