aboutsummaryrefslogtreecommitdiffstats
path: root/admin/page/delete.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/page/delete.php')
-rw-r--r--admin/page/delete.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/admin/page/delete.php b/admin/page/delete.php
new file mode 100644
index 0000000..163bbdb
--- /dev/null
+++ b/admin/page/delete.php
@@ -0,0 +1,72 @@
+<?php
+#===============================================================================
+# DEFINE: Administration
+#===============================================================================
+define('ADMINISTRATION', TRUE);
+define('AUTHENTICATION', TRUE);
+
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+require_once '../../core/application.php';
+
+#===============================================================================
+# TRY: Page\Exception
+#===============================================================================
+try {
+ $Page = Page\Factory::build(HTTP::GET('id'));
+ $Attribute = $Page->getAttribute();
+
+ if(HTTP::issetPOST(['token' => Application::getSecurityToken()], 'delete')) {
+ try {
+ if($Attribute->databaseDELETE($Database)) {
+ HTTP::redirect(Application::getAdminURL('page/'));
+ }
+ } catch(PDOException $Exception) {
+ $messages[] = $Exception->getMessage();
+ }
+ }
+
+ #===============================================================================
+ # TRY: Template\Exception
+ #===============================================================================
+ try {
+ $FormTemplate = Template\Factory::build('page/form');
+ $FormTemplate->set('HTML', $Page->getHTML());
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'DELETE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => [
+ 'ID' => $Attribute->get('id'),
+ 'BODY' => $Attribute->get('body'),
+ 'TIME_INSERT' => $Attribute->get('time_insert'),
+ 'TIME_UPDATE' => $Attribute->get('time_update'),
+ ],
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
+
+ $DeleteTemplate = Template\Factory::build('page/delete');
+ $DeleteTemplate->set('HTML', $FormTemplate);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_page_delete'));
+ $MainTemplate->set('HTML', $DeleteTemplate);
+ echo $MainTemplate;
+ }
+
+ #===============================================================================
+ # CATCH: Template\Exception
+ #===============================================================================
+ catch(Template\Exception $Exception) {
+ $Exception->defaultHandler();
+ }
+}
+
+#===============================================================================
+# CATCH: Page\Exception
+#===============================================================================
+catch(Page\Exception $Exception) {
+ Application::exit(404);
+}
+?>
+