PHP5-ize all base classes...
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 4 Mar 2007 17:45:56 +0000 (17:45 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 4 Mar 2007 17:45:56 +0000 (17:45 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1545 839d8a87-29fc-0310-9880-83ba4fa771e5

15 files changed:
classes/flagset.php
classes/mmlist.php
classes/platal.php
classes/platalpage.php
classes/pliterator.php [new file with mode: 0644]
classes/plmodule.php
classes/pltableeditor.php
classes/trombi.php
classes/varstream.php
classes/xdb.php
classes/xnet.php
classes/xorgplugin.php
include/vcard.inc.php
include/xnet/page.inc.php
include/xorg.inc.php

index 12c0703..7fe89b6 100644 (file)
 
 /** class for describing flags
  */
-class flagset {
-  /** string that holds the flagset */
-  var $value;
+class Flagset
+{
+    /** string that holds the flagset */
+    private $value;
 
-  /** the boundary between flags */
-  var $sep = ",";
+    /** the boundary between flags */
+    private $sep = ",";
 
 
-  /** set flag
-   * @param $flags services FROM coupures
-   * @return VOID
-   */
-  function flagset( $flags="" ) {
-    $this->value = $flags;
-  }
+    /** set flag
+     * @param $flags services FROM coupures
+     * @return VOID
+     */
+    public function __construct($flags = "")
+    {
+        $this->value = $flags;
+    }
 
 
-  /** add flag
-   * @param $flag XXX
-   * @return VOID
-   */
-  function addflag($flag) {
-    if (!$flag) return;
-    if (!$this->hasflag($flag)) {
-      if ($this->value)
-        $this->value .= $this->sep;
-      $this->value .= $flag;
+    /** add flag
+     * @param $flag XXX
+     * @return VOID
+     */
+    public function addflag($flag) 
+    {
+        if (!$flag) return;
+        if (!$this->hasflag($flag)) {
+            if ($this->value)
+                $this->value .= $this->sep;
+            $this->value .= $flag;
+        }
     }
-  }
 
 
-  /** test si flag ou pas
-   * @param $flag XXX
-   * @return 1 || 0
-   */
-  function hasflag($flag) {
-    $tok = strtok($this->value,$this->sep);
-    while ($tok) {
-      if ($tok==$flag) return 1;
-      $tok = strtok($this->sep);
+    /** test si flag ou pas
+     * @param $flag XXX
+     * @return 1 || 0
+     */
+    public function hasflag($flag) 
+    {
+        $tok = strtok($this->value,$this->sep);
+        while ($tok) {
+            if ($tok==$flag) return 1;
+            $tok = strtok($this->sep);
+        }
+        return 0;
     }
-    return 0;
-  }
 
 
-  /** remove flag
-   * @param $flag XXX
-   * @return VOID
-   */
-  function rmflag($flag) {
-    if (!$flag) return;
-    $newvalue = "";
-    $tok = strtok($this->value,$this->sep);
-    while ($tok) {
-      if ($tok!=$flag) {
-        if ($newvalue)
-         $newvalue .= $this->sep;
-        $newvalue .= $tok;
-      }
-      $tok = strtok($this->sep);
+    /** remove flag
+     * @param $flag XXX
+     * @return VOID
+     */
+    public function rmflag($flag) 
+    {
+        if (!$flag) return;
+        $newvalue = "";
+        $tok = strtok($this->value,$this->sep);
+        while ($tok) {
+            if ($tok!=$flag) {
+                if ($newvalue)
+                    $newvalue .= $this->sep;
+                $newvalue .= $tok;
+            }
+            $tok = strtok($this->sep);
+        }
+        $this->value=$newvalue;
     }
-    $this->value=$newvalue;
-  }
 
 } 
 
index 7062820..63fec4d 100644 (file)
@@ -21,7 +21,7 @@
 
 class MMList extends XmlrpcClient
 {
-    function __construct($uid, $pass, $fqdn = null)
+    public function __construct($uid, $pass, $fqdn = null)
     {
         global $globals;
 
@@ -33,7 +33,7 @@ class MMList extends XmlrpcClient
         }   
     }
 
-    function __call($method, $args)
+    public function __call($method, $args)
     {
         return parent::__call($method, $args);
     }
index ac3f982..5716199 100644 (file)
@@ -25,16 +25,19 @@ define('PL_NOT_FOUND', 404);
 
 class Platal
 {
-    var $__mods;
-    var $__hooks;
+    private $__mods;
+    private $__hooks;
 
-    var $ns;
-    var $path;
-    var $argv;
+    public $ns;
+    public $path;
+    public $argv;
 
-    function Platal()
+    public function __construct()
     {
         $modules    = func_get_args();
+        if (is_array($modules[0])) {
+            $modules = $modules[0];
+        }
         $this->path = trim(Get::_get('n', null), '/');
 
         $this->__mods  = array();
@@ -47,7 +50,7 @@ class Platal
         }
     }
 
-    function pl_self($n = null)
+    public function pl_self($n = null)
     {
         if (is_null($n))
             return $this->path;
@@ -61,7 +64,7 @@ class Platal
         return join('/', array_slice($this->argv, 0, $n));
     }
 
-    function find_hook()
+    protected function find_hook()
     {
         $p = $this->path;
 
@@ -88,7 +91,7 @@ class Platal
         return $hook;
     }
 
-    function find_nearest_key($key, &$array)
+    protected function find_nearest_key($key, array &$array)
     {
         $keys    = array_keys($array);
         if (in_array($key, $keys)) {
@@ -122,7 +125,7 @@ class Platal
         return null;
     }
 
-    function near_hook()
+    protected function near_hook()
     {
         $hooks = array();
         foreach ($this->__hooks as $hook=>$handler) {
@@ -172,7 +175,7 @@ class Platal
         return null;
     }
 
-    function call_hook(&$page)
+    private function call_hook(PlatalPage &$page)
     {
         $hook = $this->find_hook();
         if (empty($hook)) {
@@ -210,7 +213,7 @@ class Platal
         return $val;
     }
 
-    function force_login(&$page)
+    protected function force_login(PlatalPage &$page)
     {
         if (S::logged()) {
             $page->changeTpl('core/password_prompt_logged.tpl');
@@ -223,7 +226,7 @@ class Platal
         $page->run();
     }
 
-    function run()
+    public function run()
     {
         global $page;
 
@@ -248,7 +251,7 @@ class Platal
         $page->run();
     }
 
-    function on_subscribe($forlife, $uid, $promo, $pass)
+    private function on_subscribe($forlife, $uid, $promo, $pass)
     {
         $args = func_get_args();
         foreach ($this->__mods as $mod) {
index eac986a..84a0a91 100644 (file)
@@ -23,10 +23,10 @@ require_once 'smarty/libs/Smarty.class.php';
 
 class PlatalPage extends Smarty
 {
-    var $_page_type;
-    var $_tpl;
-    var $_errors;
-    var $_failure;
+    private $_page_type;
+    private $_tpl;
+    private $_errors;
+    private $_failure;
 
     // defaults
     var $caching          = false;
@@ -35,11 +35,11 @@ class PlatalPage extends Smarty
 
     // {{{ function PlatalPage()
 
-    function PlatalPage($tpl, $type = SKINNED)
+    public function __construct($tpl, $type = SKINNED)
     {
-        global $globals;
+        parent::Smarty();
 
-        $this->Smarty();
+        global $globals;
 
         $this->template_dir  = $globals->spoolroot."/templates/";
         $this->compile_dir   = $globals->spoolroot."/spool/templates_c/";
@@ -62,7 +62,7 @@ class PlatalPage extends Smarty
     // }}}
     // {{{ function changeTpl()
 
-    function changeTpl($tpl, $type = SKINNED)
+    public function changeTpl($tpl, $type = SKINNED)
     {
        $this->_tpl       = $tpl;
            $this->_page_type = $type;
@@ -72,7 +72,7 @@ class PlatalPage extends Smarty
     // }}}
     // {{{ function _run()
 
-    function _run($skin)
+    protected function _run($skin)
     {
         global $globals, $TIME_BEGIN;
 
@@ -150,7 +150,7 @@ class PlatalPage extends Smarty
     // }}}
     // {{{ function nb_errs()
 
-    function nb_errs()
+    public function nb_errs()
     {
         return count($this->_errors);
     }
@@ -158,7 +158,7 @@ class PlatalPage extends Smarty
     // }}}
     // {{{ function trig()
 
-    function trig($msg)
+    public function trig($msg)
     {
         $this->_errors[] = $msg;
     }
@@ -166,7 +166,7 @@ class PlatalPage extends Smarty
     // }}}
     // {{{ function kill()
 
-    function kill($msg)
+    public function kill($msg)
     {
         global $platal;
 
@@ -179,7 +179,7 @@ class PlatalPage extends Smarty
     // }}}
     // {{{ function addJsLink
 
-    function addJsLink($path)
+    public function addJsLink($path)
     {
         $this->append('xorg_js', $path);
     }
@@ -187,7 +187,7 @@ class PlatalPage extends Smarty
     // }}}
     // {{{ function addCssLink
 
-    function addCssLink($path)
+    public function addCssLink($path)
     {
         $this->append('xorg_css', $path);
     }
@@ -195,7 +195,7 @@ class PlatalPage extends Smarty
     // }}}
     // {{{ function addCssInline
 
-    function addCssInline($css)
+    public function addCssInline($css)
     {
         if (!empty($css)) {
             $this->append('xorg_inline_css', $css);
@@ -205,7 +205,7 @@ class PlatalPage extends Smarty
     // }}}
     // {{{ function setRssLink
 
-    function setRssLink($title, $path)
+    public function setRssLink($title, $path)
     {
         $this->assign('xorg_rss', array('title' => $title, 'href' => $path));
     }
diff --git a/classes/pliterator.php b/classes/pliterator.php
new file mode 100644 (file)
index 0000000..bdaf9c5
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2007 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                *
+ ***************************************************************************/
+
+interface PlIterator
+{
+    public function next();
+    public function total();
+    public function first();
+    public function last();
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
index a515a41..8a5e6ca 100644 (file)
@@ -23,7 +23,7 @@ class PLModule
 {
     function handlers()     { die("implement me"); }
 
-    function make_hook($fun, $auth, $perms = '', $type = DO_AUTH)
+    public function make_hook($fun, $auth, $perms = '', $type = DO_AUTH)
     {
         return array('hook'  => array($this, 'handler_'.$fun),
                      'auth'  => $auth,
index ed37784..ba57c72 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class PLTableEditor {
+class PLTableEditor 
+{
     // the plat/al name of the page
-    var $pl;
+    public $pl;
     // the table name
-    var $table;
+    public $table;
     // joint tables to delete when deleting an entry
-    var $jtables = array();
+    public $jtables = array();
     // sorting field
-    var $sort = array();
+    public $sort = array();
     // the id field
-    var $idfield;
+    public $idfield;
     // possibility to edit the field
-    var $idfield_editable;
+    public $idfield_editable;
     // vars
-    var $vars;
+    public $vars;
     // number of displayed fields
-    var $nbfields;
+    public $nbfields;
     // the field for sorting entries
-    var $sortfield;
-    var $sortdesc = false;
+    public $sortfield;
+    public $sortdesc = false;
     // action to do to delete row:
-       // null => delete effectively, false => no deletion, SQL
-    var $delete_action;
-    var $delete_message;
+    // null => delete effectively, false => no deletion, SQL
+    public $delete_action;
+    public $delete_message;
     // Should "Save" button return to the list view
-    var $auto_return = true;
+    public $auto_return = true;
 
     /* table editor for platal
      * $plname : the PLname of the page, ex: admin/payments
@@ -52,7 +53,7 @@ class PLTableEditor {
      * $idfield : the field of the table which is the id, ex: id
      * $editid : is the id editable or not (if not, it is considered as an int)
      */
-    function PLTableEditor($plname, $table, $idfield, $editid=false)
+    public function __construct($plname, $table, $idfield, $editid=false)
     {
         $this->pl = $plname;
         $this->table = $table;
@@ -98,8 +99,9 @@ class PLTableEditor {
         }
         $this->vars[$idfield]['desc'] = 'id';
     }
+
     // called before creating a new entry
-    function prepare_new()
+    private function prepare_new()
     {
         $entry = array();
         foreach ($this->vars as $field => $descr) {
@@ -107,8 +109,10 @@ class PLTableEditor {
         }
         return $this->prepare_edit($entry);
     }
+
     // called before editing $entry
-    function prepare_edit(&$entry) {
+    private function prepare_edit(&$entry) 
+    {
         foreach ($this->vars as $field => $descr) {
             if ($descr['Type'] == 'set') {
                 // get the list of options selected
@@ -129,56 +133,65 @@ class PLTableEditor {
         }
         return $entry;
     }
+    
     // set whether the save button show redirect to list view or edit view
-    function list_on_edit($var)
+    public function list_on_edit($var)
     {
         $this->auto_return = $var;
     }
+
     // change display of a field
-    function describe($name, $desc, $display) {
+    public function describe($name, $desc, $display)
+    {
         $this->vars[$name]['desc'] = $desc;
         $this->vars[$name]['display'] = $display;
     }
+    
     // add a join table, when deleting a row corresponding entries will be deleted in these tables
-    function add_join_table($name,$joinid,$joindel,$joinextra="") {
+    public function add_join_table($name,$joinid,$joindel,$joinextra="")
+    {
         if ($joindel)
             $this->jtables[$name] = array("joinid" => $joinid,"joinextra" => $joinextra?(" AND ".$joinextra):"");
     }
+    
     // add a sort key
-    function add_sort_field($key, $desc = false, $default = false)
+    public function add_sort_field($key, $desc = false, $default = false)
     {
-       if ($default) {
-                       $this->sortfield = $key . ($desc ? ' DESC' : '');
-               } else {
-               $this->sort[] = $key . ($desc ? ' DESC' : '');
+        if ($default) {
+            $this->sortfield = $key . ($desc ? ' DESC' : '');
+        } else {
+            $this->sort[] = $key . ($desc ? ' DESC' : '');
         }
     }
+
     // set an action when trying to delete row
-    function on_delete($action = NULL, $message = NULL)
+    public function on_delete($action = NULL, $message = NULL)
     {
-       $this->delete_action = $action;
-       $this->delete_message = $message;
+        $this->delete_action = $action;
+        $this->delete_message = $message;
     }
+
     // call when done
-    function apply(&$page, $action, $id = false) {
+    public function apply(PlatalPage &$page, $action, $id = false)
+    {
         $page->changeTpl('core/table-editor.tpl');
         $list = true;
         if ($action == 'delete') {
-               if (!isset($this->delete_action)) {
-                   foreach ($this->jtables as $table => $j)
-                       XDB::execute("DELETE FROM {$table} WHERE {$j['joinid']} = {?}{$j['joinextra']}", $id);
-                   XDB::execute("DELETE FROM {$this->table} WHERE {$this->idfield} = {?}",$id);
-                   $page->trig("L'entrée ".$id." a été supprimée.");
-               } else if ($this->delete_action) {
-                       XDB::execute($this->delete_action, $id);
-                       if (isset($this->delete_message)) {
-                       $page->trig($this->delete_message);
-                       } else {
-                       $page->trig("L'entrée ".$id." a été supprimée.");
-                               }                       
-               } else {
-                   $page->trig("Impossible de supprimer l'entrée.");
-               }
+            if (!isset($this->delete_action)) {
+                foreach ($this->jtables as $table => $j)
+                    XDB::execute("DELETE FROM {$table} WHERE {$j['joinid']} = {?}{$j['joinextra']}", $id);
+                XDB::execute("DELETE FROM {$this->table} WHERE {$this->idfield} = {?}",$id);
+                $page->trig("L'entrée ".$id." a été supprimée.");
+            } else if ($this->delete_action) {
+                XDB::execute($this->delete_action, $id);
+                if (isset($this->delete_message)) {
+                    $page->trig($this->delete_message);
+                } else {
+                    $page->trig("L'entrée ".$id." a été supprimée.");
+                }                      
+            } else {
+                $page->trig("Impossible de supprimer l'entrée.");
+            }
         }
         if ($action == 'edit') {
             $r = XDB::query("SELECT * FROM {$this->table} WHERE {$this->idfield} = {?}",$id);
@@ -256,10 +269,10 @@ class PLTableEditor {
             }
         }
         if ($action == 'sort') {
-               $this->sortfield = $id;
+            $this->sortfield = $id;
         }
         if ($action == 'sortdesc') {
-               $this->sortfield = $id.' DESC';
+            $this->sortfield = $id.' DESC';
         }
         if ($list) {
             // user can sort by field by clicking the title of the column
index 2966ef3..31aa528 100644 (file)
 
 class Trombi extends XOrgPlugin
 {
-    var $_get_vars = array('offset');
-    var $limit = 24;
-    var $admin = false;
-    var $showpromo = true;
+    private $limit = 24;
+    private $admin = false;
+    private $showpromo = true;
 
-    function setNbRows($row)
+    public function __construct($funcname = null, $prefix = null) 
+    {
+        $this->_get_vars = array('offset');
+        parent::__construct($funcname, $prefix);
+    }
+
+    public function setNbRows($row)
     { $this->limit = $row*3; }
 
-    function setAdmin()
+    public function setAdmin()
     { $this->admin = true; }
 
-    function hidePromo()
+    public function hidePromo()
     { $this->showpromo = false; }
 
-    function show()
+    public function show()
     {
-       /* this point is nasty...  but since show() is called from the template ...
-        * I can't see any more clever way to achieve that
-        */
-       global $page;
+        /* this point is nasty...  but since show() is called from the template ...
+         * I can't see any more clever way to achieve that
+         */
+        global $page;
 
-       $offset = intval($this->get_value('offset'));
-       list($total, $list) = call_user_func($this->_callback, $offset, $this->limit);
-       $page_max = intval(($total-1)/$this->limit);
+        $offset = intval($this->get_value('offset'));
+        list($total, $list) = call_user_func($this->_callback, $offset, $this->limit);
+        $page_max = intval(($total-1)/$this->limit);
 
-       $links = Array();
-       if ($offset) {
-           $links[] = Array('u'=> $this->make_url($offset-1), 'i' => $offset-1,  'text' => 'précédent');
-       }
-       for ($i = 0; $i <= $page_max ; $i++) {
-           $links[] = Array('u'=>$this->make_url($i), 'i' => $i, 'text' => $i+1);
+        $links = Array();
+        if ($offset) {
+            $links[] = Array('u'=> $this->make_url($offset-1), 'i' => $offset-1,  'text' => 'précédent');
+        }
+        for ($i = 0; $i <= $page_max ; $i++) {
+            $links[] = Array('u'=>$this->make_url($i), 'i' => $i, 'text' => $i+1);
+        }
+        if ($offset < $page_max) {
+            $links[] = Array ('u' => $this->make_url($offset+1), 'i' => $offset+1, 'text' => 'suivant');
         }
-       if ($offset < $page_max) {
-           $links[] = Array ('u' => $this->make_url($offset+1), 'i' => $offset+1, 'text' => 'suivant');
-       }
 
-       $page->assign_by_ref('trombi_show_promo', $this->showpromo);
-       $page->assign_by_ref('trombi_list', $list);
-       $page->assign_by_ref('trombi_links', $links);
-       $page->assign('trombi_admin', $this->admin);
-       return $page->fetch('include/trombi.tpl');
+        $page->assign_by_ref('trombi_show_promo', $this->showpromo);
+        $page->assign_by_ref('trombi_list', $list);
+        $page->assign_by_ref('trombi_links', $links);
+        $page->assign('trombi_admin', $this->admin);
+        return $page->fetch('include/trombi.tpl');
     }
 }
 
index 2d730b5..7816c5f 100644 (file)
@@ -25,7 +25,7 @@ class VarStream
     private $varname;
     private $position;
 
-    function stream_open($path, $mode, $options, &$opened_path)
+    public function stream_open($path, $mode, $options, &$opened_path)
     {
         $url            = parse_url($path);
         $this->varname  = $url['host'];
@@ -38,18 +38,18 @@ class VarStream
         return true;
     }
 
-    function stream_close()
+    public function stream_close()
     {
     }
 
-    function stream_read($count)
+    public function stream_read($count)
     {
         $ret = substr($GLOBALS[$this->varname], $this->position, $count);
         $this->position += strlen($ret);
         return $ret;
     }
 
-    function stream_write($data)
+    public function stream_write($data)
     {
         $len = strlen($data);
         if ($len > $this->position + strlen($GLOBALS[$this->varname])) {
@@ -60,17 +60,17 @@ class VarStream
         $this->position += $len;
     }
 
-    function stream_eof()
+    public function stream_eof()
     {
         return $this->position >= strlen($GLOBALS[$this->varname]);
     }
 
-    function stream_tell()
+    public function stream_tell()
     {
         return $this->position;
     }
 
-    function stream_seek($offs, $whence)
+    public function stream_seek($offs, $whence)
     {
         switch ($whence) {
             case SEEK_SET:
@@ -93,11 +93,11 @@ class VarStream
         return 0;
     }
 
-    function stream_flush()
+    public function stream_flush()
     {
     }
 
-    static function init()
+    static public function init()
     {
         stream_wrapper_register('var','VarStream');
     }
index 1bb976f..3aa45cd 100644 (file)
@@ -274,7 +274,9 @@ class XOrgDBResult
     }
 }
 
-class XOrgDBIterator
+require_once dirname(__FILE__) . '/pliterator.php';
+
+class XOrgDBIterator implements PlIterator
 {
     private $_result;
     private $_pos;
index 4f76e38..88c600c 100644 (file)
 
 class Xnet extends Platal
 {
-    function Xnet()
+    public function __construct()
     {
         $modules = func_get_args();
-        call_user_func_array(array(&$this, 'Platal'), $modules);
+        parent::__construct($modules);
 
         global $globals;
         if ($globals->asso()) {
@@ -38,7 +38,7 @@ class Xnet extends Platal
         }
     }
 
-    function find_nearest_key($key, &$array)
+    protected function find_nearest_key($key, array &$array)
     {
         global $globals;
         if (in_array('%grp', array_keys($array)) &&  $key == $globals->asso('diminutif')) {
@@ -47,7 +47,7 @@ class Xnet extends Platal
         return parent::find_nearest_key($key, $array);
     }
 
-    function near_hook()
+    protected function near_hook()
     {
         global $globals;
         $link = str_replace('%grp', $globals->asso('diminutif'), parent::near_hook());
@@ -57,7 +57,7 @@ class Xnet extends Platal
         return null; 
     }
 
-    function find_hook()
+    protected function find_hook()
     {
         $ans = parent::find_hook();
         if ($ans && $this->ns) {
@@ -67,7 +67,7 @@ class Xnet extends Platal
         return $ans;
     }
 
-    function force_login(&$page)
+    protected function force_login(&$page)
     {
         http_redirect(S::v('loginX'));
     }
index 0dd75aa..90fc62e 100644 (file)
 class XOrgPlugin
 {
     /** have to override, contents the fields names used to drive the plugin */
-    var $_get_vars = array();
+    public $_get_vars = array();
     /** some polymorphism at low cost, may be used, or not */
-    var $_callback;
+    public $_callback;
 
     /** constructor.
      * the constructor override $_get_vars settings by prefixing the names with $prefix
      */
-    function XOrgPlugin($funcname='', $prefix='')
+    public function __construct($funcname='', $prefix='')
     {
-       $this->_callback = $funcname;
-       $this->_prefix = $prefix;
-       foreach ($this->_get_vars as $key=>$val) {
+        $this->_callback = $funcname;
+        $this->_prefix = $prefix;
+        foreach ($this->_get_vars as $key=>$val) {
             $this->_get_vars[$key] = $prefix.$val;
         }
     }
 
     /** transparent access to $_GET, wrt the right $prefix
      */
-    function get_value($key)
+    public function get_value($key)
     {
         return Get::v($this->_prefix.$key);
     }
@@ -59,40 +59,40 @@ class XOrgPlugin
     /** construct an url with the given parameters to drive the plugin.
      * leave all other GET params alone
      */
-    function make_url($params)
+    public function make_url($params)
     {
-       $get = Array();
-       $args = isset($params) ? $params : Array();
+        $get = Array();
+        $args = isset($params) ? $params : Array();
 
-       if (!is_array($args)) {
+        if (!is_array($args)) {
             $args = array($this->_get_vars[0]=>$params);
-       }
+        }
 
-       foreach ($_GET as $key=>$val) {
+        foreach ($_GET as $key=>$val) {
             if ($key == 'n') {
                 continue;
             }
-           if (in_array($key, $this->_get_vars) && array_key_exists($key, $args)) {
+            if (in_array($key, $this->_get_vars) && array_key_exists($key, $args)) {
                 continue;
             }
-           $get[] = urlencode($key) . '=' . urlencode($val);
-       }
+            $get[] = urlencode($key) . '=' . urlencode($val);
+        }
 
-       foreach ($this->_get_vars as $key) {
-           if (array_key_exists($key, $args)) {
-               if ($args[$key]) {
+        foreach ($this->_get_vars as $key) {
+            if (array_key_exists($key, $args)) {
+                if ($args[$key]) {
                     $get[] = urlencode($key) . '=' . urlencode($args[$key]);
                 }
             } elseif (Get::has('key')) {
-               $get[] = urlencode($key) . '=' . urlencode(Get::v($key));
-           }
-       }
+                $get[] = urlencode($key) . '=' . urlencode(Get::v($key));
+            }
+        }
 
-       return pl_self() . '?' . join('&amp;', $get);
+        return pl_self() . '?' . join('&amp;', $get);
     }
 
     /** need to be overriden.  */
-    function show ()
+    public function show()
     {
         return '';
     }
index bec45bb..52d6905 100644 (file)
@@ -22,7 +22,7 @@
 require_once('xorg.misc.inc.php');
 require_once('user.func.inc.php');
 
-class VCardIterator
+class VCardIterator implements PlIterator
 {
     private $user_list = array();
     private $count     = 0;
index 2874af8..167693e 100644 (file)
 
 class XnetPage extends PlatalPage
 {
-    var $nomenu = false;
+    public $nomenu = false;
 
     // {{{ function XnetPage()
 
-    function XnetPage($tpl, $type=SKINNED)
+    public function __construct($tpl, $type=SKINNED)
     {
-        $this->PlatalPage($tpl, $type);
+        parent::__construct($tpl, $type);
 
         $this->register_function('list_all_my_groups', 'list_all_my_groups');
         $this->register_modifier('cat_pp', 'cat_pp');
@@ -41,7 +41,7 @@ class XnetPage extends PlatalPage
     // }}}
     // {{{ function run()
 
-    function run()
+    public function run()
     {
         if (!$this->nomenu) {
             $this->useMenu();
@@ -52,7 +52,7 @@ class XnetPage extends PlatalPage
     // }}}
     // {{{ function setType
 
-    function setType($type)
+    public function setType($type)
     {
         $this->assign('xnet_type', strtolower($type));
     }
@@ -60,7 +60,7 @@ class XnetPage extends PlatalPage
     // }}}
     // {{{ function useMenu
 
-    function useMenu()
+    private function useMenu()
     {
         global $globals;
 
index 207f137..5aea187 100644 (file)
@@ -29,12 +29,12 @@ XorgSession::init();
 
 class XorgPage extends PlatalPage
 {
-    function XorgPage($tpl, $type = SKINNED)
+    public function __construct($tpl, $type = SKINNED)
     {
-        $this->PlatalPage($tpl, $type);
+        parent::__construct($tpl, $type);
     }
 
-    function run()
+    public function run()
     {
         global $globals, $platal;
         $this->assign('globals', $globals);
@@ -48,24 +48,6 @@ class XorgPage extends PlatalPage
 }
 
 // }}}
-// {{{ class XorgAdmin
-
-/** Une classe pour les pages réservées aux admins (authentifiés!).
- */
-class XorgAdmin extends XorgPage
-{
-    // {{{ function XorgAdmin()
-
-    function XorgAdmin($tpl, $type = SKINNED)
-    {
-        $this->XorgPage($tpl, $type);
-        check_perms();
-    }
-
-    // }}}
-}
-
-// }}}
 
 function _new_page($type, $tpl_name, $admin=false)
 {