2008-11-04 21:24:42 +00:00
|
|
|
<?php defined("SYSPATH") or die("No direct script access.");
|
|
|
|
|
/**
|
|
|
|
|
* Gallery - a web based photo album viewer and editor
|
2013-01-21 01:22:01 -05:00
|
|
|
* Copyright (C) 2000-2013 Bharat Mediratta
|
2008-11-04 21:24:42 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
|
* your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is the API for handling albums.
|
|
|
|
|
*
|
|
|
|
|
* Note: by design, this class does not do any permission checking.
|
|
|
|
|
*/
|
2008-11-22 06:01:08 +00:00
|
|
|
class album_Core {
|
2008-12-02 21:25:15 +00:00
|
|
|
|
|
|
|
|
static function get_add_form($parent) {
|
2009-11-25 12:41:01 -08:00
|
|
|
$form = new Forge("albums/create/{$parent->id}", "", "post", array("id" => "g-add-album-form"));
|
2009-05-16 03:48:56 +00:00
|
|
|
$group = $form->group("add_album")
|
|
|
|
|
->label(t("Add an album to %album_title", array("album_title" => $parent->title)));
|
2010-01-27 22:55:54 -08:00
|
|
|
$group->input("title")->label(t("Title"))
|
|
|
|
|
->error_messages("required", t("You must provide a title"))
|
|
|
|
|
->error_messages("length", t("Your title is too long"));
|
2009-01-08 17:13:06 +00:00
|
|
|
$group->textarea("description")->label(t("Description"));
|
2009-09-07 21:01:51 -07:00
|
|
|
$group->input("name")->label(t("Directory name"))
|
2013-03-12 12:14:34 +01:00
|
|
|
->error_messages("no_slashes", t("The directory name can't contain a \"/\""))
|
|
|
|
|
->error_messages("no_backslashes", t("The directory name can't contain a \"\\\""))
|
|
|
|
|
->error_messages("no_trailing_period", t("The directory name can't end in \".\""))
|
2010-01-27 22:55:54 -08:00
|
|
|
->error_messages("required", t("You must provide a directory name"))
|
2010-02-01 21:41:16 -08:00
|
|
|
->error_messages("length", t("Your directory name is too long"))
|
|
|
|
|
->error_messages("conflict", t("There is already a movie, photo or album with this name"));
|
2009-09-07 21:01:51 -07:00
|
|
|
$group->input("slug")->label(t("Internet Address"))
|
2013-03-12 12:14:34 +01:00
|
|
|
->error_messages(
|
|
|
|
|
"conflict", t("There is already a movie, photo or album with this internet address"))
|
2012-05-15 15:53:38 -07:00
|
|
|
->error_messages(
|
|
|
|
|
"reserved", t("This address is reserved and can't be used."))
|
2009-09-07 21:01:51 -07:00
|
|
|
->error_messages(
|
|
|
|
|
"not_url_safe",
|
2010-01-27 22:55:54 -08:00
|
|
|
t("The internet address should contain only letters, numbers, hyphens and underscores"))
|
2010-01-27 23:00:49 -08:00
|
|
|
->error_messages("required", t("You must provide an internet address"))
|
|
|
|
|
->error_messages("length", t("Your internet address is too long"));
|
2008-12-02 21:25:15 +00:00
|
|
|
$group->hidden("type")->value("album");
|
2010-04-10 20:58:05 -07:00
|
|
|
|
|
|
|
|
module::event("album_add_form", $parent, $form);
|
|
|
|
|
|
2009-01-12 07:50:04 +00:00
|
|
|
$group->submit("")->value(t("Create"));
|
2009-07-28 21:33:25 +08:00
|
|
|
$form->script("")
|
|
|
|
|
->url(url::abs_file("modules/gallery/js/albums_form_add.js"));
|
2010-04-10 20:58:05 -07:00
|
|
|
|
2008-12-02 21:25:15 +00:00
|
|
|
return $form;
|
|
|
|
|
}
|
2008-12-24 00:20:26 +00:00
|
|
|
|
|
|
|
|
static function get_edit_form($parent) {
|
2010-02-01 21:41:16 -08:00
|
|
|
$form = new Forge(
|
|
|
|
|
"albums/update/{$parent->id}", "", "post", array("id" => "g-edit-album-form"));
|
2010-07-10 11:45:45 -07:00
|
|
|
$form->hidden("from_id")->value($parent->id);
|
2009-07-28 20:40:28 +08:00
|
|
|
$group = $form->group("edit_item")->label(t("Edit Album"));
|
2009-05-07 01:28:10 +00:00
|
|
|
|
2010-01-27 22:55:54 -08:00
|
|
|
$group->input("title")->label(t("Title"))->value($parent->title)
|
2013-03-12 12:14:34 +01:00
|
|
|
->error_messages("required", t("You must provide a title"))
|
2010-01-27 22:55:54 -08:00
|
|
|
->error_messages("length", t("Your title is too long"));
|
2009-01-08 17:13:06 +00:00
|
|
|
$group->textarea("description")->label(t("Description"))->value($parent->description);
|
2009-04-12 17:52:26 +00:00
|
|
|
if ($parent->id != 1) {
|
2010-01-19 19:24:46 -08:00
|
|
|
$group->input("name")->label(t("Directory Name"))->value($parent->name)
|
2010-02-01 21:41:16 -08:00
|
|
|
->error_messages("conflict", t("There is already a movie, photo or album with this name"))
|
2009-05-16 22:27:32 +00:00
|
|
|
->error_messages("no_slashes", t("The directory name can't contain a \"/\""))
|
2013-03-12 12:14:34 +01:00
|
|
|
->error_messages("no_backslashes", t("The directory name can't contain a \"\\\""))
|
2010-01-27 22:55:54 -08:00
|
|
|
->error_messages("no_trailing_period", t("The directory name can't end in \".\""))
|
|
|
|
|
->error_messages("required", t("You must provide a directory name"))
|
|
|
|
|
->error_messages("length", t("Your directory name is too long"));
|
2009-09-07 21:01:51 -07:00
|
|
|
$group->input("slug")->label(t("Internet Address"))->value($parent->slug)
|
|
|
|
|
->error_messages(
|
2010-01-14 21:04:09 -08:00
|
|
|
"conflict", t("There is already a movie, photo or album with this internet address"))
|
2012-05-15 15:53:38 -07:00
|
|
|
->error_messages(
|
|
|
|
|
"reserved", t("This address is reserved and can't be used."))
|
2009-09-07 21:01:51 -07:00
|
|
|
->error_messages(
|
|
|
|
|
"not_url_safe",
|
2010-01-27 22:55:54 -08:00
|
|
|
t("The internet address should contain only letters, numbers, hyphens and underscores"))
|
2010-01-27 23:00:49 -08:00
|
|
|
->error_messages("required", t("You must provide an internet address"))
|
|
|
|
|
->error_messages("length", t("Your internet address is too long"));
|
2009-09-19 10:51:27 -07:00
|
|
|
} else {
|
2010-01-19 19:24:46 -08:00
|
|
|
$group->hidden("name")->value($parent->name);
|
2009-09-19 10:51:27 -07:00
|
|
|
$group->hidden("slug")->value($parent->slug);
|
2009-04-12 17:52:26 +00:00
|
|
|
}
|
2009-03-09 13:30:22 +00:00
|
|
|
|
2009-10-04 00:27:22 -06:00
|
|
|
$sort_order = $group->group("sort_order", array("id" => "g-album-sort-order"))
|
2009-03-08 16:29:01 +00:00
|
|
|
->label(t("Sort Order"));
|
2009-03-09 13:30:22 +00:00
|
|
|
|
2009-10-04 00:27:22 -06:00
|
|
|
$sort_order->dropdown("column", array("id" => "g-album-sort-column"))
|
2009-03-08 16:29:01 +00:00
|
|
|
->label(t("Sort by"))
|
2009-08-28 14:27:37 -07:00
|
|
|
->options(album::get_sort_order_options())
|
2009-03-09 13:30:22 +00:00
|
|
|
->selected($parent->sort_column);
|
2009-10-04 00:27:22 -06:00
|
|
|
$sort_order->dropdown("direction", array("id" => "g-album-sort-direction"))
|
2009-03-08 16:29:01 +00:00
|
|
|
->label(t("Order"))
|
|
|
|
|
->options(array("ASC" => t("Ascending"),
|
|
|
|
|
"DESC" => t("Descending")))
|
2009-03-09 13:30:22 +00:00
|
|
|
->selected($parent->sort_order);
|
2009-07-19 17:02:20 +08:00
|
|
|
|
2009-11-09 11:52:43 -08:00
|
|
|
module::event("item_edit_form", $parent, $form);
|
2009-07-19 17:02:20 +08:00
|
|
|
|
2009-09-10 21:55:36 -07:00
|
|
|
$group = $form->group("buttons")->label("");
|
2008-12-24 00:20:26 +00:00
|
|
|
$group->hidden("type")->value("album");
|
2009-01-12 07:50:04 +00:00
|
|
|
$group->submit("")->value(t("Modify"));
|
2009-07-28 20:40:28 +08:00
|
|
|
return $form;
|
2008-12-24 00:20:26 +00:00
|
|
|
}
|
2009-08-28 14:27:37 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return a structured set of all the possible sort orders.
|
|
|
|
|
*/
|
|
|
|
|
static function get_sort_order_options() {
|
|
|
|
|
return array("weight" => t("Manual"),
|
|
|
|
|
"captured" => t("Date captured"),
|
|
|
|
|
"created" => t("Date uploaded"),
|
|
|
|
|
"title" => t("Title"),
|
2010-09-14 19:51:43 -07:00
|
|
|
"name" => t("File name"),
|
2009-08-28 14:27:37 -07:00
|
|
|
"updated" => t("Date modified"),
|
|
|
|
|
"view_count" => t("Number of views"),
|
|
|
|
|
"rand_key" => t("Random"));
|
|
|
|
|
}
|
2008-11-04 21:24:42 +00:00
|
|
|
}
|