From e576c5f8ee44d1acfbac128631f9c203fdc26e27 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 28 Apr 2009 19:01:12 +0000 Subject: Made it possible to add new pages. --- utils/modules/pages.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/utils/modules/pages.php b/utils/modules/pages.php index d69b9e9..99c8142 100644 --- a/utils/modules/pages.php +++ b/utils/modules/pages.php @@ -57,7 +57,8 @@ class Pages { // Admin config public $admin_title = "Pages"; - public $admin_submodules = array("Edit page" => "edit"); + public $admin_submodules = array("Add page" => "add", + "Edit page" => "edit"); public function admin_edit($action, $vars) { @@ -115,12 +116,34 @@ class Pages { } } + public function admin_add($action, $vars) + { + switch($action) { + case "add": + $page = new Page($vars["title"], ""); + $this->add($page); + $this->write(); + echo "The page titled \"" . $page->title . "\" has now been added."; + break; + + default: + $form = new Form("add"); + $form->addWidget(new LineEdit("Page title (must not contain spaces or special characters)", "title", "")); + $form->addWidget(new Button("Add")); + $form->render(); + break; + } + } + public function admin($sub, $action, $vars) { switch($sub) { case "edit": $this->admin_edit($action, $vars); break; + case "add": + $this->admin_add($action, $vars); + break; } } -- cgit v1.2.3