merge changes from diogenes-0.9.19 branch back into trunk
authorJeremy Laine <jeremy.laine@m4x.org>
Thu, 1 Jun 2006 07:22:04 +0000 (07:22 +0000)
committerJeremy Laine <jeremy.laine@m4x.org>
Thu, 1 Jun 2006 07:22:04 +0000 (07:22 +0000)
ChangeLog
Makefile
debian/README.Debian
debian/changelog
debian/diogenes.postinst
include/admin/menus.php
include/diogenes.barrel.inc.php
include/diogenes.page.inc.php
include/diogenes/ChangeLog
include/diogenes/diogenes.core.globals.inc.php

index 88dff6b..2a018a1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
-Diogenes 0.9.18.1
+Diogenes 0.9.20
+ * improved - overhaul of the plugin system
+
+Diogenes 0.9.19
  * fixed - fix handling of filter plugins without arguments
+ * improved - reduce database calls used to build a page's menu
+ * improved - in debug mode, trace database calls used to build page menu
 
 Diogenes 0.9.18
  * improved - resync Textile plugin with Textpattern 4.0.2
index 9aa314b..c0b9ad0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # definitions
 
-VERSION = 0.9.19pre2
+VERSION = 0.9.20pre1
 PKG_DIST = diogenes-$(VERSION)
 LIB_DIST = libdiogenes-$(VERSION)
 
index 7e8fcd8..cd3827c 100644 (file)
@@ -1,6 +1,16 @@
 Diogenes for Debian
 -------------------
 
+WEBSERVER CONFIGURATION
+
+  On a Debian system, the default webserver configuration should allow you to
+  run Diogenes. If you have made some configuration changes yourself, you
+  should check the following:
+  
+   - your webserver needs to have PHP support enabled
+   - PHP needs to have MySQL support enabled
+
+
 GETTING STARTED WITH DIOGENES
 
   Diogenes will be available at http://localhost/diogenes/ after installation.
index be952a0..f5ffac7 100644 (file)
@@ -1,10 +1,11 @@
-diogenes (0.9.18-2) unstable; urgency=low
+diogenes (0.9.19-1) unstable; urgency=low
 
+  * New upstream release.
+  * Do not try to enable PHP support in the webserver or MySQL support in PHP
   * Update to standards version 3.7.2
   * Update versioned Build-Depends on debhelper to >= 5
-  * Add debian/watch file
 
- -- Jeremy LainĂ© <jeremy.laine@m4x.org>  Mon, 22 May 2006 16:26:42 +0200
+ -- Jeremy LainĂ© <jeremy.laine@m4x.org>  Wed, 31 May 2006 21:03:46 +0200
 
 diogenes (0.9.18-1) unstable; urgency=low
 
index f0b5b83..49db604 100644 (file)
@@ -128,29 +128,8 @@ webservers="$RET"
 for server in $webservers; do
     server=$(echo $server | sed 's/,$//')
     servers="$server $servers"
-    # Make sure our web server has PHP support
-    phpver=php4
-    phpini=/etc/$phpver/$server/php.ini
-    . /usr/share/wwwconfig-common/apache-php.sh
-    if [ "$status" = "uncomment" ] ; then
-      restart="$server $restart"
-    elif [ "$status" = "error" ] ; then
-      echo "Error while trying to enable $phpver support for '$server' : $error."
-    fi
-
-    # Make sure that PHP has MySQL support enabled
-    checkextensions=mysql
-    . /usr/share/wwwconfig-common/php-extensions.sh
-    
     includefile=/etc/diogenes/apache.conf
-    # For old versions of Diogenes, remove the include of ourapache.conf
-    if dpkg --compare-versions "$2" le-nl "0.9.9.3-6" ; then
-        . /usr/share/wwwconfig-common/apache-uninclude_all.sh
-        if [ "$status" = "uncomment" ] ; then
-            restart="$server $restart"
-       fi
-    fi
-    
+
     # If necessary, add a symlink to our apache.conf
     if [ -d /etc/$server/conf.d ] && [ ! -e /etc/$server/conf.d/diogenes ] ; then
         ln -s $includefile /etc/$server/conf.d/diogenes
index e272780..269c4c7 100644 (file)
@@ -207,7 +207,9 @@ while (list($MID,$ordre,$title,$link,$PID,$ptitle) = mysql_fetch_row($res)) {
 }
 mysql_free_result($res);
 
