we are near 1.0
authorx2000habouzit <x2000habouzit>
Fri, 7 Jan 2005 15:01:26 +0000 (15:01 +0000)
committerx2000habouzit <x2000habouzit>
Fri, 7 Jan 2005 15:01:26 +0000 (15:01 +0000)
include/banana.inc.php.in
include/misc.inc.php
include/post.inc.php

index ba24a05..f98aad3 100644 (file)
@@ -40,22 +40,20 @@ class Banana
     function Banana()
     {
         require_once('include/NetNNTP.inc.php');
-        $this->_setupProfile();
+        setlocale(LC_ALL,  $this->profile['locale']);
         $this->nntp = new nntp($this->host);
-
-$this->profile['subscribe'][] = 'xorg.general';
-$this->profile['subscribe'][] = 'xorg.test';
-$this->profile['subscribe'][] = 'xorg.promo.x1970';
-$this->profile['lastnews'] = time() - 24*3600*7;
-
     }
 
-    function run()
+    function run($class = 'Banana')
     {
-        require_once("include/misc.inc.php");
         global $banana;
+        require_once("include/misc.inc.php");
+        $banana = new $class();
+
+        if (!$banana->nntp) {
+            return '<p class="error">'._b_('Impossible de contacter le serveur').'</p>';
+        }
 
-        $banana = new Banana();
         $group  = empty($_GET['group']) ? null : strtolower($_GET['group']);
         $artid  = empty($_GET['artid']) ? null : strtolower($_GET['artid']);
         $banana->state = Array ('group' => $group, 'artid' => $artid);
@@ -293,15 +291,6 @@ $this->profile['lastnews'] = time() - 24*3600*7;
             $this->newgroups = new BananaGroups(BANANA_GROUP_NEW);
         }
     }
-
-    function _setupProfile()
-    {
-        if (function_exists('hook_getprofile')) {
-            $this->profile = hook_getprofile();
-        }
-        
-        setlocale(LC_ALL,  $this->profile['locale']);
-    }
 }
 
 ?>
index aaad5b0..bdac4fa 100644 (file)
@@ -39,8 +39,9 @@ function header_translate($hdr) {
         case 'references':      return _b_('Références');
         case 'x-face':          return _b_('Image');
         default:
-            if (function_exists('hook_header_translate')) {
-                return hook_header_translate($hdr);
+            if (function_exists('hook_headerTranslate')
+                    && $res = hook_headerTranslate($hdr)) {
+                return $res;
             }
             return $hdr;
     }
@@ -87,8 +88,10 @@ function formatDisplayHeader($_header,$_text) {
             return '<img src="xface.php?face='.base64_encode($_text).'"  alt="x-face" />';
         
         default:
-            if (function_exists('hook_formatDisplayHeader')) {
-                return hook_formatDisplayHeader($_header, $_text);
+            if (function_exists('hook_formatDisplayHeader')
+                    && $res = hook_formatDisplayHeader($_header, $_text))
+            {
+                return $res;
             }
             return htmlentities($_text);
     }
@@ -139,15 +142,9 @@ function formatFrom($text) {
 
 function displayshortcuts($first = -1) {
     global $banana;
-
-    $res = '<div class="banana_scuts">';
-
-    if (function_exists('hook_displayshortcuts')) {
-        $res .= hook_displayshortcuts($sname, $first);
-    }
-
     extract($banana->state);
 
+    $res  = '<div class="banana_scuts">';
     $res .= '[<a href="?">'._b_('Liste des forums').'</a>] ';
     if (is_null($group)) {
         return $res.'</div>';
index 4df89da..499d56b 100644 (file)
@@ -86,7 +86,6 @@ class BananaPost
 
     function checkcancel()
     {
-        return true;
         if (function_exists('hook_checkcancel')) {
             return hook_checkcancel($this->headers);
         }