First fast port of banana to PlWizard
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 2 Nov 2007 13:03:26 +0000 (14:03 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 2 Nov 2007 13:03:26 +0000 (14:03 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
include/banana/forum.inc.php
include/banana/hooks.inc.php
include/banana/moderate.inc.php
modules/banana.php

index 7195d1e..961c6ab 100644 (file)
@@ -49,7 +49,7 @@ class ForumsBanana extends Banana
         if (!S::v('core_rss_hash')) {
             Banana::$feed_active = false;
         }
-        parent::__construct($params);
+        parent::__construct($params, 'NNTP', 'PlatalBananaPage');
     }
 
     public function run()
index ed55ec0..05d43cc 100644 (file)
@@ -141,7 +141,7 @@ function hook_makeLink($params)
             return $base . '/' . $params['page'];
         }
         if (@$params['action'] == 'subscribe') {
-            return $base . '/subscription';
+            return $base . '/subscribe';
         }
 
         if (!isset($params['group'])) {
@@ -253,6 +253,48 @@ function get_banana_params(array &$get, $group = null, $action = null, $artid =
     }
 }
 
+class PlatalBananaPage extends BananaPage
+{
+    public function __construct()
+    {
+        Banana::$withtabs = false;
+        parent::__construct();
+    }
+
+    protected function prepare()
+    {
+        $tpl = parent::prepare();
+        global $wiz, $page;
+        $wiz = new PlWizard('Banana', 'core/plwizard.tpl', true, false);
+        foreach ($this->pages as $name=>&$mpage) {
+            $wiz->addPage('BananaHandler', $mpage['text'], $name);
+        }
+        $wiz->apply($page, 'banana', $this->page);
+        return $tpl;
+    }
+}
+
+class BananaHandler
+{
+    public function __construct(PlWizard &$wiz)
+    {
+    }
+
+    public function template()
+    {
+        return 'banana/index.tpl';
+    }
+
+    public function prepare(PlatalPage &$page, $id)
+    {
+    }
+
+    public function process()
+    {
+        return PlWizard::CURRENT_PAGE;
+    }
+}
+
 function run_banana(&$page, $class, array $args)
 {
     $banana = new $class(S::v('forlife'), $args);
index 4931902..83b0fd9 100644 (file)
@@ -76,8 +76,6 @@ class ModerationBanana extends Banana
     }
 }
 
-require_once('banana/page.inc.php');
-
 class ModerationPage extends BananaPage
 {
     protected function prepare()
@@ -98,9 +96,6 @@ class ModerationPage extends BananaPage
     }
 }
 
-require_once('banana/protocoleinterface.inc.php');
-require_once('banana/message.inc.php');
-
 class BananaMLInterface implements BananaProtocoleInterface
 {
     private $infos; //(list, addr, host, desc, info, diff, ins, priv, sub, own, nbsub)
index 63ce688..7a7548f 100644 (file)
@@ -25,8 +25,11 @@ class BananaModule extends PLModule
     {
         return array(
             'banana'              => $this->make_hook('banana', AUTH_COOKIE),
+            'banana/forums'       => $this->make_hook('banana', AUTH_COOKIE),
+            'banana/message'      => $this->make_hook('message', AUTH_COOKIE),
+            'banana/thread'       => $this->make_hook('thread', AUTH_COOKIE),
             'banana/profile'      => $this->make_hook('profile', AUTH_MDP),
-            'banana/subscription' => $this->make_hook('subscription', AUTH_COOKIE),
+            'banana/subscribe'    => $this->make_hook('subscription', AUTH_COOKIE),
             'banana/rss'          => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS),
         );
     }
@@ -71,6 +74,16 @@ class BananaModule extends PLModule
         run_banana($page, 'ForumsBanana', $get);
     }
 
+    function handler_message(&$page)
+    {
+        pl_redirect('banana/' . S::v('banana_group') . '/read/' . S::i('banana_artid'));
+    }
+
+    function handler_thread(&$page)
+    {
+        pl_redirect('banana/' . S::v('banana_group'));
+    }
+
     function handler_profile(&$page, $action = null)
     {
         global $globals;