Commit 118c06c4 authored by fettesvieh's avatar fettesvieh

it's now possible to create a nested navigation

parent 04209819
......@@ -7,6 +7,7 @@
<meta name="keywords" content="{$KEYWORDS}" />
<script type="text/javascript" src="{$ROOT_DIR}includes/js/jquery.js"></script>
<script type="text/javascript" src="{$ROOT_DIR}includes/js/acp3.js"></script>
<script type="text/javascript" src="{$DESIGN_PATH}navbar.js"></script>
<link rel="stylesheet" type="text/css" href="{$DESIGN_PATH}style.css" />
<link rel="stylesheet" type="text/css" href="{$DESIGN_PATH}ui.datepicker.css" />
<link rel="alternate" type="application/rss+xml" href="{uri args="feeds/list/feed_news"}" title="{$PAGE_TITLE} - {lang values="news|news"}" />
......@@ -21,26 +22,14 @@
<a name="top"></a>
<div id="head">
<h1 id="page-title">{$PAGE_TITLE}</h1>
{if $navbar.main}
<ul>
{foreach from=$navbar.main item=row}
<li><a href="{$row.href}" class="{$row.css}"{$row.target}>{$row.title}</a></li>
{/foreach}
</ul>
{/if}
{navbar block="main"}
</div>
<div id="breadcrumb">
{$BREADCRUMB}
</div>
<div id="sidebar">
{if $navbar.sidebar}
<h4>Navigation</h4>
<ul>
{foreach from=$navbar.sidebar item=row}
<li><a href="{$row.href}" class="{$row.css}"{$row.target}>{$row.title}</a></li>
{/foreach}
</ul>
{/if}
{navbar block="sidebar"}
{load_module module="users|sidebar"}
</div>
<div id="content">
......
$(function() {
$('#head ul li:has(ul)').hover(function() {
$(this).children('ul').show();
}, function() {
$(this).children('ul').hide();
});
});
\ No newline at end of file
......@@ -244,17 +244,39 @@ a.form {
}
#head ul li {
float: left;
position: relative;
}
#head ul li a {
margin-right: 3px;
padding: 0 5px;
line-height: 30px;
text-align: center;
color: #fff;
white-space: nowrap;
display: block;
}
#head ul li a:hover, #head ul li a.selected {
color: #f00;
}
#head ul ul {
width: 150px;
height: auto;
padding: 0;
background: #069;
border: 1px solid #333;
font-size: 1.0em;
display: none;
position: absolute;
top: 30px;
left: 0;
}
#head ul ul li a {
width: 140px;
}
#head ul ul ul {
top: -1px;
left: 149px;
}
#breadcrumb {
padding-left: 15px;
font-weight: bold;
......
<?php
function smarty_function_navbar($params)
{
global $modules;
if ($modules->check('pages', 'functions')) {
include_once ACP3_ROOT . 'modules/pages/functions.php';
if (!cache::check('pages')) {
cache::create('pages', generatePagesCache());
}
return processNavbar(cache::output('pages'), $params['block']);
}
return '';
}
/* vim: set expandtab: */
?>
\ No newline at end of file
......@@ -30,12 +30,6 @@ if (CONFIG_MAINTENANCE == '1' && defined('IN_ACP3')) {
// Evtl. gesetzten Content-Type des Servers überschreiben
header('Content-Type: ' . (defined('CUSTOM_CONTENT_TYPE') ? CUSTOM_CONTENT_TYPE : 'text/html') . '; charset=UTF-8');
// Navigationsleisten
if ($modules->check('pages', 'functions')) {
include_once ACP3_ROOT . 'modules/pages/functions.php';
$tpl->assign('navbar', processNavbar());
}
// Seitentitel und Brotkrümelspur setzen
$tpl->assign('TITLE', breadcrumb::output(2));
$tpl->assign('BREADCRUMB', breadcrumb::output());
......
......@@ -104,7 +104,7 @@ if (!isset($_POST['submit']) || isset($errors) && is_array($errors)) {
$tpl->assign('target', $target);
$tpl->assign('form', isset($form) ? $form : '');
$tpl->assign('pages_list', pagesList(cache::output('pages')));
$tpl->assign('pages_list', pagesList());
$content = $tpl->fetch('pages/create.html');
}
......
......@@ -113,7 +113,7 @@ if (validate::isNumber($modules->id) && $db->select('id', 'pages', 'id = \'' . $
$tpl->assign('form', isset($form) ? $form : $page[0]);
$tpl->assign('pages_list', pagesList(cache::output('pages'), $page[0]['parent'], $page[0]['id']));
$tpl->assign('pages_list', pagesList(0, $page[0]['parent'], $page[0]['id']));
$content = $tpl->fetch('pages/edit.html');
}
......
......@@ -10,7 +10,7 @@ function generatePagesCache()
{
global $db;
$pages = $db->select('p.id, p.start, p.end, p.mode, p.parent, p.sort, p.title, p.target, b.index_name AS block_name', 'pages AS p, ' . CONFIG_DB_PRE . 'pages_blocks AS b', 'p.block_id = b.id', 'b.id ASC, p.sort ASC, p.title ASC');
$pages = $db->select('p.id, p.start, p.end, p.mode, p.parent, p.block_id, p.sort, p.title, p.target, b.index_name AS block_name', 'pages AS p, ' . CONFIG_DB_PRE . 'pages_blocks AS b', 'p.block_id = b.id', 'p.block_id ASC, p.sort ASC, p.title ASC');
$c_pages = count($pages);
$items = array();
......@@ -33,10 +33,16 @@ function generatePagesCache()
* @param integer $self
* @return array
*/
function pagesList($pages, $parent = 0, $self = 0)
function pagesList($pages = 0, $parent = 0, $self = 0)
{
static $output = array(), $key = 0, $spaces = '';
if (empty($pages)) {
if (!cache::check('pages')) {
generatePagesCache();
}
$pages = cache::output('pages');
}
$c_pages = count($pages);
if ($c_pages > 0) {
......@@ -93,32 +99,34 @@ function parentCheck($id, $parent_id)
*
* @return mixed
*/
function processNavbar()
function processNavbar($pages, $block)
{
global $db, $modules;
if (!cache::check('pages_navbar')) {
cache::create('pages_navbar', $db->select('p.id, p.start, p.end, p.mode, p.title, p.target, b.index_name AS block_name', 'pages AS p, ' . CONFIG_DB_PRE . 'pages_blocks AS b', 'p.block_id != \'0\' AND p.block_id = b.id', 'p.sort ASC, p.title ASC'));
}
$pages = cache::output('pages_navbar');
$c_pages = count($pages);
if ($c_pages > 0) {
$navbar = array();
$selected = ' selected';
global $modules;
static $navbar = array();
for ($i = 0; $i < $c_pages; ++$i) {
if ($pages[$i]['start'] == $pages[$i]['end'] && $pages[$i]['start'] <= dateAligned(2, time()) || $pages[$i]['start'] != $pages[$i]['end'] && $pages[$i]['start'] <= dateAligned(2, time()) && $pages[$i]['end'] >= dateAligned(2, time())) {
$link['css'] = 'navi-' . $pages[$i]['id'] . ($modules->mod == 'pages' && $modules->page == 'list' && $modules->id == $pages[$i]['id'] ? $selected : '');
$link['href'] = uri('pages/list/item_' . $pages[$i]['id']);
$link['target'] = ($pages[$i]['mode'] == 2 || $pages[$i]['mode'] == 3) && $pages[$i]['target'] == 2 ? ' onclick="window.open(this.href); return false"' : '';
$link['title'] = $pages[$i]['title'];
$navbar[$pages[$i]['block_name']][$i] = $link;
$i = 0;
$navbar[$block].= empty($navbar[$block]) ? "<ul>\n" : "\n<ul>\n";
foreach ($pages as $row) {
if ($row['block_name'] == $block && !empty($row['block_id']) && $row['start'] == $row['end'] && $row['start'] <= dateAligned(2, time()) || $row['start'] != $row['end'] && $row['start'] <= dateAligned(2, time()) && $row['end'] >= dateAligned(2, time())) {
$css = 'navi-' . $row['id'] . ($modules->mod == 'pages' && $modules->page == 'list' && $modules->item == $row['id'] ? ' selected' : '');
$href = uri('pages/list/item_' . $row['id']);
$target = ($row['mode'] == 2 || $row['mode'] == 3) && $row['target'] == 2 ? ' onclick="window.open(this.href); return false"' : '';
$navbar[$block].= "\t" . '<li><a href="' . $href . '" class="' . $css . '"' . $target . '>' . $row['title'] . '</a>';
if (!empty($row['children'])) {
processNavbar($row['children'], $block);
}
$navbar[$block].= "</li>\n";
}
if ($i == $c_pages - 1) {
$navbar[$block].= "</ul>\n";
}
++$i;
}
return $navbar;
return str_replace("\n<ul>\n</ul>\n", '', $navbar[$block]);
}
return null;
return '';
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment