<?php require "section.php"; $section = isset($_GET['section']) ? $_GET['section'] : 1; //если секция не указано, то по умолчанию главная, т.е. 1. $section = Sections::isSection($section) ? $section : 0; admin($section); function info($section) { $data = Sections::getIdSection($section); return $data; } function tree($data, $parent_id) { //объеденить с деревом admin.php if (is_array($data) and isset($data[$parent_id])) { $tree = '<ul>'; foreach ($data[$parent_id] as $d) { $tree .= '<li><a href="/?section=' . $d['id'] . '">' . $d['name'] . ' #' . $d['id']; $tree .= tree($data, $d['id']); $tree .= '</a></li>'; } $tree .= '</ul>'; } else { return null; } return $tree; } function menu($section) { $data = Sections::getIdSectionMenu($section);
function act($section) { $data = array(); $data['parent_id'] = $_POST['parent_id']; $data['name'] = $_POST['name']; $data['text'] = $_POST['text']; if (isset($_POST['edit'])) { $data['id'] = $section; if (!Sections::isSection($data['parent_id'])) { $data['parent_id'] = 0; } Sections::updateSection($data); header("Location: " . PATH . "/admin.php?section=" . $section); } else { if (isset($_POST['delete'])) { Sections::deleteSection($section); header("Location: " . PATH . "/admin.php"); } else { if (isset($_POST['add'])) { if (!Sections::isSection($data['parent_id'])) { $data['parent_id'] = 0; } Sections::insertSection($data); header("Location: " . PATH . "/admin.php?section=" . $data['parent_id']); } else { header("Location: " . PATH . "/admin.php?section=" . $section); } } } }