summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/helpers/item_rest.php3
-rw-r--r--modules/organize/controllers/organize.php167
-rw-r--r--modules/organize/css/organize.css156
-rw-r--r--modules/organize/css/organize_theme.css18
-rw-r--r--modules/organize/helpers/organize_event.php18
-rw-r--r--modules/organize/helpers/organize_installer.php32
-rw-r--r--modules/organize/helpers/organize_theme.php6
-rw-r--r--modules/organize/js/organize.js310
-rw-r--r--modules/organize/lib/Gallery3WebClient.swfbin0 -> 137234 bytes
-rw-r--r--modules/organize/source/Gallery3Organize_source.zipbin0 -> 933143 bytes
-rw-r--r--modules/organize/views/organize_dialog.html.php154
-rw-r--r--modules/organize/views/organize_thumb_grid.html.php22
-rw-r--r--modules/organize/views/organize_tree.html.php29
-rw-r--r--modules/rest/controllers/rest.php8
14 files changed, 206 insertions, 717 deletions
diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php
index c88f92d9..f99afbc2 100644
--- a/modules/gallery/helpers/item_rest.php
+++ b/modules/gallery/helpers/item_rest.php
@@ -160,6 +160,9 @@ class item_rest_Core {
case "photo":
case "movie":
+ if (empty($request->file)) {
+ throw new Rest_Exception("Bad Request: Upload failed", 400);
+ }
$item->type = $entity->type;
$item->parent_id = $parent->id;
$item->set_data_file($request->file);
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php
index 8dc8692c..d2c273b6 100644
--- a/modules/organize/controllers/organize.php
+++ b/modules/organize/controllers/organize.php
@@ -19,159 +19,40 @@
*/
class Organize_Controller extends Controller {
function dialog($album_id) {
+ $input = Input::instance();
+
$album = ORM::factory("item", $album_id);
access::required("view", $album);
access::required("edit", $album);
$v = new View("organize_dialog.html");
$v->album = $album;
- $v->album_tree = self::_expanded_tree(ORM::factory("item", 1), $album);
- $v->micro_thumb_grid = self::_get_micro_thumb_grid($album, 0);
- print $v;
- }
-
- function album($album_id, $offset) {
- $album = ORM::factory("item", $album_id);
- access::required("view", $album);
- access::required("edit", $album);
-
- print json_encode(
- array("grid" => (string)self::_get_micro_thumb_grid($album, $offset),
- "sort_column" => $album->sort_column,
- "sort_order" => $album->sort_order));
- }
-
- function move_to($target_album_id) {
- access::verify_csrf();
-
- $target_album = ORM::factory("item", $target_album_id);
- access::required("view", $target_album);
- access::required("add", $target_album);
-
- $source_album = null;
- foreach (Input::instance()->post("source_ids") as $source_id) {
- $source = ORM::factory("item", $source_id);
- if (empty($source_album)) { // get the source_album
- $source_album = $source->parent();
- }
- if (!$source->contains($target_album)) {
- access::required("edit", $source);
- item::move($source, $target_album);
- }
- }
-
- print json_encode(
- array("tree" => (string)self::_expanded_tree(ORM::factory("item", 1), $source_album),
- "grid" => (string)self::_get_micro_thumb_grid($source_album, 0)));
- }
-
- function rearrange($target_id, $before_or_after) {
- access::verify_csrf();
-
- $target = ORM::factory("item", $target_id);
- $album = $target->parent();
- access::required("view", $album);
- access::required("edit", $album);
-
- //if (locales::is_rtl()) { // invert the position if the locale is rtl
- // $before_or_after = $before_or_after == "after" ? "before" : "after";
- //}
-
- $source_ids = Input::instance()->post("source_ids", array());
-
- if ($album->sort_column != "weight") {
- $i = 0;
- foreach ($album->children() as $child) {
- // Do this directly in the database to avoid sending notifications
- db::build()
- ->update("items")
- ->set("weight", ++$i)
- ->where("id", "=", $child->id)
- ->execute();
- }
- $album->sort_column = "weight";
- $album->sort_order = "ASC";
- $album->save();
- $target->reload();
- }
-
- // Find the insertion point
- $target_weight = $target->weight;
- if ($before_or_after == "after") {
- $target_weight++;
- }
-
- // Make a hole
- $count = count($source_ids);
- db::build()
- ->update("items")
- ->set("weight", new Database_Expression("`weight` + $count"))
- ->where("weight", ">=", $target_weight)
- ->where("parent_id", "=", $album->id)
- ->execute();
-
- // Insert source items into the hole
- foreach ($source_ids as $source_id) {
- db::build()
- ->update("items")
- ->set("weight", $target_weight++)
- ->where("id", "=", $source_id)
- ->execute();
+ // @todo turn this into an api call.
+ $v->file_filter = json_encode(
+ array("photo" => array("label" => "Images",
+ "types" => array("*.jpg", "*.jpeg", "*.png", "*.gif")),
+ "movie" => array("label" => "Movies", "types" => array("*.flv", "*.mp4"))));
+ $v->domain = $input->server("SERVER_NAME");
+ // @todo figure out how to connect this w/o a dependency
+ $v->base_url = url::abs_site("rest") . "/";
+
+ $v->sort_order = json_encode(array("ASC" => (string)t("Ascending"), "DESC" => (string)t("Descending")));
+ $sort_fields = array();
+ foreach (album::get_sort_order_options() as $field => $description) {
+ $sort_fields[$field] = (string)$description;
}
+ $v->sort_fields = json_encode($sort_fields);
- module::event("album_rearrange", $album);
-
- print json_encode(
- array("grid" => (string)self::_get_micro_thumb_grid($album, 0),
- "sort_column" => $album->sort_column,
- "sort_order" => $album->sort_order));
- }
-
- public function sort_order($album_id, $col, $dir) {
- access::verify_csrf();
-
- $album = ORM::factory("item", $album_id);
- access::required("view", $album);
- access::required("edit", $album);
-
- $options = album::get_sort_order_options();
- if (!isset($options[$col])) {
- return;
- }
-
- $album->sort_column = $col;
- $album->sort_order = $dir;
- $album->save();
-
- print json_encode(
- array("grid" => (string)self::_get_micro_thumb_grid($album, 0),
- "sort_column" => $album->sort_column,
- "sort_order" => $album->sort_order));
- }
-
- private static function _get_micro_thumb_grid(Item_Model $album, $offset) {
- $v = new View("organize_thumb_grid.html");
- $v->album = $album;
- $v->offset = (int) $offset;
- return $v;
+ $user = identity::active_user();
+ $v->api_key = rest::get_access_key($user->id)->access_key;
+ print $v;
}
- public function tree($album_id) {
- $album = ORM::factory("item", $album_id);
- access::required("view", $album);
-
- print self::_expanded_tree($album);
+ function add_album_fields() {
+ print json_encode(array("title" => (string)t("Title"),
+ "description" => (string)t("Description"),
+ "name" => (string)t("Directory name"),
+ "slug" => (string)t("Internet Address")));
}
- /**
- * Create an HTML representation of the tree from the root down to the selected album. We only
- * include albums along the descendant hierarchy that includes the selected album, and the
- * immediate child albums.
- */
- private static function _expanded_tree($root, $selected_album=null) {
- $v = new View("organize_tree.html");
- $v->album = $root;
- $v->selected = $selected_album;
- return $v;
- }
}
diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css
deleted file mode 100644
index 7a8c3a5f..00000000
--- a/modules/organize/css/organize.css
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************
- * Dialog wide styles
- */
-
-#g-organize {
- margin: 0 !important;
- min-height: auto;
- padding: 0 !important;
- position: relative;
- width: 100%;
-}
-
-#g-organize-content-pane {
- height: 100%;
- margin: 0 !important;
- padding: 0 !important;
- position: absolute;
- width: 100%;
-}
-
-/*******************************************************************
- * Album Tree styles
- */
-
-#g-organize #g-organize-tree-container {
- margin: 0;
- min-height: 100%;
- padding: 0;
- position: relative;
- width: 20%;
-}
-
-#g-organize #g-organize-tree-container h3 {
- margin-bottom: 0.1em;
-}
-
-#g-organize-album-tree {
- overflow: auto;
-}
-
-#g-organize-album-tree ul li {
- padding: 0 0 .2em 1.2em;
- width: 90%;
-}
-
-.rtl #g-organize-album-tree ul li {
- padding: 0 1.2em .2em 0;
- width: 90%;
-}
-
-.g-organize-album span {
- cursor: pointer;
-}
-
-.g-organize-album-text {
- cursor: pointer;
- display: block;
- margin: 2px 0px 1px 2px;
- width: auto;
-}
-
-.rtl .g-organize-album-text {
- cursor: pointer;
- display: block;
- margin: 2px 2px 1px 1px;
- width: auto;
-}
-
-.g-organize-album-text:hover {
- border-width: 1px;
- border-style: dotted;
-}
-
-/*******************************************************************
- * Album panel styles
- */
-
-#g-organize #g-organize-detail {
- margin: 0 !important;
- min-height: 100%;
- padding: 0 !important;
- position: relative;
- width: 80%;
-}
-
-#g-organize #g-organize-detail .g-message-block {
- margin: 0;
-}
-
-#g-organize #g-organize-detail .g-message-block li {
- padding-bottom: .2em;
- padding-top: .2em;
- width: auto;
-}
-
-#g-organize-microthumb-grid {
- border-width: 1px;
- border-style: solid;
- bottom: 1.8em;
- left: 0;
- margin: 0 !important;
- overflow-x: hidden;
- overflow-y: auto;
- padding: .4em !important;
- position: absolute;
- right: 0;
- top: 1.6em;
-}
-.g-organize-microthumb-grid-cell {
- display: block;
- height: 100px;
- margin: 6px;
- padding: .4em 0 !important;
- position: relative;
- text-align: center;
- width: 110px;
-}
-
-.ui-selectable-helper {
- z-index: 2000 !important;
-}
-
-.g-organize-microthumb-grid-cell .ui-icon {
- bottom: 0;
- left: 0;
- position: absolute;
- z-index: 4000;
-}
-
-/****************************************************************
- * Controls styles
- */
-
-#g-organize-controls {
- bottom: 0;
- height: 1.9em;
- left: 0;
- margin: 0 !important;
- padding: .1em .4em;
- position: absolute;
- right: 0;
-}
-
-#g-organize-controls #g-organize-sort-order-text {
- padding: .2em 0 0 0;
-}
-
-
-#g-organize-controls select {
- margin-left: .42em;
- display: inline;
-}
-
-#g-organize-close {
- margin-right: 12px;
-}
diff --git a/modules/organize/css/organize_theme.css b/modules/organize/css/organize_theme.css
index 3d289755..e698f88d 100644
--- a/modules/organize/css/organize_theme.css
+++ b/modules/organize/css/organize_theme.css
@@ -1,16 +1,18 @@
/** *******************************************************************
* Organize styles that are theme overrideable
*********************************************************************/
-.g-organize-microthumb-grid-cell.ui-selected {
- background: #DFEFFC !important;
+#g-organize {
+ background-color: #FFFFFF;
+ border: 0px solid #000000;
+ color: #0E2B52;
}
-#g-organize-microthumb-grid,
-#g-organize-drop-target-marker,
-.g-organize-album-text:hover {
- border-color: #79B7E7;
+#g-organize-hover {
+ background-color: #CFDEFF;
+ display: none;
}
-#g-organize-drop-target-marker {
- background-color: #79B7E7;
+#g-organize-active {
+ background-color: #6699CC;
+ display: none;
}
diff --git a/modules/organize/helpers/organize_event.php b/modules/organize/helpers/organize_event.php
index a9d64637..c7d08893 100644
--- a/modules/organize/helpers/organize_event.php
+++ b/modules/organize/helpers/organize_event.php
@@ -42,4 +42,22 @@ class organize_event_Core {
}
}
+ static function pre_deactivate($data) {
+ if ($data->module == "rest") {
+ $data->messages["warn"][] = t("The Organize module requires the Rest module.");
+ }
+ }
+
+ static function module_change($changes) {
+ if (!module::is_active("rest") || in_array("rest", $changes->deactivate)) {
+ site_status::warning(
+ t("The Organize module requires the Rest module.. " .
+ "<a href=\"%url\">Activate the Rest module now</a>",
+ array("url" => html::mark_clean(url::site("admin/modules")))),
+ "organize_needs_rest");
+ } else {
+ site_status::clear("organize_needs_rest");
+ }
+ }
+
}
diff --git a/modules/organize/helpers/organize_installer.php b/modules/organize/helpers/organize_installer.php
new file mode 100644
index 00000000..7585438f
--- /dev/null
+++ b/modules/organize/helpers/organize_installer.php
@@ -0,0 +1,32 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2010 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_installer {
+ static function deactivate() {
+ site_status::clear("organize_needs_rest");
+ }
+
+ static function can_activate() {
+ $messages = array();
+ if (!module::is_active("rest")) {
+ $messages["warn"][] = t("The Organize module requires the Rest module.");
+ }
+ return $messages;
+ }
+}
diff --git a/modules/organize/helpers/organize_theme.php b/modules/organize/helpers/organize_theme.php
index da4a1b41..d69ab82c 100644
--- a/modules/organize/helpers/organize_theme.php
+++ b/modules/organize/helpers/organize_theme.php
@@ -21,12 +21,6 @@ class organize_theme {
static function head($theme) {
$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");
$theme->css("organize_theme.css");
}
}
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js
deleted file mode 100644
index 5a483caf..00000000
--- a/modules/organize/js/organize.js
+++ /dev/null
@@ -1,310 +0,0 @@
-(function($) {
- $.organize = {
- micro_thumb_draggable: {
- handle: ".ui-selected",
- distance: 10,
- cursorAt: { left: -10, top: -10},
- appendTo: "#g-organize-content-pane",
- helper: function(event, ui) {
- var selected = $(".ui-draggable.ui-selected img");
- var set = $('<div class="g-drag-helper"></div>')
- .css({
- zIndex: 2000,
- width: 80,
- height: Math.ceil(selected.length / 5) * 16
- });
-
- selected.each(function(i) {
- var row = parseInt(i / 5);
- var j = i - (row * 5);
- var o = $(this).offset();
- var copy = $(this).clone()
- .css({
- width: $(this).width(), height: $(this).height(), display: "block",
- margin: 0, position: 'absolute', outline: '5px solid #fff',
- left: o.left - event.pageX, top: o.top - event.pageY
- })
- .appendTo(set)
- .animate({ width: 10, height: 10, outlineWidth: 1, margin: 1,
- left: (20 * j), top: (row * 20) }, 500);
- });
- return set;
- },
-
- start: function(event, ui) {
- $("#g-organize-microthumb-grid .ui-selected").hide();
- },
-
- drag: function(event, ui) {
- var top = $("#g-organize-microthumb-grid").offset().top;
- var height = $("#g-organize-microthumb-grid").height();
- var scrollTop = $("#g-organize-microthumb-grid").scrollTop();
- if (ui.offset.top > height + top - 20) {
- scrollTop += 100;
- } else if (ui.offset.top < top + 20) {
- scrollTop = Math.max(0, scrollTop - 100);
- }
- $("#g-organize-microthumb-grid").scrollTop(scrollTop);
- }
- },
-
- content_droppable: {
- accept: "*",
- tolerance: "pointer",
- greedy: true,
- drop: function(event, ui) {
- $(".g-mouse-drag-over").removeClass("g-mouse-drag-over");
- var target = $("#g-organize-drop-target-marker").data("drop_position");
- if (target == null) {
- target = {
- position: false,
- id: $(".g-organize-microthumb-grid-cell:visible:last").attr("ref")
- };
- }
- $.organize.do_drop({
- url: rearrange_url
- .replace("__TARGET_ID__", target.id)
- .replace("__BEFORE__", target.position ? "before" : "after"),
- source: $(ui.helper).children("img")
- });
- }
- },
-
- branch_droppable: {
- accept: "*",
- tolerance: "pointer",
- greedy: true,
- drop: function(event, ui) {
- if ($(event.target).hasClass("g-view-only")) {
- $("#g-organize-drop-target-marker").remove();
- $(".ui-selected").show();
- } else {
- $.organize.do_drop({
- url: move_url.replace("__ALBUM_ID__", $(event.target).attr("ref")),
- source: $(ui.helper).children("img")
- });
- }
- }
- },
-
- do_drop: function(options) {
- $("#g-organize-microthumb-grid").selectable("destroy");
- var source_ids = [];
- $(options.source).each(function(i) {
- source_ids.push($(this).attr("ref"));
- });
-
- if (source_ids.length) {
- var loading = $('<div class="g-dialog-loading-large">&nbsp;</div>')
- .css({bottom: 5,
- opacity: .5,
- left: 0,
- position: "absolute",
- right: 0,
- top: 0,
- zIndex: 2000
- });
- $("#g-organize-microthumb-grid").append(loading);
-
- $.post(options.url,
- { "source_ids[]": source_ids },
- function(data) {
- $.organize._refresh(data);
- $(".g-dialog-loading-large").remove();
- },
- "json");
- }
- },
-
- _refresh: function(data) {
- if (data.tree) {
- $("#g-organize-album-tree").html(data.tree);
- }
- if (data.grid) {
- $("#g-organize-microthumb-grid").html(data.grid);
- $("#g-organize-sort-column").attr("value", data.sort_column);
- $("#g-organize-sort-order").attr("value", data.sort_order);
- }
- $.organize.set_handlers();
- },
-
- grid_mouse_leave_handler: function(event) {
- if ($(".g-drag-helper").length && $("#g-organize-drop-target-marker").length) {
- $("#g-organize-drop-target-marker").remove();
- }
- },
-
- grid_mouse_move_handler: function(event) {
- if ($(".g-drag-helper").length) {
- var organizeData = $("#g-organize").data("organizeData");
- var thumbGrid = $("#g-organize-microthumb-grid");
- var visibleCells = $(".g-organize-microthumb-grid-cell:visible");
- var scrollTop = thumbGrid.scrollTop();
-
- var item = $(".g-mouse-drag-over");
- if (item.length == 0) {
- var itemColumn = Math.floor((event.pageX - thumbGrid.offset().left) / organizeData.width);
- itemColumn = organizeData.rtl ? organizeData.width - itemColumn : itemColumn;
- var itemRow = Math.floor((event.pageY + scrollTop - thumbGrid.offset().top) / organizeData.height);
- var itemIndex = Math.min(itemRow * organizeData.columns + itemColumn, visibleCells.length - 1);
- item = visibleCells.get(itemIndex);
- }
-
- var before = event.pageX < ($(item).offset().left + $(item).width() / 2);
- var left = $(item).position().left + (before ? 0 : organizeData.width) - 3;
- var top = $(item).position().top + 6 + scrollTop;
-
- if ($("#g-organize-drop-target-marker").length) {
- $("#g-organize-drop-target-marker").remove();
- }
-
- var set = $('<div id="g-organize-drop-target-marker"></div>')
- .css({zIndex: 2000,
- width: 2,
- height: 112,
- borderWidth: 1,
- borderStyle: "solid",
- position: "absolute",
- top: top, left: left
- })
- .data("drop_position", {id: $(item).attr("ref"),
- position: organizeData.rtl ? !before : before});
- thumbGrid.append(set);
- }
- return true;
- },
-
- /**
- * Dynamically initialize the organize dialog when it is displayed
- */
- init: function(data) {
- var self = this;
- // Deal with ui.jquery bug: http://dev.jqueryui.com/ticket/4475 (target 1.8?)
- $(".sf-menu li.sfHover ul").css("z-index", 68);
- $("#g-dialog").dialog("option", "zIndex", 70);
- $("#g-dialog").bind("dialogopen", function(event, ui) {
- var outerHeight = $(".g-organize-microthumb-grid-cell").outerHeight(true);
- var outerWidth = $(".g-organize-microthumb-grid-cell").outerWidth(true);
- var gridInnerWidth = $("#g-organize-microthumb-grid").innerWidth() - 2 * parseFloat($("#g-organize-microthumb-grid").css("paddingLeft"));
- $("#g-organize")
- .height($("#g-dialog").innerHeight() - 20)
- .data("organizeData", {
- rtl: $("body").hasClass("rtl"),
- height: outerHeight,
- width: outerWidth,
- columns: Math.floor(gridInnerWidth / outerWidth)
- });
- });
-
- $("#g-dialog").bind("dialogclose", function(event, ui) {
- window.location.reload();
- });
-
- $("#g-organize-close").click(function(event) {
- $("#g-dialog").dialog("close");
- });
-
- $("#g-organize-sort-column,#g-organize-sort-order").change(function(event) {
- $.organize.resort($("#g-organize-sort-column").attr("value"),
- $("#g-organize-sort-order").attr("value"));
- });
-
- $.organize.set_handlers();
- },
-
- set_handlers: function() {
- $("#g-organize-microthumb-grid")
- .selectable({filter: ".g-organize-microthumb-grid-cell"})
- .mousemove($.organize.grid_mouse_move_handler)
- .mouseleave($.organize.grid_mouse_leave_handler)
- .droppable($.organize.content_droppable);
- $(".g-organize-microthumb-grid-cell")
- // need to manually add this class in case we care calling with additional elements
- .addClass("ui-selectee")
- .mouseleave(function(event) {
- if ($(".g-drag-helper").length) {
- $(this).removeClass("g-mouse-drag-over");
- }
- })
- .mouseenter(function(event) {
- $(".g-mouse-drag-over").removeClass("g-mouse-drag-over");
- if ($(".g-drag-helper").length) {
- $(this).addClass("g-mouse-drag-over");
- }
- })
- .draggable($.organize.micro_thumb_draggable);
- $(".g-organize-album").droppable($.organize.branch_droppable);
- $(".g-organize-album-text").click($.organize.show_album);
- $("#g-organize-album-tree .ui-icon-plus,#g-organize-album-tree .ui-icon-minus").click($.organize.toggle_branch);
- },
-
- toggle_branch: function(event) {
- event.preventDefault();
- var target = $(event.currentTarget);
- var branch = $(target).parent();
- var id = $(event.currentTarget).parent().attr("ref");
-
- if ($(target).hasClass("ui-icon-plus")) {
- // Expanding
- if (!branch.find("ul").length) {
- $.get(tree_url.replace("__ALBUM_ID__", id), { }, function(data) {
- branch.replaceWith(data);
- $.organize.set_handlers();
- });
- } else {
- branch.find("ul:eq(0)").slideDown();
- }
- } else {
- // Contracting
- branch.find("ul:eq(0)").slideUp();
- }
- $(target).toggleClass("ui-icon-plus");
- $(target).toggleClass("ui-icon-minus");
- },
-
- /**
- * When the text of a selection is clicked, then show that albums contents
- */
- show_album: function(event) {
- event.preventDefault();
- if ($(event.currentTarget).hasClass("ui-state-focus")) {
- return;
- }
- var parent = $(event.currentTarget).parents(".g-organize-album");
- if ($(parent).hasClass("g-view-only")) {
- return;
- }
- $("#g-organize-microthumb-grid").selectable("destroy");
- var id = $(event.currentTarget).attr("ref");
- $(".g-organize-album-text.ui-state-focus").removeClass("ui-state-focus");
- $(".g-organize-album-text[ref=" + id + "]").addClass("ui-state-focus");
- var url = $("#g-organize-microthumb-grid").attr("ref").replace("__ITEM_ID__", id).replace("__OFFSET__", 0);
- $.get(url, {},
- function(data) {
- $("#g-organize-microthumb-grid").html(data.grid);
- $("#g-organize-sort-column").attr("value", data.sort_column);
- $("#g-organize-sort-order").attr("value", data.sort_order);
- $.organize.set_handlers();
- },
- "json");
- },
-
- /**
- * Change the sort order.
- */
- resort: function(column, dir) {
- var url = sort_order_url
- .replace("__ALBUM_ID__", $("#g-organize-album-tree .ui-state-focus").attr("ref"))
- .replace("__COL__", column)
- .replace("__DIR__", dir);
- $.get(url, {},
- function(data) {
- $("#g-organize-microthumb-grid").html(data.grid);
- $("#g-organize-sort-column").attr("value", data.sort_column);
- $("#g-organize-sort-order").attr("value", data.sort_order);
- $.organize.set_handlers();
- },
- "json");
- }
- };
-})(jQuery);
diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf
new file mode 100644
index 00000000..54169a5b
--- /dev/null
+++ b/modules/organize/lib/Gallery3WebClient.swf
Binary files differ
diff --git a/modules/organize/source/Gallery3Organize_source.zip b/modules/organize/source/Gallery3Organize_source.zip
new file mode 100644
index 00000000..09a73acf
--- /dev/null
+++ b/modules/organize/source/Gallery3Organize_source.zip
Binary files differ
diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php
index 38d05b81..da135857 100644
--- a/modules/organize/views/organize_dialog.html.php
+++ b/modules/organize/views/organize_dialog.html.php
@@ -1,48 +1,118 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
+<script type="text/javascript" src="<?= url::file("lib/swfobject.js") ?>"></script>
+<style type="text/css" media="screen">
+ #flashContent {
+ display:none;
+ }
+
+ .g-organize {
+ padding: 0;
+ margins: 0;
+ }
+
+ object {
+ display: block;
+ outline: none;
+ }
+
+ #g-dialog {
+ padding: 0;
+ }
+</style>
+
<script type="text/javascript">
- var move_url = "<?= url::site("organize/move_to/__ALBUM_ID__?csrf=$csrf") ?>";
- var rearrange_url = "<?= url::site("organize/rearrange/__TARGET_ID__/__BEFORE__?csrf=$csrf") ?>";
- var sort_order_url = "<?= url::site("organize/sort_order/__ALBUM_ID__/__COL__/__DIR__?csrf=$csrf") ?>";
- var tree_url = "<?= url::site("organize/tree/__ALBUM_ID__") ?>";
+ $("#g-dialog").bind("dialogclose", function(event, ui) {
+ // @todo do a call to organize/closing to end the batch
+ window.location.reload();
+ });
+
+ function closeOrganizeDialog() {
+ console.log("closeOrganizeDialog");
+ $("#g-dialog").dialog("close");
+ }
+
+ function getOrganizeStyles() {
+ var styles = {
+ "color": colorToHex($("#g-organize").css("color")),
+ "backgroundColor": colorToHex($("#g-organize").css("backgroundColor")),
+ "borderColor": colorToHex($("#g-organize").css("borderLeftColor")),
+ "rollOverColor": colorToHex($("#g-organize-hover").css("backgroundColor")),
+ "selectionColor": colorToHex($("#g-organize-active").css("backgroundColor"))
+ };
+ return styles;
+ }
+
+ function colorToHex(color) {
+ var digits = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(color);
+
+ var red = parseInt(digits[2]);
+ var green = parseInt(digits[3]);
+ var blue = parseInt(digits[4]);
+
+ var rgb = blue | (green << 8) | (red << 16);
+ return digits[1] + '0x' + rgb.toString(16);
+ }
+
+ function getTextStrings() {
+ var strings = {
+ "statusText": <?= t("Drag and drop photos to re-order or move between album")->for_js() ?>,
+ "addAlbum": <?= t("Add album")->for_js() ?>,
+ "addImages": <?= t("Add photo")->for_js() ?>,
+ "deleteSelected": <?= t("Delete")->for_js() ?>,
+ "uploadedText": <?= t("Uploaded {0}")->for_js() ?>,
+ "removeFileText": <?= t("Remove")->for_js() ?>,
+ "bytes": <?= t("{0} bytes")->for_js() ?>,
+ "kilobytes": <?= t("{0} KB")->for_js() ?>,
+ "megabytes": <?= t("{0} MB")->for_js() ?>,
+ "gigabytes": <?= t("{0} GB")->for_js() ?>,
+ "progressLabel": <?= t("Completed image %1 of %2")->for_js() ?>,
+ "uploadLabel": <?= t("Loaded %1 of %2 bytes")->for_js() ?>,
+ "moveTitle": <?= t("Move images")->for_js() ?>,
+ "deleteTitle": <?= t("Delete image")->for_js() ?>,
+ "uploadTitle": <?= t("Upload image")->for_js() ?>,
+ "cancel": <?= t("Cancel")->for_js() ?>,
+ "close": <?= t("Close")->for_js() ?>
+ };
+ return strings;
+ }
+
+ /*
+ For version detection, set to min. required Flash Player version, or 0 (or 0.0.0),
+ for no version detection.
+ */
+ var swfVersionStr = "0.0.0";
+ /* To use express install, set to playerProductInstall.swf, otherwise the empty string.*/
+ var xiSwfUrlStr = "";
+ var flashvars = {
+ fileFilter: '<?= $file_filter ?>',
+ domains: '["<?= $domain ?>"]',
+ sortOrder: '<?= $sort_order ?>',
+ sortFields: '<?= $sort_fields ?>',
+ baseUrl: '<?= $base_url ?>',
+ apiKey: '<?= $api_key ?>',
+ albumId: "<?= $album->id ?>",
+ controller: '<?= url::abs_site("organize") ?>/'
+ };
+
+ var size = $.gallery_get_viewport_size();
+
+ var params = {};
+ params.quality = "high";
+ params.bgcolor = "#ffffff";
+ params.allowNetworking = "all";
+ params.allowscriptaccess = "sameDomain";
+ params.allowfullscreen = "true";
+ var attributes = {};
+ attributes.id = "g-organize-object";
+ attributes.name = "organize";
+ attributes.align = "middle";
+ swfobject.embedSWF("<?= url::file("modules/organize/lib/Gallery3WebClient.swf") ?>",
+ "flashContent", size.width() - 100, size.height() - 135,
+ swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);
</script>
<div id="g-organize" class="g-dialog-panel">
+ <!-- The following spans are placeholders so we can load the hover and active styles for the flex component -->
+ <span id="g-organize-hover" /><span id="g-organize-active" />
<h1 style="display:none"><?= t("Organize %name", array("name" => html::purify($album->title))) ?></h1>
- <div id="g-organize-content-pane">
- <div id="g-organize-tree-container" class="g-left ui-helper-clearfix">
- <h3><?= t("Albums") ?></h3>
- <ul id="g-organize-album-tree">
- <?= $album_tree ?>
- </ul>
- </div>
- <div id="g-organize-detail" class="g-left ui-helper-clearfix">
- <ul id="g-action-status" class="g-message-block">
- <li class="g-info"><?= t("Drag and drop photos to re-order or move between albums") ?></li>
- </ul>
- <div id="g-organize-microthumb-grid" class="ui-widget"
- ref="<?= url::site("organize/album/__ITEM_ID__/__OFFSET__") ?>">
- <?= $micro_thumb_grid ?>
- </div>
- <div id="g-organize-controls" class="ui-widget-header">
- <a id="g-organize-close" href="#" ref="done"
- class="g-button g-right ui-corner-all ui-state-default"><?= t("Close") ?></a>
- <form>
- <ul>
- <li id="g-organize-sort-order-text" class="g-left"><?= t("Sort order") ?></li>
- <li class="g-left">
- <?= form::dropdown(array("id" => "g-organize-sort-column"),
- album::get_sort_order_options(), $album->sort_column) ?>
- </li>
- <li class="g-left">
- <?= form::dropdown(array("id" => "g-organize-sort-order"),
- array("ASC" => t("Ascending"), "DESC" => t("Descending")), $album->sort_order) ?>
- </li>
- </ul>
- </form>
- </div>
- </div>
- </div>
+ <div id="flashContent">&nbsp;</div>
</div>
-
-<script type="text/javascript">
- $("#g-organize").ready($.organize.init);
-</script>
diff --git a/modules/organize/views/organize_thumb_grid.html.php b/modules/organize/views/organize_thumb_grid.html.php
deleted file mode 100644
index f5db53d4..00000000
--- a/modules/organize/views/organize_thumb_grid.html.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.") ?>
-<? foreach ($album->children(25, $offset) as $child): ?>
-<div class="g-organize-microthumb-grid-cell g-left ui-state-default ui-state-active <?= $child->is_album() ? "g-album" : "g-photo" ?>"
- ref="<?= $child->id ?>">
- <?= $child->thumb_img(array("class" => "g-thumbnail", "ref" => $child->id), 90, true) ?>
- <span<?= $child->is_album() ? " class=\"ui-icon ui-icon-note\"" : "" ?>></span>
-</div>
-<? endforeach ?>
-
-<? if ($album->children_count() > $offset): ?>
-<script type="text/javascript">
- setTimeout(function() {
- $.get("<?= url::site("organize/album/$album->id/" . ($offset + 25)) ?>",
- {},
- function(data) {
- $("#g-organize-microthumb-grid").append(data.grid);
- $.organize.set_handlers();
- },
- "json");
- }, 50);
-</script>
-<? endif ?>
diff --git a/modules/organize/views/organize_tree.html.php b/modules/organize/views/organize_tree.html.php
deleted file mode 100644
index 044b6858..00000000
--- a/modules/organize/views/organize_tree.html.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.") ?>
-<li class="g-organize-album ui-icon-left <?= access::can("edit", $album) ? "" : "g-view-only" ?>"
- ref="<?= $album->id ?>">
- <span class="ui-icon ui-icon-minus g-left">
- </span>
- <span class="g-organize-album-text <?= $selected && $album->id == $selected->id ? "ui-state-focus" : "" ?>"
- ref="<?= $album->id ?>">
- <?= html::clean($album->title) ?>
- </span>
- <? $child_albums = $album->viewable()->children(null, null, array(array("type", "=", "album"))); ?>
- <? if (!empty($child_albums)): ?>
- <ul>
- <? foreach ($child_albums as $child): ?>
- <? if ($selected && $child->contains($selected)): ?>
- <?= View::factory("organize_tree.html", array("selected" => $selected, "album" => $child)); ?>
- <? else: ?>
- <li class="g-organize-album ui-icon-left <?= access::can("edit", $child) ? "" : "g-view-only" ?>"
- ref="<?= $child->id ?>">
- <span class="ui-icon ui-icon-plus g-left"></span>
- <span class="g-organize-album-text <?= $selected && $child->id == $selected->id ? "ui-state-focus" : "" ?>" ref="<?= $child->id ?>">
- <?= html::clean($child->title) ?>
- </span>
- </li>
- <? endif ?>
- <? endforeach ?>
- </ul>
- <? endif ?>
-</li>
-
diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php
index dab54976..38f28171 100644
--- a/modules/rest/controllers/rest.php
+++ b/modules/rest/controllers/rest.php
@@ -41,12 +41,13 @@ class Rest_Controller extends Controller {
public function __call($function, $args) {
$input = Input::instance();
$request = new stdClass();
+
switch ($method = strtolower($input->server("REQUEST_METHOD"))) {
case "get":
$request->params = (object) $input->get();
break;
- case "post":
+ default:
$request->params = (object) $input->post();
if (isset($_FILES["file"])) {
$request->file = upload::save("file");
@@ -63,6 +64,11 @@ class Rest_Controller extends Controller {
$request->method = strtolower($input->server("HTTP_X_GALLERY_REQUEST_METHOD", $method));
$request->access_key = $input->server("HTTP_X_GALLERY_REQUEST_KEY");
+
+ if (empty($request->access_key) && !empty($request->params->access_key)) {
+ $request->access_key = $request->params->access_key;
+ }
+
$request->url = url::abs_current(true);
rest::set_active_user($request->access_key);