Improvements and bugfixes
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Sun, 25 Feb 2007 21:21:08 +0000 (21:21 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jan 2008 23:35:33 +0000 (00:35 +0100)
git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@218 9869982d-c50d-0410-be91-f2a2ec7c7c7b

banana/banana.inc.php.in
banana/feed.inc.php
banana/nntp.inc.php
banana/page.inc.php
banana/templates/banana-feed-rss2.tpl

index ac38001..ca17a13 100644 (file)
@@ -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
 
index 4befd83..b4fef0b 100644 (file)
@@ -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;
     }
 
index 6f5d245..17aaeba 100644 (file)
@@ -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
index 4fe806d..acd2e65 100644 (file)
@@ -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);
         }
index 7a3624c..b454a40 100644 (file)
@@ -3,8 +3,12 @@
   <channel>
     <title>{$title_prefix}{$feed->group}</title>
     <language>{$language}</language>
+    {if $copyright}<copyright><![CDATA[{$copyright}]]></copyright>{/if}
+    {if $email}<webMaster>{$email}</webMaster>{/if}
+    {if $generator}<generator>{$generator}</generator>{/if}
+    <lastBuildDate>{$feed->lastupdate|rss_date}</lastBuildDate>
     <link>{url group=$group}</link>
-    <description><![CDATA[{$feed->description}]]></description>
+    <description><![CDATA[{$feed->description|default:"-"}]]></description>
     {foreach from=$feed->messages key=id item=message}
     <item>
       <title><![CDATA[{$message.title}]]></title>