From 67a8ef427798d37a9629c2f3d9672c03520b9987 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 27 Mar 2010 11:16:41 -0700 Subject: Convert the old organize to the new flex based organize --- modules/organize/controllers/organize.php | 163 ++++-------------------------- 1 file changed, 17 insertions(+), 146 deletions(-) (limited to 'modules/organize/controllers') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 8dc8692c..8f9c3b5d 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -19,159 +19,30 @@ */ 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); - } + // @todo turn this into an api call. + $v->file_filter = json_encode(array("Images" => "*.jpg; *.jpeg; *.gif; *.png", + "Movies" => "*.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); - 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(); - } - - 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; - } - - public function tree($album_id) { - $album = ORM::factory("item", $album_id); - access::required("view", $album); - - print self::_expanded_tree($album); - } - - /** - * 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; + $user = identity::active_user(); + $v->api_key = rest::get_access_token($user->id)->access_key; + print $v; } } -- cgit v1.2.3 From 91f27bf32fe3d9650e5095b6747804ec97b524e8 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 30 Mar 2010 06:33:42 -0700 Subject: add a controller method to return the translated labels for the add album dialog. --- modules/organize/controllers/organize.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'modules/organize/controllers') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 8f9c3b5d..bfd4992d 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -45,4 +45,12 @@ class Organize_Controller extends Controller { $v->api_key = rest::get_access_token($user->id)->access_key; print $v; } + + 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"))); + } + } -- cgit v1.2.3 From ffc3f9f41c3d8d6df08d9ad6138f4ad74749ccec Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 18 May 2010 10:00:48 -0700 Subject: checkpoint the new organize module. At this point rearrange and move work. Rearrange is moving items within the same album, move is moving to a different album. --- modules/organize/controllers/organize.php | 2 +- modules/organize/lib/Gallery3WebClient.swf | Bin 0 -> 139321 bytes modules/organize/lib/organize.swf | Bin 778677 -> 0 bytes modules/organize/source/Gallery3Organize_source.zip | Bin 0 -> 924325 bytes modules/organize/source/flex_organize_source.7z | Bin 343272 -> 0 bytes modules/organize/views/organize_dialog.html.php | 8 ++++---- 6 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 modules/organize/lib/Gallery3WebClient.swf delete mode 100644 modules/organize/lib/organize.swf create mode 100644 modules/organize/source/Gallery3Organize_source.zip delete mode 100644 modules/organize/source/flex_organize_source.7z (limited to 'modules/organize/controllers') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index bfd4992d..e713fdd9 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -42,7 +42,7 @@ class Organize_Controller extends Controller { $v->sort_fields = json_encode($sort_fields); $user = identity::active_user(); - $v->api_key = rest::get_access_token($user->id)->access_key; + $v->api_key = rest::get_access_key($user->id)->access_key; print $v; } diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf new file mode 100644 index 00000000..a9e4c66b Binary files /dev/null and b/modules/organize/lib/Gallery3WebClient.swf differ diff --git a/modules/organize/lib/organize.swf b/modules/organize/lib/organize.swf deleted file mode 100644 index 62e733ea..00000000 Binary files a/modules/organize/lib/organize.swf and /dev/null differ diff --git a/modules/organize/source/Gallery3Organize_source.zip b/modules/organize/source/Gallery3Organize_source.zip new file mode 100644 index 00000000..c6f7eebe Binary files /dev/null and b/modules/organize/source/Gallery3Organize_source.zip differ diff --git a/modules/organize/source/flex_organize_source.7z b/modules/organize/source/flex_organize_source.7z deleted file mode 100644 index ea5951b9..00000000 Binary files a/modules/organize/source/flex_organize_source.7z and /dev/null differ diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 8163c595..5da4aca4 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -22,10 +22,12 @@ -- cgit v1.2.3 From e4ff302e3b1d64de2864e7fcd64f26e6d012089b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 20 May 2010 09:05:50 -0700 Subject: Add items and add albums are now working. What still needs to be done is add a progress bar for longer running tasks --- modules/organize/controllers/organize.php | 6 ++++-- modules/organize/lib/Gallery3WebClient.swf | Bin 139321 -> 136657 bytes .../organize/source/Gallery3Organize_source.zip | Bin 924325 -> 937810 bytes 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'modules/organize/controllers') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index e713fdd9..d2c273b6 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -28,8 +28,10 @@ class Organize_Controller extends Controller { $v = new View("organize_dialog.html"); $v->album = $album; // @todo turn this into an api call. - $v->file_filter = json_encode(array("Images" => "*.jpg; *.jpeg; *.gif; *.png", - "Movies" => "*.flv; *.mp4")); + $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") . "/"; diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index a9e4c66b..1069eae0 100644 Binary files a/modules/organize/lib/Gallery3WebClient.swf and b/modules/organize/lib/Gallery3WebClient.swf differ diff --git a/modules/organize/source/Gallery3Organize_source.zip b/modules/organize/source/Gallery3Organize_source.zip index c6f7eebe..133a7fcf 100644 Binary files a/modules/organize/source/Gallery3Organize_source.zip and b/modules/organize/source/Gallery3Organize_source.zip differ -- cgit v1.2.3 From 47aa65143060ff376d95ca182c55132d821917fb Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 13 Jun 2010 17:58:50 -0700 Subject: Fix problems ith IE and flex initialization when one of the flashvars contains a json encoded string. Also address the problem that IE returns the color values differently that Firefox and Chrome --- modules/organize/controllers/organize.php | 11 +-- modules/organize/lib/Gallery3WebClient.swf | Bin 145339 -> 142627 bytes modules/organize/views/organize_dialog.html.php | 104 ++++++++++++------------ 3 files changed, 60 insertions(+), 55 deletions(-) (limited to 'modules/organize/controllers') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index d2c273b6..b5a25400 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -28,23 +28,24 @@ class Organize_Controller extends Controller { $v = new View("organize_dialog.html"); $v->album = $album; // @todo turn this into an api call. - $v->file_filter = json_encode( + $v->file_filter = addslashes(json_encode( array("photo" => array("label" => "Images", "types" => array("*.jpg", "*.jpeg", "*.png", "*.gif")), - "movie" => array("label" => "Movies", "types" => array("*.flv", "*.mp4")))); + "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"))); + $v->sort_order = addslashes(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); + $v->sort_fields = addslashes(json_encode($sort_fields)); $user = identity::active_user(); - $v->api_key = rest::get_access_key($user->id)->access_key; + $v->access_key = rest::get_access_key($user->id)->access_key; + Kohana_Log::add("error", $v->__toString()); print $v; } diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index 6ff0d5ba..879a4fec 100644 Binary files a/modules/organize/lib/Gallery3WebClient.swf and b/modules/organize/lib/Gallery3WebClient.swf differ diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 2d340f13..8c5ba133 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -27,63 +27,76 @@ }); function closeOrganizeDialog() { - console.log("closeOrganizeDialog"); $("#g-dialog").dialog("close"); } function setTitle(title) { - $("#ui-dialog-title-g-dialog").text(for_js() ?> + title); + $("#ui-dialog-title-g-dialog").text(for_js() ?> + title); } 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 { + 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); + // Surprising no one, the color extracted from the css is in a different format + // in IE than it is when extracted from FF or Chrome. FF and Chrome return + // the of "rgb(nn,nn,nn)". Where as IE returns it as #hhhhhh. - var red = parseInt(digits[2]); - var green = parseInt(digits[3]); - var blue = parseInt(digits[4]); + if (color.indexOf("#") === 0) { + return '0x' + color.substring(1); + } else { + var digits = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(color); - var rgb = blue | (green << 8) | (red << 16); - return digits[1] + '0x' + rgb.toString(16); + 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": for_js() ?>, - "remoteError": + return { + statusText: for_js() ?>, + remoteError: for_js() ?>, - "addAlbumError": for_js() ?>, - "errorOccurred": for_js() ?>, - "addAlbum": for_js() ?>, - "addImages": for_js() ?>, - "deleteSelected": for_js() ?>, - "uploadedText": for_js() ?>, - "removeFileText": for_js() ?>, - "bytes": for_js() ?>, - "kilobytes": for_js() ?>, - "megabytes": for_js() ?>, - "gigabytes": for_js() ?>, - "progressLabel": for_js() ?>, - "uploadLabel": for_js() ?>, - "moveTitle": for_js() ?>, - "deleteTitle": for_js() ?>, - "uploadTitle": for_js() ?>, - "cancel": for_js() ?>, - "close": for_js() ?> + addAlbumError: for_js() ?>, + errorOccurred: for_js() ?>, + addAlbum: for_js() ?>, + addImages: for_js() ?>, + deleteSelected: for_js() ?>, + uploadedText: for_js() ?>, + removeFileText: for_js() ?>, + progressLabel: for_js() ?>, + uploadLabel: for_js() ?>, + moveTitle: for_js() ?>, + deleteTitle: for_js() ?>, + uploadTitle: for_js() ?>, + cancel: for_js() ?>, + close: for_js() ?> }; - return strings; } + function getGalleryParameters() { + return { + fileFilter: "", + domain: "", + sortOrder: "", + sortFields: "", + baseUrl: "", + accessKey: "", + albumId: "id ?>", + controller: "/" + }; + }; /* For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. @@ -91,16 +104,7 @@ var swfVersionStr = "0.0.0"; /* To use express install, set to playerProductInstall.swf, otherwise the empty string.*/ var xiSwfUrlStr = ""; - var flashvars = { - fileFilter: '', - domains: '[""]', - sortOrder: '', - sortFields: '', - baseUrl: '', - apiKey: '', - albumId: "id ?>", - controller: '/' - }; + var flashvars = {}; var size = $.gallery_get_viewport_size(); @@ -111,8 +115,8 @@ params.allowscriptaccess = "sameDomain"; params.allowfullscreen = "true"; var attributes = {}; - attributes.id = "g-organize-object"; - attributes.name = "organize"; + attributes.id = "Gallery3WebClient"; + attributes.name = "Gallery3WebClient"; attributes.align = "middle"; swfobject.embedSWF("", "flashContent", size.width() - 100, size.height() - 135, @@ -121,6 +125,6 @@
-

