merge xmlrpc stuff, and put it in classes/
[platal.git] / include / xorg.inc.php
index 95a7bb9..3d84c05 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  Copyright (C) 2003-2006 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -26,54 +26,62 @@ XorgGlobals::init();
 XorgGlobals::setlocale();
 XorgSession::init();
 
-// {{{ function _new_page()
+require_once dirname(__FILE__).'/../classes/Page.php';
 
-function _new_page($type, $tpl_name, $min_auth, $admin=false)
-{
-    global $page,$globals;
-    require_once("xorg/page.inc.php");
-    if (!empty($admin)) {
-        $page = new XorgAdmin($tpl_name, $type);
-    } else switch($min_auth) {
-        case AUTH_PUBLIC:
-            $page = new XorgPage($tpl_name, $type);
-            break;
+// {{{ class XorgPage
 
-        case AUTH_COOKIE:
-            $page = new XorgCookie($tpl_name, $type);
-            break;
-
-        case AUTH_MDP:
-            $page = new XorgAuth($tpl_name, $type);
+class XorgPage extends PlatalPage
+{
+    function XorgPage($tpl, $type = SKINNED)
+    {
+        $this->PlatalPage($tpl, $type);
     }
 
-    $page->assign('xorg_tpl', $tpl_name);
+    function run()
+    {
+        global $globals;
+        $this->assign('globals', $globals);
+        $this->_run('skin/'.S::v('skin', 'default.tpl'));
+    }
 }
 
 // }}}
-// {{{ function new_skinned_page()
+// {{{ class XorgAdmin
 
-function new_skinned_page($tpl_name, $min_auth)
+/** Une classe pour les pages réservées aux admins (authentifiés!).
+ */
+class XorgAdmin extends XorgPage
 {
-    _new_page(SKINNED, $tpl_name, $min_auth);
+    // {{{ function XorgAdmin()
+
+    function XorgAdmin($tpl, $type = SKINNED)
+    {
+        $this->XorgPage($tpl, $type);
+        check_perms();
+    }
+
+    // }}}
 }
 
 // }}}
-// {{{ function new_simple_page()
 
-function new_simple_page($tpl_name, $min_auth)
+function _new_page($type, $tpl_name, $admin=false)
 {
     global $page;
-    _new_page(SKINNED, $tpl_name, $min_auth);
-    $page->assign('simple', true);
+    if (!empty($admin)) {
+        $page = new XorgAdmin($tpl_name, $type);
+    } else {
+        $page = new XorgPage($tpl_name, $type);
+    }
+
+    $page->assign('xorg_tpl', $tpl_name);
 }
 
-// }}}
-// {{{ function new_nonhtml_page()
+// {{{ function new_skinned_page()
 
-function new_nonhtml_page($tpl_name, $min_auth)
+function new_skinned_page($tpl_name)
 {
-    _new_page(NO_SKIN, $tpl_name, $min_auth, false);
+    _new_page(SKINNED, $tpl_name);
 }
 
 // }}}
@@ -81,7 +89,7 @@ function new_nonhtml_page($tpl_name, $min_auth)
 
 function new_admin_page($tpl_name)
 {
-    _new_page(SKINNED, $tpl_name, AUTH_MDP, true);
+    _new_page(SKINNED, $tpl_name, true);
 }
 
 // }}}
@@ -96,7 +104,7 @@ function new_admin_table_editor($table, $idfield, $idedit=false)
     global $editor;
     new_admin_page('table-editor.tpl');
     require_once('xorg.table-editor.inc.php');
-    $editor = new XOrgAdminTableEditor($table,$idfield,$idedit);
+    $editor = new XOrgAdminTableEditor($table, $idfield, $idedit);
 }
 
 // }}}