Просмотр исходного кода

Corrige le titre des flux RSS générés

Supprime le nombre de non lus dans le titre des flux RSS générés
Marien Fressinaud 12 лет назад
Родитель
Сommit
33b68a8017
3 измененных файлов с 17 добавлено и 12 удалено
  1. 14 9
      app/controllers/indexController.php
  2. 1 1
      app/layout/layout.phtml
  3. 2 2
      app/views/helpers/view/rss_view.phtml

+ 14 - 9
app/controllers/indexController.php

@@ -3,7 +3,7 @@
 class indexController extends ActionController {
 class indexController extends ActionController {
 	private $get = false;
 	private $get = false;
 	private $nb_not_read = 0;
 	private $nb_not_read = 0;
-	private $mode = 'all';	//TODO: Is this used?
+	private $nb_not_read_cat = 0;
 
 
 	public function indexAction () {
 	public function indexAction () {
 		$output = Request::param ('output');
 		$output = Request::param ('output');
@@ -37,6 +37,8 @@ class indexController extends ActionController {
 			'params' => $params
 			'params' => $params
 		);
 		);
 
 
+		$this->view->rss_title = View::title();
+
 		if ($output == 'rss') {
 		if ($output == 'rss') {
 			// no layout for RSS output
 			// no layout for RSS output
 			$this->view->_useLayout (false);
 			$this->view->_useLayout (false);
@@ -73,6 +75,14 @@ class indexController extends ActionController {
 
 
 		$type = $this->getType ();
 		$type = $this->getType ();
 		$error = $this->checkAndProcessType ($type);
 		$error = $this->checkAndProcessType ($type);
+
+		// mise à jour des titres
+		$this->view->rss_title = $this->view->currentName . ' - ' . $this->view->rss_title;
+		View::prependTitle (
+			$this->view->currentName .
+			($this->nb_not_read_cat > 0 ? ' (' . $this->nb_not_read_cat . ')' : '')
+		);
+
 		if (!$error) {
 		if (!$error) {
 			// On récupère les différents éléments de filtrage
 			// On récupère les différents éléments de filtrage
 			$this->view->state = $state = Request::param ('state', $this->view->conf->defaultView ());
 			$this->view->state = $state = Request::param ('state', $this->view->conf->defaultView ());
@@ -139,22 +149,19 @@ class indexController extends ActionController {
 	/*
 	/*
 	 * Vérifie que la catégorie / flux sélectionné existe
 	 * Vérifie que la catégorie / flux sélectionné existe
 	 * + Initialise correctement les variables de vue get_c et get_f
 	 * + Initialise correctement les variables de vue get_c et get_f
-	 * + Initialise le titre
+	 * + Met à jour la variable $this->nb_not_read_cat
 	 */
 	 */
 	private function checkAndProcessType ($type) {
 	private function checkAndProcessType ($type) {
 		if ($type['type'] == 'all') {
 		if ($type['type'] == 'all') {
 			$this->view->currentName = Translate::t ('your_rss_feeds');
 			$this->view->currentName = Translate::t ('your_rss_feeds');
-			View::prependTitle ($this->view->currentName);
 			$this->view->get_c = $type['type'];
 			$this->view->get_c = $type['type'];
 			return false;
 			return false;
 		} elseif ($type['type'] == 'favoris') {
 		} elseif ($type['type'] == 'favoris') {
 			$this->view->currentName = Translate::t ('your_favorites');
 			$this->view->currentName = Translate::t ('your_favorites');
-			View::prependTitle ($this->view->currentName);
 			$this->view->get_c = $type['type'];
 			$this->view->get_c = $type['type'];
 			return false;
 			return false;
 		} elseif ($type['type'] == 'public') {
 		} elseif ($type['type'] == 'public') {
 			$this->view->currentName = Translate::t ('public');
 			$this->view->currentName = Translate::t ('public');
-			View::prependTitle ($this->view->currentName);
 			$this->view->get_c = $type['type'];
 			$this->view->get_c = $type['type'];
 			return false;
 			return false;
 		} elseif ($type['type'] == 'c') {
 		} elseif ($type['type'] == 'c') {
@@ -162,8 +169,7 @@ class indexController extends ActionController {
 			$cat = $catDAO->searchById ($type['id']);
 			$cat = $catDAO->searchById ($type['id']);
 			if ($cat) {
 			if ($cat) {
 				$this->view->currentName = $cat->name ();
 				$this->view->currentName = $cat->name ();
-				$nbnr = $cat->nbNotRead ();
-				View::prependTitle ($this->view->currentName . ($nbnr > 0 ? ' (' . $nbnr . ')' : ''));
+				$this->nb_not_read_cat = $cat->nbNotRead ();
 				$this->view->get_c = $type['id'];
 				$this->view->get_c = $type['id'];
 				return false;
 				return false;
 			} else {
 			} else {
@@ -174,8 +180,7 @@ class indexController extends ActionController {
 			$feed = $feedDAO->searchById ($type['id']);
 			$feed = $feedDAO->searchById ($type['id']);
 			if ($feed) {
 			if ($feed) {
 				$this->view->currentName = $feed->name ();
 				$this->view->currentName = $feed->name ();
-				$nbnr = $feed->nbNotRead ();
-				View::prependTitle ($this->view->currentName . ($nbnr > 0 ? ' (' . $nbnr . ')' : ''));
+				$this->nb_not_read_cat = $feed->nbNotRead ();
 				$this->view->get_f = $type['id'];
 				$this->view->get_f = $type['id'];
 				$this->view->get_c = $feed->category ();
 				$this->view->get_c = $feed->category ();
 				return false;
 				return false;

+ 1 - 1
app/layout/layout.phtml

@@ -6,7 +6,7 @@
 		<link rel="icon" type="image/x-icon" href="<?php echo Url::display ('/favicon.ico'); ?>" />
 		<link rel="icon" type="image/x-icon" href="<?php echo Url::display ('/favicon.ico'); ?>" />
 		<link rel="icon" type="image/png" href="<?php echo Url::display ('/favicon.ico'); ?>" />
 		<link rel="icon" type="image/png" href="<?php echo Url::display ('/favicon.ico'); ?>" />
 		<?php if (isset ($this->rss_url)) { ?>
 		<?php if (isset ($this->rss_url)) { ?>
-		<link rel="alternate" type="application/rss+xml" title="<?php echo htmlspecialchars(View::title(), ENT_COMPAT, 'UTF-8'); ?>" href="<?php echo Url::display ($this->rss_url); ?>" />
+		<link rel="alternate" type="application/rss+xml" title="<?php echo htmlspecialchars($this->rss_title, ENT_COMPAT, 'UTF-8'); ?>" href="<?php echo Url::display ($this->rss_url); ?>" />
 		<?php } ?>
 		<?php } ?>
 		<?php echo self::headTitle (); ?>
 		<?php echo self::headTitle (); ?>
 		<?php echo self::headStyle (); ?>
 		<?php echo self::headStyle (); ?>

+ 2 - 2
app/views/helpers/view/rss_view.phtml

@@ -1,9 +1,9 @@
 <?php echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?>
 <?php echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?>
 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
 	<channel>
 	<channel>
-		<title><?php echo View::title(); ?></title>
+		<title><?php echo $this->rss_title; ?></title>
 		<link><?php echo Url::display(); ?></link>
 		<link><?php echo Url::display(); ?></link>
-		<description><?php echo Translate::t ('rss_feeds_of', View::title()); ?></description>
+		<description><?php echo Translate::t ('rss_feeds_of', $this->rss_title); ?></description>
 		<pubDate><?php echo date('D, d M Y H:i:s O'); ?></pubDate>
 		<pubDate><?php echo date('D, d M Y H:i:s O'); ?></pubDate>
 		<lastBuildDate><?php echo gmdate('D, d M Y H:i:s'); ?> GMT</lastBuildDate>
 		<lastBuildDate><?php echo gmdate('D, d M Y H:i:s'); ?> GMT</lastBuildDate>
 		<atom:link href="<?php echo _url ('index', 'index', 'output', 'rss'); ?>" rel="self" type="application/rss+xml" />
 		<atom:link href="<?php echo _url ('index', 'index', 'output', 'rss'); ?>" rel="self" type="application/rss+xml" />