Hallo, ich habe hier ein Script, das verschiede Layer positionieren soll, Leide schließt der Layer (wie ausgewiesen) nicht. Hat mir jemand einen Tipp, wie ich das hinbringen könnte?
PHP-Code:
public function getTree($menu_area_id, $language_id) {
$sql = "SELECT n.id, n.menu_link, n.menu_name, n.menu_area, COUNT(*)-1 AS level, n.lft, n.rgt, ROUND ((n.rgt - n.lft - 1) / 2) AS children FROM ".self::PREFIX."sections AS n, ".self::PREFIX."sections AS p WHERE (n.lft BETWEEN p.lft AND p.rgt) AND (n.menu_area = '$menu_area_id' AND n.language_id = '".$language_id."' AND p.menu_area = '$menu_area_id' AND p.language_id = '".$language_id."' AND ((n.access_for = '#all' AND p.access_for = '#all') OR (n.access_for IN (".$this -> front_users($_SESSION['front_user_id'])."))) AND ((n.public_status = '2' AND p.public_status = '2') OR (n.public_status = '".$_ENV['open_preview']."'))) GROUP BY n.lft ORDER BY n.lft;";
$result = $this->db->query($sql);
if($this->db->error != "")
die($this->db->error."_getTree");
$tree = array();
$i = 0;
while ($row = $result->fetch_assoc()) {
$tree[$i] = $row;
$i++;
}
return $tree;
}
public function treeAsHtml($id, $menu_area_id, $language_id, $css_id, $css_class, $layers) {
$tree = $this->getTree($menu_area_id, $language_id);
$level = Array();
$html = "<ul";
if($css_id != "")
$html .= " id=\"".$css_id."\" ";
if($css_class != "")
$html .= " class=\"".$css_class."\" ";
$html .= ">";
$result = $this -> selectSimpleSql('navigation', 'id', $menu_area_id, '', '', 'id', 'ASC');
$level_data = $result->fetch_assoc();
$limits = unserialize($level_data['limits']);
$close = "";
$split_layer = Array();
$tmp_before = Array();
$tmp_after = Array();
for ($i=0; $i<count($tree); $i++) {
$level = $tree[$i]['level'] + 1;
if($layers['html_container_open_'.$level] != "" AND $layers['enclose_before_after_tag_'.$level] == "1" AND $tree[$i]['level'] < $tree[$i+1]['level']) {
$html .= $layers['html_container_open_'.$level];
$tmp_before[$level] = $i;
}
$html .= "<li "; if($limits['li_css_class_'.$level] != "") { $html .= "class=\" ". $limits['li_css_class_'.$level] . " ".$active."\""; } $html .= ">";
if($layers['enclose_tag_level_'.$level] != "") {
$split_layer = explode('><', $layers['enclose_tag_level_'.$level]);
$html .= $split_layer[0].">";
}
if(array_key_exists($tree[$i]['id'].'', $GLOBALS['url']) == false AND $tree[$i]['menu_link'] == "" AND $this -> is_content($tree[$i]['id']) != false) {
$html .= "<a href=\"?id=" . $tree[$i]['id'] . "\" "; if($limits['tag_css_class_'.$level] != "") { $html .= " class=\"". $limits['tag_css_class_'.$level] . "\""; } $html .= " >" . $tree[$i]['menu_name'] . "</a>";
} else if ($tree[$i]['id'] == $this -> getDefaultId() AND $this -> is_content($tree[$i]['id']) != false){
$html .= "<a href=\"\" "; if($limits['tag_css_class_'.$level] != "") { $html .= " class=\"". $limits['tag_css_class_'.$level] . "\""; } $html .= ">" . $tree[$i]['menu_name'] . "</a>";
} else if($tree[$i]['menu_link'] == "" AND $this -> is_content($tree[$i]['id']) != false) {
$html .= "<a href=\"" . $GLOBALS['url'][$tree[$i]['id']] . "\" "; if($limits['tag_css_class_'.$level] != "") { $html .= " class=\"". $limits['tag_css_class_'.$level] . "\""; } $html .= ">" . $tree[$i]['menu_name'] . "</a>";
} else if($this -> is_content($tree[$i]['id']) === false) {
$html .= "<".$layers['tag_layer_'.$level].""; if($limits['tag_css_class_'.$level] != "") { $html .= " class=\"".$limits['tag_css_class_'.$level] . "\""; } $html .= ">" . $tree[$i]['menu_name'] . "</".$layers['tag_layer_'.$level].">";
} else if (is_numeric($tree[$i]['menu_link'])) {
$html .= "<a href=\"" . $GLOBALS['url'][$tree[$i]['menu_link']] . "\" "; if($limits['tag_css_class_'.$level] != "") { $html .= " class=\"". $limits['tag_css_class_'.$level] . "\""; } $html .= ">" . $tree[$i]['menu_name'] . "</a>";
} else if (substr( $tree[$i]['menu_link'] , 0, 7) == "http://" OR substr( $tree[$i]['menu_link'], 0, 7) == "mailto:") {
$html .= "<a href=\"" . $tree[$i]['menu_link'] . "\" "; if($limits['tag_css_class_'.$level] != "") { $html .= " class=\"". $limits['tag_css_class_'.$level] . "\""; } $html .= ">" . $tree[$i]['menu_name'] . "</a>";
} else {
$html .= "<a href=\"" . $tree[$i]['menu_link'] . "\" target=\"_blank\" "; if($limits['tag_css_class_'.$level] != "") { $html .= " class=\"". $limits['tag_css_class_'.$level] . "\""; } $html .= ">" . $tree[$i]['menu_name']."</a>";
}
if($layers['enclose_tag_level_'.$level] != "") {
$split_layer = explode('><', $layers['enclose_tag_level_'.$level]);
$html .= "<".$split_layer[1];
}
if($tree[$i]['level'] == $tree[$i+1]['level'] OR $tree[$i]['level'] > $tree[$i+1]['level']) {
$html .= "</li>";
}
if($layers['html_container_open_'.$level] != "" AND $layers['enclose_before_after_tag_'.$level] == "2" AND $tree[$i]['level'] < $tree[$i+1]['level']) {
$html .= $layers['html_container_open_'.$level];
$tmp_after[$level] = $tree[$i]['children'] + $i;
print('#'.$tree[$i]['children'].'*'); // ist 28 sollte 4 sein
}
if(!empty($tmp_before[$level]) AND $tmp_before[$level] < $i) {
$html .= $layers['html_container_close_'.$level];
}
if(!empty($tmp_after[$level]) AND $tmp_after[$level] == $i) {
$html .= $layers['html_container_close_'.$level];
unset($tmp_after[$level]);
}
if($tree[$i]['level'] < $tree[$i+1]['level']) {
$html .= "<ul"; if($limits['ul_css_class_'.$level] != "") { $html .= " class=\"". $limits['ul_css_class_'.$level] . "\""; } $html .= ">";
} else if ($tree[$i]['level'] > $tree[$i+1]['level']) {
$diff = $tree[$i]['level'] - $tree[$i+1]['level'];
$html .= str_repeat("</ul></li>", $diff) . "";
if(!empty($tmp_after[$level]) AND $tmp_after[$level] < $i) {
$html .= $layers['html_container_close_'.$level];
}
}
$active = "";
}
$html .= "</ul>";
return $html;
}
Kommentar