<?php
/*
DynPage V1.01 - A simple Content Management System
Copyright (C) 2009-2010 Matthias Wiede <hide@address.com>
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 3 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, see http://www.gnu.org/licenses.
*/
// Create menu
$menuItems =
"Pages|page|noclick\n".
"*New page|page_new\n".
"*All pages|page_edit|noclick\n";
foreach ($_SESSION["pageFileList"] as $i => $pageData) {
// $menuItems.=("**".$pageData["name"]."|page_edit_".$i."&pid=".$i."\n");
$menuItems.=("**".$pageData["name"]."|page_edit_".$i."&pid=".$i."||file=".basename($pageData["filename"])."\n");
}
$menuItems.=
"Files|filebrowser\n".
"Config|config|noclick\n".
"*CKeditor styles|config_ckeditor\n".
"*Change password|config_changepwd\n".
"*Change layout|config_style\n".
"Logout|logout";
$itemList = explode ("\n", $menuItems);
$htmlMenu = "";
$oldDeep = 0;
foreach ($itemList as $item) {
$deep = 0;
$len = strlen ($item);
for ($i=0;$i<$len;$i++) {
if ($item[$i]=='*')
$deep++;
}
$item = trim ($item, "*");
$attrList = explode ("|", $item);
$extra = "";
// Mark correct items
$page2 = $attrList[1];
if (strpos ($page2, '&')!==false) {
list($page2, $query) = explode ("&", $page2);
}
$pagePath2 = explode ("_", $page2);
if (count ($pagePath)>=count($pagePath2)) {
for ($i=0;$i<($deep+1);$i++) {
if ($pagePath[$i]!=$pagePath2[$i])
break;
}
if ($i==($deep+1))
$extra = " class=\"marked\"";
}
$url = "?page=".$attrList[1];
if (isset ($attrList[3]))
$url = "?".$attrList[3];
if (isset ($attrList[2]) && $attrList[2]=="noclick") {
$htmlLink = "<a".$extra." href=\"#\">".htmlspecialchars ($attrList[0])."</a>";
}
else
$htmlLink = "<a".$extra." href=\"".$url."\">".htmlspecialchars ($attrList[0])."</a>";
if ($deep>$oldDeep)
$htmlMenu.= "<ul>";
if ($deep<$oldDeep) {
$htmlMenu.="</li>";
for ($i=$deep;$i<$oldDeep;$i++) {
$htmlMenu.="</ul>";
}
}
$htmlMenu.= "<li>".$htmlLink;
$oldDeep = $deep;
}
if ($htmlMenu!="")
$htmlMenu="<ul>".$htmlMenu."</li></ul>";
if (!isLogin ()) {
$htmlMenu = "";
}
?>