-$filiation = $page->menuToRoot($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) {
index 366caff..bf800e0 100644 (file)
@@ -353,35 +353,36 @@ 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();
-    $res = $this->dbh->query("select MID from {$this->table_menu} where PID='$PID'");
-    while (list($MID) = mysql_fetch_row($res))
-      $filiation = $this->menuToRoot($MID, $filiation);
-    mysql_free_result($res);
+    foreach ($mcache as $mid => $mentry)
+    {
+      if ($mentry['pid'] == $PID)
+        $filiation = $this->menuToRoot($mcache, $mid, $filiation);
+    }
 
     // add the user-defined part of the menu
-    $this->menu = array_merge($this->menu,$this->menuRecurse(0,$filiation,0));
+    $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($MID, $path) {
+  function menuToRoot($mcache, $MID, $path) {
     /* add ourself to the path */
     array_push($path,$MID);
 
     if ($MID) {
       /* recursion */
-      $res = $this->dbh->query("select MIDpere from {$this->table_menu} where MID=$MID");
-      list($MIDpere) = mysql_fetch_row($res);
-      mysql_free_result($res);
-
-      return $this->menuToRoot($MIDpere, $path);
+      return $this->menuToRoot($mcache, $mcache[$MID]['parent'], $path);
     } else {
       /* termination */
       return $path;
@@ -391,38 +392,64 @@ class DiogenesBarrel extends DiogenesPage
 
   /** Recursively add menu entries
    *
+   * @param mcache
    * @param MIDpere
    * @param filiation
    * @param level
    */
-  function menuRecurse($MIDpere, $filiation, $level) {
+  function menuRecurse($mcache, $MIDpere, $filiation, $level) {
     // the produced output
     $out = array();
 
-    $res = $this->dbh->query("select m.MID,m.title,m.link,m.PID ".
-                       "from {$this->table_menu} as m ".
-                       "where MIDpere=$MIDpere order by ordre");
-
-    while(list($mid,$title,$link,$pid) = mysql_fetch_row($res)) {
-      $location = $this->barrel->getLocation($pid);
+    foreach ($mcache[$MIDpere]['children'] as $mid)
+    {
+      $mentry = $mcache[$mid];
 //      echo "pid : $pid, location : $location<br/>";
-      $title = stripslashes($title);
-      $entry = htmlentities(stripslashes($title), ENT_QUOTES);
-      $link = $pid ? $this->urlSite($location) : $link;      
+      $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($mid, $filiation, $level+1));
+      array_push($out, array($level, $entry, $link, $expanded));
+      $out = array_merge($out, $this->menuRecurse($mcache, $mid, $filiation, $level+1));
     }
 
-    // free MySQL result and return output
-    mysql_free_result($res);
     return $out;
   }
 
 
+  /** Read this barrel's menu entries from database.
+   */
+  function menuRead()
+  {
+    $menu = 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;
+  }
+
+
   /** 
    * Break down a PATH_INFO into site, page id and file
    * Directories *must* be accessed with a final slash.
index 1c3aa2f..6c058db 100644 (file)
@@ -78,13 +78,13 @@ class DiogenesPage extends DiogenesCorePage
     global $globals;
     
     $this->assign('page_template', $template);
+    $this->makeMenu();
     if ($globals->debugdatabase) 
       $this->assign('db_trace',$globals->db->trace_format($this)); 
     if ($globals->debugplugins)
       $this->assign('plugins_trace',$globals->plugins->trace_format($this));
     if (($globals->debugplugins) || ($globals->debugdatabase))
       $this->assign('debug_css', $this->url("common.css"));
-    $this->makeMenu();
 
     if (!$master)
       $master = $this->getTemplate();
index 42d3d55..3d79608 100644 (file)
@@ -1,3 +1,6 @@
+libdiogenes 0.9.19
+ * improved - (globals) set HTTP status code 500 if database connection fails
+
 libdiogenes 0.9.18
  * improved - (mime) recognise MIME type of OMA DRM content
  * added - (mime) add function to retrieve a multipart content's boundary
index 61132b1..b940478 100644 (file)
@@ -59,7 +59,11 @@ class DiogenesCoreGlobals {
   {
     $db = new DiogenesDatabase($this->dbdb, $this->dbhost, $this->dbuser, $this->dbpwd);
     if (!$db->connect_id)
+    {
+      if (!headers_sent())
+        header("HTTP/1.0 500 Internal Server Error");
       die("Could not connect to database (".mysql_error().")");
+    }
     $this->db = $db;
   }