recreate 'trunk' from 'branches/diogenes-0.9.19'
authorJeremy Laine <jeremy.laine@m4x.org>
Thu, 20 Jul 2006 17:07:51 +0000 (17:07 +0000)
committerJeremy Laine <jeremy.laine@m4x.org>
Thu, 20 Jul 2006 17:07:51 +0000 (17:07 +0000)
33 files changed:
ChangeLog
Makefile
config/db/diogenes.sql
config/updatedb.php
debian/changelog
htdocs/toplevel/plugins.php
include/Barrel.php
include/Barrel/Events.php [deleted file]
include/Barrel/Menu.php [deleted file]
include/Barrel/Page.php
include/Plugin/Editor.php
include/Plugin/Filter.php [moved from include/Plugin/Skel/Filter.php with 97% similarity]
include/Plugin/Render.php [moved from include/Plugin/Skel/Render.php with 95% similarity]
include/Plugin/Skel.php
include/Plugins.php
include/Tree/Node.php [deleted file]
include/admin/index.php
include/admin/menus.php
include/admin/plugins.php
include/admin/rss.php [deleted file]
include/diogenes.barrel.inc.php
include/diogenes.compose.inc.php [deleted file]
plugins/FileList.php
plugins/HtmlHead.php
plugins/HttpHeader.php
plugins/LinksMagic.php
plugins/MailForm.php
plugins/RenderPhp.php
plugins/TextileMarkup.php
plugins/WikiMarkup.php
templates/admin-index.tpl
templates/admin-rss.tpl [deleted file]
templates/plugin-editor.tpl

index 5e98829..b369111 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,3 @@
-Diogenes 0.9.20
- * improved - overhaul of the plugin system
- * added - add RSS feeds describing public changes to barrels
-
 Diogenes 0.9.19.1
  * fixed - fix a warning when a barrel's menu is empty
 
index c0b9ad0..612b629 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # definitions
 
-VERSION = 0.9.20pre1
+VERSION = 0.9.19.1
 PKG_DIST = diogenes-$(VERSION)
 LIB_DIST = libdiogenes-$(VERSION)
 
index 6b5fd4c..dad6e88 100644 (file)
@@ -113,9 +113,10 @@ CREATE TABLE `diogenes_plugin` (
   `plugin` varchar(32) NOT NULL default '',
   `barrel` varchar(16) NOT NULL default '',
   `page` int(10) unsigned NOT NULL default '0',
+  `pos` int(10) unsigned NOT NULL default '0',
   `params` text NOT NULL,
-  `status` int(1) unsigned NOT NULL default '0',
-  PRIMARY KEY  (`plugin`,`barrel`,`page`)
+  PRIMARY KEY  (`plugin`,`barrel`,`page`),
+  KEY `pos` (`pos`)
 ) TYPE=MyISAM;
 
 -- --------------------------------------------------------
