ich habe mir mal die die Funktion printNavigation() in Version 4.0.2 angesehen. Dabei sind mir gleich einige Anmerkungen und Verbesserungsvorschläge eingefallen.
Wenn man in eine Externe URL javascript eingibt, darf man nur einfache Anführungszeichen einsetzen. Dies ist mir beim Einsatz der folgenden URL aufgefallen:
Code: Alles auswählen
javascript:Fenster=window.open('../webhosting/index_js_paketuebersicht.php');Fenster.focus()
Code: Alles auswählen
if (!empty($v['navigation']['externalURLTarget'])) $target = ' target="'.$v['navigation']['externalURLTarget'].'"';
Code: Alles auswählen
if (!empty($link)) echo '<a href="'.$link.'"'.(($target) ? $target : '' ).'>'.htmlspecialchars($v['caption']).'</a>';
Code: Alles auswählen
'.(($target) ? $target : '' ).'
Code: Alles auswählen
<?php /* _\|/_ vim: set et ts=4 sw=4 sts=4 nowrap fdm=marker:
*/
// $navi = getNavigation();
// $activeRubric = $cpoRubric['id'];
function getActiveElements($navi='', $activeRubric=0)
{
if ($navi=='') $navi = getNavigation();
if (empty($navi)) return false;
if ($activeRubric==0) $activeRubric = $GLOBALS['cpoRubric']['id'];
$naviElements = array();
$actElements = array();
$currLevels = array();
foreach ($navi as $k=>$v) {
$currLevels[$v['level']] = $v['id'];
$naviElements[$v['id']] = $v;
if ($v['rubric']['id']==$activeRubric) {
$actElements = array_splice($currLevels, 0, $v['level']);
}
}
// add an element at position 0,
// so that $actElements[Y] makes Y equal the level
array_unshift($actElements, 'X');
return $actElements;
}
// $navi = getNavigation();
// $activeRubric = $cpoRubric['id'];
// $levels: how many levels to display
// $parent: which element to start with
// $activeOnly: do not print inactive sublevels
function printNavigation($navi = '', $activeRubric = 0, $levels = 99, $parent = 0, $activeOnly = false)
{
if ($navi=='') $navi = getNavigation();
if (empty($navi)) return false;
if ($activeRubric==0) $activeRubric = $GLOBALS['cpoRubric']['id'];
$actLevels = getActiveElements($navi, $activeRubric);
$level = 0;
if ($parent==0) $level = 1; // start with first level
$ulstart = '<ul>';
$ulend = '';
foreach ($navi as $k=>$v) {
if ($v['level']<$level) $level = 0; // printed all childs of active parent => clear $level
if ($v['id']==$parent) $level = $v['level']+1; // found active parent => save $level
if ($v['level']!=$level) continue; // not the active level => continue
if ($v['rubric']['seclevel']==SECLEVEL_CLOSED) {
if (empty($_SESSION['SID_user']['id'])) continue;
$db = new DB;
$db->query("SELECT COUNT(*) FROM ".CPO_RUBRIC_PERMISSION." "
."WHERE rubric_id='".(int)$v['rubric']['id']."' "
."AND usergroups_id='".(int)$_SESSION['SID_user']['usergroups_id']."'");
$db->next_record();
if ($db->v('COUNT(*)')<=0 && $_SESSION['SID_user']['admin']!=ROLE_ADMIN) continue;
}
echo $ulstart;
$ulstart = '';
$ulend = '</ul>';
// build link
$link = $v['navigation']['externalURL'];
if (!empty($v['navigation']['externalURLTarget'])) $target = ' target="'.$v['navigation']['externalURLTarget'].'"';
else $target = false;
if (isset($v['rubric']['directory']))
$link = BASE_URL.$v['rubric']['directory'].'/index.php?rubric='.urlencode($v['rubric']['name']);
// mark active list elements
if ($actLevels[$level]==$v['id']) echo '<li class="active">';
else echo '<li>';
// print caption
if (!empty($link)) echo '<a href="'.$link.'"'.(($target) ? $target : '' ).'>'.htmlspecialchars($v['caption']).'</a>';
else echo htmlspecialchars($v['caption']);
// RECURSION!
if (
(!$activeOnly || $actLevels[$level]==$v['id']) && // print only active sublevels
$levels-1>0 // maximum number of levels to print
) printNavigation($navi, $activeRubric, $levels-1, $v['id'], $activeOnly);
echo '</li>';
}
echo $ulend;
}
Darüber hinaus, habe ich noch eine Variable an die Funktion übergeben, deren Text an das Navielement der aktiven Rubrik angehangen wird. Dies benutze ich, um alle freigegebenen Artikel mit in die Navigation zu hängen. Aber diese Funktion werde ich wahrscheinlich noch etwas anders realisieren, damit in einer Sitemap an alle Rubriken die freigegebenen Artikel als Link angehängt werden.
Eine weitere kleine Veränderung habe ich eingefügt, damit die <ul> Tags noch folgendermaßen aussehen: <ul class="navi3">. Dies müsste ich aber nocheinmal verfeinern.
Gruß Matthias V