function getPages($page_id, $level = 0, $class = 'a', $current_page = '') { global $db, $class_ul; $level++; if($current_page == '') { $isfirst == 1; $current_page = getMainPage($page_id); $ul_class = ' class="page_menu"'; $sql = "SELECT page_id FROM pages WHERE page_parent = '".$page_id."' AND page_ts_delete IS NULL;"; $has_childs = $db->get_results($sql); if(count($has_childs)>0) $return.= '<span class="page_menu_title">'.utf8_encode(getDBData('page', 'title', $current_page)).':</span>'; } $return.= '<ul'.$ul_class.'>'; $level_spacer = ''; for($l=1;$l<=$level;$l++) { $level_spacer = $level_spacer.' ';} $sql = "SELECT * FROM pages WHERE page_parent = '".$current_page."' AND page_ts_delete IS NULL;"; $pages = $db->get_results($sql); if(count($pages)>0) { foreach($pages as $page) { $return.= '<li '.(($level>1)? '':'class="menu-'.$class).' id="link_'.$page->page_title.'">'.$level_spacer.'<a href="?p='.$page->page_id.'">'.utf8_encode($page->page_title).'</a>'; if($page->page_id != '' && $page->page_id == $page_id) $return.= '<div class="menu-'.$class.$liclass.'" id="selected"></div>'; $sql = "SELECT page_id FROM pages WHERE page_parent = '".$page->page_id."' AND page_ts_delete IS NULL;"; $has_childs = $db->get_results($sql); if(count($has_childs)>0) $return.= getPages($page_id, $level, $class, $page->page_id); $return.= '</li>'; if($class == 'a') { $class = 'b'; } else { $class = 'a'; } } $return.= '</ul>'; } return $return; }
if($_POST['page_save']) { if($_POST['page_title'] != '' && $_POST['page_title'] != "Geben Sie hier den Titel an" && $_POST['page_content'] != '') { if($_POST['page_comments'] == 'on') { $page_comments = '1'; } else { $page_comments = '0'; } if($_POST['page_loginrequired'] == 'on') { $page_loginrequired = '1'; } else { $page_loginrequired = '0'; } if($_POST['page_id'] == 0) { $menu_id = $_POST['menu_id']; } else { $menu_id = $db->get_var("SELECT menu_id FROM pages WHERE page_id = '".getMainPage($_POST['page_id'])."';"); } $insert = $db->query('UPDATE pages SET page_title = "'.utf8_decode($db->escape($_POST['page_title'])).'", page_content = "'.utf8_decode($db->escape($_POST['page_content'])).'", page_ts_update = NOW(), page_id_update = '.$_SESSION['user_id'].', page_comments = '.$page_comments.', page_loginrequired = '.$page_loginrequired.', page_parent = "'.$_POST['page_id'].'", menu_id = "'.$_POST['menu_id'].'" WHERE page_id = '.$_GET['edit'].';'); if($insert) { message("Die Seite wurde erfolgreich gespeichert", 'success'); } else { message('Die Seite konnte nicht gespeichert werden', 'error'); }