summaryrefslogtreecommitdiff
path: root/modules/organize/helpers
diff options
context:
space:
mode:
authorChad Kieffer <ckieffer@gmail.com>2009-08-28 13:48:54 -0600
committerChad Kieffer <ckieffer@gmail.com>2009-08-28 13:48:54 -0600
commit5a2853bca1ea9a9231e01814df9aa373bf50d19c (patch)
tree431264bfb9de1d8bbdc6a9ba7775a363381f96e8 /modules/organize/helpers
parentf1e008a14f2dfb51d1204dad3deb19e2e3df16c8 (diff)
parent6dcfdb6432d556f43736d60de8f310f247868bfa (diff)
Merge branch 'master' of git@github.com:gallery/gallery3
Diffstat (limited to 'modules/organize/helpers')
-rw-r--r--modules/organize/helpers/organize.php94
-rw-r--r--modules/organize/helpers/organize_event.php4
-rw-r--r--modules/organize/helpers/organize_task.php131
-rw-r--r--modules/organize/helpers/organize_theme.php13
4 files changed, 11 insertions, 231 deletions
diff --git a/modules/organize/helpers/organize.php b/modules/organize/helpers/organize.php
deleted file mode 100644
index 25284771..00000000
--- a/modules/organize/helpers/organize.php
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * 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.
- */
-class organize_Core {
- static function get_general_edit_form($item) {
- $generalPane = new Forge("organize/__FUNCTION__", "", "post",
- array("id" => "gEditGeneral", "ref" => "general"));
- // In this case we know there is only 1 item, but in general we should loop
- // and create multiple hidden items.
- $generalPane->hidden("item[]")->value($item->id);
- $generalPane->input("title")->label(t("Title"))->value($item->title);
- $generalPane->textarea("description")->label(t("Description"))->value($item->description);
- $generalPane->input("dirname")->label(t("Path Name"))->value($item->name)
- ->callback("item::validate_no_slashes")
- ->error_messages("no_slashes", t("The directory name can't contain a \"/\""))
- ->callback("item::validate_no_trailing_period")
- ->error_messages("no_trailing_period", t("The directory name can't end in \".\""))
- ->callback("item::validate_no_name_conflict")
- ->error_messages("conflict", t("The path name is not unique"));
-
- return $generalPane;
- }
-
- static function get_sort_edit_form($item) {
- $sortPane = new Forge("organize/__FUNCTION__", "", "post",
- array("id" => "gEditSort", "ref" => "sort"));
- $sortPane->hidden("item[]")->value($item->id);
- $sortPane->dropdown("column", array("id" => "gAlbumSortColumn"))
- ->label(t("Sort by"))
- ->options(array("weight" => t("Order Added"),
- "captured" => t("Capture Date"),
- "created" => t("Creation Date"),
- "title" => t("Title"),
- "updated" => t("Updated Date"),
- "view_count" => t("Number of views"),
- "rand_key" => t("Random")))
- ->selected($item->sort_column);
- $sortPane->dropdown("direction", array("id" => "gAlbumSortDirection"))
- ->label(t("Order"))
- ->options(array("ASC" => t("Ascending"),
- "DESC" => t("Descending")))
- ->selected($item->sort_order);
-
- return $sortPane;
- }
-
- static function get_tag_form($itemids) {
- $tagPane = new Forge("organize/__FUNCTION__", "", "post",
- array("id" => "gEditTags", "ref" => "edit_tags"));
- $tagPane->hidden("item")->value(implode("|", $itemids));
- $item_count = count($itemids);
- $ids = implode(", ", $itemids);
-
- // Lame stopgap security check. This code is going to get rewritten anyway.
- foreach ($itemids as $id) {
- $item = ORM::factory("item", $id);
- access::required("view", $item);
- access::required("edit", $item);
- }
-
- $tags = Database::instance()->query(
- "SELECT t.name, COUNT(it.item_id) as count
- FROM {items_tags} it, {tags} t
- WHERE it.tag_id = t.id
- AND it.item_id in($ids)
- GROUP BY it.tag_id
- ORDER BY t.name ASC");
- $taglist = array();
- foreach ($tags as $tag) {
- $taglist[] = $tag->name . ($item_count > $tag->count ? "*" : "");
- }
- $taglist = implode("; ", $taglist);
- $tagPane->textarea("tags")->label(t("Tags"))->value($taglist);
-
- return $tagPane;
- }
-
-} \ No newline at end of file
diff --git a/modules/organize/helpers/organize_event.php b/modules/organize/helpers/organize_event.php
index 99a28673..7d6b3e24 100644
--- a/modules/organize/helpers/organize_event.php
+++ b/modules/organize/helpers/organize_event.php
@@ -23,11 +23,11 @@ class organize_event_Core {
if ($item && access::can("edit", $item) && $item->is_album()) {
$menu->get("options_menu")
- ->append(Menu::factory("link")
+ ->append(Menu::factory("dialog")
->id("organize")
->label(t("Organize Album"))
->css_id("gOrganizeLink")
- ->url(url::site("organize/index/{$item->id}")));
+ ->url(url::site("organize/dialog/{$item->id}")));
}
}
}
diff --git a/modules/organize/helpers/organize_task.php b/modules/organize/helpers/organize_task.php
deleted file mode 100644
index dc474818..00000000
--- a/modules/organize/helpers/organize_task.php
+++ /dev/null
@@ -1,131 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * 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.
- */
-class organize_task_Core {
- static function available_tasks() {
- // Return empty array so nothing appears in the maintenance screen
- return array();
- }
-
- static function run($task) {
- $context = unserialize($task->context);
- $taskType = $context["type"];
-
- try {
- $target = ORM::factory("item", $context["target"]);
- $total = count($context["items"]);
- $stop = min($total - $context["position"], $context["batch"]);
- $context["post_process"] = array();
- for ($offset = 0; $offset < $stop; $offset++) {
- $current_id = $context["position"] + $offset;
- $id = $context["items"][$current_id];
- switch ($taskType) {
- case "move":
- $source = ORM::factory("item", $id);
- access::required("view", $source);
- access::required("view", $target);
- access::required("edit", $source);
- access::required("edit", $target);
-
- item::move($source, $target);
- break;
-
- case "rearrange":
- $item = ORM::factory("item", $id);
- access::required("view", $item);
- access::required("edit", $item);
-
- Database::instance()
- ->query("Update {items} set weight = {$context["position"]} where id=$id;");
- break;
-
- case "rotateCcw":
- case "rotateCw":
- $item = ORM::factory("item", $id);
- access::required("view", $item);
- access::required("edit", $item);
-
- if ($item->is_photo()) {
- $context["post_process"]["reload"][] =
- self::_do_rotation($item, $taskType == "rotateCcw" ? -90 : 90);
- }
- break;
-
- case "albumCover":
- $item = ORM::factory("item", $id);
- access::required("view", $item);
- access::required("view", $item->parent());
- access::required("edit", $item->parent());
-
- item::make_album_cover($item);
- break;
-
- case "delete":
- $item = ORM::factory("item", $id);
- access::required("view", $item);
- access::required("edit", $item);
-
- $item->delete();
- $context["post_process"]["remove"][] = array("id" => $id);
- break;
-
- default:
- throw new Exception("Task '$taskType' is not implemented");
- }
- }
- $context["position"] += $stop;
- $task->state = "success";
- } catch(Exception $e) {
- $task->status = $e->getMessage();
- $task->state = "error";
- $task->save();
- throw $e;
- }
- $task->context = serialize($context);
- $total = count($context["items"]);
- $task->percent_complete = $context["position"] / (float)$total * 100;
- $task->done = $context["position"] == $total || $task->state == "error";
- }
-
- private static function _do_rotation($item, $degrees) {
- // This code is copied from Quick_Controller::rotate
- graphics::rotate($item->file_path(), $item->file_path(), array("degrees" => $degrees));
-
- list($item->width, $item->height) = getimagesize($item->file_path());
- $item->resize_dirty= 1;
- $item->thumb_dirty= 1;
- $item->save();
-
- graphics::generate($item);
-
- $parent = $item->parent();
- if ($parent->album_cover_item_id == $item->id) {
- copy($item->thumb_path(), $parent->thumb_path());
- $parent->thumb_width = $item->thumb_width;
- $parent->thumb_height = $item->thumb_height;
- $parent->save();
- }
- list ($height, $width) = $item->scale_dimensions(90);
- $margin_top = (90 - $height) / 20;
-
- return array("src" => $item->thumb_url() . "?rnd=" . rand(),
- "id" => $item->id,
- "marginTop" => "{$margin_top}em", "width" => $width, "height" => $height);
- }
-} \ No newline at end of file
diff --git a/modules/organize/helpers/organize_theme.php b/modules/organize/helpers/organize_theme.php
index e4feba2b..61b6fe7d 100644
--- a/modules/organize/helpers/organize_theme.php
+++ b/modules/organize/helpers/organize_theme.php
@@ -19,9 +19,14 @@
*/
class organize_theme {
static function head($theme) {
- // @tdo remove the addition css and organize.js (just here to test)
- $theme->script("organize_init.js");
- $theme->script("organize.js");
- $theme->css("organize.css");
+ $item = $theme->item();
+ if ($item && access::can("edit", $item) && $item->is_album()) {
+ // @todo: Defer loading js/css until we're loading the organize dialog as <script> and
+ // <link> elements so that we're not forcing them to be downloaded on every page view (which
+ // is expensive in terms of browser latency). When we do that, we'll have to figure out an
+ // approach that lets us continue to use the Kohana cascading filesystem.
+ $theme->script("organize.js");
+ $theme->css("organize.css");
+ }
}
}