A bit of code factorization. xorg/f/xnet-new-events
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Mon, 21 Jan 2008 21:03:33 +0000 (22:03 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Mon, 21 Jan 2008 21:03:33 +0000 (22:03 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
modules/xnetevents.php
modules/xnetevents/xnetevents.editionsteps.inc.php
templates/xnetevents/edit.tpl [new file with mode: 0644]

index e84fffc..76871c1 100644 (file)
@@ -62,7 +62,7 @@ class XnetEventsModule extends PLModule
         global $globals;
         $wiz = new PlWizard('XNetEvent_' . $globals->asso('diminutif'), 'core/plwizard.tpl', false, false);
         $wiz->addPage('XNetEventEditStart', 'Nouvel événement', 'start');
-        $wiz->apply($page, 'events/edit/' . $eid, $tab)
+        $wiz->apply($page, 'events/edit/' . $eid, $tab);
     }
 
     function handler_admin(&$page, $eid = null, $item_id = null)
index f093327..498f5d7 100644 (file)
  ***************************************************************************/
 
 __autoload('PlWizard');
+require_once dirname(__FILE__) . '/xnetevents.inc.php';
 
 
-// Welcome page {{{1
+// Generic page template {{{1
 
-class XNetEventEditStart implements PlWizardPage
+abstract class XNetEventEditPage implements PlWizardPage
 {
+    protected $pg_template;
+    public $event;
+
     public function __construct(PlWizard &$wiz)
     {
+        if (!isset($_SESSION['new_xnetevent'])) {
+            $_SESSION['new_xnetevent'] = new XNetEvent();
+        }
+        $this->event =& $_SESSION['new_xnetevent'];
     }
 
     public function template()
     {
-        return 'xnetevents/edit-start.tpl';
+        return 'xnetevents/edit.tpl';
     }
 
     public function prepare(PlatalPage &$page, $id)
     {
+        $this->_prepare($page, $id);
+        $page->assign('edit_event_page', $this->pg_template);
+    }
+
+    protected function _prepare(PlatalPage &$page, $id)
+    {
+    }
+}
+
+
+// Welcome page {{{1
+
+class XNetEventEditStart extends XNetEventEditPage
+{
+    protected $pg_template = 'xnetevents/edit-start.tpl';
+
+    public function __construct(PlWizard &$wiz)
+    {
+        parent::__construct($wiz);
     }
 
     public function process()
diff --git a/templates/xnetevents/edit.tpl b/templates/xnetevents/edit.tpl
new file mode 100644 (file)
index 0000000..1308b6b
--- /dev/null
@@ -0,0 +1,32 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<form action="{$wiz_baseurl}/{$lookup[$current]}" method="post" id="edit_event">
+
+<div>
+{include file=$edit_event_page}
+</div>
+
+</form>
+
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}