Diogenes 0.9.20pre1
- * TODO
+ * 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
--- /dev/null
+<?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&dir={$myarr['dir']}&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;
+ }
+}
+
+?>
--- /dev/null
+<?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;
+ }
+
+}
+
+?>
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;
-$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);
-}
-
+$events = new Diogenes_Barrel_Events($bbarrel);
// retrieve recent events
-$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&dir=$mydir&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);
+$event_arr = $events->getEvents($page);
+$page->assign('events', $event_arr);
// do display
$page->assign('greeting',__("Welcome to the Diogenes backoffice"));
<?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"));
/* we want to erase the current entry */
case "supprimer":
$MID = $_REQUEST['MID'];
- 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);
+ $bmenu->deleteEntry($MID, $MIDpere, $page);
break;
/* bring an entry up in the menu */
case "remonter":
$ordre = $_REQUEST['ordre'];
- swapentries($MIDpere,$ordre-1,$ordre,$bbarrel->table_menu);
+ $bmenu->swapEntries($MIDpere, $ordre-1, $ordre);
break;
/* push an entry down in the menu */
case "descendre":
$ordre = $_REQUEST['ordre'];
- swapentries($MIDpere,$ordre,$ordre+1,$bbarrel->table_menu);
+ $bmenu->swapEntries($MIDpere, $ordre, $ordre+1);
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" :
- $pid = isset($_REQUEST['PIvaleur']) ? $_REQUEST['PIvaleur'] : 0;
- $link = "";
+ $props['pid'] = isset($_REQUEST['PIvaleur']) ? $_REQUEST['PIvaleur'] : 0;
break;
case "boutonSE" :
- $pid = 0;
- $link = $_REQUEST['SEvaleur'];
+ $props['link'] = $_REQUEST['SEvaleur'];
break;
- default:
- $pid = 0;
- $link = "";
- }
- $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");
}
-
+ $MID = $bmenu->writeEntry($_REQUEST['MID'], $props);
break;
/* display the form to edit an entry */
// if this is an existing entry, retrieve data
if ($MID) {
- $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);
+ $mcache = $bmenu->menuRead();
+ $link = $mcache[$MID]['link'];
+ $title = $mcache[$MID]['title'];
+ $pid = $mcache[$MID]['pid'];
}
// fill out form data
}
// get the maximum order
-$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)) {
+$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'];
$clickup="?action=remonter&MIDpere=$MIDpere&ordre=$ordre";
$clickdown="?action=descendre&MIDpere=$MIDpere&ordre=$ordre";
// describe the current link
if ($PID) {
- $descr = "<a href=\"pages?dir=$PID\">$ptitle</a>";
+ $tpage = Diogenes_Barrel_Page::fromDb($bbarrel, $PID);
+ $descr = "<a href=\"pages?dir=$PID\">".$tpage->props['title']."</a>";
} elseif ($link) {
$descr = "<a href=\"$link\">[ext] $link</a>";
} else {
stripslashes($descr),
$edit,$del,$up,$down));
}
-mysql_free_result($res);
// all menu entries from database
-$mcache = $page->menuRead();
-$filiation = $page->menuToRoot($mcache,$MIDpere,array());
+$filiation = $bmenu->menuToRoot($mcache,$MIDpere,array());
$menubar = array();
foreach($filiation as $mykey=>$myval) {
if ($myval == 0) {
$blab = "<i>home</i>";
} else {
- $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);
+ $blab = stripslashes($mcache[$myval]['title']);
}
array_unshift($menubar,$mykey ? array($blab,"?MIDpere=$myval") : array($blab));
}
--- /dev/null
+<?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');
+?>
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
// 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").'" />');
}
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
- $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;
+ $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')));
}
}
return $path;
}
-
+
/** Returns the URL to one of the barrel's pages relative to
* the current location.
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);
+ }
+
}
?>
<tr>
<td>{if $myevent.icon}<img class="fileicon" src="{$myevent.icon}" />{else} {/if}</td>
<td class="logdate">{$myevent.stamp|date_format:"%Y-%m-%d %H:%M:%S"}</td>
- <td class="logauthor">{$myevent.username}</td>
- <td>{a lnk=$myevent.desc}</td>
- <td>{$myevent.file}</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>
</tr>
{/foreach}
</table>
--- /dev/null
+<!-- 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>