<?php

/**
 * Deletes a web page.
 */

$page->layout = 'admin';

if (! User::require_admin ()) {
	$this->redirect ('/admin');
}

$lock = new Lock ('Webpage', $_GET['page']);
if ($lock->exists ()) {
	$page->title = i18n_get ('Editing Locked');
	echo $tpl->render ('admin/locked', $lock->info ());
	return;
}

$wp = new Webpage ($_GET['page']);

if (! $wp->remove ()) {
	$page->title = i18n_get ('An Error Occurred');
	echo i18n_get ('Error Message') . ': ' . $wp->error;
	return;
}

$memcache->delete ('_admin_page_' . $_GET['page']);
$this->add_notification (i18n_get ('Page deleted.'));
$this->hook ('admin/delete', $_GET);
$this->redirect ('/');

?>