html::purify($album->title))) ?>

+

html::purify($album->title))) ?>

 
-- cgit v1.2.3 From 821d3f7854d76922b53df7e523eeaa8d4dca8c7b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 13 Jun 2010 19:50:52 -0700 Subject: Remove a debugging statement. --- modules/organize/controllers/organize.php | 1 - 1 file changed, 1 deletion(-) (limited to 'modules/organize/controllers') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index b5a25400..199aeaf3 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -45,7 +45,6 @@ class Organize_Controller extends Controller { $user = identity::active_user(); $v->access_key = rest::get_access_key($user->id)->access_key; - Kohana_Log::add("error", $v->__toString()); print $v; } -- cgit v1.2.3 From f10d641044fe31224af5b42b148a8ee77d9a34db Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 14 Jun 2010 13:07:58 -0700 Subject: Change the parameters for the organize dialog box. The baseUrl parameter was removed and replaced with the restUri, which contains the relative uri for the rest controller. The controller parameter is now the relative uri for the organize controller. The protocol parameter was added. In addition, there is not default size for the organize flex object. It attempts to fit within the gallery3 dialog box. --- modules/organize/controllers/organize.php | 2 ++ modules/organize/lib/Gallery3WebClient.swf | Bin 142627 -> 147590 bytes modules/organize/views/organize_dialog.html.php | 11 +++++++---- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'modules/organize/controllers') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 199aeaf3..d688a76d 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -45,6 +45,8 @@ class Organize_Controller extends Controller { $user = identity::active_user(); $v->access_key = rest::get_access_key($user->id)->access_key; + + $v->protocol = (empty($_SERVER["HTTPS"]) OR $_SERVER["HTTPS"] === "off") ? "http" : "https"; print $v; } diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index 879a4fec..c51fa4e8 100644 Binary files a/modules/organize/lib/Gallery3WebClient.swf and b/modules/organize/lib/Gallery3WebClient.swf differ diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 8c5ba133..8160a339 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -87,14 +87,17 @@ function getGalleryParameters() { return { - fileFilter: "", + dialogWidth: $("#g-dialog:parent").width(), + dialogHeight: $("#g-dialog").height(), domain: "", + accessKey: "", + protocol: "", + fileFilter: "", sortOrder: "", sortFields: "", - baseUrl: "", - accessKey: "", albumId: "id ?>", - controller: "/" + restUri: "/", + controller: "/" }; }; /* -- cgit v1.2.3 From 359235182ebb14c75b495a889a2298d1e0130d77 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 17 Jun 2010 09:57:38 -0700 Subject: Add a cache-buster to the SWF url so that it'll refresh in the browser every time the SWF file changes. --- modules/organize/controllers/organize.php | 2 ++ modules/organize/views/organize_dialog.html.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'modules/organize/controllers') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index d688a76d..488f1eb1 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -47,6 +47,8 @@ class Organize_Controller extends Controller { $v->access_key = rest::get_access_key($user->id)->access_key; $v->protocol = (empty($_SERVER["HTTPS"]) OR $_SERVER["HTTPS"] === "off") ? "http" : "https"; + $v->swf_url = url::file("modules/organize/lib/Gallery3WebClient.swf?") . + filemtime(MODPATH . "organize/lib/Gallery3WebClient.swf"); print $v; } diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 8113a1af..d68534cf 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -121,7 +121,7 @@ attributes.id = "Gallery3WebClient"; attributes.name = "Gallery3WebClient"; attributes.align = "middle"; - swfobject.embedSWF("", + swfobject.embedSWF("", "flashContent", size.width() - 100, size.height() - 135, swfVersionStr, xiSwfUrlStr, flashvars, params, attributes); -- cgit v1.2.3 From 070db2a97ab3e508456780639faa643934081966 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 17 Jun 2010 10:21:37 -0700 Subject: Rearrange the adding of fields to the template so that they match the order of appearance in the template. Also remove the @todo's --- modules/organize/controllers/organize.php | 21 +++++++++++++-------- modules/organize/views/organize_dialog.html.php | 4 ++-- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'modules/organize/controllers') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 488f1eb1..1d188ade 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -27,26 +27,31 @@ class Organize_Controller extends Controller { $v = new View("organize_dialog.html"); $v->album = $album; - // @todo turn this into an api call. + + $v->domain = $input->server("SERVER_NAME"); + + $user = identity::active_user(); + $v->access_key = rest::get_access_key($user->id)->access_key; + + $v->protocol = (empty($_SERVER["HTTPS"]) OR $_SERVER["HTTPS"] === "off") ? "http" : "https"; + $v->file_filter = addslashes(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 = addslashes(json_encode(array("ASC" => (string)t("Ascending"), "DESC" => (string)t("Descending")))); + $v->sort_order = addslashes( + 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 = addslashes(json_encode($sort_fields)); - $user = identity::active_user(); - $v->access_key = rest::get_access_key($user->id)->access_key; + $v->rest_uri = url::site("rest") . "/"; + + $v->controller_uri = url::site("organize") . "/"; - $v->protocol = (empty($_SERVER["HTTPS"]) OR $_SERVER["HTTPS"] === "off") ? "http" : "https"; $v->swf_url = url::file("modules/organize/lib/Gallery3WebClient.swf?") . filemtime(MODPATH . "organize/lib/Gallery3WebClient.swf"); print $v; diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index d68534cf..a4fdc071 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -96,8 +96,8 @@ sortOrder: "", sortFields: "", albumId: "id ?>", - restUri: "/", - controllerUri: "/" + restUri: "", + controllerUri: "/" }; }; /* -- cgit v1.2.3 From ec40e03a377a8a5cd74b448135307c77a2b9e0e9 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 18 Jun 2010 15:20:32 -0700 Subject: Use request::protocol(). --- modules/organize/controllers/organize.php | 2 -- modules/organize/views/organize_dialog.html.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'modules/organize/controllers') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 1d188ade..e8db991b 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -33,8 +33,6 @@ class Organize_Controller extends Controller { $user = identity::active_user(); $v->access_key = rest::get_access_key($user->id)->access_key; - $v->protocol = (empty($_SERVER["HTTPS"]) OR $_SERVER["HTTPS"] === "off") ? "http" : "https"; - $v->file_filter = addslashes(json_encode( array("photo" => array("label" => "Images", "types" => array("*.jpg", "*.jpeg", "*.png", "*.gif")), diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 4224c10b..9e70d168 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -91,7 +91,7 @@ dialogHeight: $("#g-dialog").height(), domain: "", accessKey: "", - protocol: "", + protocol: "", fileFilter: "", sortOrder: "", sortFields: "", -- cgit v1.2.3 From 545a91270d22506362e67032a3c54fdb21f8823e Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 18 Jun 2010 19:05:59 -0700 Subject: 1) Change how the size of the flexstage is calculated. (Basically remove the dialogWidth and dialogHeight and adjsut the internal controls when added to the stage. 2) Cleanup the controller code --- modules/organize/controllers/organize.php | 31 ++++++++++-------------- modules/organize/lib/Gallery3WebClient.swf | Bin 150760 -> 147793 bytes modules/organize/views/organize_dialog.html.php | 4 +-- 3 files changed, 14 insertions(+), 21 deletions(-) (limited to 'modules/organize/controllers') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index e8db991b..732ac3f6 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -25,32 +25,27 @@ class Organize_Controller extends Controller { access::required("view", $album); access::required("edit", $album); - $v = new View("organize_dialog.html"); - $v->album = $album; - - $v->domain = $input->server("SERVER_NAME"); - $user = identity::active_user(); - $v->access_key = rest::get_access_key($user->id)->access_key; - - $v->file_filter = addslashes(json_encode( - array("photo" => array("label" => "Images", - "types" => array("*.jpg", "*.jpeg", "*.png", "*.gif")), - "movie" => array("label" => "Movies", "types" => array("*.flv", "*.mp4"))))); - - $v->sort_order = addslashes( - 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 = addslashes(json_encode($sort_fields)); + $sort_order = array("ASC" => (string)t("Ascending"), "DESC" => (string)t("Descending")); + $file_filter = json_encode( + array("photo" => array("label" => "Images", + "types" => array("*.jpg", "*.jpeg", "*.png", "*.gif")), + "movie" => array("label" => "Movies", "types" => array("*.flv", "*.mp4")))); + $v = new View("organize_dialog.html"); + $v->album = $album; + $v->domain = $input->server("SERVER_NAME"); + $v->access_key = rest::get_access_key($user->id)->access_key; + $v->file_filter = addslashes($file_filter); + $v->sort_order = addslashes(json_encode($sort_order)); + $v->sort_fields = addslashes(json_encode($sort_fields)); $v->rest_uri = url::site("rest") . "/"; - $v->controller_uri = url::site("organize") . "/"; - - $v->swf_url = url::file("modules/organize/lib/Gallery3WebClient.swf?") . + $v->swf_uri = url::file("modules/organize/lib/Gallery3WebClient.swf?") . filemtime(MODPATH . "organize/lib/Gallery3WebClient.swf"); print $v; } diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index 82735217..9f753076 100644 Binary files a/modules/organize/lib/Gallery3WebClient.swf and b/modules/organize/lib/Gallery3WebClient.swf differ diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 9e70d168..c41e5960 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -87,8 +87,6 @@ function getGalleryParameters() { return { - dialogWidth: $("#g-dialog:parent").width(), - dialogHeight: $("#g-dialog").height(), domain: "", accessKey: "", protocol: "", @@ -121,7 +119,7 @@ attributes.id = "Gallery3WebClient"; attributes.name = "Gallery3WebClient"; attributes.align = "middle"; - swfobject.embedSWF("", + swfobject.embedSWF("", "flashContent", size.width() - 100, size.height() - 135, swfVersionStr, xiSwfUrlStr, flashvars, params, attributes); -- cgit v1.2.3 From 9b788674275c843947d44934a50dd395b515737a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 18 Jun 2010 20:43:14 -0700 Subject: Simplify rest::get_access_key($user) to rest::access_key() that returns just the access key string for the active user. That's how we use the API, so keep it simple. --- modules/organize/controllers/organize.php | 2 +- modules/rest/controllers/rest.php | 3 +-- modules/rest/helpers/rest.php | 7 ++++--- modules/rest/tests/Rest_Controller_Test.php | 15 +++++---------- 4 files changed, 11 insertions(+), 16 deletions(-) (limited to 'modules/organize/controllers') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 732ac3f6..135a6fc9 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -39,7 +39,7 @@ class Organize_Controller extends Controller { $v = new View("organize_dialog.html"); $v->album = $album; $v->domain = $input->server("SERVER_NAME"); - $v->access_key = rest::get_access_key($user->id)->access_key; + $v->access_key = rest::access_key(); $v->file_filter = addslashes($file_filter); $v->sort_order = addslashes(json_encode($sort_order)); $v->sort_fields = addslashes(json_encode($sort_fields)); diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php index acc4a7df..ccccc762 100644 --- a/modules/rest/controllers/rest.php +++ b/modules/rest/controllers/rest.php @@ -34,8 +34,7 @@ class Rest_Controller extends Controller { auth::login($user); - $key = rest::get_access_key($user->id); - rest::reply($key->access_key); + rest::reply(rest::access_key()); } public function __call($function, $args) { diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php index b382cb29..0bad58f6 100644 --- a/modules/rest/helpers/rest.php +++ b/modules/rest/helpers/rest.php @@ -66,9 +66,9 @@ class rest_Core { identity::set_active_user($user); } - static function get_access_key($user_id) { + static function access_key() { $key = ORM::factory("user_access_key") - ->where("user_id", "=", $user_id) + ->where("user_id", "=", identity::active_user()->id) ->find(); if (!$key->loaded()) { @@ -76,7 +76,8 @@ class rest_Core { $key->access_key = md5(md5(uniqid(mt_rand(), true) . access::private_key())); $key->save(); } - return $key; + + return $key->access_key; } /** diff --git a/modules/rest/tests/Rest_Controller_Test.php b/modules/rest/tests/Rest_Controller_Test.php index fe83283d..0c8a4a98 100644 --- a/modules/rest/tests/Rest_Controller_Test.php +++ b/modules/rest/tests/Rest_Controller_Test.php @@ -21,8 +21,7 @@ class Rest_Controller_Test extends Gallery_Unit_Test_Case { public function setup() { $this->_save = array($_GET, $_POST, $_SERVER); - $key = rest::get_access_key(1); // admin user - $_SERVER["HTTP_X_GALLERY_REQUEST_KEY"] = $key->access_key; + $_SERVER["HTTP_X_GALLERY_REQUEST_KEY"] = rest::access_key(); } public function teardown() { @@ -83,11 +82,10 @@ class Rest_Controller_Test extends Gallery_Unit_Test_Case { $_SERVER["REQUEST_METHOD"] = "GET"; $_GET["key"] = "value"; - $key = rest::get_access_key(1); // admin user $this->assert_array_equal_to_json( array("params" => array("key" => "value"), "method" => "get", - "access_key" => $key->access_key, + "access_key" => rest::access_key(), "url" => "http://./index.php/gallery_unit_test"), test::call_and_capture(array(new Rest_Controller(), "mock"))); } @@ -96,11 +94,10 @@ class Rest_Controller_Test extends Gallery_Unit_Test_Case { $_SERVER["REQUEST_METHOD"] = "POST"; $_POST["key"] = "value"; - $key = rest::get_access_key(1); // admin user $this->assert_array_equal_to_json( array("params" => array("key" => "value"), "method" => "post", - "access_key" => $key->access_key, + "access_key" => rest::access_key(), "url" => "http://./index.php/gallery_unit_test"), test::call_and_capture(array(new Rest_Controller(), "mock"))); } @@ -110,11 +107,10 @@ class Rest_Controller_Test extends Gallery_Unit_Test_Case { $_SERVER["HTTP_X_GALLERY_REQUEST_METHOD"] = "put"; $_POST["key"] = "value"; - $key = rest::get_access_key(1); // admin user $this->assert_array_equal_to_json( array("params" => array("key" => "value"), "method" => "put", - "access_key" => $key->access_key, + "access_key" => rest::access_key(), "url" => "http://./index.php/gallery_unit_test"), test::call_and_capture(array(new Rest_Controller(), "mock"))); } @@ -124,11 +120,10 @@ class Rest_Controller_Test extends Gallery_Unit_Test_Case { $_SERVER["HTTP_X_GALLERY_REQUEST_METHOD"] = "delete"; $_POST["key"] = "value"; - $key = rest::get_access_key(1); // admin user $this->assert_array_equal_to_json( array("params" => array("key" => "value"), "method" => "delete", - "access_key" => $key->access_key, + "access_key" => rest::access_key(), "url" => "http://./index.php/gallery_unit_test"), test::call_and_capture(array(new Rest_Controller(), "mock"))); } -- cgit v1.2.3