Commit e8e14acc authored by fettesvieh's avatar fettesvieh

massive changes to the breadcrumbs and menu items (dynamic pages can now also have superior pages)

parent da6fc7b8
{if $comments}
<h1 id="comments">{lang values="comments|comments"}</h1>
{if $comments}
{$pagination}
{foreach from=$comments item=row}
<div class="gb">
......
......@@ -39,11 +39,6 @@
<dl>
<dt><label for="title">{lang values="pages|title"}</label></dt>
<dd><input type="text" name="form[title]" id="title" value="{$form.title}" maxlength="120" /></dd>
</dl>
</fieldset>
<fieldset id="static_page" style="width:70%">
<legend>{lang values="pages|static_page"}</legend>
<dl>
<dt><label for="parent">{lang values="pages|superior_page"}</label></dt>
<dd>
<select name="form[parent]" id="parent">
......@@ -53,6 +48,11 @@
{/foreach}
</select>
</dd>
</dl>
</fieldset>
<fieldset id="static_page" style="width:70%">
<legend>{lang values="pages|static_page"}</legend>
<dl>
<dt><label for="text">{lang values="pages|text"}</label></dt>
<dd>{fckeditor InstanceName="text" Value="`$form.text`" Width="100%" Height="250px"}</dd>
</dl>
......
......@@ -39,11 +39,6 @@
<dl>
<dt><label for="title">{lang values="pages|title"}</label></dt>
<dd><input type="text" name="form[title]" id="title" value="{$form.title}" maxlength="120" /></dd>
</dl>
</fieldset>
<fieldset id="static_page" style="width:70%">
<legend>{lang values="pages|static_page"}</legend>
<dl>
<dt><label for="parent">{lang values="pages|superior_page"}</label></dt>
<dd>
<select name="form[parent]" id="parent">
......@@ -53,6 +48,11 @@
{/foreach}
</select>
</dd>
</dl>
</fieldset>
<fieldset id="static_page" style="width:70%">
<legend>{lang values="pages|static_page"}</legend>
<dl>
<dt><label for="text">{lang values="pages|text"}</label></dt>
<dd>{fckeditor InstanceName="text" Value="`$form.text`" Width="100%" Height="250px"}</dd>
</dl>
......
......@@ -61,15 +61,60 @@ class breadcrumb
* 2 = Nur Seitentitel ausgeben
* @return string
*/
public static function output($mode = 1)
public static function output($mode = 1, $id = '')
{
global $modules, $tpl;
$module = $modules->mod;
$page = $modules->page;
// Brotkrümelspur für die Menüpunkte
if ($module == 'pages' && $page == 'list') {
global $db;
if (!validate::isNumber($id))
$id = $modules->id;
$page = $db->select('mode, parent, title', 'pages', 'id = \'' . $id . '\' AND (mode = \'1\' OR mode = \'2\')');
// Dynamische Seiten (ACP3 intern)
if ($id == $modules->id && $page[0]['mode'] == 2 && empty($page[0]['parent']) && !empty(self::$steps) && self::$end != '') {
if ($mode == 1) {
$tpl->assign('breadcrumb', self::$steps);
$tpl->assign('end', self::$end);
return $tpl->fetch('common/breadcrumb.html');
} else {
return self::$end;
}
// Statische Seiten
} else {
// Brotkrümelspur ausgeben
if ($mode == 1) {
if ($id == $modules->id) {
self::$steps = array();
self::$end = '';
}
if (empty(self::$end)) {
self::$end = $page[0]['title'];
}
if ($db->select('parent', 'pages', 'id = \'' . $page[0]['parent'] . '\' AND (mode = \'1\' OR mode = \'2\')', 0, 0, 0, 1) > 0) {
$parent = $db->select('title', 'pages', 'id = \'' . $page[0]['parent'] . '\' AND (mode = \'1\' OR mode = \'2\')');
self::assign($parent[0]['title'], uri('pages/list/id_' . $page[0]['parent']));
return self::output(1, $page[0]['parent']);
}
$pages = self::$steps;
krsort($pages);
$tpl->assign('breadcrumb', $pages);
$tpl->assign('end', self::$end);
return $tpl->fetch('common/breadcrumb.html');
// Nur Seitentitel ausgeben
} else {
return $page[0]['title'];
}
}
// Brotkrümelspur für das Frontend
if (defined('IN_ACP3') && $mode == 1) {
} elseif (defined('IN_ACP3') && $mode == 1) {
// Zusätzlich zugewiesene Brotkrumen an Smarty übergeben
if (count(self::$steps) > 0) {
$tpl->assign('breadcrumb', self::$steps);
......
......@@ -20,7 +20,7 @@ if (CONFIG_MAINTENANCE == '1' && defined('IN_ACP3')) {
if ($modules->check()) {
include ACP3_ROOT . 'modules/' . $modules->mod . '/' . $modules->page . '.php';
$tpl->assign('CONTENT', isset($content) ? $content : '');
$tpl->assign('CONTENT', !empty($content) ? $content : '');
} elseif (!$auth->isUser() && defined('IN_ADM') && $modules->mod != 'users' && $modules->page != 'login') {
redirect('users/login');
} else {
......
......@@ -40,7 +40,6 @@ if (isset($_POST['submit'])) {
$form['uri'] = '';
$form['target'] = '';
} else {
$form['parent'] = '';
$form['text'] = '';
}
......@@ -60,7 +59,7 @@ if (isset($_POST['submit'])) {
$bool = $db->insert('pages', $insert_values);
cache::create('pages', $db->select('p.id, p.start, p.end, p.mode, p.title, p.uri, 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'));
cache::create('pages', $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'));
$content = comboBox($bool ? lang('pages', 'create_success') : lang('pages', 'create_error'), uri('acp/pages'));
}
......
......@@ -30,7 +30,7 @@ if (!isset($entries)) {
}
}
cache::create('pages', $db->select('p.id, p.start, p.end, p.mode, p.title, p.uri, 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'));
cache::create('pages', $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'));
$content = comboBox($bool ? lang('pages', 'delete_success') : lang('pages', 'delete_error'), uri('acp/pages'));
}
......
......@@ -44,7 +44,6 @@ if (validate::isNumber($modules->id) && $db->select('id', 'pages', 'id = \'' . $
$form['uri'] = '';
$form['target'] = '';
} else {
$form['parent'] = '';
$form['text'] = '';
}
......@@ -63,7 +62,7 @@ if (validate::isNumber($modules->id) && $db->select('id', 'pages', 'id = \'' . $
$bool = $db->update('pages', $update_values, 'id = \'' . $modules->id . '\'');
cache::create('pages', $db->select('p.id, p.start, p.end, p.mode, p.title, p.uri, 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'));
cache::create('pages', $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'));
cache::create('pages_list_id_' . $modules->id, $db->select('mode, uri, text', 'pages', 'id = \'' . $modules->id . '\''));
$content = comboBox($bool ? lang('pages', 'edit_success') : lang('pages', 'edit_error'), uri('acp/pages'));
......@@ -73,7 +72,7 @@ if (validate::isNumber($modules->id) && $db->select('id', 'pages', 'id = \'' . $
//Funktionen einbinden
include_once ACP3_ROOT . 'modules/pages/functions.php';
$page = $db->select('start, end, mode, parent, block_id, sort, title, uri, target, text', 'pages', 'id = \'' . $modules->id . '\'');
$page = $db->select('id, start, end, mode, parent, block_id, sort, title, uri, target, text', 'pages', 'id = \'' . $modules->id . '\'');
$page[0]['text'] = $db->escape($page[0]['text'], 3);
$page[0]['uri'] = $db->escape($page[0]['uri'], 3);
......@@ -114,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(0, $page[0]['parent']));
$tpl->assign('pages_list', pagesList(0, $page[0]['parent'], $page[0]['id']));
$content = $tpl->fetch('pages/edit.html');
}
......
......@@ -13,12 +13,12 @@
* @param integer $parent
* @return array
*/
function pagesList($id = 0, $parent = 0)
function pagesList($id = 0, $parent = 0, $newVar = 0)
{
global $db;
static $output = array(), $key = 0, $spaces = '';
$pages = $db->select('id, title', 'pages', 'mode = \'1\' AND parent = \'' . $id . '\'', 'block_id ASC, sort ASC, title ASC');
$pages = $db->select('id, title', 'pages', '(mode = \'1\' OR mode = \'2\') AND parent = \'' . $id . '\' AND id != \'' . $newVar . '\'', 'block_id ASC, sort ASC, title ASC');
$c_pages = count($pages);
if ($c_pages > 0) {
......@@ -31,7 +31,7 @@ function pagesList($id = 0, $parent = 0)
$output[$key]['title'] = $spaces . $pages[$i]['title'];
$key++;
pagesList($pages[$i]['id'], $parent);
pagesList($pages[$i]['id'], $parent, $newVar);
if ($i == $c_pages - 1) {
$spaces = substr($spaces, 0, -12);
......@@ -60,7 +60,7 @@ function parentCheck($id, $parent_id)
return true;
if ($db->select('id', 'pages', 'id = \'' . $parents[$i]['parent'] . '\'', 0, 0, 0, 1) > 0)
parent_check($id, $parents[$i]['parent']);
parentCheck($id, $parents[$i]['parent']);
}
}
return false;
......@@ -76,7 +76,7 @@ function processNavbar()
global $db, $modules;
if (!cache::check('pages')) {
cache::create('pages', $db->select('p.id, p.start, p.end, p.mode, p.title, p.uri, 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'));
cache::create('pages', $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');
$c_pages = count($pages);
......@@ -87,23 +87,9 @@ function processNavbar()
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'];
switch ($pages[$i]['mode']) {
case '1':
$link['href'] = uri('pages/list/id_' . $pages[$i]['id']);
$link['css'].= $modules->mod == 'pages' && $modules->page == 'list' && $modules->id == $pages[$i]['id'] ? $selected : '';
break;
case '2':
$link['href'] = uri($pages[$i]['uri']);
if (uri($modules->query) == uri($pages[$i]['uri'])) {
$link['css'].= $selected;
}
break;
default:
$link['href'] = $pages[$i]['uri'];
}
$link['target'] = ($pages[$i]['mode'] == '2' || $pages[$i]['mode'] == '3') && $pages[$i]['target'] == '2' ? ' onclick="window.open(this.href); return false"' : '';
$link['css'] = 'navi-' . $pages[$i]['id'] . ($modules->mod == 'pages' && $modules->page == 'list' && $modules->id == $pages[$i]['id'] ? $selected : '');
$link['href'] = uri('pages/list/id_' . $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;
......@@ -111,6 +97,6 @@ function processNavbar()
}
return $navbar;
}
return false;
return null;
}
?>
\ No newline at end of file
......@@ -19,99 +19,29 @@ if (validate::isNumber($modules->id) && $db->select('id', 'pages', 'id = \'' . $
$page = cache::output('pages_list_id_' . $modules->id);
if ($page[0]['mode'] == '1') {
/**
* Erweitert die Breadcrumb Klasse, damit für die statischen Seiten die Brotkrümelspur erstellt werden kann
*
*/
class breadcrumb
{
/**
* Enthält alle Schritte der Brotkrümelspur
*
* @var array
* @access protected
*/
protected static $steps = array();
/**
* Das Ende der Brotkrümelspur
*
* @var string
* @access protected
*/
protected static $end = '';
/**
* Zuweisung der jewiligen Stufen der Brotkrümelspur
*
* @param string $title
* Bezeichnung der jeweiligen Stufe der Brotkrume
* @param string $uri
* Der zum $title zugehörige Hyperlink
* @return array
*/
public static function assign($title, $uri = 0)
{
static $i = 0;
if (!empty($uri)) {
self::$steps[$i]['uri'] = $uri;
self::$steps[$i]['title'] = $title;
$i++;
return;
} else {
self::$end = $title;
return;
}
}
/**
* Gibt die Brotkrümelspur bzw. den Seitentitel einer statischen Seite aus
*
* @param integer $mode
* 1 = Brotkrümelspur ausgeben
* 2 = Nur Seitentitel ausgeben
* @param integer $id
* ID der jeweiligen statischen Seite
* @return string
*/
public static function output($mode = 1, $id = 0)
{
global $db, $modules, $tpl;
// Zuweisung der ID von der Elternseite bzw. der Ausgangsseite
$id = !empty($id) ? $id : $modules->id;
$page = $db->select('parent, title', 'pages', 'id = \'' . $id . '\' AND mode = \'1\'');
// Brotkrümelspur ausgeben
if ($mode == 1) {
if (empty(self::$end)) {
self::$end = $page[0]['title'];
}
if ($db->select('parent', 'pages', 'id = \'' . $page[0]['parent'] . '\' AND mode = \'1\'', 0, 0, 0, 1) > 0) {
$parent = $db->select('title', 'pages', 'id = \'' . $page[0]['parent'] . '\' AND mode = \'1\'');
self::assign($parent[0]['title'], uri('pages/list/id_' . $page[0]['parent']));
return self::output(1, $page[0]['parent']);
}
$pages = self::$steps;
krsort($pages);
$tpl->assign('breadcrumb', $pages);
$tpl->assign('end', self::$end);
return $tpl->fetch('common/breadcrumb.html');
// Nur Seitentitel ausgeben
} else {
return $page[0]['title'];
$tpl->assign('text', $db->escape($page[0]['text'], 3));
$content = $tpl->fetch('pages/list.html');
} elseif ($page[0]['mode'] == '2') {
$params = explode('/', $db->escape($page[0]['uri'], 3));
$c_params = count($params);
if (!empty($params[2])) {
for ($i = 2; $i < $c_params; ++$i) {
if (preg_match('/^(([a-z0-9-]+)_(.+))$/', $params[$i])) {
$param = explode('_', $params[$i], 2);
$modules->$param[0] = $param[1];
}
}
}
$tpl->assign('text', $db->escape($page[0]['text'], 3));
} elseif ($page[0]['mode'] == '2') {
redirect($page[0]['uri']);
if (!empty($params[0]) && !empty($params[1]) && $modules->check($params[0], $params[1])) {
include ACP3_ROOT . 'modules/' . $params[0] . '/' . $params[1] . '.php';
} else {
redirect('errors/404');
}
} else {
redirect(0, $db->escape($page[0]['uri'], 3));
}
} else {
redirect('errors/404');
}
$content = $tpl->fetch('pages/list.html');
?>
\ 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