From 3f1dda1e19e1f77e908df1d49d028d0932d0f1a1 Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 23 Apr 2009 07:41:28 +0000 Subject: A completely new forms class, to replace the old function based method. Also some work on a new config module, evenmtuelly to replace the old hardcoded values. --- utils/modules/gallery.php | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'utils/modules/gallery.php') diff --git a/utils/modules/gallery.php b/utils/modules/gallery.php index 4820a04..c6d2f86 100644 --- a/utils/modules/gallery.php +++ b/utils/modules/gallery.php @@ -83,8 +83,8 @@ class Album { htmlspecialchars($this->copyright, ENT_QUOTES, "UTF-8") . "\"\n"); fwrite($fp, " icon=\"" . htmlspecialchars($this->icon, ENT_QUOTES, "UTF-8") . "\"\n"); - fwrite($fp, " enabled=\"" . - htmlspecialchars($this->enabled, ENT_QUOTES, "UTF-8") . "\">\n"); + if($this->enabled) fwrite($fp, " enabled=\"true\">\n"); + else fwrite($fp, " enabled=\"false\">\n"); foreach($this->photos as $photo) { $photo->write($fp); } @@ -124,7 +124,7 @@ class Album { $this->title = $title; $this->copyright = $copyright; $this->icon = $icon; - $this->enabled = $enabled; + $this->enabled = $enabled == 'on'; } } @@ -178,9 +178,11 @@ class Gallery { // Admin config public $admin_title = "Gallery"; - public $admin_submodules = array("New gallery" => "newgallery"); + public $admin_submodules = array("New album" => "new", + "Edit album" => "edit", + "Delete album" => "delete"); - public function admin_newgallery($action, $vars) + public function admin_new($action, $vars) { global $ALBUMS_DIR; switch($action) { @@ -194,13 +196,13 @@ class Gallery { case "select": default: - beginform("create", true); - lineedit("Album title:", "title"); - lineedit("Album copyright:", "copyright"); - lineedit("Album enabled:", "enabled", "true"); - fileupload("Select image archive:", "images", "application/zip"); - button("Create"); - endform(); + $form = new Form("create"); + $form->addWidget(new LineEdit("Album title:", "title")); + $form->addWidget(new LineEdit("Album copyright:", "copyright")); + $form->addWidget(new CheckBox("Album enabled:", "enabled")); + $form->addWidget(new FileUpload("Select image archive:", "images", "application/zip")); + $form->addWidget(new Button("Create")); + $form->render(); break; } } @@ -208,8 +210,14 @@ class Gallery { public function admin($sub, $action, $vars) { switch($sub) { - case "newgallery": - $this->admin_newgallery($action, $vars); + case "new": + $this->admin_new($action, $vars); + break; + case "edit": + $this->admin_new($action, $vars); + break; + case "delete": + $this->admin_new($action, $vars); break; } } -- cgit v1.2.3