From fb6e22e1457ce4d1503c739d7354d51fe3af4e94 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 6 Dec 2008 21:14:36 +0000 Subject: Implemented photo::_get_photo_add(). You need to create the var/uploads directory and make it writable by the server. The location of the temporary upload directory is specified in config/upload.php --- core/config/upload.php | 17 +++++++++++++++++ core/controllers/photos.php | 9 +++++++++ core/controllers/welcome.php | 14 +++----------- core/helpers/album.php | 6 +++--- core/helpers/photo.php | 15 +++++++++++++++ 5 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 core/config/upload.php (limited to 'core') diff --git a/core/config/upload.php b/core/config/upload.php new file mode 100644 index 00000000..9885ab32 --- /dev/null +++ b/core/config/upload.php @@ -0,0 +1,17 @@ +render(); + } } diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php index 7f1070ba..e61ae674 100644 --- a/core/controllers/welcome.php +++ b/core/controllers/welcome.php @@ -507,16 +507,8 @@ class Welcome_Controller extends Template_Controller { $this->auto_render = false; } - public function _get_add_photo_html() { - return ' -
- Photos -
- - - -
-
- '; + public function _get_add_photo_html($parent_id=1) { + $parent = ORM::factory("item", $parent_id); + return photo::get_add_form($parent); } } diff --git a/core/helpers/album.php b/core/helpers/album.php index d82f076b..3e3b6054 100644 --- a/core/helpers/album.php +++ b/core/helpers/album.php @@ -62,9 +62,9 @@ class album_Core { static function get_add_form($parent) { $form = new Forge("albums/{$parent->id}", "", "post", array("id" => "gAddAlbumForm")); $group = $form->group(sprintf(_("Add Album to %s"), $parent->title)); - $group->input("name"); - $group->input("title"); - $group->input("description"); + $group->input("name")->label(true); + $group->input("title")->label(true); + $group->input("description")->label(true); $group->hidden("type")->value("album"); $group->submit(_("Create")); $form->add_rules_from(ORM::factory("item")); diff --git a/core/helpers/photo.php b/core/helpers/photo.php index fc23c375..6d9887a4 100644 --- a/core/helpers/photo.php +++ b/core/helpers/photo.php @@ -82,4 +82,19 @@ class photo_Core { return $result; } + + static function get_add_form($parent) { + $form = new Forge("albums/{$parent->id}", "", "post", + array("id" => "gAddPhotoForm", "enctype" => "multipart/form-data")); + $group = $form->group(sprintf(_("Add Photo to %s"), $parent->title)); + $group->input("name")->label(true); + $group->input("title")->label(true); + $group->input("description")->label(true)->rules("length[0, 255"); + $group->upload("file")->label(true)->rules("allow[jpg,png,gif,tiff]"); + $group->hidden("type")->value("photo"); + $group->submit(_("Upload")); + $form->add_rules_from(ORM::factory("item")); + return $form; + } + } -- cgit v1.2.3