From 3957bfef9f70e565776a7e743c6e70623556db35 Mon Sep 17 00:00:00 2001 From: Jeremy Laine Date: Thu, 1 Jun 2006 07:22:04 +0000 Subject: [PATCH] merge changes from diogenes-0.9.19 branch back into trunk --- ChangeLog | 7 ++- Makefile | 2 +- debian/README.Debian | 10 ++++ debian/changelog | 7 ++- debian/diogenes.postinst | 23 +------- include/admin/menus.php | 4 +- include/diogenes.barrel.inc.php | 77 +++++++++++++++++--------- include/diogenes.page.inc.php | 2 +- include/diogenes/ChangeLog | 3 + include/diogenes/diogenes.core.globals.inc.php | 4 ++ 10 files changed, 85 insertions(+), 54 deletions(-) diff --git a/ChangeLog b/ChangeLog index 88dff6b..2a018a1 100644 --- 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 diff --git a/Makefile b/Makefile index 9aa314b..c0b9ad0 100644 --- 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) diff --git a/debian/README.Debian b/debian/README.Debian index 7e8fcd8..cd3827c 100644 --- a/debian/README.Debian +++ b/debian/README.Debian @@ -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. diff --git a/debian/changelog b/debian/changelog index be952a0..f5ffac7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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é Mon, 22 May 2006 16:26:42 +0200 + -- Jeremy Lainé Wed, 31 May 2006 21:03:46 +0200 diogenes (0.9.18-1) unstable; urgency=low diff --git a/debian/diogenes.postinst b/debian/diogenes.postinst index f0b5b83..49db604 100644 --- a/debian/diogenes.postinst +++ b/debian/diogenes.postinst @@ -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 diff --git a/include/admin/menus.php b/include/admin/menus.php index e272780..269c4c7 100644 --- a/include/admin/menus.php +++ b/include/admin/menus.php @@ -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) { diff --git a/include/diogenes.barrel.inc.php b/include/diogenes.barrel.inc.php index 366caff..bf800e0 100644 --- a/include/diogenes.barrel.inc.php +++ b/include/diogenes.barrel.inc.php @@ -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
"; - $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. diff --git a/include/diogenes.page.inc.php b/include/diogenes.page.inc.php index 1c3aa2f..6c058db 100644 --- a/include/diogenes.page.inc.php +++ b/include/diogenes.page.inc.php @@ -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(); diff --git a/include/diogenes/ChangeLog b/include/diogenes/ChangeLog index 42d3d55..3d79608 100644 --- a/include/diogenes/ChangeLog +++ b/include/diogenes/ChangeLog @@ -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 diff --git a/include/diogenes/diogenes.core.globals.inc.php b/include/diogenes/diogenes.core.globals.inc.php index 61132b1..b940478 100644 --- a/include/diogenes/diogenes.core.globals.inc.php +++ b/include/diogenes/diogenes.core.globals.inc.php @@ -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; } -- 2.1.4