From cd58d95426350549d9195a358c474847211676c6 Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Sun, 25 Feb 2007 21:21:08 +0000 Subject: [PATCH] Improvements and bugfixes git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@218 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- banana/banana.inc.php.in | 4 +++- banana/feed.inc.php | 8 +++++++- banana/nntp.inc.php | 8 ++------ banana/page.inc.php | 10 +++++++--- banana/templates/banana-feed-rss2.tpl | 6 +++++- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/banana/banana.inc.php.in b/banana/banana.inc.php.in index ac38001..ca17a13 100644 --- a/banana/banana.inc.php.in +++ b/banana/banana.inc.php.in @@ -81,7 +81,9 @@ class Banana static public $feed_active = true; static public $feed_format = 'rss2'; static public $feed_updateOnDemand = false; // Update the feed each time sbd check it - static public $feed_copyright = null; + static public $feed_copyright = null; // Global copyright informations + static public $feed_generator = 'Banana @VERSION@'; // Feed generator + static public $feed_email = null; // Admin e-mail static public $feed_namePrefix = 'Banana :: '; static public $feed_size = 15; // Number of messages in the feed diff --git a/banana/feed.inc.php b/banana/feed.inc.php index 4befd83..b4fef0b 100644 --- a/banana/feed.inc.php +++ b/banana/feed.inc.php @@ -32,13 +32,17 @@ class BananaFeed */ public $messages = array(); + /** Last update time + */ + public $lastupdate = 0; + /** Create an empty feed */ private function __construct() { $this->version = BANANA_FEED_VERSION; $this->group = Banana::$group; - $this->description = Banana::$protocole->getDescription(); + $this->description = trim(Banana::$protocole->getDescription()); } /** Update the feed, using current settings of Banana @@ -76,6 +80,7 @@ class BananaFeed $this->messages[$key] = $array; } uasort($this->messages, Array('BananaFeed', 'compare')); + $this->lastupdate = time(); $this->writeToFile(); } @@ -171,6 +176,7 @@ class BananaFeed } uasort($messages, array('BananaFeed', 'compare')); $master->messages =& $messages; + $master->lastupdate = time(); return $master; } diff --git a/banana/nntp.inc.php b/banana/nntp.inc.php index 6f5d245..17aaeba 100644 --- a/banana/nntp.inc.php +++ b/banana/nntp.inc.php @@ -14,7 +14,6 @@ require_once dirname(__FILE__) . '/protocoleinterface.inc.php'; class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface { - private $description = null; private $ingroup = null; private $mode = null; @@ -43,14 +42,11 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface */ public function getDescription() { - if ($this->description) { - return $this->description; - } $descs = $this->xgtitle(Banana::$group); if (isset($descs[Banana::$group])) { - $this->description = $descs[Banana::$group]; + return trim(utf8_encode($descs[Banana::$group])); } - return $this->description; + return null; } /** Return the list of the boxes diff --git a/banana/page.inc.php b/banana/page.inc.php index 4fe806d..acd2e65 100644 --- a/banana/page.inc.php +++ b/banana/page.inc.php @@ -151,17 +151,19 @@ class BananaPage extends Smarty @list($lg) = explode('_', Banana::$profile['locale']); $tpl = 'banana-feed-' . Banana::$feed_format . '.tpl'; $this->assign('copyright', Banana::$feed_copyright); + $this->assign('generator', Banana::$feed_generator); + $this->assign('email', Banana::$feed_email); $this->assign('title_prefix', Banana::$feed_namePrefix); $this->assign('language', $lg); $this->register_function('rss_date', 'rss_date'); header('Content-Type: application/rss+xml; charset=utf-8'); - echo $this->_run($tpl); + echo $this->_run($tpl, false); exit; } /** Code generation */ - private function _run($tpl) + private function _run($tpl, $ent = true) { $this->assign('group', Banana::$group); $this->assign('artid', Banana::$artid); @@ -192,7 +194,9 @@ class BananaPage extends Smarty $error_level = error_reporting(0); } $text = $this->fetch($tpl); - $text = banana_utf8entities($text); + if ($ent) { + $text = banana_utf8entities($text); + } if (!Banana::$debug_smarty) { error_reporting($error_level); } diff --git a/banana/templates/banana-feed-rss2.tpl b/banana/templates/banana-feed-rss2.tpl index 7a3624c..b454a40 100644 --- a/banana/templates/banana-feed-rss2.tpl +++ b/banana/templates/banana-feed-rss2.tpl @@ -3,8 +3,12 @@ {$title_prefix}{$feed->group} {$language} + {if $copyright}{/if} + {if $email}{$email}{/if} + {if $generator}{$generator}{/if} + {$feed->lastupdate|rss_date} {url group=$group} - description}]]> + description|default:"-"}]]> {foreach from=$feed->messages key=id item=message} <![CDATA[{$message.title}]]> -- 2.1.4