@@ -137,4 +138,4 @@ CREATE TABLE `diogenes_site` (
 -- Set the database format version
 --
 
-INSERT INTO `diogenes_option` SET name='dbversion', value='0.9.20';
+INSERT INTO `diogenes_option` SET name='dbversion', value='0.9.16+0.9.17pre21';
index 56c4803..3012f23 100755 (executable)
@@ -13,7 +13,7 @@ require_once("diogenes/diogenes.database-creator.inc.php");
 class DiogenesDbInit extends DiogenesDatabaseCreator
 {
   /** database versions history */
-  var $versions = array("0.9.9.3", "0.9.10", "0.9.12", "0.9.15", "0.9.16", "0.9.16+0.9.17pre15", "0.9.16+0.9.17pre19", "0.9.16+0.9.17pre21", "0.9.20");
+  var $versions = array("0.9.9.3", "0.9.10", "0.9.12", "0.9.15", "0.9.16", "0.9.16+0.9.17pre15", "0.9.16+0.9.17pre19", "0.9.16+0.9.17pre21");
 
   /**
    * Upgrades the database from one version to the next
@@ -38,7 +38,6 @@ class DiogenesDbInit extends DiogenesDatabaseCreator
     // upgrade master tables
     $this->info("* Upgrading master tables : diogenes_*");
     $this->upgradeMaster($newversion);
-    exit(1);
   }
 
   
@@ -214,15 +213,6 @@ class DiogenesDbInit extends DiogenesDatabaseCreator
       $this->dbh->query("INSERT INTO diogenes_logactions VALUES (16, 'page_plugins', 'the page plugins were modified');");
       break;
 
-    case "0.9.20":
-      $this->info(" - adding 'status' field to 'diogenes_plugin' table");
-      $this->dbh->query("ALTER TABLE `diogenes_plugin` ADD `status` INT( 1 ) UNSIGNED NOT NULL default '0'");
-      $this->dbh->query("update diogenes_plugin set status=0 where page=0");
-      $this->dbh->query("update diogenes_plugin set status=1 where page!=0");
-      $this->info(" - removing 'pos' field to 'diogenes_plugin' table");
-      $this->dbh->query("ALTER TABLE `diogenes_plugin` DROP `pos`");
-      break;
-    
     default:
       $this->info(" - no changes needed.");
       break;
index 74f4529..6c06799 100644 (file)
@@ -1,3 +1,9 @@
+diogenes (0.9.19.1-1) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Jeremy LainĂ© <jeremy.laine@m4x.org>  Thu, 20 Jul 2006 07:09:33 +0200
+
 diogenes (0.9.19-1) unstable; urgency=low
 
   * New upstream release.
index e449f16..c874d4d 100644 (file)
@@ -23,9 +23,26 @@ if ($barrel)
 
 /* plugin editor */
 $editor = new Diogenes_Plugin_Editor($barrel, 0);
-$editor->set_mode(MODE_ROOT);
+$editor->hide_params(1);
 $editor->run($page,'editor_content');
 
+// if necessary, rebuild site plugin caches
+if ($action == "update" && !$barrel)
+{
+  $res = $globals->db->query("select alias,flags from diogenes_site");
+  while (list($p_alias, $p_flags) = mysql_fetch_row($res))
+  {
+    $flags = new flagset($p_flags);
+    if ($p_alias && $flags->hasFlag('plug')) 
+    {
+      $page->info(sprintf( __("Rebuilding plugin cache for barrel '%s'"), $p_alias));
+      $cachefile = $globals->plugins->cacheFile($p_alias);
+      $globals->plugins->compileCache($cachefile, $p_alias);
+    }
+  }
+  mysql_free_result($res);
+}
+
 // translations
 $page->assign('msg_clean_database', __('Clean plugins database'));
 $page->assign('msg_clean_database_text', __("If you are having problems with references to plugins that no longer exist, you can have Diogenes remove such entries from the database."));
index aab8e3f..cc41014 100644 (file)
@@ -21,7 +21,6 @@
 require_once 'Barrel/Page.php';
 require_once 'Barrel/Options.php';
 require_once 'diogenes/diogenes.flagset.inc.php';
-require_once 'Plugin/Skel.php';
  
 
 /** This class describes a Diogenes Barrel.
@@ -245,6 +244,24 @@ class Diogenes_Barrel
   }
   
   
+  /** List the plugins that are active in a given context
+   *
+   * @param $page   
+   */
+  function getPlugins($page = 0)
+  {
+    $plugins = array();
+    foreach ($this->pluginsCache as $plug)
+    {
+      if ($plug['page'] == $page) 
+      {
+        array_push($plugins, $plug);
+      }
+    }
+    return $plugins;    
+  }
+
+  
   /** Check whether the barrel has a given flag
    *
    * @param $flag
@@ -309,7 +326,7 @@ class Diogenes_Barrel
   }
 
   
-  /** Load all active plugins for the specified page.
+  /** Load all plugins for the specified page.
    *
    * @param $bpage
    */
@@ -317,11 +334,12 @@ class Diogenes_Barrel
   {
     global $globals;
   
-    $plugins = $globals->plugins->cacheGetActive($this->pluginsCache, $this->alias, $page);
+    $plugins = $this->getPlugins($bpage->props['PID']);
+    
     $loaded = array();
-    foreach ($plugins as $plugname => $plugentry) 
+    foreach ($plugins as $plugentry) 
     {
-      $loaded[$plugname] =& $globals->plugins->load($plugname, $plugentry);
+      $loaded[$plugentry['plugin']] =& $globals->plugins->load($plugentry);
     }
     return $loaded;
   }
diff --git a/include/Barrel/Events.php b/include/Barrel/Events.php
deleted file mode 100644 (file)
index 5a20fed..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-<?php
-/*
- * Copyright (C) 2003-2006 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
- */
-
-define('EVENT_FLAG_NONE', 0);
-define('EVENT_FLAG_PUBLIC', 1);
-
-/** This class is used to generate the menu of a Diogenes barrel page.
- */
-class Diogenes_Barrel_Events
-{
-  /** The barrel we are watching */
-  var $barrel;
-
-  /** Constructor.
-   */
-  function Diogenes_Barrel_Events(&$barrel)
-  {
-    $this->barrel = $barrel;
-  }
-
-
-  /** Filename transformations.
-   */
-  function makeFileLoc($log_file, &$caller)
-  {
-    $homepage = $this->barrel->getPID('');
-    if (stristr($log_file, '/') == FALSE ) {
-      // this is a directory
-      $mydir = $log_file;
-      $myfile = '';
-    } else {
-      $myfile = basename($log_file);
-      $mydir = dirname($log_file);
-    }
-
-    $myloc = $this->barrel->getLocation($mydir);
-    if ($myloc or ($mydir == $homepage))
-    {
-      $log_file = $myloc ? "$myloc/$myfile" : $myfile;
-      $url_loc = $myloc ? "$myloc/" : '';
-      $link = $caller->urlBarrel($this->barrel->alias, $this->barrel->vhost, $url_loc);
-    } else {
-      $link = '';
-    }
-  
-    return array($log_file, $mydir, $myfile, $link);
-  }
-
-  /** Retrieve recent events.
-   */
-  function getEvents($caller)
-  {
-    global $globals;
-    $events = array();
-    $res = $globals->db->query("select e.action,e.stamp,e.data,a.text,s.auth,s.uid "
-                  ."from {$globals->table_log_events} as e "
-                  ."left join {$globals->table_log_actions} as a on e.action=a.id "
-                  ."left join {$globals->table_log_sessions} as s on e.session=s.id "
-                  ."where e.data like '{$this->barrel->alias}:%' "
-                  ."order by stamp desc limit 0,10");
-    while ($myarr = mysql_fetch_array($res)) {
-      $myarr['author'] = call_user_func(array($globals->session,'getUsername'),$myarr['auth'],$myarr['uid']);
-      $myarr['flags'] = EVENT_FLAG_NONE;
-      list($op_alias, $op_file) = split(":",$myarr['data']);
-
-      switch($myarr['text']) {
-      case "barrel_create":
-        $myarr['title'] = __("site created");
-        $myarr['icon'] = $globals->icons->get_action_icon('add');    
-        break;
-    
-      case "barrel_options":
-        $myarr['title'] = __("barrel options");
-        $myarr['icon'] = $globals->icons->get_action_icon('properties');    
-        break;
-  
-      case "barrel_plugins":
-        $myarr['title'] = __("barrel plugins");
-        $myarr['icon'] = $globals->icons->get_action_icon('plugins');
-       $myarr['link_admin'] = "plugins";
-        break;
-        
-      case "page_create":
-        $myarr['title'] = __("page created");
-        $myarr['icon'] = $globals->icons->get_action_icon('add');    
-        list($op_file, $myarr['dir'], $myarr['file'], $myarr['link']) = $this->makeFileLoc($op_file, $caller);
-        $myarr['link_admin'] = "pages?dir={$myarr['dir']}";
-        $myarr['flags'] |= EVENT_FLAG_PUBLIC;
-        break;
-
-      case "page_delete":
-        $myarr['title'] = __("page removed");
-        $myarr['icon'] = $globals->icons->get_action_icon('remove');
-        break;
-    
-      case "page_props":
-        $myarr['title'] = __("page properties");
-        $myarr['icon'] = $globals->icons->get_action_icon('properties');
-        list($op_file, $myarr['dir'], $myarr['file']) = $this->makeFileLoc($op_file, $caller);
-        $myarr['link_admin'] = "pages?dir={$myarr['dir']}";
-        break;
-  
-      case "page_plugins":
-        $myarr['title'] = __("page plugins");
-        $myarr['icon'] = $globals->icons->get_action_icon('plugins');
-        list($op_file, $myarr['dir'], $myarr['file']) = $this->makeFileLoc($op_file, $caller);
-        $myarr['link_admin'] = "plugins?plug_page={$myarr['dir']}";
-        break;
-
-      case "rcs_commit": 
-        $myarr['title'] = __("file updated");
-        $myarr['icon'] = $globals->icons->get_action_icon('update');    
-        list($op_file, $myarr['dir'], $myarr['file'], $myarr['link']) = $this->makeFileLoc($op_file, $caller);  
-        $myarr['link_admin'] = "files?action=revs&amp;dir={$myarr['dir']}&amp;target={$myarr['file']}";
-        $myarr['flags'] |= EVENT_FLAG_PUBLIC;
-
-        break;
-      
-      case "rcs_delete":
-        $myarr['title'] = __("file deleted");        
-        $myarr['icon'] = $globals->icons->get_action_icon('delete');    
-        list($op_file, $myarr['dir'], $myarr['file']) = $this->makeFileLoc($op_file, $caller);    
-        break;
-      }
-      $myarr['opfile'] = $op_file;
-      if (isset($myarr['title']))
-        array_push($events, $myarr);
-    }
-    mysql_free_result($res);
-    return $events;
-  }
-}
-
-?>
diff --git a/include/Barrel/Menu.php b/include/Barrel/Menu.php
deleted file mode 100644 (file)
index e5279c9..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-<?php
-/*
- * Copyright (C) 2003-2005 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
- */
-
-
-/** This class is used to generate the menu of a Diogenes barrel page.
- */
-class Diogenes_Barrel_Menu
-{
-  /** Database handle */
-  var $dbh;
-  
-  /** The database table holding the menus */
-  var $table_menu;
-
-  /** Constructs a Smarty-derived object to display contents within a barrel.
-   *
-   * @param $override_pathinfo 
-   */
-  function Diogenes_Barrel_Menu(&$dbh, $table_menu)
-  {
-    $this->dbh =& $dbh;
-    $this->table_menu = $table_menu;
-  }
-
-  /** Delete the specified entry.
-   *
-   * @param $MID
-   * @param $parent
-   * @param $caller
-   */
-  function deleteEntry($MID, $parent, &$caller)
-  {
-    if (mysql_num_rows($this->dbh->query("SELECT MID FROM {$this->table_menu} WHERE MIDpere=$MID")) > 0) {
-      $caller->info(__("The selected menu has child items, please remove them first."));
-      return;
-    }
-
-    /* erase the current entry */
-    $this->dbh->query("DELETE FROM {$this->table_menu} WHERE MID=$MID");
-
-    /* renumber the other menu entries so that they are between 1 and the number of entries */
-    $res = $this->dbh->query("SELECT MID FROM {$this->table_menu} WHERE MIDpere=$parent ORDER BY ordre");
-    $i = 0;
-    while (list($MIDtoorder) = mysql_fetch_array($res)) {
-      $i++;
-      $this->dbh->query("UPDATE {$this->table_menu} SET ordre=$i WHERE MID=$MIDtoorder");
-    }
-    mysql_free_result($res);
-  }
-
-
-  /** Build the user-defined part of the menu.
-   *
-   * @param $PID
-   * @param $pid_to_url
-   */
-  function makeMenu($PID, $min_level, $pid_to_url)
-  {
-    // all menu entries from database
-    $mcache = $this->menuRead();
-
-    // try to figure out the current MID from the current PID
-    // and build filiation
-    $filiation = array();
-    foreach ($mcache as $mid => $mentry)
-    {
-      if ($mentry['pid'] == $PID)
-        $filiation = $this->menuToRoot($mcache, $mid, $filiation);
-    }
-
-    $menu = $this->menuRecurse($mcache, 0, $filiation, 0, $min_level, $pid_to_url);
-
-    return $menu;
-  }
-
-
-  /** Return the maximum index for children of a given entry.
-   *
-   * @param $parent
-   */
-   function maxChildIndex($parent)
-   {
-      $res=$this->dbh->query("SELECT MAX(ordre) from {$this->table_menu} where MIDpere=$parent");
-      list($maxOrdre)=mysql_fetch_row($res);
-      mysql_free_result($res);
-      return $maxOrdre;
-   }
-
-
-  /** Return the filiation to get to the root element.
-   *
-   * @param mcache
-   * @param MID
-   * @param path
-   */
-  function menuToRoot($mcache, $MID, $path) {
-    /* add ourself to the path */
-    array_push($path,$MID);
-
-    if ($MID) {
-      /* recursion */
-      return $this->menuToRoot($mcache, $mcache[$MID]['parent'], $path);
-    } else {
-      /* termination */
-      return $path;
-    }
-  }
-
-
-  /** Recursively add menu entries
-   *
-   * @param mcache
-   * @param MIDpere
-   * @param filiation
-   * @param level
-   * @param min_level
-   * @param pid_to_url
-   */
-  function menuRecurse($mcache, $MIDpere, $filiation, $level, $min_level, $pid_to_url) {
-    // the produced output
-    $out = array();
-
-    foreach ($mcache[$MIDpere]['children'] as $mid)
-    {
-      $mentry = $mcache[$mid];
-//      echo "pid : $pid, location : $location<br/>";
-      $entry = htmlentities(stripslashes($mentry['title']), ENT_QUOTES);
-      if ($mentry['pid'])
-      {
-        $link = call_user_func($pid_to_url, $mentry['pid']);
-      } else {
-        $link = $mentry['link'];
-      }
-      // decide whether this menu should be expanded
-      $expanded = ($min_level == 0) || 
-                  ($level+1 < $min_level) || 
-                   in_array($mid, $filiation);
-      array_push($out, array($level, $entry, $link, $expanded));
-      $out = array_merge($out, $this->menuRecurse($mcache, $mid, $filiation, $level+1, $min_level, $pid_to_url));
-    }
-
-    return $out;
-  }
-
-
-  /** Read this barrel's menu entries from database.
-   */
-  function menuRead()
-  {
-    $menu = array();
-    $menu[0]['children'] = array();
-    $res = $this->dbh->query("select MID,MIDpere,title,link,PID,ordre from {$this->table_menu} order by ordre");
-    while (list($mid, $parent, $title, $link, $pid, $ordre) = mysql_fetch_row($res))
-    {
-      $menu[$mid]['parent'] = $parent;
-      $menu[$mid]['title'] = $title;
-      $menu[$mid]['link'] = $link;
-      $menu[$mid]['title'] = $title;
-      $menu[$mid]['pid'] = $pid;
-      $menu[$mid]['ordre'] = $ordre;
-      if (!is_array($menu[$mid]['children']))
-        $menu[$mid]['children'] = array();
-
-      // register this entry with its parent
-      if (!is_array($menu[$parent]['children']))
-        $menu[$parent]['children'] = array();
-      array_push($menu[$parent]['children'], $mid);
-    }
-    mysql_free_result($res);
-    return $menu;
-  }
-
-
-  /**
-   * Swap entries $a and $b within $parent.
-   *
-   * @param $parent
-   * @param $a
-   * @param $b
-   */
-  function swapEntries($parent, $a, $b)
-  {
-    $res = $this->dbh->query("SELECT MID from {$this->table_menu} where MIDpere=$parent and (ordre=$a or ordre=$b) ORDER BY ordre");
-    /* make sure that $a <= $b */
-    if ($a > $b)
-    {
-      $c = $a;
-      $a = $b;
-      $b = $c;
-    }
-    /* perform swap */
-    list($MIDa) = mysql_fetch_row($res);
-    list($MIDb) = mysql_fetch_row($res);
-    mysql_free_result($res);
-
-    $this->dbh->query("UPDATE {$this->table_menu} SET ordre=$b WHERE MID=$MIDa");
-    $this->dbh->query("UPDATE {$this->table_menu} SET ordre=$a WHERE MID=$MIDb");
-  }
-
-
-  /**
-   * Write an entry to database. If $mid is 0, a new entry is created.
-   *
-   * @param $mid
-   * @param $props
-   */
-  function writeEntry($mid, $props)
-  {
-    if ($mid == 0) {
-      $props['ordre'] = $this->maxChildIndex($props['parent']) + 1;
-    }
-
-    // build SQL string
-    $nprops = array('parent' => 'MIDpere', 'ordre' => 'ordre', 'title' => 'title', 'link' => 'link', 'pid' => 'pid');
-    $sprops = "";
-    foreach($nprops as $prop => $dbkey)
-    {
-      if (isset($props[$prop]))
-      {
-        $val = $props[$prop];
-        $sprops .= "$dbkey='$val', ";
-      }
-    }
-    if (!$sprops)
-      return;
-    $sprops = substr($sprops, 0, -2);
-    if ($mid == 0) {
-      $this->dbh->query("INSERT INTO {$this->table_menu} SET $sprops");
-      $mid = mysql_insert_id();
-    } else {
-      $this->dbh->query("UPDATE {$this->table_menu} SET $sprops WHERE MID=$mid");
-    }
-    return $mid;
-  }
-
-}
-
-?>
index baa9fcc..d680bc4 100644 (file)
@@ -216,7 +216,7 @@ class Diogenes_Barrel_Page
     if ($props['PID'])
     {
       $cache = $globals->plugins->readCache($this->barrel->pluginsCacheFile, $this->barrel->alias);
-      $plugs_active = $globals->plugins->cacheGetActive($cache, $this->barrel->alias, $props['PID']);
+      $plugs_active = $globals->plugins->cachedActive($cache, $this->barrel->alias, $props['PID']);
       foreach($plugs_active as $plugentry)
       {
         $plug_h = $globals->plugins->load($plugentry);
index 22994db..9de3b2f 100644 (file)
 // dependency on PEAR
 require_once 'System.php';
 
-define('MODE_NORMAL', 0);
-define('MODE_ROOT', 1);
-define('MODE_READONLY', 2);
-define('MODE_NOPARAMS', 4);
 
 /** This class provides a configuration tool for Diogenes plugins. 
  */
 class Diogenes_Plugin_Editor {
+  /** Should we show plugins parameters? */
+  var $show_params = 1;
+  
+  /** Should editing functions be disabled? */
+  var $readonly = false;
+
   /** The alias of the barrel we are working on. */
   var $plug_barrel;
 
@@ -37,9 +39,6 @@ class Diogenes_Plugin_Editor {
       
   /** The write permissions of the page we are working on. */
   var $plug_page_wperms;
-
-  /** The plugin editor mode */
-  var $mode = MODE_NORMAL;
   
   /** Construct a new plugin editor.
    *
@@ -53,8 +52,8 @@ class Diogenes_Plugin_Editor {
     $this->plug_page = $plug_page;
     $this->plug_page_wperms = $plug_page_wperms;
   }
-
-
+  
+  
   /** Run the plugin editor.
    *
    * @param $page
@@ -63,179 +62,229 @@ class Diogenes_Plugin_Editor {
   function run(&$page, $outputvar = '')
   {
     global $globals;
-
+    
     $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';    
     $target = isset($_REQUEST['plug_target']) ? $_REQUEST['plug_target'] : '';
-
-    // if the tree cache does not exits try to init it
+         
+    // load all available plugins
     $cachefile = $globals->plugins->cacheFile($this->plug_barrel);
-    if(!file_exists($cachefile))
-    {
-      $globals->plugins->compileCache($this->plug_barrel, $page);
-    }
+    
+    // if the tree cache does not exits, try to init it
+    if (!file_exists($cachefile)) {
+      $globals->plugins->compileCache($cachefile, $this->plug_barrel);
+    }        
     $cache = $globals->plugins->readCache($cachefile, $this->plug_barrel);
-    $available = $globals->plugins->cacheGetVisible($cache, $this->plug_barrel, $this->plug_page);
-
+    $available = $globals->plugins->cachedAvailable($cache, $this->plug_barrel, $this->plug_page);
+           
+    
     // handle updates
-    $rebuild_cache = 0;
     switch ($action) {
+    case "move_up": case "move_down":
+      if ($this->readonly) die("Sorry, this plugin view is read-only.");
+      
+      $delta = ($action == "move_down") ? 1 : -1;
+      //$page->info("moving plugin '$target'..");
+      $plugcache_a = $globals->plugins->cacheGet($cache, $this->plug_barrel, $this->plug_page, $target);
+      $plug_a =& $globals->plugins->load($plugcache_a);
+      //$plug_a =& $globals->plugins->get($target);
+      
+      if (is_object($plug_a) && ($plug_a->active)) {
+        $old_pos = $plug_a->pos;
+        //$plug_b =& $globals->plugins->getAtPos($old_pos + $delta);        
+        $plugcache_b = $globals->plugins->cacheGetAtPos($cache, $this->plug_barrel, $this->plug_page, $old_pos + $delta);
+        
+        if (is_array($plugcache_b))
+        {
+          $plug_b =& $globals->plugins->load($plugcache_b);
+  
+          // swap the current plugin and the next plugin
+          if (is_object($plug_b) && ($plug_b->active)) 
+          {
+            $plug_a->writeParams($this->plug_barrel, $this->plug_page, $old_pos + $delta);        
+            $plug_b->writeParams($this->plug_barrel, $this->plug_page, $old_pos);
+          }        
+        }
+      }     
+      $globals->plugins->compileCache($cachefile, $this->plug_barrel);
+      $cache = $globals->plugins->readCache($cachefile, $this->plug_barrel);  
+      $available = $globals->plugins->cachedAvailable($cache, $this->plug_barrel, $this->plug_page);       
+      break;
+      
     case "update":
-      if ($this->mode & MODE_READONLY) die("Sorry, this plugin view is read-only.");
-      foreach ($available as $plugin => $plugentry)
-      {
+      if ($this->readonly) die("Sorry, this plugin view is read-only.");
+    
+      // list of active plugins
+      $active = array();
+      if (isset($_REQUEST['plugins_active'])) {
+        $active = array_values($_REQUEST['plugins_active']);
+      }
+      
+      foreach ($available as $plugin) {  
+        $plugentry =& $globals->plugins->cacheGet($cache, $this->plug_barrel, $this->plug_page, $plugin);
+        if (!is_array($plugentry) and $this->plug_page) {
+          $plugentry = $globals->plugins->cacheGet($cache, $this->plug_barrel, 0, $plugin);
+          if (is_array($plugentry))
+          {
+            $plugentry['active'] = 0;
+          }
+        }
+        
         // check we have a valid cache entry
         if (!is_array($plugentry)) {
-          $page->info("could not find plugin '$plugin' in cache for barrel '{$this->plug_barrel}'");
+          $page->info("could not find plugin '$plugin' in cache for barrel '{$this->plug_barrel}'");          
           return;
         }
-
-        $plug_h =& $globals->plugins->load($plugin, $plugentry);
-        if (!is_object($plug_h)) {
-          $page->info("could not load plugin '$plugin' in cache for barrel '{$this->plug_barrel}'");
-          return;
-        }
-
-        if ($pos !== false) {
-          // check the plugin is allowed in the current context
-          if ($this->plug_barrel and $this->plug_page) {
-            $wperms = $this->plug_page_wperms;
-
-            // $page->info("checking plugin '$plugin' vs. write permissions '$wperms'..");
-            if (!$plug_h->allow_wperms($wperms))
-            {
-              $page->info("plugin '$plugin' is not allowed with write permissions '$wperms'!");
-              break;
+        
+        $plug_h =& $globals->plugins->load($plugentry);
+        
+        if (is_object($plug_h) && is_array($plugentry)) {
+          $pos = array_search($plugin, $active);
+          
+          if ($pos !== false) {
+            // check the plugin is allowed in the current context
+            if ($this->plug_barrel and $this->plug_page) {
+              $wperms = $this->plug_page_wperms;
+              
+              // $page->info("checking plugin '$plugin' vs. write permissions '$wperms'..");
+              if (!$plug_h->allow_wperms($wperms))
+              {
+                $page->info("plugin '$plugin' is not allowed with write permissions '$wperms'!");
+                break;
+              }             
             }
-          }
-
-          // retrieve parameters from REQUEST
-          if (isset($_REQUEST[$plug_h->name."_status"])) 
-          {
-            $plug_h->status = $_REQUEST[$plug_h->name."_status"];
-          }
-          foreach ($plug_h->getParamNames() as $key)
-          {
-            if (isset($_REQUEST[$plug_h->name."_".$key])) {
-              $plug_h->setParamValue($key, $_REQUEST[$plug_h->name."_".$key]);
+            
+            // retrieve parameters from REQUEST
+            foreach ($plug_h->params as $key => $val)
+            {
+              if (isset($_REQUEST[$plug_h->name."_".$key])) {
+                $plug_h->params[$key] = $_REQUEST[$plug_h->name."_".$key];              
+              }
             }
-          }
-
-          // write parameters to database
-          if ($plug_h->status & PLUG_SET)
-          {
-            $plug_h->toDatabase($this->plug_barrel, $this->plug_page, $pos);
-          } else {
-            $plug_h->eraseParameters($this->plug_barrel, $his->plug_page);
-          }
-          $rebuild_cache = 1;
+            
+            // write parameters to database
+            $plug_h->writeParams($this->plug_barrel, $this->plug_page, $pos);
+          } else {        
+            // erase parameters from database
+            $plug_h->eraseParams($this->plug_barrel, $this->plug_page);          
+          }        
         }
       }
-      break;
-    }
-
-    // if necessary, rebuild the plugin cache
-    if ($rebuild_cache)
-    {
+      
       // log this action
       if ($this->plug_barrel)
       { 
         if ($this->plug_page)
         {
-          $page->log('page_plugins', $this->plug_barrel.":".$this->plug_page);
+          $page->log('page_plugins', $this->plug_barrel.":".$this->plug_page);        
         } else {
-          $page->log('barrel_plugins', $this->plug_barrel.":*");
+          $page->log('barrel_plugins', $this->plug_barrel.":*");        
         }
       }
-      // rebuild plugin cache
-      $globals->plugins->compileCache($this->plug_barrel, $page);
-      $cache = $globals->plugins->readCache($cachefile, $this->plug_barrel);
-      $available = $globals->plugins->cacheGetVisible($cache, $this->plug_barrel, $this->plug_page);
+      
+      $globals->plugins->compileCache($cachefile, $this->plug_barrel);
+      $cache = $globals->plugins->readCache($cachefile, $this->plug_barrel);  
+      $available = $globals->plugins->cachedAvailable($cache, $this->plug_barrel, $this->plug_page);    
+      break;
     }
     
     // get dump of plugins to fill out form
     $page->assign('plug_barrel', $this->plug_barrel);
     $page->assign('plug_page', $this->plug_page);
-    $ro_plugs = array();
-    $rw_plugs_on = array();
-    $rw_plugs_off = array();
     
-    /* run over the plugins and split plugins into the following categories:
-     *  - read-only,
-     *  - read-write/active 
-     *  - read-write/inactive
-     */
-    foreach ($available as $plugname => $plugcache)
+    $plugs = array();
+    
+    // start by adding the active plugins
+    foreach ($cache as $plugcache)
     {
-      $plugentry = $plugcache;
-      $plugentry['icon'] = $globals->icons->get_action_icon('plugins');
-      $type = $plugentry['type'];
-
-      // FIXME : the test below needs to be refined
-      if (!($this->mode & MODE_ROOT) && ($plugentry['status'] & PLUG_LOCK))
+      if (in_array($plugcache['plugin'], $available) and ($plugcache['page'] == $this->plug_page) and ($plugcache['active']))
       {
-        $o_plugs =& $ro_plugs;
-        $plugentry['readonly'] = 1;
-      } else {
-        if ($plugentry['status'] & PLUG_ACTIVE)
-          $o_plugs =& $rw_plugs_on;
-        else 
-          $o_plugs =& $rw_plugs_off;
-      }
+        // check we have a valid plugin handle
+        $plug_h = $globals->plugins->load($plugcache);
+        if (!is_object($plug_h)) {
 
-      if (empty($o_plugs[$type])) {
-        $o_plugs[$type] = array();
-      }
-      array_push($o_plugs[$type], $plugentry);
-    }
+          $page->info("could not load disabled plugin '{$plugcache['plugin']}' in barrel '{$this->plug_barrel}'"); 
 
-    // merge the different plugin categories into a global list
-    $plugs = array_merge_recursive($rw_plugs_on, $rw_plugs_off);
-    $plugs = array_merge_recursive($plugs, $ro_plugs);
-    $page->assign('plugins', $plugs);
+        } else {
+                
+          $plugentry = $plug_h->dump();
+          $plugentry['icon'] = $globals->icons->get_action_icon('plugins');            
+          $type = $plugentry['type'];        
+          if (!empty($plugs[$type])) {
+            $plugentry['move_up'] = 1;
+            $last = count($plugs[$type]) - 1;
+            $plugs[$type][$last]['move_down'] = 1;              
+          } else {
+            $plugs[$type] = array();      
+          }                
+          array_push($plugs[$type], $plugentry);
 
-    // debugging
-    foreach ($plugs as $p_type => $p_entries)
+       }
+      }    
+    }
+    
+    // next we add the disabled plugins
+    if (!$this->readonly)
     {
-      $globals->plugins->log = array_merge($globals->plugins->log, $p_entries);
+      foreach ($available as $plugname)
+      {
+        $plugcache = $globals->plugins->cacheGet($cache, $this->plug_barrel, $this->plug_page, $plugname);
+        if (!is_array($plugcache) or !$plugcache['active'])
+        {
+          $plugcache = $globals->plugins->cacheGet($cache, $this->plug_barrel, 0, $plugname);
+          $plugcache['active'] = 0;        
+          $plug_h = $globals->plugins->load($plugcache);
+          if (!is_object($plug_h)) {
+            $page->info("could not load disabled plugin '$plugname' in barrel '{$this->plug_barrel}'"); 
+            return;
+          }
+                    
+          $plugentry = $plug_h->dump();        
+          $plugentry['icon'] = $globals->icons->get_action_icon('plugins');                        
+          $type = $plugentry['type'];          
+          if (empty($plugs[$type])) {
+            $plugs[$type] = array();
+          }
+          array_push($plugs[$type], $plugentry);
+        }
+      }
     }
-
+    
+    /*
+    echo "plugins <pre>";
+    print_r($plugs);
+    echo "</pre>";
+    */
+    $page->assign('plugins', $plugs);
+    
     // values
-    $page->assign('show_params', !($this->mode & MODE_NOPARAMS));
-    $page->assign('readonly', ($this->mode & MODE_READONLY));
-    $statusvals = array(
-        PLUG_DISABLED => 'default',
-        PLUG_SET | PLUG_DISABLED => 'off',
-        PLUG_SET | PLUG_ACTIVE => 'on',
-        PLUG_SET | PLUG_DISABLED | PLUG_LOCK => 'off (lock)',
-        PLUG_SET | PLUG_ACTIVE | PLUG_LOCK => 'on (lock)',
-    );
-    $rwstatusvals = $statusvals;
-    if (!($this->mode & MODE_ROOT)) {
-      unset($rwstatusvals[PLUG_SET | PLUG_DISABLED | PLUG_LOCK]);
-      unset($rwstatusvals[PLUG_SET | PLUG_ACTIVE | PLUG_LOCK]);
-    }
-    $page->assign('statusvals', $statusvals);
-    $page->assign('rwstatusvals', $rwstatusvals);
+    $page->assign('show_params', $this->show_params);
+    $page->assign('readonly',$this->readonly);
 
-    // translations
+    // translations    
     $page->assign('msg_submit', __("Submit"));
-    $page->assign('msg_plugedit_plugin', __("plugin"));
+    $page->assign('msg_plugedit_plugin', __("plugin"));    
     $page->assign('msg_plugedit_plugins', __("plugins"));
     $page->assign('msg_plugedit_description', __("description"));
     $page->assign('msg_plugedit_parameters', __("parameters"));
-
+    $page->assign('msg_move_up', __("move up"));
+    $page->assign('msg_move_down', __("move down"));
+    
     // if requested, assign the content to be displayed
     if (!empty($outputvar)) {
       $page->assign($outputvar, $page->fetch('plugin-editor.tpl'));
     }
   }
-
-  /** Set the editor mode.
+  
+  
+  /** Do not display plugin parameters.
+   *
+   * @param $hide boolean
    */
-  function set_mode($mode)
+  function hide_params($hide)
   {
-    $this->mode = $mode;
+    $this->show_params = !$hide;
   }
+  
 }
 
 ?>
similarity index 97%
rename from include/Plugin/Skel/Filter.php
rename to include/Plugin/Filter.php
index 9a8fe4b..d9cdf50 100644 (file)
@@ -23,7 +23,7 @@ require_once 'Plugin/Skel.php';
 
 /** This class describes a Diogenes filter plugin. 
  */
-class Diogenes_Plugin_Skel_Filter extends Diogenes_Plugin_Skel
+class Diogenes_Plugin_Filter extends Diogenes_Plugin_Skel
 {
   /** Plugin name */
   var $name = "Plugin_Filter";
similarity index 95%
rename from include/Plugin/Skel/Render.php
rename to include/Plugin/Render.php
index 1ce6b76..0165f8d 100644 (file)
@@ -23,7 +23,7 @@ require_once 'Plugin/Skel.php';
 
 /** This class describes a Diogenes rendering plugin. 
  */
-class Diogenes_Plugin_Skel_Render extends Diogenes_Plugin_Skel
+class Diogenes_Plugin_Render extends Diogenes_Plugin_Skel
 {
   var $name = "Plugin_Render";
   var $description = "Rendering plugin skeleton";
index 19c58a8..093000d 100644 (file)
 
 // dependency on PEAR
 require_once 'System.php';
-require_once 'Tree/Node.php';
-
-define('PLUG_DISABLED', 0);
-define('PLUG_ACTIVE', 1);
-define('PLUG_LOCK', 2);
-define('PLUG_SET', 4);
 
 /** Recursive stripslashes.
  *
@@ -44,7 +38,7 @@ function stripslashes_recurse($value)
  */
 class Diogenes_Plugin_Skel {
   /** Plugin type (object, filter) */
-  var $type = '';
+  var $type;
   
   /** Array of plugin parameters */
   var $params = array();
@@ -59,11 +53,12 @@ class Diogenes_Plugin_Skel {
   var $version = "0.1";
 
   /** Position of the plugin */
-  var $pos = 0;
+  var $pos;
+  
+  /** Is the plugin active ? */
+  var $active = 0;
+  
   
-  /** The plugin status (disabled, available, active) */
-  var $status = PLUG_DISABLED;
   /** Is the plugin allowed with respect to a given write permission on a page ?
    *
    * @param $wperms
@@ -72,107 +67,89 @@ class Diogenes_Plugin_Skel {
   {
     return ($wperms != 'public');
   }
+   
 
-
-  /** Declare a plugin parameter.
-   */
-  function declareParam($key, $val)
-  {
-    $this->params[$key]['value'] = $val;
-  }
-
-
-  /** Return an array of parameter names.
-   */
-  function getParamNames()
-  {
-    return array_keys($this->params);
-  }
-
-
-  /** Return the value of a parameter of the plugin.
-   */
-  function getParamValue($key)
-  {
-    return isset($this->params[$key]['value']) ? $this->params[$key]['value'] : '';
-  }
-
-
-  /** Set the value of a parameter of the plugin.
+  /** Set plugin parameters.
+   *
+   * @param $params
    */
-  function setParamValue($key, $val)
+  function setParams($params)
   {
-    if (isset($this->params[$key]['value'])) {
-      $this->params[$key]['value'] = $val; 
+    $bits = explode("\0", $params);      
+    foreach ($bits as $bit)
+    {
+      $frags = explode("=", $bit, 2);
+      $key = $frags[0];
+      $val = isset($frags[1]) ? $frags[1] : '';
+      if (isset($this->params[$key])) {
+        $this->params[$key] = $val;
+      }
     }
   }
-
-
+  
+  
   /** Erase parameters from database.
    *
    * @param $barrel
    * @param $page
    */
-  function eraseParameters($barrel = '', $page = 0)
+  function eraseParams($barrel = '', $page = 0)
   {
     global $globals;
-    //echo $this->name . " : eraseParams($barrel, $page)<br/>\n";
+    
+    //echo $this->name . " : deleteParams($barrel, $page)<br/>\n";
     $globals->db->query("delete from diogenes_plugin where plugin='{$this->name}' and barrel='$barrel' and page='$page'");
-
+    
+    $this->active = 0;
     unset($this->pos);
-    foreach ($this->getParamNames() as $key)
+    foreach ($this->params as $key => $val)
     {
-      //echo "$this->name : erasing param<br/>\n";
-      $this->setParamValue($key, '');
+      $this->params[$key] = '';
     }
   }
-
-
-  /** Read parameters from an array.
-    */
-  function fromArray($plugentry)
-  {
-      $this->pos = $plugentry['pos'];
-      $this->status = $plugentry['status'];
-      foreach ($plugentry['params'] as $key => $val)
-      {
-        $this->setParamValue($key, $val['value']);
-      }
-  }
-
-
+   
+    
   /** Store parameters to database.
    *
    * @param $barrel
    * @param $page
-   * @param $pos
+   * @param $pos   
    */
-  function toDatabase($barrel = '', $page = 0, $pos = 0)
+  function writeParams($barrel = '', $page = 0, $pos = 0)
   {
     global $globals;
 
     $this->pos = $pos;
-    $params = var_encode_bin($this->params);
-    //echo "toDatabase called for '{$this->name}' in barrel '$barrel' (status : {$this->status}, params : '$params')<br/>";
-    $globals->db->query("replace into diogenes_plugin set plugin='{$this->name}', status='{$this->status}', barrel='$barrel', page='$page', pos='$pos', params='$params'");
+    $this->active = 1;
+    
+    $params = '';
+    foreach ($this->params as $key => $val)
+    { 
+      //echo $this->name . " $key=$val<br/>";
+      $params .= "$key=$val\0";     
+    }        
+    $globals->db->query("replace into diogenes_plugin set plugin='{$this->name}', barrel='$barrel', page='$page', pos='$pos', params='$params'");
   }
-
-
+  
+  
   /** Dump parameters to a table.
    */
-  function toArray()
+  function dump()
   {
     $plugentr = array();
 
     // copy over properties
-    $props = array('status', 'name', 'params', 'description', 'version', 'type', 'pos');
+    $props = array('active', 'name', 'params', 'description', 'version', 'type', 'pos');
     foreach ($props as $prop)
     {
-      $plugentr[$prop] =  stripslashes_recurse($this->$prop);
-    }
+      if (isset($this->$prop))
+      {
+        $plugentr[$prop] =  stripslashes_recurse($this->$prop);
+      }
+    }    
     return $plugentr;
   }
-
+  
 }
   
 ?>
index 120e22c..dc55ac7 100644 (file)
 
 // dependency on PEAR
 require_once 'System.php';
-require_once 'Tree/Node.php';
-require_once 'Plugin/Skel.php';
-
 
 /** This class describes Diogenes' plugins. 
  */
 class Diogenes_Plugins
 {
+  /** Array of currently loaded plugins */
+  var $loaded = array();
+
   /** Directory that holds the plugins cache files */
   var $cachedir;
-
+  
   /** Directory that holds the plugins */
   var $plugdir;
-
-  /** Plugins that will be sent to trace */
-  var $log = array();
-
+  
+  
   /** Constructs a new holder for Diogenes plugins.
    *
    * @param $dbh
@@ -47,7 +45,7 @@ class Diogenes_Plugins
   {
     $this->dbh =& $dbh;
     $this->plugdir = $plugdir;
-    $this->cachedir = $cachedir;
+    $this->cachedir = $cachedir;    
   }
   
   
@@ -60,77 +58,89 @@ class Diogenes_Plugins
     $cachefile = $this->cachedir . "/" . ($barrel ? $barrel : "__diogenes__") . ".plugins";
     return $cachefile;
   }
-
-
+    
+  
   /** Return the cache entry for specified plugin
    *
    * @param $cache
    * @param $barrel
    * @param $page
    * @param $plugin
-   */
+   */    
   function cacheGet($cache, $barrel, $page, $plugin)
   {
-    $p_node = $this->cacheGetPageNode($cache, $barrel, $page);
-    return $p_node->data[$plugin];
+    foreach ($cache as $plugentry)
+    {      
+      if (($plugentry['plugin'] == $plugin) && ($plugentry['page'] == $page))
+      {
+        return $plugentry;
+      }
+    }
+    return;     
   }
 
-
-  /** Return the cache entry for specified plugin
+  
+  /** Return the cache entry for a plugin at a specified position
    *
    * @param $cache
    * @param $barrel
    * @param $page
-   * @param $plugin
-   */
-  function cacheGetPageNode($cache, $barrel, $page)
+   * @param $pos
+   */  
+  function cacheGetAtPos($cache, $barrel, $page, $pos)
   {
-    if ($page) {
-      $p_node = $cache->getChild($page);
-    } else {
-      $p_node = $cache;
-    }
-    return $p_node;
-  }
-
+    foreach ($cache as $plugentry)
+    {      
+      if (($plugentry['pos'] == $pos) && ($plugentry['page'] == $page))
+      {
+        return $plugentry;
+      }
+    }  
+  }  
 
+  
   /** List the plugins that are active in a given context
    *
    * @param $cache
    * @param $barrel
-   * @param $page
+   * @param $page   
    */
-  function cacheGetActive($cache, $barrel, $page)
+  function cachedActive($cache, $barrel, $page)
   {
-    $p_node = $this->cacheGetPageNode($cache, $barrel, $page);
     $plugins = array();
-    foreach ($p_node->data as $plugname => $plugentry)
+    foreach ($cache as $plug)
     {
-      //echo "cacheGetActive : examining $plugname (status {$plugentry['status']})<br/>\n";
-      if ($plugentry['status'] & PLUG_ACTIVE)
+      if ($plug['page'] == $page) 
       {
-        //echo "cacheGetActive : adding $plugname<br/>\n";
-        $plugins[$plugname] = $plugentry;
+        array_push($plugins, $plug);
       }
     }
-    return $plugins;
+    return $plugins;    
   }
 
-
+    
   /** Returns an array of cache entries representing the available plugins
    *  in a given context
    *
    * @param $cache
    * @param $barrel
    * @param $page
-   */
-  function cacheGetVisible($cache, $barrel, $page)
-  {
-    $p_node = $this->cacheGetPageNode($cache, $barrel, $page);
-    return $p_node->data;
+   */  
+  function cachedAvailable($cache, $barrel, $page)
+  {      
+    $available = array();
+    foreach ($cache as $plugentry)
+    {      
+      $plugfile = $this->plugdir."/".$plugentry['plugin'].".php";
+      if (file_exists($plugfile) and ($plugentry['page'] == 0) and (!$page or $plugentry['active']))
+      {
+        array_push($available, $plugentry['plugin']);
+      }
+    }
+    return $available;    
   }
-
-
+  
+  
   /** Remove database references to plugins that are not available.
    */
   function clean_database(&$page)
@@ -150,165 +160,109 @@ class Diogenes_Plugins
     */
   }
 
-
-  /** Build view for current level.
-  */
-  function compileNode($node, &$outparent, $index)
-  {
-    $outvals = array();
-    foreach ($outparent->data as $plugin => $parentval)
-    {
-      //echo "Processing plugin '$plugin' for &lt;{$node->name}&gt;<br/>\n";
-      $outval = '';
-      if (($parentval['status'] & PLUG_ACTIVE) || !($parentval['status'] & PLUG_LOCK))
-      {
-        //echo "* plugin '$plugin' not locked off parent level<br/>\n";
-        $outval = $parentval;
-        if ((is_array($node->data[$plugin])) && ($node->data[$plugin]['status'] & PLUG_SET))
-        {
-          //echo "** plugin set at current level<br/>\n";
-          $outval['params'] = $node->data[$plugin]['params'];
-          if (!($parentval['status'] & PLUG_LOCK)) {
-            //echo "*** plugin status set to DB-specified value<br/>\n";
-            $outval['status'] = $node->data[$plugin]['status'];
-          } else {
-            $outval['status'] = $parentval['status'];
-          }
-        } else {
-          //echo "** plugin unset at current level<br/>\n";
-        }
-      }
-
-      // add the plugin to output
-      if (is_array($outval))
-      {
-        $outvals[$plugin] = $outval;
-      }
-    }
-    $outnode = new Diogenes_Tree_Node($outvals, $node->name);
-    //echo "<hr/>";
-
-    // recurse into children
-    foreach ($node->children as $cindex => $child)
-    {
-      $this->compileNode($child, $outnode, $cindex);
-    }
-
-    // add the produced node
-    $outparent->setChild($index, $outnode);
-  }
-
-
+    
   /** Compile plugin cache.
    *
+   * @param $cachefile
    * @param $barrel
    */
-  function compileCache($barrel, &$caller)
+  function compileCache($cachefile, $barrel)
   {
-    $caller->info("Recompiling " .($barrel ? "plugin cache for barrel '$barrel'" : "global plugin cache"));
-
-    // get the list of all plugins present on the system
-    $allplugins = array();
-    $plugfiles = System::find($this->plugdir.' -type f -name *.php');
-    foreach ($plugfiles as $file) {
-      $name = basename($file);
-      $name = substr($name, 0, -4);
-      array_push($allplugins, $name);
-    }
-
-    $defcache = array();
-    // fill initial values
-    foreach ($allplugins as $plugin)
-    {
-      $plug_h = $this->load($plugin);
-      $defcache[$plugin] = $plug_h->toArray();
-    }
-
-    // get DB values
-    $dbcache = array();
-
-    $sql_limit = $barrel ? " where barrel='{$barrel}' or barrel=''" : "";
-    $sql = "select barrel, page, plugin, status, params from diogenes_plugin" . $sql_limit;
-    $res = $this->dbh->query($sql);
-    while($row = mysql_fetch_row($res))
-    {
-      $c_barrel = array_shift($row);
-      $c_page = array_shift($row);
-      $plugin = array_shift($row);
-      $plugentry = array(
-        'status' => $row[0],
-        'params' => ($row[1] ? var_decode_bin($row[1]) : array())
-      );
-      $plug_h = $this->load($plugin, $plugentry);
-      //echo "Got params from DB for '$plugin', barrel '$c_barrel', page '$c_page' : ".$row[2]."<br/>";
-      $dbcache[$c_barrel][$c_page][$plugin] = $plug_h->toArray();
+    if (!$fp = fopen($cachefile, "w")) {
+      trigger_error("failed to open '$cachefile' for writing", E_USER_ERROR);
     }
-    mysql_free_result($res);
-
-    // build the input tree
-    $globals_node = new Diogenes_Tree_Node($dbcache[''][0], 'globals defaults');
-    $sql_limit = $barrel ? " where alias='{$barrel}'" : " where alias!=''";
-    $res = $this->dbh->query("select alias from diogenes_site" . $sql_limit);
-    while(list($c_barrel) = mysql_fetch_row($res))
-    {
-      $barrel_node = new Diogenes_Tree_Node($dbcache[$c_barrel][0], "barrel '$c_barrel' defaults");
-      $res2 = $this->dbh->query("select PID from {$c_barrel}_page");
-      while(list($page) = mysql_fetch_row($res2))
-      {
-        $page_node = new Diogenes_Tree_Node($dbcache[$c_barrel][$page], "barrel '$c_barrel' page $page"); 
-        $barrel_node->setChild($page, $page_node);
-      }
-      mysql_free_result($res2);
-      $globals_node->setChild($c_barrel, $barrel_node);
-    }
-    mysql_free_result($res);
 
-    // compile the cache
-    $top_out_node = new Diogenes_Tree_Node($defcache, 'plugin defaults');
-    $this->compileNode($globals_node, $top_out_node, 'globals');
-    $globals_out_node = $top_out_node->getChild('globals');
-    //echo "<pre>" . $top_out_node->dump() . "</pre><hr/>";
-
-    // produce dump(s)
-    if ($barrel) {
-      $dump_node = $globals_out_node->getChild($barrel);
-      $dump_node->writeFile($this->cachefile($barrel));
-      $dump_node->writeFile($this->cachefile($barrel).".txt", NODE_DUMP_TEXT);
+    // get the list of available plugins
+    $available = array();            
+    if (!$barrel) {
+    
+      $plugfiles = System::find($this->plugdir.' -type f -name *.php');  
+      foreach ($plugfiles as $file) {
+        $name = basename($file);
+        $name = substr($name, 0, -4);      
+        array_push($available, $name);
+      }      
+      
     } else {
-      $globals_out_node->writeFile($this->cachefile($barrel), NODE_DUMP_NOCHILDREN);
-      $globals_out_node->writeFile($this->cachefile($barrel).".txt", NODE_DUMP_NOCHILDREN | NODE_DUMP_TEXT);
-      foreach ($globals_out_node->children as $c_barrel => $dump_node)
+            
+      $sql = "select plugin from diogenes_plugin where page=0 AND barrel=''";
+      $res = $this->dbh->query($sql);
+      while (list($plugin) = mysql_fetch_row($res))
       {
-        $dump_node->writeFile($this->cachefile($c_barrel));
-        $dump_node->writeFile($this->cachefile($c_barrel).".txt", NODE_DUMP_TEXT);
+        array_push($available, $plugin);
       }
-    }
-  }
-
+      mysql_free_result($res);
+   }
+    
+/*
+   echo "compile : available <pre>";
+   print_r($available);
+   echo "</pre>";
+*/   
+   // get active plugins
+   $sql = "select page, pos, plugin, params from diogenes_plugin where barrel='{$barrel}' order by page, pos";
+   $res = $this->dbh->query($sql);
+   $active = array();
+   while ($row = mysql_fetch_row($res))
+   {
+     $plugin = $row[2];
+     if (in_array($plugin, $available)) {
+       array_unshift($row, 1); 
+       fputs($fp, join("\t", $row) . "\n");       
+       if (!$row[1]) {
+         array_push($active, $plugin);
+         //echo "compileCache : adding active plugin $plugin<br/>";       
+       }
+     }
+   }
+   mysql_free_result($res);    
+   
+   // add inactive plugins
+   foreach ($available as $plugin)
+   {
+     if (!in_array($plugin, $active))
+     {
+       //echo "compileCache : adding inactive plugin $plugin<br/>";
+       $row = array(0, 0, 0, $plugin, '');
+       fputs($fp, join("\t", $row) . "\n");     
+     }
+   }
+   
+   fclose($fp);
+   
+   //$this->log("rcs_commit","{$this->alias}:$dir/$file:$message");
 
+  }
+  
+   
   /** Load the specified plugin
    *
    * @param $plugentry
    */
-  function load($plugin, $plugentry = '')
+  function load($plugentry)
   {
+    $plugin = $plugentry['plugin'];
     $plugfile = $this->plugdir."/$plugin.php";
     if (!file_exists($plugfile)) {
       trigger_error("could not find plugin file '$plugfile'", E_USER_WARNING);
       return;
     }
+     
     include_once($plugfile);
+  
     if (!class_exists($plugin)) {
       trigger_error("could not find class '$plugin'", E_USER_WARNING);
       return;
     }
-
+    
     // load and register plugin
-    $plug_h = new $plugin();
-    if (is_array($plugentry))
-      $plug_h->fromArray($plugentry);
-
-    return $plug_h;
+    $plug = new $plugin();
+    $plug->pos = $plugentry['pos'];
+    $plug->active = $plugentry['active'];
+    $plug->setParams($plugentry['params']);
+    $this->loaded[$plugin] =& $plug;      
+    
+    return $plug;
   }
     
 
@@ -322,33 +276,62 @@ class Diogenes_Plugins
     if (!file_exists($cachefile)) {
         return array();
     }
-
-    return Diogenes_Tree_Node::readFile($cachefile);
+    
+    if (!$fp = fopen($cachefile, "r")) {
+      trigger_error("failed to open '$cachefile' for reading", E_USER_WARNING);
+      return;
+    }
+    
+    $plugins = array();
+    while ($line = fgets($fp))
+    {
+      // drop end of line
+      $line = substr($line, 0, -1);
+      $bits = explode("\t", $line);
+      $plug = array(
+        'active' => $bits[0],
+        'page'   => $bits[1],
+        'pos'    => $bits[2],
+        'plugin' => $bits[3],
+        'params' => $bits[4],
+      );        
+      array_push($plugins, $plug);
+    }
+        
+    fclose($fp);
+    
+    return $plugins;
   }
 
-
+      
   /** Prepare plugins trace for output
-   */
+   */    
   function trace_format()
   {
-    $out = '<table class="light" style="width: 100%; font-family: monospace">'."\n";
-    $odd = 0;
-    foreach ($this->log as $key => $val)
-    {
-      $trclass = $odd ? ' class="odd"' : '';
-      $out .= "<tr><th colspan=\"2\">{$val['name']} v{$val['version']}</th></tr>\n";
-      $out .= "<tr><td>status</td><td>{$val['status']}</td></tr>\n";
-      $out .= "<tr$trclass><td>type</td><td>{$val['type']}</td></tr>\n";
-      $out .= "<tr$trclass><td>description</td><td>{$val['description']}</td></tr>\n";
-      if (!empty($val['params'])) {
-        $out .= "<tr$trclass><td>parameters</td><td>".var_encode_html($val['params'])."</td></tr>\n";
+    $out = "";
+    foreach ($this->loaded as $key => $val)
+    {      
+      $out .= '<table class="light" style="width: 100%; font-family: monospace">';
+      $out .= '<tr><th colspan="2">'.$key.' v'.$val->version.'</th></tr>';
+      if (isset($val->pos)) {
+        $out .= '<tr><td>position</td><td>'.$val->pos.'</td></tr>';
       }
-      $odd = ($odd+1) % 2;
+      $out .= '<tr><td>type</td><td>'.$val->type.'</td></tr>';
+      $out .= '<tr><td>description</td><td>'.$val->description.'</td></tr>';
+      if (empty($val->params)) {
+        $out .= '<tr class="odd"><td colspan="2">parameters</td></tr>';
+        foreach ($val->params as $skey => $sval) 
+        {
+          $out .= "<tr><td>$skey</td><td>$sval</td></tr>";
+        }
+      }
+      $out .= "</table><br/>";
     }
-    $out .= "</table>\n";
     return $out;
   }
-
+  
+  
+  
 }
 
 ?>
diff --git a/include/Tree/Node.php b/include/Tree/Node.php
deleted file mode 100644 (file)
index 2ff8edb..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-<?php
-/*
- * Copyright (C) 2003-2004 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
- */
-
-require_once 'diogenes/diogenes.misc.inc.php';
-
-define('NODE_DUMP_BINARY', 0);
-define('NODE_DUMP_TEXT', 1);
-define('NODE_DUMP_NOCHILDREN', 2);
-define('VAR_TYPE_NULL', 0);
-define('VAR_TYPE_INT', 1);
-define('VAR_TYPE_STRING', 2);
-define('VAR_TYPE_ARRAY', 3);
-define('VAR_TYPE_NODE', 4);
-
-function var_encode_text($var, $level = 0, $no_children = FALSE, $tabstr = '  ', $eol = "\n")
-{
-  if (is_object($var) && (strtolower(get_class($var)) == 'diogenes_tree_node')) {
-    // node name
-    $code = str_repeat($tabstr, $level) . "node : {$var->name}" . $eol;
-
-    // encode this node's data
-    $code .= str_repeat($tabstr, $level+1) . "* data : " . var_encode_text($var->data, $level + 2, $no_children, $tabstr, $eol). $eol;
-
-    // encode this node's children
-    if (!$no_children)
-    {
-      $code .= str_repeat($tabstr, $level+1) . "* children" . $eol;
-      foreach ($var->children as $index => $child)
-      {
-        $code .= str_repeat($tabstr, $level+2) . "index : $index" . $eol;
-        $code .= var_encode_text($child, $level+2, $no_children, $tabstr, $eol);
-      }
-    }
-    return $code;
-  } elseif (is_array($var)) {
-    $arraysep = ",$eol";
-    $vcode = '';
-    foreach ($var as $key => $value) {
-      $vcode .= str_repeat($tabstr, $level + 1);
-      $vcode .= "'$key'=>".var_encode_text($value, $level + 1, $no_children, $tabstr, $eol);
-      $vcode .= $arraysep;
-    }
-    if (substr($vcode, -strlen($arraysep)) == $arraysep)
-      $vcode = substr($vcode, 0, - strlen($arraysep));
-
-    $code = "array(".($vcode ? "$eol$vcode$eol".str_repeat($tabstr, $level)  : ""). ")";
-    return $code;
-  } elseif (is_scalar($var)) {
-    return "'".$var."'";
-  } else {
-    return 'NULL';
-  }
-}
-
-function var_encode_html($var, $level = 0, $no_children = FALSE)
-{
-  return var_encode_text($var, $level, $no_children, '&nbsp;&nbsp;', $eol = "<br/>\n");
-}
-
-function var_encode_bin($var, $no_children = FALSE)
-{
-  if (is_object($var) && (strtolower(get_class($var)) == 'diogenes_tree_node')) {
-    $code = pack('C', VAR_TYPE_NODE);
-    $code .= var_encode_bin($var->name);
-    $code .= var_encode_bin($var->data);
-    if ($no_children)
-      $code .= var_encode_bin(array());
-    else
-      $code .= var_encode_bin($var->children);
-  } elseif (is_array($var)) {
-    $code = pack('C', VAR_TYPE_ARRAY);
-    $contents = '';
-    foreach ($var as $key => $value) {
-      $contents .= var_encode_bin($key);
-      $contents .= var_encode_bin($value);
-    }
-    $code .= pack('L', strlen($contents));
-    $code .= $contents;
-  } elseif (is_scalar($var)) {
-    $str = "$var";
-    $code = pack('C', VAR_TYPE_STRING);
-    $code .= pack('L', strlen($str));
-    $code .= $str;
-  } else {
-    $code = pack('C', VAR_TYPE_NULL);
-   }
-   return $code;
-}
-
-function var_decode_bin(&$bin)
-{
-  list(,$type) = unpack('C', $bin);
-  $bin = substr($bin, 1);
-  if ($type == VAR_TYPE_NODE)
-  {
-    $name = var_decode_bin($bin);
-    $data = var_decode_bin($bin);
-    $children = var_decode_bin($bin);
-    $var = new Diogenes_Tree_Node($data, $name, $children);
-  } elseif ($type == VAR_TYPE_ARRAY)
-  {
-    list(,$length) = unpack('L', $bin);
-    $bin = substr($bin, 4);
-    $contents = substr($bin, 0, $length);
-    $bin = substr($bin, $length);
-
-    $var = array();
-    while(strlen($contents)) {
-      $key = var_decode_bin($contents);
-      $var[$key] = var_decode_bin($contents);
-    }
-  } elseif ($type == VAR_TYPE_STRING) {
-    list(,$length) = unpack('L', $bin);
-    $bin = substr($bin, 4);
-    $var = substr($bin, 0, $length);
-    $bin = substr($bin, $length);
-  } elseif ($type == VAR_TYPE_NULL) {
-    $var = NULL;
-  } else {
-    trigger_error("unknown type in var_decode_bin : ". $type);
-  }
-  return $var;
-}
-
-/** This class describes Diogenes' plugins. 
- */
-class Diogenes_Tree_Node
-{
-  /** Data for the current node */
-  var $data;
-
-  /** Name for the current node */
-  var $name;
-
-  /** An array of child nodes */
-  var $children = array();
-
-  /** The parent of this node */
-  // var $parent;
-
-  /** Construct a new tree node.
-   */
-  function Diogenes_Tree_Node($data, $name = '', $children=array())
-  {
-    $this->data = $data;
-    $this->name = $name;
-    $this->children = $children;
-  }
-
-  /** Return the specified child of this node.
-   */
-  function getChild($index)
-  {
-    return $this->children[$index];
-  }
-
-  /** Assign the specified child of this node.
-   */
-  function setChild($index, $node)
-  {
-    $this->children[$index] = $node;
-  }
-
-  /** Read a dump of a node and its children.
-   */
-  function readFile($filename)
-  {
-    $bin = file_get_contents($filename);
-    $node = var_decode_bin($bin);
-    if (!is_object($node) || strtolower(get_class($node)) != 'diogenes_tree_node')
-    {
-      trigger_error('readFile : not a Diogenes_Tree_Node', E_USER_ERROR);
-    }
-    return $node;
-  }
-
-  /** Write a dump of this node and its children.
-   */
-  function writeFile($filename, $mode = NODE_DUMP_IO)
-  {
-    if (!$fp = fopen($filename, "w")) {
-      trigger_error("writeFile : failed to open '$cachefile' for writing", E_USER_ERROR);
-    }
-
-    if ($mode & NODE_DUMP_TEXT) {
-      $out = var_encode_text($this, $level, ($mode & NODE_DUMP_NOCHILDREN));
-    } else {
-      $out = var_encode_bin($this, ($mode & NODE_DUMP_NOCHILDREN));
-    }
-    fputs($fp, $out);
-
-    fclose($fp);
-  }
-
-}
-
-?>
index 64b5df2..4604049 100644 (file)
 require_once 'diogenes.common.inc.php';
 require_once 'diogenes.admin.inc.php';
 require_once 'diogenes.icons.inc.php';
-require_once 'Barrel/Events.php';
 
 $page = new DiogenesAdmin;
 $bbarrel =& $page->barrel;
-$events = new Diogenes_Barrel_Events($bbarrel);
+$homepage = $bbarrel->getPID('');
+
+// filename transformations
+function makeFileLoc($log_file) {
+  global $homepage, $bbarrel;
+
+  if (stristr($log_file, '/') == FALSE ) {
+    // this is a directory
+    $mydir = $log_file;
+    $myfile = '';
+  } else {
+    $myfile = basename($log_file);
+    $mydir = dirname($log_file);
+  }
+  
+  $myloc = $bbarrel->getLocation($mydir);    
+  if ($myloc or ($mydir == $homepage))
+  {
+    $log_file = $myloc ? "$myloc/$myfile" : $myfile;
+  }
+  
+  return array($log_file, $mydir, $myfile);
+}
+
 
 // retrieve recent events
-$event_arr = $events->getEvents($page);
-$page->assign('events', $event_arr);
+$res = $globals->db->query("select e.action,e.stamp,e.data,a.text,s.auth,s.uid "
+                  ."from {$globals->table_log_events} as e "
+                  ."left join {$globals->table_log_actions} as a on e.action=a.id "
+                  ."left join {$globals->table_log_sessions} as s on e.session=s.id "
+                  ."where e.data like '{$bbarrel->alias}:%' "
+                  ."order by stamp desc limit 0,10");
+while ($myarr = mysql_fetch_array($res)) {
+  $myarr['username'] = call_user_func(array($globals->session,'getUsername'),$myarr['auth'],$myarr['uid']);
+  list($op_alias, $op_file) = split(":",$myarr['data']);
+
+  switch($myarr['text']) {
+  case "barrel_create":
+    $myarr['icon'] = $globals->icons->get_action_icon('add');    
+    $myarr['desc'] = __("site created");
+    break;
+    
+  case "barrel_options":
+    $myarr['icon'] = $globals->icons->get_action_icon('properties');    
+    $myarr['desc'] = array(__("barrel options"), "options");    
+    break;
+
+  case "barrel_plugins":
+    $myarr['icon'] = $globals->icons->get_action_icon('plugins');
+    $myarr['desc'] = array(__("barrel plugins"), "plugins");  
+    break;
+        
+  case "page_create":
+    $myarr['icon'] = $globals->icons->get_action_icon('add');    
+    list($op_file, $mydir, $myfile) = makeFileLoc($op_file);
+    $myarr['desc'] = array(__("page created"), "pages?dir=$mydir");  
+    break;
+
+  case "page_delete":
+    $myarr['icon'] = $globals->icons->get_action_icon('remove');
+    $myarr['desc'] = __("page removed");
+    break;
+    
+  case "page_props":
+    $myarr['icon'] = $globals->icons->get_action_icon('properties');
+    list($op_file, $mydir, $myfile) = makeFileLoc($op_file);
+    $myarr['desc'] = array(__("page properties"), "pages?dir=$mydir");  
+    break;
+
+  case "page_plugins":
+    $myarr['icon'] = $globals->icons->get_action_icon('plugins');
+    list($op_file, $mydir, $myfile) = makeFileLoc($op_file);
+    $myarr['desc'] = array(__("page plugins"), "plugins?plug_page=$mydir");  
+    break;
+            
+  case "rcs_commit": 
+    $myarr['icon'] = $globals->icons->get_action_icon('update');    
+    list($op_file, $mydir, $myfile) = makeFileLoc($op_file);  
+    $myarr['desc'] = array(__("file updated"), "files?action=revs&amp;dir=$mydir&amp;target=$myfile");        
+    break;
+      
+  case "rcs_delete":
+    $myarr['icon'] = $globals->icons->get_action_icon('delete');    
+    list($op_file, $mydir, $myfile) = makeFileLoc($op_file);    
+    $myarr['desc'] = __("file deleted");        
+    break;
+    
+  }
+    
+  $myarr['file'] = $op_file;
+
+  if (isset($myarr['desc']))
+    $page->append('events',$myarr);
+}
+mysql_free_result($res);
 
 // do display
 $page->assign('greeting',__("Welcome to the Diogenes backoffice"));
index 1875326..269c4c7 100644 (file)
@@ -1,16 +1,37 @@
 <?php
 require_once 'diogenes.common.inc.php';
 require_once 'diogenes.admin.inc.php';
-require_once 'Barrel/Menu.php';
-require_once 'Barrel/Page.php';
 
 $page = new DiogenesAdmin;
 $bbarrel =& $page->barrel;
-$bmenu = new Diogenes_Barrel_Menu($globals->db, $bbarrel->table_menu);
 
 // the id of the parent menu
 $MIDpere = isset($_REQUEST['MIDpere']) ? $_REQUEST['MIDpere'] : 0;
 
+/**
+ * This function swaps entries $a and $b within $parent.
+ */
+function swapentries($parent,$a,$b,$table_menu)
+{
+  global $globals;
+  $res = $globals->db->query("SELECT MID from $table_menu where MIDpere=$parent and (ordre=$a or ordre=$b) ORDER BY ordre");
+  /* make sure that $a <= $b */
+  if ($a > $b)
+  {
+    $c = $a;
+    $a = $b;
+    $b = $c;
+  }
+  /* perform swap */
+  list($MIDa) = mysql_fetch_row($res);
+  list($MIDb) = mysql_fetch_row($res);
+  mysql_free_result($res);
+
+  $globals->db->query("UPDATE $table_menu SET ordre=$b WHERE MID=$MIDa");
+  $globals->db->query("UPDATE $table_menu SET ordre=$a WHERE MID=$MIDb");
+}
+
+
 //// start constructing the page
 
 $page->assign('greeting',__("The site's menus"));
@@ -20,39 +41,64 @@ switch ($action) {
 /* we want to erase the current entry */
 case "supprimer":
   $MID = $_REQUEST['MID'];
-  $bmenu->deleteEntry($MID, $MIDpere, $page);
+  if (mysql_num_rows($globals->db->query("SELECT MID FROM {$bbarrel->table_menu} WHERE MIDpere=$MID")) > 0) {
+    $page->info(__("The selected menu has child items, please remove them first."));
+    break;
+  }
+
+  /* erase the current entry */
+  $globals->db->query("DELETE FROM {$bbarrel->table_menu} WHERE MID=$MID");
+
+  /* renumber the other menu entries so that they are between 1 and the number of entries */
+  $res = $globals->db->query("SELECT MID FROM {$bbarrel->table_menu} WHERE MIDpere=$MIDpere ORDER BY ordre");
+  $i = 0;
+  while (list($MIDtoorder) = mysql_fetch_array($res)) {
+    $i++;
+    $globals->db->query("UPDATE {$bbarrel->table_menu} SET ordre=$i WHERE MID=$MIDtoorder");
+  }
+  mysql_free_result($res);
   break;
 
 /* bring an entry up in the menu */
 case "remonter":
   $ordre = $_REQUEST['ordre'];
-  $bmenu->swapEntries($MIDpere, $ordre-1, $ordre);
+  swapentries($MIDpere,$ordre-1,$ordre,$bbarrel->table_menu);
   break;
 
 /* push an entry down in the menu */
 case "descendre":
   $ordre = $_REQUEST['ordre'];
-  $bmenu->swapEntries($MIDpere, $ordre, $ordre+1);
+  swapentries($MIDpere,$ordre,$ordre+1,$bbarrel->table_menu);
   break;
 
 /* create or update a menu entry */
 case "modifier":
     $typelink = $_REQUEST['typelink'];
-    $props = array(
-      'parent' => $MIDpere,
-      'pid' => 0,
-      'link' => '',
-      'title' => $_REQUEST['title'],
-    );
     switch ($typelink) {
     case "boutonPI" :
-      $props['pid'] = isset($_REQUEST['PIvaleur']) ? $_REQUEST['PIvaleur'] : 0;
+      $pid = isset($_REQUEST['PIvaleur']) ? $_REQUEST['PIvaleur'] : 0;
+      $link = "";
       break;
     case "boutonSE" :
-      $props['link'] = $_REQUEST['SEvaleur'];
+      $pid = 0;
+      $link = $_REQUEST['SEvaleur'];
       break;
+    default:
+      $pid = 0;
+      $link = "";
     }
-    $MID = $bmenu->writeEntry($_REQUEST['MID'], $props);
+    $MID = $_REQUEST['MID'];
+    $title = $_REQUEST['title'];
+    if ($MID == 0) {
+      $res=$globals->db->query("SELECT MAX(ordre) from {$bbarrel->table_menu} where MIDpere=$MIDpere");
+      list($ordre) = mysql_fetch_row($res);
+      $ordre++;
+      $globals->db->query("INSERT INTO {$bbarrel->table_menu} SET MIDpere='$MIDpere',ordre='$ordre',title='$title',link='$link',pid='$pid'");
+      $MID = mysql_insert_id();
+    } else {
+      $globals->db->query("UPDATE {$bbarrel->table_menu} SET title='$title',link='$link',pid='$pid' WHERE MID=$MID");
+    }
+
     break;
 
 /* display the form to edit an entry */
@@ -65,10 +111,9 @@ case "editer":
 
   // if this is an existing entry, retrieve data
   if ($MID) {
-    $mcache = $bmenu->menuRead();
-    $link = $mcache[$MID]['link'];
-    $title = $mcache[$MID]['title'];
-    $pid = $mcache[$MID]['pid'];
+    $res = $globals->db->query("SELECT link,title,pid FROM {$bbarrel->table_menu} WHERE MID=$MID");
+    list($link, $title, $pid) = mysql_fetch_row($res);
+    mysql_free_result($res);
   }
 
   // fill out form data
@@ -123,17 +168,16 @@ case "editer":
 }
 
 // get the maximum order
-$maxOrdre = $bmenu->maxChildIndex($MIDpere);
-
-// all menu entries from database
-$mcache = $bmenu->menuRead();
-
-foreach($mcache[$MIDpere]['children'] as $MID)
-{
-  $ordre = $mcache[$MID]['ordre'];
-  $title = $mcache[$MID]['title'];
-  $link = $mcache[$MID]['link'];
-  $PID = $mcache[$MID]['pid'];
+$res=$globals->db->query("SELECT MAX(ordre) from {$bbarrel->table_menu} where MIDpere=$MIDpere");
+list($maxOrdre)=mysql_fetch_row($res);
+mysql_free_result($res);
+
+// retrieve the entries
+$res = $globals->db->query("SELECT m.MID,m.ordre,m.title,m.link,m.PID,p.title ".
+                       "from {$bbarrel->table_menu} as m ".
+                       "left join {$bbarrel->table_page} as p on m.PID=p.PID ".
+                       "where MIDpere=$MIDpere order by ordre");
+while (list($MID,$ordre,$title,$link,$PID,$ptitle) = mysql_fetch_row($res)) {
   $clickup="?action=remonter&amp;MIDpere=$MIDpere&amp;ordre=$ordre";
   $clickdown="?action=descendre&amp;MIDpere=$MIDpere&amp;ordre=$ordre";
 
@@ -148,8 +192,7 @@ foreach($mcache[$MIDpere]['children'] as $MID)
   
   // describe the current link
   if ($PID) {
-    $tpage = Diogenes_Barrel_Page::fromDb($bbarrel, $PID);
-    $descr = "<a href=\"pages?dir=$PID\">".$tpage->props['title']."</a>";
+    $descr = "<a href=\"pages?dir=$PID\">$ptitle</a>";
   } elseif ($link) {
     $descr = "<a href=\"$link\">[ext] $link</a>";
   } else {
@@ -162,14 +205,20 @@ foreach($mcache[$MIDpere]['children'] as $MID)
           stripslashes($descr),
           $edit,$del,$up,$down));
 }
+mysql_free_result($res);
 
-$filiation = $bmenu->menuToRoot($mcache,$MIDpere,array());
+// all menu entries from database
+$mcache = $page->menuRead();
+$filiation = $page->menuToRoot($mcache,$MIDpere,array());
 $menubar = array();
 foreach($filiation as $mykey=>$myval) {
   if ($myval == 0) {
     $blab = "<i>home</i>";
   } else {
-    $blab = stripslashes($mcache[$myval]['title']);
+    $res = $globals->db->query("SELECT title FROM {$bbarrel->table_menu} WHERE MID='$myval'");
+    list($blab) = mysql_fetch_row($res);
+    $blab = stripslashes($blab);
+    mysql_free_result($res);
   }
   array_unshift($menubar,$mykey ? array($blab,"?MIDpere=$myval") : array($blab));
 }
index 5ae4ae3..c529c31 100644 (file)
@@ -30,7 +30,8 @@ if ($dir != 0)
 /* plugin editor */
 $editor = new Diogenes_Plugin_Editor($page->alias, $dir, $wperms);
 if ($dir == 0) {
-  $editor->set_mode(MODE_NOPARAMS);
+  $editor->readonly = 1;
+  $editor->hide_params(1);
 }
 $editor->run($page,'page_content');
 $page->display('');
diff --git a/include/admin/rss.php b/include/admin/rss.php
deleted file mode 100644 (file)
index 9a9187a..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-require_once 'diogenes.common.inc.php';
-require_once 'diogenes.barrel.inc.php';
-require_once 'Barrel/Events.php';
-$page = new $globals->barrel;
-$events = new Diogenes_Barrel_Events($page->barrel);
-
-// assignments
-$page->assign('version', $globals->version);
-$page->assign('site_title', stripslashes($page->barrel->options->title));
-$page->assign('site_link', $page->urlBarrel($page->barrel->alias, $page->barrel->vhost, ''));
-
-// retrieve recent events
-$event_arr = $events->getEvents($page);
-foreach($event_arr as $event)
-{
-  //$page->assign('events', $event_arr);
-  if ($event['flags'] & EVENT_FLAG_PUBLIC)
-  {
-    $item = $event;
-    $item['date'] = gmstrftime("%a, %d %b %Y %T %Z", strtotime($event['stamp']));
-    $item['title'] .= " : ". $item['opfile'];
-    $page->append('items', $item);
-  }
-}
-header("Content-Type: application/rss+xml");
-$page->display('', 'admin-rss.tpl');
-?>
index 457f8ce..3893284 100644 (file)
@@ -21,7 +21,6 @@
 
 require_once 'diogenes.page.inc.php';
 require_once 'Barrel.php';
-require_once 'Barrel/Menu.php';
 
 /** This class is used to display a page of a Diogenes barrel,
  *  that is an RCS-managed website with a virtual directory
@@ -214,7 +213,6 @@ class DiogenesBarrel extends DiogenesPage
         $render_plugin = $plugobj;
       }
     }
-
     // source page or pass it to a rendering plugin
     if (is_object($render_plugin)) {    
       $content = $render_plugin->render($path);
@@ -314,9 +312,6 @@ class DiogenesBarrel extends DiogenesPage
     // favicon
     if ($bbarrel->options->favicon)
       array_push($this->head, '<link rel="icon" href="'.$this->urlSite("", $bbarrel->options->favicon).'" type="image/png" />');
-
-    // RSS feed
-    array_push($this->head, '<link rel="alternate" type="application/rss+xml" title="'.stripslashes($bbarrel->options->title).'" href="'.$this->urlSite("admin", "rss").'" />');
   }
 
 
@@ -357,9 +352,101 @@ class DiogenesBarrel extends DiogenesPage
     if (!isset($this->table_menu))
       return;
    
+    // all menu entries from database
+    $mcache = $this->menuRead();
+
+    // try to figure out the current MID from the current PID
+    // and build filiation
+    $filiation = array();
+    foreach ($mcache as $mid => $mentry)
+    {
+      if ($mentry['pid'] == $PID)
+        $filiation = $this->menuToRoot($mcache, $mid, $filiation);
+    }
+
     // add the user-defined part of the menu
-    $bmenu = new Diogenes_Barrel_Menu($this->dbh, $this->table_menu);
-    $this->menu = array_merge($this->menu, $bmenu->makeMenu($PID, $this->barrel->options->menu_min_level, array($this, 'urlSiteByPid')));
+    $this->menu = array_merge($this->menu,$this->menuRecurse($mcache,0,$filiation,0));
+  }
+
+
+  /** Return the filiation to get to the root element.
+   *
+   * @param mcache
+   * @param MID
+   * @param path
+   */
+  function menuToRoot($mcache, $MID, $path) {
+    /* add ourself to the path */
+    array_push($path,$MID);
+
+    if ($MID) {
+      /* recursion */
+      return $this->menuToRoot($mcache, $mcache[$MID]['parent'], $path);
+    } else {
+      /* termination */
+      return $path;
+    }
+  }
+
+
+  /** Recursively add menu entries
+   *
+   * @param mcache
+   * @param MIDpere
+   * @param filiation
+   * @param level
+   */
+  function menuRecurse($mcache, $MIDpere, $filiation, $level) {
+    // the produced output
+    $out = array();
+
+    foreach ($mcache[$MIDpere]['children'] as $mid)
+    {
+      $mentry = $mcache[$mid];
+//      echo "pid : $pid, location : $location<br/>";
+      $entry = htmlentities(stripslashes($mentry['title']), ENT_QUOTES);
+      if ($mentry['pid'])
+      {
+        $link = $this->urlSite($this->barrel->getLocation($mentry['pid']));
+      } else {
+        $link = $mentry['link'];
+      }
+      // decide whether this menu should be expanded
+      $expanded = ($this->barrel->options->menu_min_level == 0) || 
+                  ($level+1 < $this->barrel->options->menu_min_level) || 
+                   in_array($mid, $filiation);
+      array_push($out, array($level, $entry, $link, $expanded));
+      $out = array_merge($out, $this->menuRecurse($mcache, $mid, $filiation, $level+1));
+    }
+
+    return $out;
+  }
+
+
+  /** Read this barrel's menu entries from database.
+   */
+  function menuRead()
+  {
+    $menu = array();
+    $menu[0]['children'] = array();
+    $res = $this->dbh->query("select MID,MIDpere,title,link,PID from {$this->table_menu} order by ordre");
+    while (list($mid, $parent, $title, $link, $pid) = mysql_fetch_row($res))
+    {
+      $menu[$mid]['parent'] = $parent;
+      $menu[$mid]['title'] = $title;
+      $menu[$mid]['link'] = $link;
+      $menu[$mid]['title'] = $title;
+      $menu[$mid]['pid'] = $pid;
+      if (!is_array($menu[$mid]['children']))
+        $menu[$mid]['children'] = array();
+
+      // register this entry with its parent
+      if (!is_array($menu[$parent]['children']))
+        $menu[$parent]['children'] = array();
+      array_push($menu[$parent]['children'], $mid);
+    }
+    mysql_free_result($res);
+    return $menu;
   }
 
 
@@ -409,7 +496,7 @@ class DiogenesBarrel extends DiogenesPage
     }
     return $path;
   }
-
 
   /** Returns the URL to one of the barrel's pages relative to
    *  the current location.
@@ -424,18 +511,6 @@ class DiogenesBarrel extends DiogenesPage
     return strlen($url) ? $url : "./";
   }
 
-
-  /** Returns the URL to one of the barrel's pages relative to
-   *  the current location.
-   *
-   * @param dir
-   * @param file
-   */
-  function urlSiteByPid($PID, $file = '')
-  {
-    return $this->urlSite($this->barrel->getLocation($PID), $file);
-  }
-
 }
 
 ?>
diff --git a/include/diogenes.compose.inc.php b/include/diogenes.compose.inc.php
deleted file mode 100644 (file)
index e69de29..0000000
index 28d6bbf..2399b79 100644 (file)
@@ -18,7 +18,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-require_once 'Plugin/Skel/Filter.php';
+require_once 'Plugin/Filter.php';
 require_once 'diogenes.icons.inc.php';
 
 
@@ -28,24 +28,16 @@ require_once 'diogenes.icons.inc.php';
  * To make use of this plugin, insert {FileList} in your page where 
  * the file list should appear.
  */
-class FileList extends Diogenes_Plugin_Skel_Filter {
+class FileList extends Diogenes_Plugin_Filter {
   /** Plugin name */
   var $name = "FileList";
   
   /** Plugin description */
   var $description = "This plugin allows you to insert a directory listing with icons and modification date. To make use of this plugin, insert <b>{FileList}</b> in your page where the file list should appear.";
   
-  /** Constructor.
-   */
-  function FileList()
-  {
-    global $page;
-    $this->declareParam('dirbase', '');
-    $this->declareParam('urlbase', '');
-    $this->declareParam('match', '');
-  }
-
+  /** Plugin parameters */
+  var $params = array('dirbase' => "", 'urlbase' => "", 'match' => "");
+    
   
   /** Prepare the output for a single file of the list.
    *
@@ -105,21 +97,21 @@ class FileList extends Diogenes_Plugin_Skel_Filter {
   {
     global $page;
     $bbarel = $page->barrel;
-   
+    
     // process arguments
-    $instance_vals = array();
-    foreach($this->getParamNames() as $key) {
-      $instance_vals[$key] = isset($args[$key]) ? $args[key] : $this->getParamValue($key);
+    $params = array();
+    foreach($this->params as $key => $val) {
+      $params[$key] = isset($args[$key]) ? $args[$key] : $this->params[$key];
     }
     
-   //print_r($instance_vals);
-    if (empty($instance_vals['dirbase'])) {
-      $instance_vals['dirbase'] =  $bbarel->spool->spoolPath($page->curpage->props['PID']);
+   //print_r($params);
+    if (empty($params['dirbase'])) {
+      $params['dirbase'] = $bbarel->spool->spoolPath($page->curpage->props['PID']);
     }
 
     // process parameters 
     $output = '';
-    $dir = $instance_vals['dirbase'];
+    $dir = $params['dirbase'];    
     if (is_dir($dir) && ($dh = opendir($dir))) {
       $output .= 
        '<table class="light">
@@ -133,7 +125,7 @@ class FileList extends Diogenes_Plugin_Skel_Filter {
       /* get the matching files */
       while (($fname = readdir($dh)) !== false) {
         if ( is_file("$dir/$fname") 
-              && preg_match('/^'.$instance_vals['match'].'/',$fname) )
+              && preg_match('/^'.$params['match'].'/',$fname) )
           $filelist[] = $fname;
       }
       closedir($dh);
@@ -142,7 +134,7 @@ class FileList extends Diogenes_Plugin_Skel_Filter {
       if (is_array($filelist)) {
         rsort($filelist);
         while(list ($key,$val) = each($filelist)) {
-          $output .= $this->list_file("$dir/$val",$val,$instance_vals['urlbase'].$val);
+          $output .= $this->list_file("$dir/$val",$val,$params['urlbase'].$val);
         }
       } else {
         $output .= '<tr><td colspan="4"><i>'.__("no files").'</i></td></tr>';
index 50a4665..a1be65c 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-require_once 'Plugin/Skel/Filter.php';
+require_once 'Plugin/Filter.php';
 require_once 'diogenes/diogenes.hermes.inc.php';
 
 /** The HtmlHead plugin allows you to add entries to a page's <head> block.
  */
-class HtmlHead extends Diogenes_Plugin_Skel_Filter
+class HtmlHead extends Diogenes_Plugin_Filter
 {  
   /** Plugin name */
   var $name = "HtmlHead";
   
   /** Plugin description */
   var $description = "This plugin allows you to add entries to a page's &lt;head&gt; block.";
-
-  /** Constructor.
-   */
-  function HtmlHead()
-  {
-    $this->declareParam('contents', '');
-  }
-
+  
+  /** Plugin parameters */
+  var $params = array('contents' => '');
 
   /** Apply filtering to the input and return an output.
    *
@@ -47,10 +41,10 @@ class HtmlHead extends Diogenes_Plugin_Skel_Filter
   function filter($input)
   {
     global $page;
-    $contents = $this->getParamValue('content'); 
-    if (!empty($contents))
+   
+    if ($this->params['contents'])
     {
-      array_push($page->head, $contents);
+      array_push($page->head, $this->params['contents']);
     }
 
     return $input;
index 497ffb2..9c89fb4 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-require_once 'Plugin/Skel/Filter.php';
+require_once 'Plugin/Filter.php';
 require_once 'diogenes/diogenes.hermes.inc.php';
 
 /** The HttpHeader plugin allows you to add an HTTP header to a page.
  */
-class HttpHeader extends Diogenes_Plugin_Skel_Filter
+class HttpHeader extends Diogenes_Plugin_Filter
 {  
   /** Plugin name */
   var $name = "HttpHeader";
@@ -31,14 +31,8 @@ class HttpHeader extends Diogenes_Plugin_Skel_Filter
   /** Plugin description */
   var $description = "This plugin allows you to add an HTTP header to a page.";
   
-
-  /** Constructor.
-   */
-  function HttpHeader()
-  {
-    $this->declareParam('contents', '');
-  }
-   
+  /** Plugin parameters */
+  var $params = array('contents' => '');
 
   /** Apply filtering to the input and return an output.
    *
@@ -46,11 +40,13 @@ class HttpHeader extends Diogenes_Plugin_Skel_Filter
    */
   function filter($input)
   {
-    $header = $this->getParamValue('contents');
+    $header = $this->params['contents'];
+
     if ($header) 
     {
       header($header);
     }
+   
     return $input;
   }
   
index 4ba04bd..7301c0f 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-require_once 'Plugin/Skel/Filter.php';
+require_once 'Plugin/Filter.php';
 require_once 'diogenes/diogenes.hermes.inc.php';
 
 /** The MailForm plugin allows you to insert a form to send
  *  an e-mail to a fixed recipient.
 */  
-class LinksMagic extends Diogenes_Plugin_Skel_Filter
+class LinksMagic extends Diogenes_Plugin_Filter
 {  
   /** Plugin name */
   var $name = "LinksMagic";
   
   /** Plugin description */
   var $description = "This plugin allows you to mark external and secure (HTTPS) links in your pages.";
-
-  /** Constructor.
-   */
-  function LinksMagic()
-  {
-    $this->declareParam('main', 1);
-    $this->declareParam('sidebar', 1);
-  }
-
   
+  /** Plugin parameters */
+  var $params = array('main' => 1, 'sidebar' => 1);
+
   /** Apply filtering to the input and return an output.
    *
    * @param $input
@@ -50,12 +43,12 @@ class LinksMagic extends Diogenes_Plugin_Skel_Filter
   {
     global $page;
  
-    if ($this->getParamValue('sidebar'))
+    if ($this->params['sidebar'])
     {
       array_unshift($page->head, '<link rel="stylesheet" href="'.$page->url('links-sidebar.css').'" type="text/css" />');
     }
 
-    if ($this->getParamValue('main'))
+    if ($this->params['main'])
     {
       array_unshift($page->head, '<link rel="stylesheet" href="'.$page->url('links-main.css').'" type="text/css" />');
     }
index 79164ac..8125ebb 100644 (file)
@@ -18,7 +18,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-require_once 'Plugin/Skel/Filter.php';
+require_once 'Plugin/Filter.php';
 require_once 'diogenes/diogenes.hermes.inc.php';
 
 /** The MailForm plugin allows you to insert a form to send
@@ -27,7 +27,7 @@ require_once 'diogenes/diogenes.hermes.inc.php';
  * To make use of this plugin, insert {MailForm}in your page
  * where the mail form should appear.
  */
-class MailForm extends Diogenes_Plugin_Skel_Filter
+class MailForm extends Diogenes_Plugin_Filter
 {  
   /** Plugin name */
   var $name = "MailForm";
@@ -35,16 +35,8 @@ class MailForm extends Diogenes_Plugin_Skel_Filter
   /** Plugin description */
   var $description = "This plugin allows you to insert a form to send an e-mail to a fixed recipient. To make use of this plugin, insert <b>{MailForm}</b> in your page where the mail form should appear.";
   
-
-  /** Constructor.
-   */
-  function MailForm()
-  {
-    $this->declareParam('email', '');
-    $this->declareParam('title', '');
-    $this->declareParam('subject_tag', '[web form]');
-  }
-
+  /** Plugin parameters */
+  var $params = array('email' => '', 'title' => '', 'subject_tag' => '[web form] ');
 
   /** Show an instance of the MailForm plugin.
    */
@@ -52,9 +44,9 @@ class MailForm extends Diogenes_Plugin_Skel_Filter
   {
     global $page;
 
-    // get parameters
-    $to_email = $this->getParamValue('email');
-    $form_title = $this->getParamValue('title');
+    // get params
+    $to_email = $this->params['email'];
+    $form_title = $this->params['title'];
     
     if (!isvalid_email($to_email)) {
       return '<p>You must specify a valid e-mail in the "email" parameter to make use of the MailForm plugin.<p>';
@@ -88,7 +80,7 @@ class MailForm extends Diogenes_Plugin_Skel_Filter
       
       $mymail = new HermesMailer();
       $mymail->setFrom($from);
-      $mymail->setSubject($this->getParamValue('subject_tag').$subject);
+      $mymail->setSubject($this->params['subject_tag'].$subject);
       $mymail->addTo($to_email);
       $mymail->setTxtBody($message);
       $mymail->send();
index c1a736c..d1aa999 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-require_once 'Plugin/Skel/Render.php';
+require_once 'Plugin/Render.php';
 
 /** The RenderPhp plugin allows you to execute a file as PHP
  *  rather than return its content.
  **/
-class RenderPhp extends Diogenes_Plugin_Skel_Render
+class RenderPhp extends Diogenes_Plugin_Render
 {
   /** Plugin name */
   var $name = "RenderPhp";
index 7b032e6..251cd6d 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-require_once 'Plugin/Skel/Filter.php';
+require_once 'Plugin/Filter.php';
 require_once 'classTextile.php';
 require_once 'diogenes.text.inc.php';
 
 /** The TextileMarkup plugin allows you to render Textile markup into XHTML.
  */
-class TextileMarkup extends Diogenes_Plugin_Skel_Filter
+class TextileMarkup extends Diogenes_Plugin_Filter
 {
   /** Plugin name */
   var $name = "TextileMarkup";
index 2d970b4..f1cf322 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-require_once 'Plugin/Skel/Filter.php';
+require_once 'Plugin/Filter.php';
 require_once 'Text/Wiki.php';
 
 
 /** The WikiMarkup plugin allows you to render Wiki markup into XHTML. 
  */
-class WikiMarkup extends Diogenes_Plugin_Skel_Filter
+class WikiMarkup extends Diogenes_Plugin_Filter
 {
   /** Plugin name */
   var $name = "WikiMarkup";
index 1529cd8..bac68e0 100644 (file)
@@ -9,9 +9,9 @@
 <tr>
   <td>{if $myevent.icon}<img class="fileicon" src="{$myevent.icon}" />{else}&nbsp;{/if}</td>
   <td class="logdate">{$myevent.stamp|date_format:"%Y-%m-%d %H:%M:%S"}</td>
-  <td class="logauthor">{$myevent.author}</td>
-  <td><a {if $myevent.link_admin}href="{$myevent.link_admin}"{else}class="empty"{/if}>{$myevent.title}</a></td>
-  <td>{$myevent.opfile}</td>
+  <td class="logauthor">{$myevent.username}</td>
+  <td>{a lnk=$myevent.desc}</td>
+  <td>{$myevent.file}</td>
 </tr>
 {/foreach}
 </table>
diff --git a/templates/admin-rss.tpl b/templates/admin-rss.tpl
deleted file mode 100644 (file)
index aea0e1e..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<!-- generator="Diogenes {$version}" -->
-<rss version="2.0">
-<channel>
-<title>Diogenes</title>
-<description>Diogenes RSS feed - {$site_title}</description>
-<link>
-{$site_link}
-</link>
-<generator>Diogenes {$version}</generator>
-{foreach item=item from=$items}
-<item>
-  <title>{$item.title}</title>
-  {if $item.link}<link>{$item.link}</link>{/if}
-  {if $item.description}<description>{$item.description}</description>{/if}
-  {if $item.author}<author>{$item.author}</author>{/if}
-  {if $item.data}<pubDate>{$item.date}</pubDate>{/if}
-</item>
-{/foreach}
-</channel>
-</rss>
index e5b485b..14155d5 100644 (file)
@@ -1,4 +1,23 @@
 {if !$readonly}
+{literal}
+<script type="text/javascript">
+  <!--
+  function move_up( myplug ) {
+    document.plug_form.action.value = "move_up";
+    document.plug_form.plug_target.value = myplug;
+    document.plug_form.submit();
+    return true;
+  }
+  function move_down( myplug ) {
+    document.plug_form.action.value = "move_down";
+    document.plug_form.plug_target.value = myplug;
+    document.plug_form.submit();
+    return true;
+  }
+  // -->
+</script>
+{/literal}
+
 <form name="plug_form" method="post" action="{$post}">
 <input type="hidden" name="action" value="update" />
 <input type="hidden" name="plug_target" value="" />
 {foreach from=$plugins key=plugtype item=plugarr}
 <table class="light" style="width:80%">
 <tr>
-  <th colspan="2">{$plugtype} {$msg_plugedit_plugins}</th>
+  <th colspan="{if $show_params}4{else}3{/if}">{$plugtype} {$msg_plugedit_plugins}</th>
 </tr>
+{counter start=0 assign=cnt print=0}
 {foreach from=$plugarr item=plug}
-<tr class="odd">
-  <td><img class="fileicon" src="{$plug.icon}"/>&nbsp;{$plug.name}&nbsp;v{$plug.version}</td>
-  <td>
-{if $readonly || $plug.readonly}
-    {$statusvals[$plug.status]}
-{else}
-    <select name="{$plug.name}_status">{html_options options=$rwstatusvals selected=$plug.status}</select>
+<tr{if $cnt % 2} class="odd"{/if}>
+  <td style="width:30px">
+    <img class="fileicon" src="{$plug.icon}" />
+  </td>
+  <td>    
+    <div class="name">{if !$readonly}<input type="checkbox" name="plugins_active[]" value="{$plug.name}"{if $plug.active} checked="checked"{/if} />&nbsp;{/if}{$plug.name}&nbsp;v{$plug.version}</div>
+{if !$readonly}
+    <a class="action"{if $plug.move_up}href="javascript:move_up('{$plug.name}');"{/if}>{$msg_move_up}</a>&nbsp;<a class="action"{if $plug.move_down}href="javascript:move_down('{$plug.name}');"{/if}>{$msg_move_down}</a>
 {/if}
   </td>
-</tr>
-<tr>
-  <td><div class="description">{$plug.description}</div></td>
   <td>
-{if $show_params}
-    <table class="plugparams">
+  <div class="description">{$plug.description}</div>
+  </td>  
+{if !$readonly && $show_params}       
+  <td>
+    <table>
 {foreach from=$plug.params key=key item=val}
     <tr>
       <td>{$key}</td>
-      <td><input type="text" name="{$plug.name}_{$key}" value="{$val.value|escape}" size="30" /></td>
+      <td><input type="text" name="{$plug.name}_{$key}" value="{$val|escape}" size="30" /></td>
     </tr>
 {/foreach}
     </table>
-{else}
-    &nbsp;
-{/if}
   </td>
+{/if}  
 </tr>
+{counter}
 {/foreach}
 </table>
 <br/>