exist($_GET['id'])) {
$art = new Art($_POST);
$app->update($art);
header('Location: ?id=' . $art->id() . '&edit=1');
}
break;
case 'template':
if ($app->exist($_GET['id'])) {
$template = $app->get($_POST['template']);
$art = $app->get($_POST['id']);
$art->setcss($template->css());
$app->update($art);
header('Location: ?id=' . $art->id() . '&edit=1');
}
break;
case 'delete':
if ($app->exist($_GET['id'])) {
$art = new Art($_POST);
$app->delete($art);
header('Location: ?id=' . $art->id());
}
break;
case 'login':
$_SESSION['level'] = $app->login($_POST['pass']);
if (isset($_GET['id'])) {
header('Location: ?id=' . $_GET['id']);
} else {
header('Location: ?');
}
break;
case 'logout':
$_SESSION['level'] = $app->logout();
if (isset($_GET['id'])) {
header('Location: ?id=' . $_GET['id']);
} else {
header('Location: ?');
}
break;
}
}
// _______________________________________________________ H E A D _____________________________________________________________
$titre = 'home';
if (isset($_GET['id'])) {
$titre = $_GET['id'];
if ($app->exist($_GET['id'])) {
$art = $app->get($_GET['id']);
$titre = $art->titre();
}
}
$aff->head($titre, 'w');
// ______________________________________________________ B O D Y _______________________________________________________________
$aff->nav($app);
if (isset($_GET['id'])) {
if ($app->exist($_GET['id'])) {
$art = $app->get($_GET['id']);
if (isset($_GET['edit']) and $_GET['edit'] == 1) {
$aff->edit($art);
$aff->template($art, $app->lister());
$aff->aside($app->lister());
} else {
$aff->lecture($art, $app);
}
} else {
if (isset($_POST['action'])) {
if ($_POST['action'] == 'new') {
$art = new Art($_GET);
$art->reset();
$app->add($art);
header('Location: ?id=' . $_GET['id'] . '&edit=1');
}
} else {
echo 'Cet article n\'existe pas encore
';
if ($level >= 2) {
echo '