From 5e703186fbf0c0cb689fc737de7c074249361ef9 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 9 Feb 2010 08:23:43 -0800 Subject: Current state of organize. works for all browsers except IE. IE no longer implodes, but dragging doesn't work. Selecting works fine, either by using the lasso or clicking. Ctrl-Click adds to the selection. The problem is that when a drag is attempted, the selection gets lost and things start falling apart. --- modules/organize/js/organize.js | 56 ++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index 942e49e5..130c0f99 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -6,32 +6,30 @@ cursorAt: { left: -10, top: -10}, appendTo: "#g-organize-content-pane", helper: function(event, ui) { - var selected = $(".ui-draggable.ui-selected img"); - if (selected.length) { - var set = $('
') - .css({ - zIndex: 2000, - width: 80, - height: Math.ceil(selected.length / 5) * 16 - }); + var selected = $(".ui-selected"); + var set = $('
') + .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; - } - return null; + selected.each(function(i) { + var row = parseInt(i / 5); + var j = i - (row * 5); + var img = $("img", this); + var o = img.offset(); + var copy = img.clone() + .css({ + width: img.width(), height: img.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) { @@ -138,6 +136,7 @@ }, grid_mouse_move_handler: function(event) { + var continue_events = true; if ($(".g-drag-helper").length) { var organizeData = $("#g-organize").data("organizeData"); var thumbGrid = $("#g-organize-microthumb-grid"); @@ -173,8 +172,13 @@ .data("drop_position", {id: $(item).attr("ref"), position: organizeData.rtl ? !before : before}); thumbGrid.append(set); + if ($.browser.msie) { + $(".g-drag-helper").offset({top: event.pageY, left: event.PageX}); + event.preventDefault(); + continue_events = false; + } } - return true; + return continue_events; }, /** -- cgit v1.2.3 From da251228cbb54818852c49d37ec7eb31f2313160 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 13 Feb 2010 13:44:09 -0800 Subject: If the return object is empty still return the empty object in the json response. --- modules/rest/helpers/rest.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php index a61aba2f..3c53784d 100644 --- a/modules/rest/helpers/rest.php +++ b/modules/rest/helpers/rest.php @@ -21,17 +21,15 @@ class rest_Core { static function reply($data=array()) { Session::instance()->abort_save(); - if ($data) { - if (Input::instance()->get("output") == "html") { - header("Content-type: text/html"); - $html = preg_replace( - "#([\w]+?://[\w]+[^ \'\"\n\r\t<]*)#ise", "'\\1'", - var_export($data, 1)); - print "
$html
"; - } else { - header("Content-type: application/json"); - print json_encode($data); - } + if (Input::instance()->get("output") == "html") { + header("Content-type: text/html"); + $html = preg_replace( + "#([\w]+?://[\w]+[^ \'\"\n\r\t<]*)#ise", "'\\1'", + var_export(!empty($data) ? $data : t("Empty response"), 1)); + print "
$html
"; + } else { + header("Content-type: application/json"); + print json_encode($data); } } -- cgit v1.2.3 From b7786fe9a3edca070cac45d0fba221033e0e3ee2 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 13 Mar 2010 08:16:37 -0800 Subject: Changes to support updating the child elements within an album. In this change the urls of the children are sent up asan array of post fields children[0].... children[n]. If an existing child is not included it is deleted. Including a url to an child in another album will move the child. Changing the order of the children will respect the order of the children, if the sort column is 'weight' --- modules/gallery/helpers/item_rest.php | 78 +++++++++++++++++++++++++++++----- modules/gallery/helpers/items_rest.php | 12 +++++- modules/rest/controllers/rest.php | 2 +- 3 files changed, 79 insertions(+), 13 deletions(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 16abec5a..5d31291e 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -88,35 +88,91 @@ class item_rest_Core { $params = $request->params; + $sort_order_changed_to_weight = false; + // Start the batch + batch::start(); + // Only change fields from a whitelist. foreach (array("album_cover", "captured", "description", "height", "mime_type", "name", "parent", "rand_key", "resize_dirty", "resize_height", "resize_width", "slug", "sort_column", "sort_order", "thumb_dirty", "thumb_height", "thumb_width", "title", "view_count", "weight", "width") as $key) { - switch ($key) { - case "album_cover": - if (property_exists($request->params, "album_cover")) { + if (property_exists($request->params, $key)) { + switch ($key) { + case "album_cover": $album_cover_item = rest::resolve($request->params->album_cover); access::required("view", $album_cover_item); $item->album_cover_item_id = $album_cover_item->id; - } - break; - - case "parent": - if (property_exists($request->params, "parent")) { + break; + + case "sort_column": + if ($request->params->sort_column == "weight" && $item->sort_column != "weight") { + $sort_order_changed_to_weight = true; + $item->sort_column = "weight"; + } + break; + case "parent": $parent = rest::resolve($request->params->parent); access::required("edit", $parent); $item->parent_id = $parent->id; - } break; - default: - if (property_exists($request->params, $key)) { + default: $item->$key = $request->params->$key; } } } $item->save(); + + // If children are supplied, then update the children based on that client tells us. + // if the sort order changed, then update the weights if there are no children to be updated + if (property_exists($request->params, "children")) { + // Map the existing children by their restful urls + $children = array(); + foreach ($item->children() as $child) { + $children[rest::url("item", $child)] = $child; + } + $update_weight = $item->sort_column == "weight"; + $weight = $item->sort_order == "ASC" ? -1 : $request->params->url->length; + $weight_increment = $item->sort_order == "ASC" ? 1 : -1; + + foreach($request->params->children as $url) { + if (isset($children[$url])) { + $child = $children[$url]; + unset($children[$url]); + } else { + $child = rest::resolve($url); + $child->parent_id = $item->id; + } + $child->save(); + if ($update_weight) { + $weight += $weight_increment; + db::build() + ->update("items") + ->set("weight", $weight) + ->where("id", "=", $child->id) + ->execute(); + } + } + // Anything left in the mapping needs to be deleted + foreach ($children as $child) { + $child->delete(); + } + } else if ($sort_order_changed_to_weight) { + $weight = $item->sort_order == "ASC" ? -1 : $request->params->url->length; + $weight_increment = $item->sort_order == "ASC" ? 1 : -1; + foreach ($item->children() as $child) { + // Do this directly in the database to avoid sending notifications + $weight += $weight_increment; + db::build() + ->update("items") + ->set("weight", $weight) + ->where("id", "=", $child->id) + ->execute(); + } + } + + batch::stop(); } static function post($request) { diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 05ca65cf..48839dc9 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -19,10 +19,12 @@ */ class items_rest_Core { static function get($request) { + $parent = rest::resolve($request->url); + access::required("view", $parent); $items = array(); if (isset($request->params->url)) { - foreach($request->params->url as $url) { + foreach ($request->params->url as $url) { $item = rest::resolve($url); if (access::can("view", $item)) { $members = array(); @@ -41,4 +43,12 @@ class items_rest_Core { return $items; } + + static function resolve($id) { + $item = ORM::factory("item", $id); + if (!access::can("view", $item)) { + throw new Kohana_404_Exception(); + } + return $item; + } } diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php index eed54bd4..7a9e3b0b 100644 --- a/modules/rest/controllers/rest.php +++ b/modules/rest/controllers/rest.php @@ -46,7 +46,7 @@ class Rest_Controller extends Controller { $request->params = (object) $input->get(); break; - case "post": + default: $request->params = (object) $input->post(); if (isset($_FILES["file"])) { $request->file = upload::save("file"); -- cgit v1.2.3 From 08f11ce90edae83729537323925f167ef11b659e Mon Sep 17 00:00:00 2001 From: Florent Paterno Date: Mon, 1 Mar 2010 17:23:56 +0100 Subject: Fix bug #1015 : repeated ids are prohibited --- modules/gallery/helpers/gallery_event.php | 2 +- modules/organize/helpers/organize_event.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 4fd447bd..d723cc1b 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -383,7 +383,7 @@ class gallery_event_Core { ->id("delete") ->label($delete_title) ->css_class("ui-icon-trash") - ->css_id("g-quick-delete") + ->css_class("g-quick-delete") ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))); } diff --git a/modules/organize/helpers/organize_event.php b/modules/organize/helpers/organize_event.php index 4b048630..a9d64637 100644 --- a/modules/organize/helpers/organize_event.php +++ b/modules/organize/helpers/organize_event.php @@ -26,7 +26,7 @@ class organize_event_Core { ->append(Menu::factory("dialog") ->id("organize") ->label(t("Organize album")) - ->css_id("g-organize-link") + ->css_id("g-menu-organize-link") ->url(url::site("organize/dialog/{$item->id}"))); } } @@ -37,8 +37,7 @@ class organize_event_Core { ->append(Menu::factory("dialog") ->id("organize") ->label(t("Organize album")) - ->css_id("g-organize-link") - ->css_class("ui-icon-folder-open") + ->css_class("ui-icon-folder-open g-organize-link") ->url(url::site("organize/dialog/{$item->id}"))); } } -- cgit v1.2.3 From c69f5f4906c367b900ec251d83a3156b9f9d73aa Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 3 Mar 2010 10:17:48 -0800 Subject: Guests don't get access to the REST API. --- modules/rest/helpers/rest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php index cd962057..7440350f 100644 --- a/modules/rest/helpers/rest.php +++ b/modules/rest/helpers/rest.php @@ -39,8 +39,7 @@ class rest_Core { static function set_active_user($access_token) { if (empty($access_token)) { - identity::set_active_user(identity::guest()); - return; + throw new Rest_Exception("Forbidden", 403); } $key = ORM::factory("user_access_token") -- cgit v1.2.3 From 931453304805b59751c5d3dffef42b8692b6fe65 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 5 Mar 2010 21:42:39 -0800 Subject: Update tests to reflect the fact that you have to be logged in to do anything. --- modules/rest/tests/Rest_Controller_Test.php | 32 ++++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/modules/rest/tests/Rest_Controller_Test.php b/modules/rest/tests/Rest_Controller_Test.php index a5c7dda6..21be8300 100644 --- a/modules/rest/tests/Rest_Controller_Test.php +++ b/modules/rest/tests/Rest_Controller_Test.php @@ -20,6 +20,9 @@ class Rest_Controller_Test extends Gallery_Unit_Test_Case { public function setup() { $this->_save = array($_GET, $_POST, $_SERVER); + + $key = rest::get_access_token(1); // admin user + $_SERVER["HTTP_X_GALLERY_REQUEST_KEY"] = $key->access_key; } public function teardown() { @@ -60,24 +63,26 @@ class Rest_Controller_Test extends Gallery_Unit_Test_Case { } public function get_test() { + unset($_SERVER["HTTP_X_GALLERY_REQUEST_KEY"]); + $_SERVER["REQUEST_METHOD"] = "GET"; $_GET["key"] = "value"; - $this->assert_array_equal_to_json( - array("params" => array("key" => "value"), - "method" => "get", - "access_token" => null, - "url" => "http://./index.php/gallery_unit_test"), - test::call_and_capture(array(new Rest_Controller(), "mock"))); + try { + test::call_and_capture(array(new Rest_Controller(), "mock")); + } catch (Rest_Exception $e) { + $this->assert_same(403, $e->getCode()); + return; + } + + $this->assert_true(false, "Should be forbidden"); } public function get_with_access_key_test() { - $key = rest::get_access_token(1); // admin user - $_SERVER["REQUEST_METHOD"] = "GET"; - $_SERVER["HTTP_X_GALLERY_REQUEST_KEY"] = $key->access_key; $_GET["key"] = "value"; + $key = rest::get_access_token(1); // admin user $this->assert_array_equal_to_json( array("params" => array("key" => "value"), "method" => "get", @@ -90,10 +95,11 @@ class Rest_Controller_Test extends Gallery_Unit_Test_Case { $_SERVER["REQUEST_METHOD"] = "POST"; $_POST["key"] = "value"; + $key = rest::get_access_token(1); // admin user $this->assert_array_equal_to_json( array("params" => array("key" => "value"), "method" => "post", - "access_token" => null, + "access_token" => $key->access_key, "url" => "http://./index.php/gallery_unit_test"), test::call_and_capture(array(new Rest_Controller(), "mock"))); } @@ -103,10 +109,11 @@ class Rest_Controller_Test extends Gallery_Unit_Test_Case { $_SERVER["HTTP_X_GALLERY_REQUEST_METHOD"] = "put"; $_POST["key"] = "value"; + $key = rest::get_access_token(1); // admin user $this->assert_array_equal_to_json( array("params" => array("key" => "value"), "method" => "put", - "access_token" => null, + "access_token" => $key->access_key, "url" => "http://./index.php/gallery_unit_test"), test::call_and_capture(array(new Rest_Controller(), "mock"))); } @@ -116,10 +123,11 @@ class Rest_Controller_Test extends Gallery_Unit_Test_Case { $_SERVER["HTTP_X_GALLERY_REQUEST_METHOD"] = "delete"; $_POST["key"] = "value"; + $key = rest::get_access_token(1); // admin user $this->assert_array_equal_to_json( array("params" => array("key" => "value"), "method" => "delete", - "access_token" => null, + "access_token" => $key->access_key, "url" => "http://./index.php/gallery_unit_test"), test::call_and_capture(array(new Rest_Controller(), "mock"))); } -- cgit v1.2.3 From 5467e21e8b9941a2b64aa093c0cf0f591ef5ca82 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 13 Mar 2010 08:16:37 -0800 Subject: Changes to support updating the child elements within an album. In this change the urls of the children are sent up asan array of post fields children[0].... children[n]. If an existing child is not included it is deleted. Including a url to an child in another album will move the child. Changing the order of the children will respect the order of the children, if the sort column is 'weight' --- modules/gallery/helpers/item_rest.php | 78 +++++++++++++++++++++++++++++----- modules/gallery/helpers/items_rest.php | 12 +++++- modules/rest/controllers/rest.php | 2 +- 3 files changed, 79 insertions(+), 13 deletions(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 16abec5a..5d31291e 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -88,35 +88,91 @@ class item_rest_Core { $params = $request->params; + $sort_order_changed_to_weight = false; + // Start the batch + batch::start(); + // Only change fields from a whitelist. foreach (array("album_cover", "captured", "description", "height", "mime_type", "name", "parent", "rand_key", "resize_dirty", "resize_height", "resize_width", "slug", "sort_column", "sort_order", "thumb_dirty", "thumb_height", "thumb_width", "title", "view_count", "weight", "width") as $key) { - switch ($key) { - case "album_cover": - if (property_exists($request->params, "album_cover")) { + if (property_exists($request->params, $key)) { + switch ($key) { + case "album_cover": $album_cover_item = rest::resolve($request->params->album_cover); access::required("view", $album_cover_item); $item->album_cover_item_id = $album_cover_item->id; - } - break; - - case "parent": - if (property_exists($request->params, "parent")) { + break; + + case "sort_column": + if ($request->params->sort_column == "weight" && $item->sort_column != "weight") { + $sort_order_changed_to_weight = true; + $item->sort_column = "weight"; + } + break; + case "parent": $parent = rest::resolve($request->params->parent); access::required("edit", $parent); $item->parent_id = $parent->id; - } break; - default: - if (property_exists($request->params, $key)) { + default: $item->$key = $request->params->$key; } } } $item->save(); + + // If children are supplied, then update the children based on that client tells us. + // if the sort order changed, then update the weights if there are no children to be updated + if (property_exists($request->params, "children")) { + // Map the existing children by their restful urls + $children = array(); + foreach ($item->children() as $child) { + $children[rest::url("item", $child)] = $child; + } + $update_weight = $item->sort_column == "weight"; + $weight = $item->sort_order == "ASC" ? -1 : $request->params->url->length; + $weight_increment = $item->sort_order == "ASC" ? 1 : -1; + + foreach($request->params->children as $url) { + if (isset($children[$url])) { + $child = $children[$url]; + unset($children[$url]); + } else { + $child = rest::resolve($url); + $child->parent_id = $item->id; + } + $child->save(); + if ($update_weight) { + $weight += $weight_increment; + db::build() + ->update("items") + ->set("weight", $weight) + ->where("id", "=", $child->id) + ->execute(); + } + } + // Anything left in the mapping needs to be deleted + foreach ($children as $child) { + $child->delete(); + } + } else if ($sort_order_changed_to_weight) { + $weight = $item->sort_order == "ASC" ? -1 : $request->params->url->length; + $weight_increment = $item->sort_order == "ASC" ? 1 : -1; + foreach ($item->children() as $child) { + // Do this directly in the database to avoid sending notifications + $weight += $weight_increment; + db::build() + ->update("items") + ->set("weight", $weight) + ->where("id", "=", $child->id) + ->execute(); + } + } + + batch::stop(); } static function post($request) { diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 05ca65cf..48839dc9 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -19,10 +19,12 @@ */ class items_rest_Core { static function get($request) { + $parent = rest::resolve($request->url); + access::required("view", $parent); $items = array(); if (isset($request->params->url)) { - foreach($request->params->url as $url) { + foreach ($request->params->url as $url) { $item = rest::resolve($url); if (access::can("view", $item)) { $members = array(); @@ -41,4 +43,12 @@ class items_rest_Core { return $items; } + + static function resolve($id) { + $item = ORM::factory("item", $id); + if (!access::can("view", $item)) { + throw new Kohana_404_Exception(); + } + return $item; + } } diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php index eed54bd4..7a9e3b0b 100644 --- a/modules/rest/controllers/rest.php +++ b/modules/rest/controllers/rest.php @@ -46,7 +46,7 @@ class Rest_Controller extends Controller { $request->params = (object) $input->get(); break; - case "post": + default: $request->params = (object) $input->post(); if (isset($_FILES["file"])) { $request->file = upload::save("file"); -- cgit v1.2.3 From 50a3ae7d0c6e7ce9b525f736f271c691df622176 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 13 Mar 2010 08:39:53 -0800 Subject: Synchronize line endings --- lib/swfupload/swfupload.js | 1960 +++++++++++++++++++------------------- lib/swfupload/swfupload.queue.js | 194 ++-- 2 files changed, 1077 insertions(+), 1077 deletions(-) diff --git a/lib/swfupload/swfupload.js b/lib/swfupload/swfupload.js index 969e2008..e65b19cb 100644 --- a/lib/swfupload/swfupload.js +++ b/lib/swfupload/swfupload.js @@ -1,980 +1,980 @@ -/** - * SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com - * - * mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/ - * - * SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License: - * http://www.opensource.org/licenses/mit-license.php - * - * SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License: - * http://www.opensource.org/licenses/mit-license.php - * - */ - - -/* ******************* */ -/* Constructor & Init */ -/* ******************* */ -var SWFUpload; - -if (SWFUpload == undefined) { - SWFUpload = function (settings) { - this.initSWFUpload(settings); - }; -} - -SWFUpload.prototype.initSWFUpload = function (settings) { - try { - this.customSettings = {}; // A container where developers can place their own settings associated with this instance. - this.settings = settings; - this.eventQueue = []; - this.movieName = "SWFUpload_" + SWFUpload.movieCount++; - this.movieElement = null; - - - // Setup global control tracking - SWFUpload.instances[this.movieName] = this; - - // Load the settings. Load the Flash movie. - this.initSettings(); - this.loadFlash(); - this.displayDebugInfo(); - } catch (ex) { - delete SWFUpload.instances[this.movieName]; - throw ex; - } -}; - -/* *************** */ -/* Static Members */ -/* *************** */ -SWFUpload.instances = {}; -SWFUpload.movieCount = 0; -SWFUpload.version = "2.2.0 2009-03-25"; -SWFUpload.QUEUE_ERROR = { - QUEUE_LIMIT_EXCEEDED : -100, - FILE_EXCEEDS_SIZE_LIMIT : -110, - ZERO_BYTE_FILE : -120, - INVALID_FILETYPE : -130 -}; -SWFUpload.UPLOAD_ERROR = { - HTTP_ERROR : -200, - MISSING_UPLOAD_URL : -210, - IO_ERROR : -220, - SECURITY_ERROR : -230, - UPLOAD_LIMIT_EXCEEDED : -240, - UPLOAD_FAILED : -250, - SPECIFIED_FILE_ID_NOT_FOUND : -260, - FILE_VALIDATION_FAILED : -270, - FILE_CANCELLED : -280, - UPLOAD_STOPPED : -290 -}; -SWFUpload.FILE_STATUS = { - QUEUED : -1, - IN_PROGRESS : -2, - ERROR : -3, - COMPLETE : -4, - CANCELLED : -5 -}; -SWFUpload.BUTTON_ACTION = { - SELECT_FILE : -100, - SELECT_FILES : -110, - START_UPLOAD : -120 -}; -SWFUpload.CURSOR = { - ARROW : -1, - HAND : -2 -}; -SWFUpload.WINDOW_MODE = { - WINDOW : "window", - TRANSPARENT : "transparent", - OPAQUE : "opaque" -}; - -// Private: takes a URL, determines if it is relative and converts to an absolute URL -// using the current site. Only processes the URL if it can, otherwise returns the URL untouched -SWFUpload.completeURL = function(url) { - if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) { - return url; - } - - var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : ""); - - var indexSlash = window.location.pathname.lastIndexOf("/"); - if (indexSlash <= 0) { - path = "/"; - } else { - path = window.location.pathname.substr(0, indexSlash) + "/"; - } - - return /*currentURL +*/ path + url; - -}; - - -/* ******************** */ -/* Instance Members */ -/* ******************** */ - -// Private: initSettings ensures that all the -// settings are set, getting a default value if one was not assigned. -SWFUpload.prototype.initSettings = function () { - this.ensureDefault = function (settingName, defaultValue) { - this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName]; - }; - - // Upload backend settings - this.ensureDefault("upload_url", ""); - this.ensureDefault("preserve_relative_urls", false); - this.ensureDefault("file_post_name", "Filedata"); - this.ensureDefault("post_params", {}); - this.ensureDefault("use_query_string", false); - this.ensureDefault("requeue_on_error", false); - this.ensureDefault("http_success", []); - this.ensureDefault("assume_success_timeout", 0); - - // File Settings - this.ensureDefault("file_types", "*.*"); - this.ensureDefault("file_types_description", "All Files"); - this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited" - this.ensureDefault("file_upload_limit", 0); - this.ensureDefault("file_queue_limit", 0); - - // Flash Settings - this.ensureDefault("flash_url", "swfupload.swf"); - this.ensureDefault("prevent_swf_caching", true); - - // Button Settings - this.ensureDefault("button_image_url", ""); - this.ensureDefault("button_width", 1); - this.ensureDefault("button_height", 1); - this.ensureDefault("button_text", ""); - this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;"); - this.ensureDefault("button_text_top_padding", 0); - this.ensureDefault("button_text_left_padding", 0); - this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES); - this.ensureDefault("button_disabled", false); - this.ensureDefault("button_placeholder_id", ""); - this.ensureDefault("button_placeholder", null); - this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW); - this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW); - - // Debug Settings - this.ensureDefault("debug", false); - this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API - - // Event Handlers - this.settings.return_upload_start_handler = this.returnUploadStart; - this.ensureDefault("swfupload_loaded_handler", null); - this.ensureDefault("file_dialog_start_handler", null); - this.ensureDefault("file_queued_handler", null); - this.ensureDefault("file_queue_error_handler", null); - this.ensureDefault("file_dialog_complete_handler", null); - - this.ensureDefault("upload_start_handler", null); - this.ensureDefault("upload_progress_handler", null); - this.ensureDefault("upload_error_handler", null); - this.ensureDefault("upload_success_handler", null); - this.ensureDefault("upload_complete_handler", null); - - this.ensureDefault("debug_handler", this.debugMessage); - - this.ensureDefault("custom_settings", {}); - - // Other settings - this.customSettings = this.settings.custom_settings; - - // Update the flash url if needed - if (!!this.settings.prevent_swf_caching) { - this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime(); - } - - if (!this.settings.preserve_relative_urls) { - //this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url); // Don't need to do this one since flash doesn't look at it - this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url); - this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url); - } - - delete this.ensureDefault; -}; - -// Private: loadFlash replaces the button_placeholder element with the flash movie. -SWFUpload.prototype.loadFlash = function () { - var targetElement, tempParent; - - // Make sure an element with the ID we are going to use doesn't already exist - if (document.getElementById(this.movieName) !== null) { - throw "ID " + this.movieName + " is already in use. The Flash Object could not be added"; - } - - // Get the element where we will be placing the flash movie - targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder; - - if (targetElement == undefined) { - throw "Could not find the placeholder element: " + this.settings.button_placeholder_id; - } - - // Append the container and load the flash - tempParent = document.createElement("div"); - tempParent.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers) - targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement); - - // Fix IE Flash/Form bug - if (window[this.movieName] == undefined) { - window[this.movieName] = this.getMovieElement(); - } - -}; - -// Private: getFlashHTML generates the object tag needed to embed the flash in to the document -SWFUpload.prototype.getFlashHTML = function () { - // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay - return ['', - '', - '', - '', - '', - '', - '', - ''].join(""); -}; - -// Private: getFlashVars builds the parameter string that will be passed -// to flash in the flashvars param. -SWFUpload.prototype.getFlashVars = function () { - // Build a string from the post param object - var paramString = this.buildParamString(); - var httpSuccessString = this.settings.http_success.join(","); - - // Build the parameter string - return ["movieName=", encodeURIComponent(this.movieName), - "&uploadURL=", encodeURIComponent(this.settings.upload_url), - "&useQueryString=", encodeURIComponent(this.settings.use_query_string), - "&requeueOnError=", encodeURIComponent(this.settings.requeue_on_error), - "&httpSuccess=", encodeURIComponent(httpSuccessString), - "&assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout), - "&params=", encodeURIComponent(paramString), - "&filePostName=", encodeURIComponent(this.settings.file_post_name), - "&fileTypes=", encodeURIComponent(this.settings.file_types), - "&fileTypesDescription=", encodeURIComponent(this.settings.file_types_description), - "&fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit), - "&fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit), - "&fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit), - "&debugEnabled=", encodeURIComponent(this.settings.debug_enabled), - "&buttonImageURL=", encodeURIComponent(this.settings.button_image_url), - "&buttonWidth=", encodeURIComponent(this.settings.button_width), - "&buttonHeight=", encodeURIComponent(this.settings.button_height), - "&buttonText=", encodeURIComponent(this.settings.button_text), - "&buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding), - "&buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding), - "&buttonTextStyle=", encodeURIComponent(this.settings.button_text_style), - "&buttonAction=", encodeURIComponent(this.settings.button_action), - "&buttonDisabled=", encodeURIComponent(this.settings.button_disabled), - "&buttonCursor=", encodeURIComponent(this.settings.button_cursor) - ].join(""); -}; - -// Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload -// The element is cached after the first lookup -SWFUpload.prototype.getMovieElement = function () { - if (this.movieElement == undefined) { - this.movieElement = document.getElementById(this.movieName); - } - - if (this.movieElement === null) { - throw "Could not find Flash element"; - } - - return this.movieElement; -}; - -// Private: buildParamString takes the name/value pairs in the post_params setting object -// and joins them up in to a string formatted "name=value&name=value" -SWFUpload.prototype.buildParamString = function () { - var postParams = this.settings.post_params; - var paramStringPairs = []; - - if (typeof(postParams) === "object") { - for (var name in postParams) { - if (postParams.hasOwnProperty(name)) { - paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString())); - } - } - } - - return paramStringPairs.join("&"); -}; - -// Public: Used to remove a SWFUpload instance from the page. This method strives to remove -// all references to the SWF, and other objects so memory is properly freed. -// Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state. -// Credits: Major improvements provided by steffen -SWFUpload.prototype.destroy = function () { - try { - // Make sure Flash is done before we try to remove it - this.cancelUpload(null, false); - - - // Remove the SWFUpload DOM nodes - var movieElement = null; - movieElement = this.getMovieElement(); - - if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE - // Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround) - for (var i in movieElement) { - try { - if (typeof(movieElement[i]) === "function") { - movieElement[i] = null; - } - } catch (ex1) {} - } - - // Remove the Movie Element from the page - try { - movieElement.parentNode.removeChild(movieElement); - } catch (ex) {} - } - - // Remove IE form fix reference - window[this.movieName] = null; - - // Destroy other references - SWFUpload.instances[this.movieName] = null; - delete SWFUpload.instances[this.movieName]; - - this.movieElement = null; - this.settings = null; - this.customSettings = null; - this.eventQueue = null; - this.movieName = null; - - - return true; - } catch (ex2) { - return false; - } -}; - - -// Public: displayDebugInfo prints out settings and configuration -// information about this SWFUpload instance. -// This function (and any references to it) can be deleted when placing -// SWFUpload in production. -SWFUpload.prototype.displayDebugInfo = function () { - this.debug( - [ - "---SWFUpload Instance Info---\n", - "Version: ", SWFUpload.version, "\n", - "Movie Name: ", this.movieName, "\n", - "Settings:\n", - "\t", "upload_url: ", this.settings.upload_url, "\n", - "\t", "flash_url: ", this.settings.flash_url, "\n", - "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n", - "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n", - "\t", "http_success: ", this.settings.http_success.join(", "), "\n", - "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n", - "\t", "file_post_name: ", this.settings.file_post_name, "\n", - "\t", "post_params: ", this.settings.post_params.toString(), "\n", - "\t", "file_types: ", this.settings.file_types, "\n", - "\t", "file_types_description: ", this.settings.file_types_description, "\n", - "\t", "file_size_limit: ", this.settings.file_size_limit, "\n", - "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n", - "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n", - "\t", "debug: ", this.settings.debug.toString(), "\n", - - "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n", - - "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n", - "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n", - "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n", - "\t", "button_width: ", this.settings.button_width.toString(), "\n", - "\t", "button_height: ", this.settings.button_height.toString(), "\n", - "\t", "button_text: ", this.settings.button_text.toString(), "\n", - "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n", - "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n", - "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n", - "\t", "button_action: ", this.settings.button_action.toString(), "\n", - "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n", - - "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n", - "Event Handlers:\n", - "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n", - "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n", - "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n", - "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n", - "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n", - "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n", - "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n", - "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n", - "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n", - "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n" - ].join("") - ); -}; - -/* Note: addSetting and getSetting are no longer used by SWFUpload but are included - the maintain v2 API compatibility -*/ -// Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used. -SWFUpload.prototype.addSetting = function (name, value, default_value) { - if (value == undefined) { - return (this.settings[name] = default_value); - } else { - return (this.settings[name] = value); - } -}; - -// Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found. -SWFUpload.prototype.getSetting = function (name) { - if (this.settings[name] != undefined) { - return this.settings[name]; - } - - return ""; -}; - - - -// Private: callFlash handles function calls made to the Flash element. -// Calls are made with a setTimeout for some functions to work around -// bugs in the ExternalInterface library. -SWFUpload.prototype.callFlash = function (functionName, argumentArray) { - argumentArray = argumentArray || []; - - var movieElement = this.getMovieElement(); - var returnValue, returnString; - - // Flash's method if calling ExternalInterface methods (code adapted from MooTools). - try { - returnString = movieElement.CallFunction('' + __flash__argumentsToXML(argumentArray, 0) + ''); - returnValue = eval(returnString); - } catch (ex) { - throw "Call to " + functionName + " failed"; - } - - // Unescape file post param values - if (returnValue != undefined && typeof returnValue.post === "object") { - returnValue = this.unescapeFilePostParams(returnValue); - } - - return returnValue; -}; - -/* ***************************** - -- Flash control methods -- - Your UI should use these - to operate SWFUpload - ***************************** */ - -// WARNING: this function does not work in Flash Player 10 -// Public: selectFile causes a File Selection Dialog window to appear. This -// dialog only allows 1 file to be selected. -SWFUpload.prototype.selectFile = function () { - this.callFlash("SelectFile"); -}; - -// WARNING: this function does not work in Flash Player 10 -// Public: selectFiles causes a File Selection Dialog window to appear/ This -// dialog allows the user to select any number of files -// Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names. -// If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around -// for this bug. -SWFUpload.prototype.selectFiles = function () { - this.callFlash("SelectFiles"); -}; - - -// Public: startUpload starts uploading the first file in the queue unless -// the optional parameter 'fileID' specifies the ID -SWFUpload.prototype.startUpload = function (fileID) { - this.callFlash("StartUpload", [fileID]); -}; - -// Public: cancelUpload cancels any queued file. The fileID parameter may be the file ID or index. -// If you do not specify a fileID the current uploading file or first file in the queue is cancelled. -// If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter. -SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) { - if (triggerErrorEvent !== false) { - triggerErrorEvent = true; - } - this.callFlash("CancelUpload", [fileID, triggerErrorEvent]); -}; - -// Public: stopUpload stops the current upload and requeues the file at the beginning of the queue. -// If nothing is currently uploading then nothing happens. -SWFUpload.prototype.stopUpload = function () { - this.callFlash("StopUpload"); -}; - -/* ************************ - * Settings methods - * These methods change the SWFUpload settings. - * SWFUpload settings should not be changed directly on the settings object - * since many of the settings need to be passed to Flash in order to take - * effect. - * *********************** */ - -// Public: getStats gets the file statistics object. -SWFUpload.prototype.getStats = function () { - return this.callFlash("GetStats"); -}; - -// Public: setStats changes the SWFUpload statistics. You shouldn't need to -// change the statistics but you can. Changing the statistics does not -// affect SWFUpload accept for the successful_uploads count which is used -// by the upload_limit setting to determine how many files the user may upload. -SWFUpload.prototype.setStats = function (statsObject) { - this.callFlash("SetStats", [statsObject]); -}; - -// Public: getFile retrieves a File object by ID or Index. If the file is -// not found then 'null' is returned. -SWFUpload.prototype.getFile = function (fileID) { - if (typeof(fileID) === "number") { - return this.callFlash("GetFileByIndex", [fileID]); - } else { - return this.callFlash("GetFile", [fileID]); - } -}; - -// Public: addFileParam sets a name/value pair that will be posted with the -// file specified by the Files ID. If the name already exists then the -// exiting value will be overwritten. -SWFUpload.prototype.addFileParam = function (fileID, name, value) { - return this.callFlash("AddFileParam", [fileID, name, value]); -}; - -// Public: removeFileParam removes a previously set (by addFileParam) name/value -// pair from the specified file. -SWFUpload.prototype.removeFileParam = function (fileID, name) { - this.callFlash("RemoveFileParam", [fileID, name]); -}; - -// Public: setUploadUrl changes the upload_url setting. -SWFUpload.prototype.setUploadURL = function (url) { - this.settings.upload_url = url.toString(); - this.callFlash("SetUploadURL", [url]); -}; - -// Public: setPostParams changes the post_params setting -SWFUpload.prototype.setPostParams = function (paramsObject) { - this.settings.post_params = paramsObject; - this.callFlash("SetPostParams", [paramsObject]); -}; - -// Public: addPostParam adds post name/value pair. Each name can have only one value. -SWFUpload.prototype.addPostParam = function (name, value) { - this.settings.post_params[name] = value; - this.callFlash("SetPostParams", [this.settings.post_params]); -}; - -// Public: removePostParam deletes post name/value pair. -SWFUpload.prototype.removePostParam = function (name) { - delete this.settings.post_params[name]; - this.callFlash("SetPostParams", [this.settings.post_params]); -}; - -// Public: setFileTypes changes the file_types setting and the file_types_description setting -SWFUpload.prototype.setFileTypes = function (types, description) { - this.settings.file_types = types; - this.settings.file_types_description = description; - this.callFlash("SetFileTypes", [types, description]); -}; - -// Public: setFileSizeLimit changes the file_size_limit setting -SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) { - this.settings.file_size_limit = fileSizeLimit; - this.callFlash("SetFileSizeLimit", [fileSizeLimit]); -}; - -// Public: setFileUploadLimit changes the file_upload_limit setting -SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) { - this.settings.file_upload_limit = fileUploadLimit; - this.callFlash("SetFileUploadLimit", [fileUploadLimit]); -}; - -// Public: setFileQueueLimit changes the file_queue_limit setting -SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) { - this.settings.file_queue_limit = fileQueueLimit; - this.callFlash("SetFileQueueLimit", [fileQueueLimit]); -}; - -// Public: setFilePostName changes the file_post_name setting -SWFUpload.prototype.setFilePostName = function (filePostName) { - this.settings.file_post_name = filePostName; - this.callFlash("SetFilePostName", [filePostName]); -}; - -// Public: setUseQueryString changes the use_query_string setting -SWFUpload.prototype.setUseQueryString = function (useQueryString) { - this.settings.use_query_string = useQueryString; - this.callFlash("SetUseQueryString", [useQueryString]); -}; - -// Public: setRequeueOnError changes the requeue_on_error setting -SWFUpload.prototype.setRequeueOnError = function (requeueOnError) { - this.settings.requeue_on_error = requeueOnError; - this.callFlash("SetRequeueOnError", [requeueOnError]); -}; - -// Public: setHTTPSuccess changes the http_success setting -SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) { - if (typeof http_status_codes === "string") { - http_status_codes = http_status_codes.replace(" ", "").split(","); - } - - this.settings.http_success = http_status_codes; - this.callFlash("SetHTTPSuccess", [http_status_codes]); -}; - -// Public: setHTTPSuccess changes the http_success setting -SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) { - this.settings.assume_success_timeout = timeout_seconds; - this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]); -}; - -// Public: setDebugEnabled changes the debug_enabled setting -SWFUpload.prototype.setDebugEnabled = function (debugEnabled) { - this.settings.debug_enabled = debugEnabled; - this.callFlash("SetDebugEnabled", [debugEnabled]); -}; - -// Public: setButtonImageURL loads a button image sprite -SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) { - if (buttonImageURL == undefined) { - buttonImageURL = ""; - } - - this.settings.button_image_url = buttonImageURL; - this.callFlash("SetButtonImageURL", [buttonImageURL]); -}; - -// Public: setButtonDimensions resizes the Flash Movie and button -SWFUpload.prototype.setButtonDimensions = function (width, height) { - this.settings.button_width = width; - this.settings.button_height = height; - - var movie = this.getMovieElement(); - if (movie != undefined) { - movie.style.width = width + "px"; - movie.style.height = height + "px"; - } - - this.callFlash("SetButtonDimensions", [width, height]); -}; -// Public: setButtonText Changes the text overlaid on the button -SWFUpload.prototype.setButtonText = function (html) { - this.settings.button_text = html; - this.callFlash("SetButtonText", [html]); -}; -// Public: setButtonTextPadding changes the top and left padding of the text overlay -SWFUpload.prototype.setButtonTextPadding = function (left, top) { - this.settings.button_text_top_padding = top; - this.settings.button_text_left_padding = left; - this.callFlash("SetButtonTextPadding", [left, top]); -}; - -// Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button -SWFUpload.prototype.setButtonTextStyle = function (css) { - this.settings.button_text_style = css; - this.callFlash("SetButtonTextStyle", [css]); -}; -// Public: setButtonDisabled disables/enables the button -SWFUpload.prototype.setButtonDisabled = function (isDisabled) { - this.settings.button_disabled = isDisabled; - this.callFlash("SetButtonDisabled", [isDisabled]); -}; -// Public: setButtonAction sets the action that occurs when the button is clicked -SWFUpload.prototype.setButtonAction = function (buttonAction) { - this.settings.button_action = buttonAction; - this.callFlash("SetButtonAction", [buttonAction]); -}; - -// Public: setButtonCursor changes the mouse cursor displayed when hovering over the button -SWFUpload.prototype.setButtonCursor = function (cursor) { - this.settings.button_cursor = cursor; - this.callFlash("SetButtonCursor", [cursor]); -}; - -/* ******************************* - Flash Event Interfaces - These functions are used by Flash to trigger the various - events. - - All these functions a Private. - - Because the ExternalInterface library is buggy the event calls - are added to a queue and the queue then executed by a setTimeout. - This ensures that events are executed in a determinate order and that - the ExternalInterface bugs are avoided. -******************************* */ - -SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) { - // Warning: Don't call this.debug inside here or you'll create an infinite loop - - if (argumentArray == undefined) { - argumentArray = []; - } else if (!(argumentArray instanceof Array)) { - argumentArray = [argumentArray]; - } - - var self = this; - if (typeof this.settings[handlerName] === "function") { - // Queue the event - this.eventQueue.push(function () { - this.settings[handlerName].apply(this, argumentArray); - }); - - // Execute the next queued event - setTimeout(function () { - self.executeNextEvent(); - }, 0); - - } else if (this.settings[handlerName] !== null) { - throw "Event handler " + handlerName + " is unknown or is not a function"; - } -}; - -// Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout -// we must queue them in order to garentee that they are executed in order. -SWFUpload.prototype.executeNextEvent = function () { - // Warning: Don't call this.debug inside here or you'll create an infinite loop - - var f = this.eventQueue ? this.eventQueue.shift() : null; - if (typeof(f) === "function") { - f.apply(this); - } -}; - -// Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have -// properties that contain characters that are not valid for JavaScript identifiers. To work around this -// the Flash Component escapes the parameter names and we must unescape again before passing them along. -SWFUpload.prototype.unescapeFilePostParams = function (file) { - var reg = /[$]([0-9a-f]{4})/i; - var unescapedPost = {}; - var uk; - - if (file != undefined) { - for (var k in file.post) { - if (file.post.hasOwnProperty(k)) { - uk = k; - var match; - while ((match = reg.exec(uk)) !== null) { - uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16))); - } - unescapedPost[uk] = file.post[k]; - } - } - - file.post = unescapedPost; - } - - return file; -}; - -// Private: Called by Flash to see if JS can call in to Flash (test if External Interface is working) -SWFUpload.prototype.testExternalInterface = function () { - try { - return this.callFlash("TestExternalInterface"); - } catch (ex) { - return false; - } -}; - -// Private: This event is called by Flash when it has finished loading. Don't modify this. -// Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded. -SWFUpload.prototype.flashReady = function () { - // Check that the movie element is loaded correctly with its ExternalInterface methods defined - var movieElement = this.getMovieElement(); - - if (!movieElement) { - this.debug("Flash called back ready but the flash movie can't be found."); - return; - } - - this.cleanUp(movieElement); - - this.queueEvent("swfupload_loaded_handler"); -}; - -// Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE. -// This function is called by Flash each time the ExternalInterface functions are created. -SWFUpload.prototype.cleanUp = function (movieElement) { - // Pro-actively unhook all the Flash functions - try { - if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE - this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)"); - for (var key in movieElement) { - try { - if (typeof(movieElement[key]) === "function") { - movieElement[key] = null; - } - } catch (ex) { - } - } - } - } catch (ex1) { - - } - - // Fix Flashes own cleanup code so if the SWFMovie was removed from the page - // it doesn't display errors. - window["__flash__removeCallback"] = function (instance, name) { - try { - if (instance) { - instance[name] = null; - } - } catch (flashEx) { - - } - }; - -}; - - -/* This is a chance to do something before the browse window opens */ -SWFUpload.prototype.fileDialogStart = function () { - this.queueEvent("file_dialog_start_handler"); -}; - - -/* Called when a file is successfully added to the queue. */ -SWFUpload.prototype.fileQueued = function (file) { - file = this.unescapeFilePostParams(file); - this.queueEvent("file_queued_handler", file); -}; - - -/* Handle errors that occur when an attempt to queue a file fails. */ -SWFUpload.prototype.fileQueueError = function (file, errorCode, message) { - file = this.unescapeFilePostParams(file); - this.queueEvent("file_queue_error_handler", [file, errorCode, message]); -}; - -/* Called after the file dialog has closed and the selected files have been queued. - You could call startUpload here if you want the queued files to begin uploading immediately. */ -SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) { - this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]); -}; - -SWFUpload.prototype.uploadStart = function (file) { - file = this.unescapeFilePostParams(file); - this.queueEvent("return_upload_start_handler", file); -}; - -SWFUpload.prototype.returnUploadStart = function (file) { - var returnValue; - if (typeof this.settings.upload_start_handler === "function") { - file = this.unescapeFilePostParams(file); - returnValue = this.settings.upload_start_handler.call(this, file); - } else if (this.settings.upload_start_handler != undefined) { - throw "upload_start_handler must be a function"; - } - - // Convert undefined to true so if nothing is returned from the upload_start_handler it is - // interpretted as 'true'. - if (returnValue === undefined) { - returnValue = true; - } - - returnValue = !!returnValue; - - this.callFlash("ReturnUploadStart", [returnValue]); -}; - - - -SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) { - file = this.unescapeFilePostParams(file); - this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]); -}; - -SWFUpload.prototype.uploadError = function (file, errorCode, message) { - file = this.unescapeFilePostParams(file); - this.queueEvent("upload_error_handler", [file, errorCode, message]); -}; - -SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) { - file = this.unescapeFilePostParams(file); - this.queueEvent("upload_success_handler", [file, serverData, responseReceived]); -}; - -SWFUpload.prototype.uploadComplete = function (file) { - file = this.unescapeFilePostParams(file); - this.queueEvent("upload_complete_handler", file); -}; - -/* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the - internal debug console. You can override this event and have messages written where you want. */ -SWFUpload.prototype.debug = function (message) { - this.queueEvent("debug_handler", message); -}; - - -/* ********************************** - Debug Console - The debug console is a self contained, in page location - for debug message to be sent. The Debug Console adds - itself to the body if necessary. - - The console is automatically scrolled as messages appear. - - If you are using your own debug handler or when you deploy to production and - have debug disabled you can remove these functions to reduce the file size - and complexity. -********************************** */ - -// Private: debugMessage is the default debug_handler. If you want to print debug messages -// call the debug() function. When overriding the function your own function should -// check to see if the debug setting is true before outputting debug information. -SWFUpload.prototype.debugMessage = function (message) { - if (this.settings.debug) { - var exceptionMessage, exceptionValues = []; - - // Check for an exception object and print it nicely - if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") { - for (var key in message) { - if (message.hasOwnProperty(key)) { - exceptionValues.push(key + ": " + message[key]); - } - } - exceptionMessage = exceptionValues.join("\n") || ""; - exceptionValues = exceptionMessage.split("\n"); - exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: "); - SWFUpload.Console.writeLine(exceptionMessage); - } else { - SWFUpload.Console.writeLine(message); - } - } -}; - -SWFUpload.Console = {}; -SWFUpload.Console.writeLine = function (message) { - var console, documentForm; - - try { - console = document.getElementById("SWFUpload_Console"); - - if (!console) { - documentForm = document.createElement("form"); - document.getElementsByTagName("body")[0].appendChild(documentForm); - - console = document.createElement("textarea"); - console.id = "SWFUpload_Console"; - console.style.fontFamily = "monospace"; - console.setAttribute("wrap", "off"); - console.wrap = "off"; - console.style.overflow = "auto"; - console.style.width = "700px"; - console.style.height = "350px"; - console.style.margin = "5px"; - documentForm.appendChild(console); - } - - console.value += message + "\n"; - - console.scrollTop = console.scrollHeight - console.clientHeight; - } catch (ex) { - alert("Exception: " + ex.name + " Message: " + ex.message); - } -}; +/** + * SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com + * + * mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/ + * + * SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + * + * SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + * + */ + + +/* ******************* */ +/* Constructor & Init */ +/* ******************* */ +var SWFUpload; + +if (SWFUpload == undefined) { + SWFUpload = function (settings) { + this.initSWFUpload(settings); + }; +} + +SWFUpload.prototype.initSWFUpload = function (settings) { + try { + this.customSettings = {}; // A container where developers can place their own settings associated with this instance. + this.settings = settings; + this.eventQueue = []; + this.movieName = "SWFUpload_" + SWFUpload.movieCount++; + this.movieElement = null; + + + // Setup global control tracking + SWFUpload.instances[this.movieName] = this; + + // Load the settings. Load the Flash movie. + this.initSettings(); + this.loadFlash(); + this.displayDebugInfo(); + } catch (ex) { + delete SWFUpload.instances[this.movieName]; + throw ex; + } +}; + +/* *************** */ +/* Static Members */ +/* *************** */ +SWFUpload.instances = {}; +SWFUpload.movieCount = 0; +SWFUpload.version = "2.2.0 2009-03-25"; +SWFUpload.QUEUE_ERROR = { + QUEUE_LIMIT_EXCEEDED : -100, + FILE_EXCEEDS_SIZE_LIMIT : -110, + ZERO_BYTE_FILE : -120, + INVALID_FILETYPE : -130 +}; +SWFUpload.UPLOAD_ERROR = { + HTTP_ERROR : -200, + MISSING_UPLOAD_URL : -210, + IO_ERROR : -220, + SECURITY_ERROR : -230, + UPLOAD_LIMIT_EXCEEDED : -240, + UPLOAD_FAILED : -250, + SPECIFIED_FILE_ID_NOT_FOUND : -260, + FILE_VALIDATION_FAILED : -270, + FILE_CANCELLED : -280, + UPLOAD_STOPPED : -290 +}; +SWFUpload.FILE_STATUS = { + QUEUED : -1, + IN_PROGRESS : -2, + ERROR : -3, + COMPLETE : -4, + CANCELLED : -5 +}; +SWFUpload.BUTTON_ACTION = { + SELECT_FILE : -100, + SELECT_FILES : -110, + START_UPLOAD : -120 +}; +SWFUpload.CURSOR = { + ARROW : -1, + HAND : -2 +}; +SWFUpload.WINDOW_MODE = { + WINDOW : "window", + TRANSPARENT : "transparent", + OPAQUE : "opaque" +}; + +// Private: takes a URL, determines if it is relative and converts to an absolute URL +// using the current site. Only processes the URL if it can, otherwise returns the URL untouched +SWFUpload.completeURL = function(url) { + if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) { + return url; + } + + var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : ""); + + var indexSlash = window.location.pathname.lastIndexOf("/"); + if (indexSlash <= 0) { + path = "/"; + } else { + path = window.location.pathname.substr(0, indexSlash) + "/"; + } + + return /*currentURL +*/ path + url; + +}; + + +/* ******************** */ +/* Instance Members */ +/* ******************** */ + +// Private: initSettings ensures that all the +// settings are set, getting a default value if one was not assigned. +SWFUpload.prototype.initSettings = function () { + this.ensureDefault = function (settingName, defaultValue) { + this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName]; + }; + + // Upload backend settings + this.ensureDefault("upload_url", ""); + this.ensureDefault("preserve_relative_urls", false); + this.ensureDefault("file_post_name", "Filedata"); + this.ensureDefault("post_params", {}); + this.ensureDefault("use_query_string", false); + this.ensureDefault("requeue_on_error", false); + this.ensureDefault("http_success", []); + this.ensureDefault("assume_success_timeout", 0); + + // File Settings + this.ensureDefault("file_types", "*.*"); + this.ensureDefault("file_types_description", "All Files"); + this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited" + this.ensureDefault("file_upload_limit", 0); + this.ensureDefault("file_queue_limit", 0); + + // Flash Settings + this.ensureDefault("flash_url", "swfupload.swf"); + this.ensureDefault("prevent_swf_caching", true); + + // Button Settings + this.ensureDefault("button_image_url", ""); + this.ensureDefault("button_width", 1); + this.ensureDefault("button_height", 1); + this.ensureDefault("button_text", ""); + this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;"); + this.ensureDefault("button_text_top_padding", 0); + this.ensureDefault("button_text_left_padding", 0); + this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES); + this.ensureDefault("button_disabled", false); + this.ensureDefault("button_placeholder_id", ""); + this.ensureDefault("button_placeholder", null); + this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW); + this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW); + + // Debug Settings + this.ensureDefault("debug", false); + this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API + + // Event Handlers + this.settings.return_upload_start_handler = this.returnUploadStart; + this.ensureDefault("swfupload_loaded_handler", null); + this.ensureDefault("file_dialog_start_handler", null); + this.ensureDefault("file_queued_handler", null); + this.ensureDefault("file_queue_error_handler", null); + this.ensureDefault("file_dialog_complete_handler", null); + + this.ensureDefault("upload_start_handler", null); + this.ensureDefault("upload_progress_handler", null); + this.ensureDefault("upload_error_handler", null); + this.ensureDefault("upload_success_handler", null); + this.ensureDefault("upload_complete_handler", null); + + this.ensureDefault("debug_handler", this.debugMessage); + + this.ensureDefault("custom_settings", {}); + + // Other settings + this.customSettings = this.settings.custom_settings; + + // Update the flash url if needed + if (!!this.settings.prevent_swf_caching) { + this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime(); + } + + if (!this.settings.preserve_relative_urls) { + //this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url); // Don't need to do this one since flash doesn't look at it + this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url); + this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url); + } + + delete this.ensureDefault; +}; + +// Private: loadFlash replaces the button_placeholder element with the flash movie. +SWFUpload.prototype.loadFlash = function () { + var targetElement, tempParent; + + // Make sure an element with the ID we are going to use doesn't already exist + if (document.getElementById(this.movieName) !== null) { + throw "ID " + this.movieName + " is already in use. The Flash Object could not be added"; + } + + // Get the element where we will be placing the flash movie + targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder; + + if (targetElement == undefined) { + throw "Could not find the placeholder element: " + this.settings.button_placeholder_id; + } + + // Append the container and load the flash + tempParent = document.createElement("div"); + tempParent.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers) + targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement); + + // Fix IE Flash/Form bug + if (window[this.movieName] == undefined) { + window[this.movieName] = this.getMovieElement(); + } + +}; + +// Private: getFlashHTML generates the object tag needed to embed the flash in to the document +SWFUpload.prototype.getFlashHTML = function () { + // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay + return ['', + '', + '', + '', + '', + '', + '', + ''].join(""); +}; + +// Private: getFlashVars builds the parameter string that will be passed +// to flash in the flashvars param. +SWFUpload.prototype.getFlashVars = function () { + // Build a string from the post param object + var paramString = this.buildParamString(); + var httpSuccessString = this.settings.http_success.join(","); + + // Build the parameter string + return ["movieName=", encodeURIComponent(this.movieName), + "&uploadURL=", encodeURIComponent(this.settings.upload_url), + "&useQueryString=", encodeURIComponent(this.settings.use_query_string), + "&requeueOnError=", encodeURIComponent(this.settings.requeue_on_error), + "&httpSuccess=", encodeURIComponent(httpSuccessString), + "&assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout), + "&params=", encodeURIComponent(paramString), + "&filePostName=", encodeURIComponent(this.settings.file_post_name), + "&fileTypes=", encodeURIComponent(this.settings.file_types), + "&fileTypesDescription=", encodeURIComponent(this.settings.file_types_description), + "&fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit), + "&fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit), + "&fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit), + "&debugEnabled=", encodeURIComponent(this.settings.debug_enabled), + "&buttonImageURL=", encodeURIComponent(this.settings.button_image_url), + "&buttonWidth=", encodeURIComponent(this.settings.button_width), + "&buttonHeight=", encodeURIComponent(this.settings.button_height), + "&buttonText=", encodeURIComponent(this.settings.button_text), + "&buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding), + "&buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding), + "&buttonTextStyle=", encodeURIComponent(this.settings.button_text_style), + "&buttonAction=", encodeURIComponent(this.settings.button_action), + "&buttonDisabled=", encodeURIComponent(this.settings.button_disabled), + "&buttonCursor=", encodeURIComponent(this.settings.button_cursor) + ].join(""); +}; + +// Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload +// The element is cached after the first lookup +SWFUpload.prototype.getMovieElement = function () { + if (this.movieElement == undefined) { + this.movieElement = document.getElementById(this.movieName); + } + + if (this.movieElement === null) { + throw "Could not find Flash element"; + } + + return this.movieElement; +}; + +// Private: buildParamString takes the name/value pairs in the post_params setting object +// and joins them up in to a string formatted "name=value&name=value" +SWFUpload.prototype.buildParamString = function () { + var postParams = this.settings.post_params; + var paramStringPairs = []; + + if (typeof(postParams) === "object") { + for (var name in postParams) { + if (postParams.hasOwnProperty(name)) { + paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString())); + } + } + } + + return paramStringPairs.join("&"); +}; + +// Public: Used to remove a SWFUpload instance from the page. This method strives to remove +// all references to the SWF, and other objects so memory is properly freed. +// Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state. +// Credits: Major improvements provided by steffen +SWFUpload.prototype.destroy = function () { + try { + // Make sure Flash is done before we try to remove it + this.cancelUpload(null, false); + + + // Remove the SWFUpload DOM nodes + var movieElement = null; + movieElement = this.getMovieElement(); + + if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE + // Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround) + for (var i in movieElement) { + try { + if (typeof(movieElement[i]) === "function") { + movieElement[i] = null; + } + } catch (ex1) {} + } + + // Remove the Movie Element from the page + try { + movieElement.parentNode.removeChild(movieElement); + } catch (ex) {} + } + + // Remove IE form fix reference + window[this.movieName] = null; + + // Destroy other references + SWFUpload.instances[this.movieName] = null; + delete SWFUpload.instances[this.movieName]; + + this.movieElement = null; + this.settings = null; + this.customSettings = null; + this.eventQueue = null; + this.movieName = null; + + + return true; + } catch (ex2) { + return false; + } +}; + + +// Public: displayDebugInfo prints out settings and configuration +// information about this SWFUpload instance. +// This function (and any references to it) can be deleted when placing +// SWFUpload in production. +SWFUpload.prototype.displayDebugInfo = function () { + this.debug( + [ + "---SWFUpload Instance Info---\n", + "Version: ", SWFUpload.version, "\n", + "Movie Name: ", this.movieName, "\n", + "Settings:\n", + "\t", "upload_url: ", this.settings.upload_url, "\n", + "\t", "flash_url: ", this.settings.flash_url, "\n", + "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n", + "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n", + "\t", "http_success: ", this.settings.http_success.join(", "), "\n", + "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n", + "\t", "file_post_name: ", this.settings.file_post_name, "\n", + "\t", "post_params: ", this.settings.post_params.toString(), "\n", + "\t", "file_types: ", this.settings.file_types, "\n", + "\t", "file_types_description: ", this.settings.file_types_description, "\n", + "\t", "file_size_limit: ", this.settings.file_size_limit, "\n", + "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n", + "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n", + "\t", "debug: ", this.settings.debug.toString(), "\n", + + "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n", + + "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n", + "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n", + "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n", + "\t", "button_width: ", this.settings.button_width.toString(), "\n", + "\t", "button_height: ", this.settings.button_height.toString(), "\n", + "\t", "button_text: ", this.settings.button_text.toString(), "\n", + "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n", + "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n", + "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n", + "\t", "button_action: ", this.settings.button_action.toString(), "\n", + "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n", + + "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n", + "Event Handlers:\n", + "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n", + "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n", + "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n", + "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n", + "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n", + "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n", + "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n", + "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n", + "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n", + "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n" + ].join("") + ); +}; + +/* Note: addSetting and getSetting are no longer used by SWFUpload but are included + the maintain v2 API compatibility +*/ +// Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used. +SWFUpload.prototype.addSetting = function (name, value, default_value) { + if (value == undefined) { + return (this.settings[name] = default_value); + } else { + return (this.settings[name] = value); + } +}; + +// Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found. +SWFUpload.prototype.getSetting = function (name) { + if (this.settings[name] != undefined) { + return this.settings[name]; + } + + return ""; +}; + + + +// Private: callFlash handles function calls made to the Flash element. +// Calls are made with a setTimeout for some functions to work around +// bugs in the ExternalInterface library. +SWFUpload.prototype.callFlash = function (functionName, argumentArray) { + argumentArray = argumentArray || []; + + var movieElement = this.getMovieElement(); + var returnValue, returnString; + + // Flash's method if calling ExternalInterface methods (code adapted from MooTools). + try { + returnString = movieElement.CallFunction('' + __flash__argumentsToXML(argumentArray, 0) + ''); + returnValue = eval(returnString); + } catch (ex) { + throw "Call to " + functionName + " failed"; + } + + // Unescape file post param values + if (returnValue != undefined && typeof returnValue.post === "object") { + returnValue = this.unescapeFilePostParams(returnValue); + } + + return returnValue; +}; + +/* ***************************** + -- Flash control methods -- + Your UI should use these + to operate SWFUpload + ***************************** */ + +// WARNING: this function does not work in Flash Player 10 +// Public: selectFile causes a File Selection Dialog window to appear. This +// dialog only allows 1 file to be selected. +SWFUpload.prototype.selectFile = function () { + this.callFlash("SelectFile"); +}; + +// WARNING: this function does not work in Flash Player 10 +// Public: selectFiles causes a File Selection Dialog window to appear/ This +// dialog allows the user to select any number of files +// Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names. +// If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around +// for this bug. +SWFUpload.prototype.selectFiles = function () { + this.callFlash("SelectFiles"); +}; + + +// Public: startUpload starts uploading the first file in the queue unless +// the optional parameter 'fileID' specifies the ID +SWFUpload.prototype.startUpload = function (fileID) { + this.callFlash("StartUpload", [fileID]); +}; + +// Public: cancelUpload cancels any queued file. The fileID parameter may be the file ID or index. +// If you do not specify a fileID the current uploading file or first file in the queue is cancelled. +// If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter. +SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) { + if (triggerErrorEvent !== false) { + triggerErrorEvent = true; + } + this.callFlash("CancelUpload", [fileID, triggerErrorEvent]); +}; + +// Public: stopUpload stops the current upload and requeues the file at the beginning of the queue. +// If nothing is currently uploading then nothing happens. +SWFUpload.prototype.stopUpload = function () { + this.callFlash("StopUpload"); +}; + +/* ************************ + * Settings methods + * These methods change the SWFUpload settings. + * SWFUpload settings should not be changed directly on the settings object + * since many of the settings need to be passed to Flash in order to take + * effect. + * *********************** */ + +// Public: getStats gets the file statistics object. +SWFUpload.prototype.getStats = function () { + return this.callFlash("GetStats"); +}; + +// Public: setStats changes the SWFUpload statistics. You shouldn't need to +// change the statistics but you can. Changing the statistics does not +// affect SWFUpload accept for the successful_uploads count which is used +// by the upload_limit setting to determine how many files the user may upload. +SWFUpload.prototype.setStats = function (statsObject) { + this.callFlash("SetStats", [statsObject]); +}; + +// Public: getFile retrieves a File object by ID or Index. If the file is +// not found then 'null' is returned. +SWFUpload.prototype.getFile = function (fileID) { + if (typeof(fileID) === "number") { + return this.callFlash("GetFileByIndex", [fileID]); + } else { + return this.callFlash("GetFile", [fileID]); + } +}; + +// Public: addFileParam sets a name/value pair that will be posted with the +// file specified by the Files ID. If the name already exists then the +// exiting value will be overwritten. +SWFUpload.prototype.addFileParam = function (fileID, name, value) { + return this.callFlash("AddFileParam", [fileID, name, value]); +}; + +// Public: removeFileParam removes a previously set (by addFileParam) name/value +// pair from the specified file. +SWFUpload.prototype.removeFileParam = function (fileID, name) { + this.callFlash("RemoveFileParam", [fileID, name]); +}; + +// Public: setUploadUrl changes the upload_url setting. +SWFUpload.prototype.setUploadURL = function (url) { + this.settings.upload_url = url.toString(); + this.callFlash("SetUploadURL", [url]); +}; + +// Public: setPostParams changes the post_params setting +SWFUpload.prototype.setPostParams = function (paramsObject) { + this.settings.post_params = paramsObject; + this.callFlash("SetPostParams", [paramsObject]); +}; + +// Public: addPostParam adds post name/value pair. Each name can have only one value. +SWFUpload.prototype.addPostParam = function (name, value) { + this.settings.post_params[name] = value; + this.callFlash("SetPostParams", [this.settings.post_params]); +}; + +// Public: removePostParam deletes post name/value pair. +SWFUpload.prototype.removePostParam = function (name) { + delete this.settings.post_params[name]; + this.callFlash("SetPostParams", [this.settings.post_params]); +}; + +// Public: setFileTypes changes the file_types setting and the file_types_description setting +SWFUpload.prototype.setFileTypes = function (types, description) { + this.settings.file_types = types; + this.settings.file_types_description = description; + this.callFlash("SetFileTypes", [types, description]); +}; + +// Public: setFileSizeLimit changes the file_size_limit setting +SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) { + this.settings.file_size_limit = fileSizeLimit; + this.callFlash("SetFileSizeLimit", [fileSizeLimit]); +}; + +// Public: setFileUploadLimit changes the file_upload_limit setting +SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) { + this.settings.file_upload_limit = fileUploadLimit; + this.callFlash("SetFileUploadLimit", [fileUploadLimit]); +}; + +// Public: setFileQueueLimit changes the file_queue_limit setting +SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) { + this.settings.file_queue_limit = fileQueueLimit; + this.callFlash("SetFileQueueLimit", [fileQueueLimit]); +}; + +// Public: setFilePostName changes the file_post_name setting +SWFUpload.prototype.setFilePostName = function (filePostName) { + this.settings.file_post_name = filePostName; + this.callFlash("SetFilePostName", [filePostName]); +}; + +// Public: setUseQueryString changes the use_query_string setting +SWFUpload.prototype.setUseQueryString = function (useQueryString) { + this.settings.use_query_string = useQueryString; + this.callFlash("SetUseQueryString", [useQueryString]); +}; + +// Public: setRequeueOnError changes the requeue_on_error setting +SWFUpload.prototype.setRequeueOnError = function (requeueOnError) { + this.settings.requeue_on_error = requeueOnError; + this.callFlash("SetRequeueOnError", [requeueOnError]); +}; + +// Public: setHTTPSuccess changes the http_success setting +SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) { + if (typeof http_status_codes === "string") { + http_status_codes = http_status_codes.replace(" ", "").split(","); + } + + this.settings.http_success = http_status_codes; + this.callFlash("SetHTTPSuccess", [http_status_codes]); +}; + +// Public: setHTTPSuccess changes the http_success setting +SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) { + this.settings.assume_success_timeout = timeout_seconds; + this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]); +}; + +// Public: setDebugEnabled changes the debug_enabled setting +SWFUpload.prototype.setDebugEnabled = function (debugEnabled) { + this.settings.debug_enabled = debugEnabled; + this.callFlash("SetDebugEnabled", [debugEnabled]); +}; + +// Public: setButtonImageURL loads a button image sprite +SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) { + if (buttonImageURL == undefined) { + buttonImageURL = ""; + } + + this.settings.button_image_url = buttonImageURL; + this.callFlash("SetButtonImageURL", [buttonImageURL]); +}; + +// Public: setButtonDimensions resizes the Flash Movie and button +SWFUpload.prototype.setButtonDimensions = function (width, height) { + this.settings.button_width = width; + this.settings.button_height = height; + + var movie = this.getMovieElement(); + if (movie != undefined) { + movie.style.width = width + "px"; + movie.style.height = height + "px"; + } + + this.callFlash("SetButtonDimensions", [width, height]); +}; +// Public: setButtonText Changes the text overlaid on the button +SWFUpload.prototype.setButtonText = function (html) { + this.settings.button_text = html; + this.callFlash("SetButtonText", [html]); +}; +// Public: setButtonTextPadding changes the top and left padding of the text overlay +SWFUpload.prototype.setButtonTextPadding = function (left, top) { + this.settings.button_text_top_padding = top; + this.settings.button_text_left_padding = left; + this.callFlash("SetButtonTextPadding", [left, top]); +}; + +// Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button +SWFUpload.prototype.setButtonTextStyle = function (css) { + this.settings.button_text_style = css; + this.callFlash("SetButtonTextStyle", [css]); +}; +// Public: setButtonDisabled disables/enables the button +SWFUpload.prototype.setButtonDisabled = function (isDisabled) { + this.settings.button_disabled = isDisabled; + this.callFlash("SetButtonDisabled", [isDisabled]); +}; +// Public: setButtonAction sets the action that occurs when the button is clicked +SWFUpload.prototype.setButtonAction = function (buttonAction) { + this.settings.button_action = buttonAction; + this.callFlash("SetButtonAction", [buttonAction]); +}; + +// Public: setButtonCursor changes the mouse cursor displayed when hovering over the button +SWFUpload.prototype.setButtonCursor = function (cursor) { + this.settings.button_cursor = cursor; + this.callFlash("SetButtonCursor", [cursor]); +}; + +/* ******************************* + Flash Event Interfaces + These functions are used by Flash to trigger the various + events. + + All these functions a Private. + + Because the ExternalInterface library is buggy the event calls + are added to a queue and the queue then executed by a setTimeout. + This ensures that events are executed in a determinate order and that + the ExternalInterface bugs are avoided. +******************************* */ + +SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) { + // Warning: Don't call this.debug inside here or you'll create an infinite loop + + if (argumentArray == undefined) { + argumentArray = []; + } else if (!(argumentArray instanceof Array)) { + argumentArray = [argumentArray]; + } + + var self = this; + if (typeof this.settings[handlerName] === "function") { + // Queue the event + this.eventQueue.push(function () { + this.settings[handlerName].apply(this, argumentArray); + }); + + // Execute the next queued event + setTimeout(function () { + self.executeNextEvent(); + }, 0); + + } else if (this.settings[handlerName] !== null) { + throw "Event handler " + handlerName + " is unknown or is not a function"; + } +}; + +// Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout +// we must queue them in order to garentee that they are executed in order. +SWFUpload.prototype.executeNextEvent = function () { + // Warning: Don't call this.debug inside here or you'll create an infinite loop + + var f = this.eventQueue ? this.eventQueue.shift() : null; + if (typeof(f) === "function") { + f.apply(this); + } +}; + +// Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have +// properties that contain characters that are not valid for JavaScript identifiers. To work around this +// the Flash Component escapes the parameter names and we must unescape again before passing them along. +SWFUpload.prototype.unescapeFilePostParams = function (file) { + var reg = /[$]([0-9a-f]{4})/i; + var unescapedPost = {}; + var uk; + + if (file != undefined) { + for (var k in file.post) { + if (file.post.hasOwnProperty(k)) { + uk = k; + var match; + while ((match = reg.exec(uk)) !== null) { + uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16))); + } + unescapedPost[uk] = file.post[k]; + } + } + + file.post = unescapedPost; + } + + return file; +}; + +// Private: Called by Flash to see if JS can call in to Flash (test if External Interface is working) +SWFUpload.prototype.testExternalInterface = function () { + try { + return this.callFlash("TestExternalInterface"); + } catch (ex) { + return false; + } +}; + +// Private: This event is called by Flash when it has finished loading. Don't modify this. +// Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded. +SWFUpload.prototype.flashReady = function () { + // Check that the movie element is loaded correctly with its ExternalInterface methods defined + var movieElement = this.getMovieElement(); + + if (!movieElement) { + this.debug("Flash called back ready but the flash movie can't be found."); + return; + } + + this.cleanUp(movieElement); + + this.queueEvent("swfupload_loaded_handler"); +}; + +// Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE. +// This function is called by Flash each time the ExternalInterface functions are created. +SWFUpload.prototype.cleanUp = function (movieElement) { + // Pro-actively unhook all the Flash functions + try { + if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE + this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)"); + for (var key in movieElement) { + try { + if (typeof(movieElement[key]) === "function") { + movieElement[key] = null; + } + } catch (ex) { + } + } + } + } catch (ex1) { + + } + + // Fix Flashes own cleanup code so if the SWFMovie was removed from the page + // it doesn't display errors. + window["__flash__removeCallback"] = function (instance, name) { + try { + if (instance) { + instance[name] = null; + } + } catch (flashEx) { + + } + }; + +}; + + +/* This is a chance to do something before the browse window opens */ +SWFUpload.prototype.fileDialogStart = function () { + this.queueEvent("file_dialog_start_handler"); +}; + + +/* Called when a file is successfully added to the queue. */ +SWFUpload.prototype.fileQueued = function (file) { + file = this.unescapeFilePostParams(file); + this.queueEvent("file_queued_handler", file); +}; + + +/* Handle errors that occur when an attempt to queue a file fails. */ +SWFUpload.prototype.fileQueueError = function (file, errorCode, message) { + file = this.unescapeFilePostParams(file); + this.queueEvent("file_queue_error_handler", [file, errorCode, message]); +}; + +/* Called after the file dialog has closed and the selected files have been queued. + You could call startUpload here if you want the queued files to begin uploading immediately. */ +SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) { + this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]); +}; + +SWFUpload.prototype.uploadStart = function (file) { + file = this.unescapeFilePostParams(file); + this.queueEvent("return_upload_start_handler", file); +}; + +SWFUpload.prototype.returnUploadStart = function (file) { + var returnValue; + if (typeof this.settings.upload_start_handler === "function") { + file = this.unescapeFilePostParams(file); + returnValue = this.settings.upload_start_handler.call(this, file); + } else if (this.settings.upload_start_handler != undefined) { + throw "upload_start_handler must be a function"; + } + + // Convert undefined to true so if nothing is returned from the upload_start_handler it is + // interpretted as 'true'. + if (returnValue === undefined) { + returnValue = true; + } + + returnValue = !!returnValue; + + this.callFlash("ReturnUploadStart", [returnValue]); +}; + + + +SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) { + file = this.unescapeFilePostParams(file); + this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]); +}; + +SWFUpload.prototype.uploadError = function (file, errorCode, message) { + file = this.unescapeFilePostParams(file); + this.queueEvent("upload_error_handler", [file, errorCode, message]); +}; + +SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) { + file = this.unescapeFilePostParams(file); + this.queueEvent("upload_success_handler", [file, serverData, responseReceived]); +}; + +SWFUpload.prototype.uploadComplete = function (file) { + file = this.unescapeFilePostParams(file); + this.queueEvent("upload_complete_handler", file); +}; + +/* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the + internal debug console. You can override this event and have messages written where you want. */ +SWFUpload.prototype.debug = function (message) { + this.queueEvent("debug_handler", message); +}; + + +/* ********************************** + Debug Console + The debug console is a self contained, in page location + for debug message to be sent. The Debug Console adds + itself to the body if necessary. + + The console is automatically scrolled as messages appear. + + If you are using your own debug handler or when you deploy to production and + have debug disabled you can remove these functions to reduce the file size + and complexity. +********************************** */ + +// Private: debugMessage is the default debug_handler. If you want to print debug messages +// call the debug() function. When overriding the function your own function should +// check to see if the debug setting is true before outputting debug information. +SWFUpload.prototype.debugMessage = function (message) { + if (this.settings.debug) { + var exceptionMessage, exceptionValues = []; + + // Check for an exception object and print it nicely + if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") { + for (var key in message) { + if (message.hasOwnProperty(key)) { + exceptionValues.push(key + ": " + message[key]); + } + } + exceptionMessage = exceptionValues.join("\n") || ""; + exceptionValues = exceptionMessage.split("\n"); + exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: "); + SWFUpload.Console.writeLine(exceptionMessage); + } else { + SWFUpload.Console.writeLine(message); + } + } +}; + +SWFUpload.Console = {}; +SWFUpload.Console.writeLine = function (message) { + var console, documentForm; + + try { + console = document.getElementById("SWFUpload_Console"); + + if (!console) { + documentForm = document.createElement("form"); + document.getElementsByTagName("body")[0].appendChild(documentForm); + + console = document.createElement("textarea"); + console.id = "SWFUpload_Console"; + console.style.fontFamily = "monospace"; + console.setAttribute("wrap", "off"); + console.wrap = "off"; + console.style.overflow = "auto"; + console.style.width = "700px"; + console.style.height = "350px"; + console.style.margin = "5px"; + documentForm.appendChild(console); + } + + console.value += message + "\n"; + + console.scrollTop = console.scrollHeight - console.clientHeight; + } catch (ex) { + alert("Exception: " + ex.name + " Message: " + ex.message); + } +}; diff --git a/lib/swfupload/swfupload.queue.js b/lib/swfupload/swfupload.queue.js index 00aef320..69e619da 100644 --- a/lib/swfupload/swfupload.queue.js +++ b/lib/swfupload/swfupload.queue.js @@ -1,98 +1,98 @@ -/* - Queue Plug-in - - Features: - *Adds a cancelQueue() method for cancelling the entire queue. - *All queued files are uploaded when startUpload() is called. - *If false is returned from uploadComplete then the queue upload is stopped. - If false is not returned (strict comparison) then the queue upload is continued. - *Adds a QueueComplete event that is fired when all the queued files have finished uploading. - Set the event handler with the queue_complete_handler setting. - - */ - -var SWFUpload; -if (typeof(SWFUpload) === "function") { - SWFUpload.queue = {}; - - SWFUpload.prototype.initSettings = (function (oldInitSettings) { - return function () { - if (typeof(oldInitSettings) === "function") { - oldInitSettings.call(this); - } - - this.queueSettings = {}; - - this.queueSettings.queue_cancelled_flag = false; - this.queueSettings.queue_upload_count = 0; - - this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler; - this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler; - this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler; - this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler; - - this.settings.queue_complete_handler = this.settings.queue_complete_handler || null; - }; - })(SWFUpload.prototype.initSettings); - - SWFUpload.prototype.startUpload = function (fileID) { - this.queueSettings.queue_cancelled_flag = false; - this.callFlash("StartUpload", [fileID]); - }; - - SWFUpload.prototype.cancelQueue = function () { - this.queueSettings.queue_cancelled_flag = true; - this.stopUpload(); - - var stats = this.getStats(); - while (stats.files_queued > 0) { - this.cancelUpload(); - stats = this.getStats(); - } - }; - - SWFUpload.queue.uploadStartHandler = function (file) { - var returnValue; - if (typeof(this.queueSettings.user_upload_start_handler) === "function") { - returnValue = this.queueSettings.user_upload_start_handler.call(this, file); - } - - // To prevent upload a real "FALSE" value must be returned, otherwise default to a real "TRUE" value. - returnValue = (returnValue === false) ? false : true; - - this.queueSettings.queue_cancelled_flag = !returnValue; - - return returnValue; - }; - - SWFUpload.queue.uploadCompleteHandler = function (file) { - var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler; - var continueUpload; - - if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) { - this.queueSettings.queue_upload_count++; - } - - if (typeof(user_upload_complete_handler) === "function") { - continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true; - } else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) { - // If the file was stopped and re-queued don't restart the upload - continueUpload = false; - } else { - continueUpload = true; - } - - if (continueUpload) { - var stats = this.getStats(); - if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) { - this.startUpload(); - } else if (this.queueSettings.queue_cancelled_flag === false) { - this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]); - this.queueSettings.queue_upload_count = 0; - } else { - this.queueSettings.queue_cancelled_flag = false; - this.queueSettings.queue_upload_count = 0; - } - } - }; +/* + Queue Plug-in + + Features: + *Adds a cancelQueue() method for cancelling the entire queue. + *All queued files are uploaded when startUpload() is called. + *If false is returned from uploadComplete then the queue upload is stopped. + If false is not returned (strict comparison) then the queue upload is continued. + *Adds a QueueComplete event that is fired when all the queued files have finished uploading. + Set the event handler with the queue_complete_handler setting. + + */ + +var SWFUpload; +if (typeof(SWFUpload) === "function") { + SWFUpload.queue = {}; + + SWFUpload.prototype.initSettings = (function (oldInitSettings) { + return function () { + if (typeof(oldInitSettings) === "function") { + oldInitSettings.call(this); + } + + this.queueSettings = {}; + + this.queueSettings.queue_cancelled_flag = false; + this.queueSettings.queue_upload_count = 0; + + this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler; + this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler; + this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler; + this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler; + + this.settings.queue_complete_handler = this.settings.queue_complete_handler || null; + }; + })(SWFUpload.prototype.initSettings); + + SWFUpload.prototype.startUpload = function (fileID) { + this.queueSettings.queue_cancelled_flag = false; + this.callFlash("StartUpload", [fileID]); + }; + + SWFUpload.prototype.cancelQueue = function () { + this.queueSettings.queue_cancelled_flag = true; + this.stopUpload(); + + var stats = this.getStats(); + while (stats.files_queued > 0) { + this.cancelUpload(); + stats = this.getStats(); + } + }; + + SWFUpload.queue.uploadStartHandler = function (file) { + var returnValue; + if (typeof(this.queueSettings.user_upload_start_handler) === "function") { + returnValue = this.queueSettings.user_upload_start_handler.call(this, file); + } + + // To prevent upload a real "FALSE" value must be returned, otherwise default to a real "TRUE" value. + returnValue = (returnValue === false) ? false : true; + + this.queueSettings.queue_cancelled_flag = !returnValue; + + return returnValue; + }; + + SWFUpload.queue.uploadCompleteHandler = function (file) { + var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler; + var continueUpload; + + if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) { + this.queueSettings.queue_upload_count++; + } + + if (typeof(user_upload_complete_handler) === "function") { + continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true; + } else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) { + // If the file was stopped and re-queued don't restart the upload + continueUpload = false; + } else { + continueUpload = true; + } + + if (continueUpload) { + var stats = this.getStats(); + if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) { + this.startUpload(); + } else if (this.queueSettings.queue_cancelled_flag === false) { + this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]); + this.queueSettings.queue_upload_count = 0; + } else { + this.queueSettings.queue_cancelled_flag = false; + this.queueSettings.queue_upload_count = 0; + } + } + }; } \ No newline at end of file -- cgit v1.2.3 From 99c1c2a6b1d483993b24d1a25cc3c12663589020 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 13 Mar 2010 23:12:40 -0800 Subject: Changes to the example client to test updating the members of an album. --- modules/gallery/helpers/item_rest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 5d31291e..32b9c620 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -70,6 +70,8 @@ class item_rest_Core { $orm->where("type", "IN", explode(",", $p->type)); } + // Respect the requested ordering + $orm->order_by($item->sort_column, $item->sort_order); $members = array(); foreach ($orm->find_all() as $child) { $members[] = rest::url("item", $child); -- cgit v1.2.3 From 7b35091b47f0b1ed2677795885553c07fd7bf168 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 21 Mar 2010 20:45:22 -0700 Subject: If the access token is not set, then look in the post data. --- modules/rest/controllers/rest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php index 3db5e9b1..13594763 100644 --- a/modules/rest/controllers/rest.php +++ b/modules/rest/controllers/rest.php @@ -41,6 +41,7 @@ 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(); @@ -56,6 +57,11 @@ class Rest_Controller extends Controller { $request->method = strtolower($input->server("HTTP_X_GALLERY_REQUEST_METHOD", $method)); $request->access_token = $input->server("HTTP_X_GALLERY_REQUEST_KEY"); + + if (empty($request->access_token) && !empty($request->params->access_token)) { + $request->access_token = $request->params->access_token; + } + $request->url = url::abs_current(true); rest::set_active_user($request->access_token); -- cgit v1.2.3 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 ++--------- modules/organize/css/organize.css | 156 ---------- modules/organize/css/organize_theme.css | 18 +- modules/organize/helpers/organize_theme.php | 6 - modules/organize/js/organize.js | 317 --------------------- modules/organize/views/organize_dialog.html.php | 160 ++++++++--- .../organize/views/organize_thumb_grid.html.php | 22 -- modules/organize/views/organize_tree.html.php | 29 -- 8 files changed, 145 insertions(+), 726 deletions(-) delete mode 100644 modules/organize/css/organize.css delete mode 100644 modules/organize/js/organize.js delete mode 100644 modules/organize/views/organize_thumb_grid.html.php delete mode 100644 modules/organize/views/organize_tree.html.php 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; } } 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_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 + +" /> + + +
+

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

-
-
-

-
    - -
-
-
-
    -
  • -
-
"> - -
-
- -
-
    -
  • -
  • - "g-organize-sort-column"), - album::get_sort_order_options(), $album->sort_column) ?> -
  • -
  • - "g-organize-sort-order"), - array("ASC" => t("Ascending"), "DESC" => t("Descending")), $album->sort_order) ?> -
  • -
-
-
-
-
+
 
- - 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 @@ - -children(25, $offset) as $child): ?> -
" - ref="id ?>"> - thumb_img(array("class" => "g-thumbnail", "ref" => $child->id), 90, true) ?> - is_album() ? " class=\"ui-icon ui-icon-note\"" : "" ?>> -
- - -children_count() > $offset): ?> - - 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 @@ - -
  • " - ref="id ?>"> - - - " - ref="id ?>"> - title) ?> - - viewable()->children(null, null, array(array("type", "=", "album"))); ?> - -
      - - contains($selected)): ?> - $selected, "album" => $child)); ?> - -
    • " - ref="id ?>"> - - " ref="id ?>"> - title) ?> - -
    • - - -
    - -
  • - -- cgit v1.2.3 From 0c1595d7e8c1b31e886ac712ce7e794cf3c33fdd Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 27 Mar 2010 15:55:42 -0700 Subject: Clean up the organize_dialog file of some cruft and add the organize.swf file to the organize module. --- modules/organize/lib/organize.swf | Bin 0 -> 766983 bytes modules/organize/views/organize_dialog.html.php | 17 ++--------------- 2 files changed, 2 insertions(+), 15 deletions(-) create mode 100644 modules/organize/lib/organize.swf diff --git a/modules/organize/lib/organize.swf b/modules/organize/lib/organize.swf new file mode 100644 index 00000000..f2389f22 Binary files /dev/null and b/modules/organize/lib/organize.swf differ diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index c7dc967e..f31cf161 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -1,7 +1,5 @@ - -" /> -
    +

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

     
    -- 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(+) 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 7c84ee1b33a768fc4a44f3b6db2530f01cfcd081 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 30 Mar 2010 07:55:56 -0700 Subject: Organize now has the add album functionality. --- modules/organize/lib/organize.swf | Bin 766983 -> 778676 bytes modules/organize/views/organize_dialog.html.php | 10 +++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/organize/lib/organize.swf b/modules/organize/lib/organize.swf index f2389f22..3d2182ee 100644 Binary files a/modules/organize/lib/organize.swf and b/modules/organize/lib/organize.swf differ diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index f31cf161..8163c595 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -56,8 +56,9 @@ function getTextStrings() { var strings = { "statusText": for_js() ?>, - "addToolTip": for_js() ?>, - "deleteToolTip": for_js() ?>, + "addAlbum": for_js() ?>, + "addImages": for_js() ?>, + "deleteSelected": for_js() ?>, "uploadedText": for_js() ?>, "removeFileText": for_js() ?>, "totalFiles": for_js() ?>, @@ -66,6 +67,8 @@ "kilobytes": for_js() ?>, "megabytes": for_js() ?>, "gigabytes": for_js() ?>, + "cancel": for_js() ?>, + "close": for_js() ?> }; return strings; } @@ -84,7 +87,8 @@ sortOrder: '', sortFields: '', baseUrl: '', - apiKey: '' + apiKey: '', + controller: '/' }; var size = $.gallery_get_viewport_size(); -- cgit v1.2.3 From e56473c5d78842210b7825300bd9b373c104cb83 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 30 Mar 2010 08:08:30 -0700 Subject: Checkpoint the organize flex source. Not production ready, but worth checkpointing. --- modules/organize/source/flex_organize_source.7z | Bin 0 -> 343328 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 modules/organize/source/flex_organize_source.7z diff --git a/modules/organize/source/flex_organize_source.7z b/modules/organize/source/flex_organize_source.7z new file mode 100644 index 00000000..7d2993fb Binary files /dev/null and b/modules/organize/source/flex_organize_source.7z differ -- cgit v1.2.3 From 0dfc62051e7e3dac79489a6a2964c3e6b333b517 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 31 Mar 2010 07:14:48 -0700 Subject: Update the flex organize to use access_key instead of access_token --- modules/organize/lib/organize.swf | Bin 778676 -> 778677 bytes modules/organize/source/flex_organize_source.7z | Bin 343328 -> 343272 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/modules/organize/lib/organize.swf b/modules/organize/lib/organize.swf index 3d2182ee..62e733ea 100644 Binary files a/modules/organize/lib/organize.swf and b/modules/organize/lib/organize.swf differ diff --git a/modules/organize/source/flex_organize_source.7z b/modules/organize/source/flex_organize_source.7z index 7d2993fb..ea5951b9 100644 Binary files a/modules/organize/source/flex_organize_source.7z and b/modules/organize/source/flex_organize_source.7z differ -- cgit v1.2.3 From 9bb4c954bbc10e71a695b57f7e8979a140f4873f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 7 Apr 2010 08:07:41 -0700 Subject: Merge bharat_dev rest implementation --- modules/gallery/helpers/item_rest.php | 135 ++++++++++++--------------------- modules/gallery/models/item.php | 2 +- modules/rest/controllers/rest.php | 7 ++ modules/tag/helpers/item_tags_rest.php | 5 +- modules/tag/helpers/tag_item_rest.php | 2 +- modules/tag/helpers/tag_items_rest.php | 4 +- modules/tag/helpers/tag_rest.php | 27 +++---- modules/tag/helpers/tags_rest.php | 6 +- 8 files changed, 77 insertions(+), 111 deletions(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 32b9c620..f52713b8 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -70,8 +70,14 @@ class item_rest_Core { $orm->where("type", "IN", explode(",", $p->type)); } - // Respect the requested ordering - $orm->order_by($item->sort_column, $item->sort_order); + // Apply the item's sort order, using id as the tie breaker. + // See Item_Model::children() + $order_by = array($item->sort_column => $item->sort_order); + if ($item->sort_column != "id") { + $order_by["id"] = "ASC"; + } + $orm->order_by($order_by); + $members = array(); foreach ($orm->find_all() as $child) { $members[] = rest::url("item", $child); @@ -88,126 +94,81 @@ class item_rest_Core { $item = rest::resolve($request->url); access::required("edit", $item); - $params = $request->params; - - $sort_order_changed_to_weight = false; - // Start the batch - batch::start(); - - // Only change fields from a whitelist. - foreach (array("album_cover", "captured", "description", - "height", "mime_type", "name", "parent", "rand_key", "resize_dirty", - "resize_height", "resize_width", "slug", "sort_column", "sort_order", - "thumb_dirty", "thumb_height", "thumb_width", "title", "view_count", - "weight", "width") as $key) { - if (property_exists($request->params, $key)) { + if ($entity = $request->params->entity) { + // Only change fields from a whitelist. + foreach (array("album_cover", "captured", "description", + "height", "mime_type", "name", "parent", "rand_key", "resize_dirty", + "resize_height", "resize_width", "slug", "sort_column", "sort_order", + "thumb_dirty", "thumb_height", "thumb_width", "title", "view_count", + "width") as $key) { switch ($key) { case "album_cover": - $album_cover_item = rest::resolve($request->params->album_cover); - access::required("view", $album_cover_item); - $item->album_cover_item_id = $album_cover_item->id; + if (property_exists($entity, "album_cover")) { + $album_cover_item = rest::resolve($entity->album_cover); + access::required("view", $album_cover_item); + $item->album_cover_item_id = $album_cover_item->id; + } break; - case "sort_column": - if ($request->params->sort_column == "weight" && $item->sort_column != "weight") { - $sort_order_changed_to_weight = true; - $item->sort_column = "weight"; + case "parent": + if (property_exists($entity, "parent")) { + $parent = rest::resolve($entity->parent); + access::required("edit", $parent); + $item->parent_id = $parent->id; } break; - case "parent": - $parent = rest::resolve($request->params->parent); - access::required("edit", $parent); - $item->parent_id = $parent->id; - break; default: - $item->$key = $request->params->$key; + if (property_exists($entity, $key)) { + $item->$key = $entity->$key; + } } } } - $item->save(); - // If children are supplied, then update the children based on that client tells us. - // if the sort order changed, then update the weights if there are no children to be updated - if (property_exists($request->params, "children")) { - // Map the existing children by their restful urls - $children = array(); - foreach ($item->children() as $child) { - $children[rest::url("item", $child)] = $child; - } - $update_weight = $item->sort_column == "weight"; - $weight = $item->sort_order == "ASC" ? -1 : $request->params->url->length; - $weight_increment = $item->sort_order == "ASC" ? 1 : -1; - - foreach($request->params->children as $url) { - if (isset($children[$url])) { - $child = $children[$url]; - unset($children[$url]); - } else { - $child = rest::resolve($url); - $child->parent_id = $item->id; + $weight = 0; + if (isset($request->params->members)) { + foreach ($request->params->members as $url) { + $child = rest::resolve($url); + if ($child->parent_id == $item->id && $child->weight != $weight) { + $child->weight = $weight++; + $child->save(); } - $child->save(); - if ($update_weight) { - $weight += $weight_increment; - db::build() - ->update("items") - ->set("weight", $weight) - ->where("id", "=", $child->id) - ->execute(); - } - } - // Anything left in the mapping needs to be deleted - foreach ($children as $child) { - $child->delete(); - } - } else if ($sort_order_changed_to_weight) { - $weight = $item->sort_order == "ASC" ? -1 : $request->params->url->length; - $weight_increment = $item->sort_order == "ASC" ? 1 : -1; - foreach ($item->children() as $child) { - // Do this directly in the database to avoid sending notifications - $weight += $weight_increment; - db::build() - ->update("items") - ->set("weight", $weight) - ->where("id", "=", $child->id) - ->execute(); } } - - batch::stop(); + $item->save(); } static function post($request) { $parent = rest::resolve($request->url); access::required("edit", $parent); - $params = $request->params; + $entity = $request->params->entity; $item = ORM::factory("item"); - switch ($params->type) { + switch ($entity->type) { case "album": $item->type = "album"; $item->parent_id = $parent->id; - $item->name = $params->name; - $item->title = isset($params->title) ? $params->title : $name; - $item->description = isset($params->description) ? $params->description : null; - $item->slug = isset($params->slug) ? $params->slug : null; + $item->name = $entity->name; + $item->title = isset($entity->title) ? $entity->title : $name; + $item->description = isset($entity->description) ? $entity->description : null; + $item->slug = isset($entity->slug) ? $entity->slug : null; $item->save(); break; case "photo": case "movie": - $item->type = $params->type; + $item->type = $entity->type; $item->parent_id = $parent->id; $item->set_data_file($request->file); - $item->name = $params->name; - $item->title = isset($params->title) ? $params->title : $params->name; - $item->description = isset($params->description) ? $params->description : null; - $item->slug = isset($params->slug) ? $params->slug : null; + $item->name = $entity->name; + $item->title = isset($entity->title) ? $entity->title : $entity->name; + $item->description = isset($entity->description) ? $entity->description : null; + $item->slug = isset($entity->slug) ? $entity->slug : null; $item->save(); break; default: - throw new Rest_Exception("Invalid type: $params->type", 400); + throw new Rest_Exception("Invalid type: $entity->type", 400); } return array("url" => rest::url("item", $item)); diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 1026264f..7fc37325 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -947,7 +947,7 @@ class Item_Model extends ORM_MPTT { // Elide some internal-only data that is going to cause confusion in the client. foreach (array("relative_path_cache", "relative_url_cache", "left_ptr", "right_ptr", - "thumb_dirty", "resize_dirty") as $key) { + "thumb_dirty", "resize_dirty", "weight") as $key) { unset($data[$key]); } return $data; diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php index 410eeece..38f28171 100644 --- a/modules/rest/controllers/rest.php +++ b/modules/rest/controllers/rest.php @@ -55,6 +55,13 @@ class Rest_Controller extends Controller { break; } + if (isset($request->params->entity)) { + $request->params->entity = json_decode($request->params->entity); + } + if (isset($request->params->members)) { + $request->params->members = json_decode($request->params->members); + } + $request->method = strtolower($input->server("HTTP_X_GALLERY_REQUEST_METHOD", $method)); $request->access_key = $input->server("HTTP_X_GALLERY_REQUEST_KEY"); diff --git a/modules/tag/helpers/item_tags_rest.php b/modules/tag/helpers/item_tags_rest.php index 8a1b1e8b..02c79e5d 100644 --- a/modules/tag/helpers/item_tags_rest.php +++ b/modules/tag/helpers/item_tags_rest.php @@ -31,8 +31,8 @@ class item_tags_rest_Core { } static function post($request) { - $tag = rest::resolve($request->params->tag); - $item = rest::resolve($request->params->item); + $tag = rest::resolve($request->params->entity->tag); + $item = rest::resolve($request->params->entity->item); access::required("view", $item); tag::add($item, $tag->name); @@ -45,6 +45,7 @@ class item_tags_rest_Core { static function delete($request) { list ($tag, $item) = rest::resolve($request->url); + access::required("edit", $item); $tag->remove($item); $tag->save(); } diff --git a/modules/tag/helpers/tag_item_rest.php b/modules/tag/helpers/tag_item_rest.php index bce00a9f..17cb726e 100644 --- a/modules/tag/helpers/tag_item_rest.php +++ b/modules/tag/helpers/tag_item_rest.php @@ -22,7 +22,7 @@ class tag_item_rest_Core { list ($tag, $item) = rest::resolve($request->url); return array( "url" => $request->url, - "members" => array( + "entity" => array( "tag" => rest::url("tag", $tag), "item" => rest::url("item", $item))); } diff --git a/modules/tag/helpers/tag_items_rest.php b/modules/tag/helpers/tag_items_rest.php index 003c7c95..848c2cd3 100644 --- a/modules/tag/helpers/tag_items_rest.php +++ b/modules/tag/helpers/tag_items_rest.php @@ -33,8 +33,8 @@ class tag_items_rest_Core { } static function post($request) { - $tag = rest::resolve($request->params->tag); - $item = rest::resolve($request->params->item); + $tag = rest::resolve($request->params->entity->tag); + $item = rest::resolve($request->params->entity->item); access::required("view", $item); if (!$tag->loaded()) { diff --git a/modules/tag/helpers/tag_rest.php b/modules/tag/helpers/tag_rest.php index f30706bd..e0b7bd87 100644 --- a/modules/tag/helpers/tag_rest.php +++ b/modules/tag/helpers/tag_rest.php @@ -36,28 +36,25 @@ class tag_rest_Core { "members" => $tag_items))); } - static function post($request) { - if (empty($request->params->url)) { - throw new Rest_Exception("Bad request", 400); - } - - $tag = rest::resolve($request->url); - $item = rest::resolve($request->params->url); - access::required("edit", $item); - - tag::add($item, $tag->name); - return array("url" => rest::url("tag_item", $tag, $item)); - } - static function put($request) { + // Who can we allow to edit a tag name? If we allow anybody to do it then any logged in + // user can rename all your tags to something offensive. Right now limit renaming to admins. + if (!identity::active_user()->admin) { + access::forbidden(); + } $tag = rest::resolve($request->url); - if (isset($request->params->name)) { - $tag->name = $request->params->name; + if (isset($request->params->entity->name)) { + $tag->name = $request->params->entity->name; $tag->save(); } } static function delete($request) { + // Restrict deleting tags to admins. Otherwise, a logged in user can do great harm to an + // install. + if (!identity::active_user()->admin) { + access::forbidden(); + } $tag = rest::resolve($request->url); $tag->delete(); } diff --git a/modules/tag/helpers/tags_rest.php b/modules/tag/helpers/tags_rest.php index 82826d8e..434e774a 100644 --- a/modules/tag/helpers/tags_rest.php +++ b/modules/tag/helpers/tags_rest.php @@ -40,13 +40,13 @@ class tags_rest_Core { } } - if (empty($request->params->name)) { + if (empty($request->params->entity->name)) { throw new Rest_Exception("Bad Request", 400); } - $tag = ORM::factory("tag")->where("name", "=", $request->params->name)->find(); + $tag = ORM::factory("tag")->where("name", "=", $request->params->entity->name)->find(); if (!$tag->loaded()) { - $tag->name = $request->params->name; + $tag->name = $request->params->entity->name; $tag->count = 0; $tag->save(); } -- cgit v1.2.3 From 009b47262b9b81dc996459119af822e2e7306255 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 15 Apr 2010 06:18:47 -0700 Subject: Only return the members element to the rest client if the item is an album. This makes it consistent to the rest client that collections will have a members element. --- modules/gallery/helpers/item_rest.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index f52713b8..36d2ca62 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -78,16 +78,18 @@ class item_rest_Core { } $orm->order_by($order_by); - $members = array(); - foreach ($orm->find_all() as $child) { - $members[] = rest::url("item", $child); - } - - return array( + $result = array( "url" => $request->url, "entity" => $item->as_restful_array(), - "members" => $members, "relationships" => rest::relationships("item", $item)); + if ($item->is_album()) { + $result["members"] = array(); + foreach ($orm->find_all() as $child) { + $result["members"][] = rest::url("item", $child); + } + } + + return $result; } static function put($request) { -- cgit v1.2.3 From 027312596c29c1986d3480c7dda48533e6dd3ca8 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 16 Apr 2010 15:28:35 -0700 Subject: Don't show the member element for non-collection elements in the response. Having a members sidebar element indicates to the rest clients that this is a resource collection. --- modules/gallery/helpers/items_rest.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 48839dc9..37ebb088 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -24,19 +24,20 @@ class items_rest_Core { $items = array(); if (isset($request->params->url)) { - foreach ($request->params->url as $url) { + foreach (json_decode($request->params->url) as $url) { $item = rest::resolve($url); if (access::can("view", $item)) { - $members = array(); + $item_rest = array("url" => $url, + "entity" => $item->as_restful_array(), + "relationship" => rest::relationships("item", $item)); if ($item->type == "album") { + $members = array(); foreach ($item->children() as $child) { $members[] = rest::url("item", $child); } + $item_rest["members"] = $members; } - $items[] = array("url" => $url, - "entity" => $item->as_restful_array(), - "members" => $members, - "relationship" => rest::relationships("item", $item)); + $items[] = $item_rest; } } } -- cgit v1.2.3 From 14683ec0e8b8b9622539990c8d56310b0e0ced21 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 21 Apr 2010 15:32:49 -0700 Subject: Correct typo: change relationship to relationships --- modules/gallery/helpers/items_rest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 37ebb088..ab2fe927 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -29,7 +29,7 @@ class items_rest_Core { if (access::can("view", $item)) { $item_rest = array("url" => $url, "entity" => $item->as_restful_array(), - "relationship" => rest::relationships("item", $item)); + "relationships" => rest::relationships("item", $item)); if ($item->type == "album") { $members = array(); foreach ($item->children() as $child) { -- cgit v1.2.3 From fcc446bf006f88d2079f52ed559c31f01c156dbe Mon Sep 17 00:00:00 2001 From: ckieffer Date: Sat, 8 May 2010 13:54:27 -0600 Subject: Move print with digibug to the site menu. --- modules/digibug/helpers/digibug_event.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/digibug/helpers/digibug_event.php b/modules/digibug/helpers/digibug_event.php index cf7cdf21..4c842615 100644 --- a/modules/digibug/helpers/digibug_event.php +++ b/modules/digibug/helpers/digibug_event.php @@ -26,14 +26,17 @@ class digibug_event_Core { ->url(url::site("admin/digibug"))); } - static function photo_menu($menu, $theme) { + static function site_menu($menu, $theme) { $item = $theme->item(); - $menu->append(Menu::factory("link") - ->id("digibug") - ->label(t("Print with Digibug")) - ->url(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf")) - ->css_id("g-print-digibug-link") - ->css_class("g-print-digibug-link ui-icon-print")); + if ($item->type == "photo") { + $menu->get("options_menu") + ->append(Menu::factory("link") + ->id("digibug") + ->label(t("Print with Digibug")) + ->url(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf")) + ->css_id("g-print-digibug-link") + ->css_class("g-print-digibug-link ui-icon-print")); + } } static function context_menu($menu, $theme, $item) { -- cgit v1.2.3 From 44753c524996415f465f44d05be46e878911ce4a Mon Sep 17 00:00:00 2001 From: ckieffer Date: Sat, 8 May 2010 15:05:56 -0600 Subject: Deleted extra CSS class assignment for context_menu delete option. --- modules/gallery/helpers/gallery_event.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index d723cc1b..c77ed9d4 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -383,7 +383,6 @@ class gallery_event_Core { ->id("delete") ->label($delete_title) ->css_class("ui-icon-trash") - ->css_class("g-quick-delete") ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))); } -- cgit v1.2.3 From 32fa15ca3a54ef0266f4dd8ce0edb570ad526df7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 9 May 2010 20:39:31 -0700 Subject: Add dependency checking to insure the administrator is notified if the rest module is deactivated --- modules/organize/helpers/organize_event.php | 18 ++++++++++++++ modules/organize/helpers/organize_installer.php | 32 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 modules/organize/helpers/organize_installer.php 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.. " . + "Activate the Rest module now", + 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 @@ + Date: Sun, 9 May 2010 20:41:37 -0700 Subject: Remove the item id from the rest/gallery/items url as that was inconsistent. Add the query parameter ancestors_for= to provide a restful way to retrieve the ancestors of an item. --- modules/gallery/helpers/items_rest.php | 55 ++++++++---- modules/gallery/tests/Items_Rest_Helper_Test.php | 103 +++++++++++++++++++++++ 2 files changed, 142 insertions(+), 16 deletions(-) create mode 100644 modules/gallery/tests/Items_Rest_Helper_Test.php diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index ab2fe927..ef1ac006 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -18,28 +18,35 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class items_rest_Core { + /** + * To retrieve a collection of items, you can specify the following query parameters to specify the + * type of the collection. If both are specified, then the url parameter is used and the + * ancestor_for is ignored. + * + * urls=url1,url2,url3 + * return items that match the specified urls. Typically used to return the member detail + * + * ancestor_for=url + * return the ancestors of the specified item + */ static function get($request) { - $parent = rest::resolve($request->url); - access::required("view", $parent); - $items = array(); - if (isset($request->params->url)) { - foreach (json_decode($request->params->url) as $url) { + if (isset($request->params->urls)) { + foreach (json_decode($request->params->urls) as $url) { $item = rest::resolve($url); if (access::can("view", $item)) { - $item_rest = array("url" => $url, - "entity" => $item->as_restful_array(), - "relationships" => rest::relationships("item", $item)); - if ($item->type == "album") { - $members = array(); - foreach ($item->children() as $child) { - $members[] = rest::url("item", $child); - } - $item_rest["members"] = $members; - } - $items[] = $item_rest; + $items[] = items_rest::format_restful_item($item); } } + } else if (isset($request->params->ancestor_for)) { + $item = rest::resolve($request->params->ancestor_for); + if (!access::can("view", $item)) { + throw new Kohana_404_Exception(); + } + $items[] = items_rest::format_restful_item($item); + while (($item = $item->parent()) != null) { + array_unshift($items, items_rest::format_restful_item($item)); + }; } return $items; @@ -52,4 +59,20 @@ class items_rest_Core { } return $item; } + + private static function format_restful_item($item) { + $item_rest = array("url" => rest::url("item", $item), + "entity" => $item->as_restful_array(), + "relationships" => rest::relationships("item", $item)); + if ($item->type == "album") { + $members = array(); + foreach ($item->children() as $child) { + $members[] = rest::url("item", $child); + } + $item_rest["members"] = $members; + } + + return $item_rest; + } + } diff --git a/modules/gallery/tests/Items_Rest_Helper_Test.php b/modules/gallery/tests/Items_Rest_Helper_Test.php new file mode 100644 index 00000000..cd01ae0c --- /dev/null +++ b/modules/gallery/tests/Items_Rest_Helper_Test.php @@ -0,0 +1,103 @@ +reload(); + $album2->reload(); + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->urls = json_encode(array( + rest::url("item", $photo1), + rest::url("item", $album2))); + $this->assert_equal_array( + array( + array("url" => rest::url("item", $photo1), + "entity" => $photo1->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $photo1), + "members" => array()))), + array("url" => rest::url("item", $album2), + "entity" => $album2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album2), + "members" => array())), + "members" => array( + rest::url("item", $photo2)))), + items_rest::get($request)); + } + + public function get_ancestor_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $root = ORM::factory("item", 1); + $restful_root = array( + "url" => rest::url("item", $root), + "entity" => $root->as_restful_array(), + "relationships" => rest::relationships("item", $root)); + $restful_root["members"] = array(); + foreach ($root->children() as $child) { + $restful_root["members"][] = rest::url("item", $child); + } + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->ancestor_for = rest::url("item", $photo2); + $this->assert_equal_array( + array( + $restful_root, + array("url" => rest::url("item", $album1), + "entity" => $album1->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album1), + "members" => array())), + "members" => array( + rest::url("item", $photo1), + rest::url("item", $album2)), + ), + array("url" => rest::url("item", $album2), + "entity" => $album2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album2), + "members" => array())), + "members" => array( + rest::url("item", $photo2))), + array("url" => rest::url("item", $photo2), + "entity" => $photo2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $photo2), + "members" => array())))), + items_rest::get($request)); + } +} -- cgit v1.2.3 From 3fe10b15cf9359b66452c24965df575203e8af8e Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 10 May 2010 06:31:38 -0700 Subject: Allow the use of the type query parameter to filter the results of a rest/gallery/items?urls=... request. This allows the client to pass the entire list of member urls and have the rest server filter the results based on the specified types. --- modules/gallery/helpers/items_rest.php | 22 ++++-- modules/gallery/tests/Items_Rest_Helper_Test.php | 85 ++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 4 deletions(-) diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index ef1ac006..5ca6facd 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -19,23 +19,37 @@ */ class items_rest_Core { /** - * To retrieve a collection of items, you can specify the following query parameters to specify the - * type of the collection. If both are specified, then the url parameter is used and the - * ancestor_for is ignored. + * To retrieve a collection of items, you can specify the following query parameters to specify + * the type of the collection. If both are specified, then the url parameter is used and the + * ancestor_for is ignored. Specifying the "type" parameter with the urls parameter, will + * filter the results based on the specified type. Using the type parameter with the + * ancestor_for parameter makes no sense and will be ignored. * * urls=url1,url2,url3 * return items that match the specified urls. Typically used to return the member detail * * ancestor_for=url * return the ancestors of the specified item + * + * type= + * limit the type to types in this list. eg, "type=photo,movie" */ static function get($request) { $items = array(); if (isset($request->params->urls)) { foreach (json_decode($request->params->urls) as $url) { + if (isset($request->params->type)) { + $types = explode(",", $request->params->type); + } $item = rest::resolve($url); if (access::can("view", $item)) { - $items[] = items_rest::format_restful_item($item); + if (isset($types)) { + if (in_array($item->type, $types)) { + $items[] = items_rest::format_restful_item($item); + } + } else { + $items[] = items_rest::format_restful_item($item); + } } } } else if (isset($request->params->ancestor_for)) { diff --git a/modules/gallery/tests/Items_Rest_Helper_Test.php b/modules/gallery/tests/Items_Rest_Helper_Test.php index cd01ae0c..94bf912a 100644 --- a/modules/gallery/tests/Items_Rest_Helper_Test.php +++ b/modules/gallery/tests/Items_Rest_Helper_Test.php @@ -50,6 +50,91 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { items_rest::get($request)); } + public function get_url_filter_album_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->urls = json_encode(array( + rest::url("item", $photo1), + rest::url("item", $album2))); + $request->params->type = "album"; + $this->assert_equal_array( + array( + array("url" => rest::url("item", $album2), + "entity" => $album2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album2), + "members" => array())), + "members" => array( + rest::url("item", $photo2)))), + items_rest::get($request)); + } + + public function get_url_filter_photo_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->urls = json_encode(array( + rest::url("item", $photo1), + rest::url("item", $album2))); + $request->params->type = "photo"; + $this->assert_equal_array( + array( + array("url" => rest::url("item", $photo1), + "entity" => $photo1->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $photo1), + "members" => array())))), + items_rest::get($request)); + } + + public function get_url_filter_albums_photos_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->urls = json_encode(array( + rest::url("item", $photo1), + rest::url("item", $album2))); + $request->params->type = "photo,album"; + $this->assert_equal_array( + array( + array("url" => rest::url("item", $photo1), + "entity" => $photo1->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $photo1), + "members" => array()))), + array("url" => rest::url("item", $album2), + "entity" => $album2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album2), + "members" => array())), + "members" => array( + rest::url("item", $photo2)))), + items_rest::get($request)); + } + public function get_ancestor_test() { $album1 = test::random_album(); $photo1 = test::random_photo($album1); -- cgit v1.2.3 From dcd09c09e817e9e12223fc11ac9f830a81abea83 Mon Sep 17 00:00:00 2001 From: ckieffer Date: Fri, 14 May 2010 17:13:35 -0600 Subject: Missed this in commit 9e3c0c08849b5842f9c345d7b4f90ee82359dedb. --- themes/admin_wind/views/admin.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/admin_wind/views/admin.html.php b/themes/admin_wind/views/admin.html.php index 2f64c847..6446deeb 100644 --- a/themes/admin_wind/views/admin.html.php +++ b/themes/admin_wind/views/admin.html.php @@ -6,7 +6,7 @@ <? if ($page_title): ?> - <?= $page_title ?> + Gallery Admin: <?= $page_title ?> <? else: ?> <?= t("Admin dashboard") ?> <? endif ?> -- cgit v1.2.3 From d98b85f7d3142676e6b4f407a18ed81564823f88 Mon Sep 17 00:00:00 2001 From: ckieffer <ckieffer@192.168.0.219> Date: Fri, 14 May 2010 17:14:34 -0600 Subject: Drop context_menu for wind's photo/resize view. Move photo edit options to the site_menu. --- modules/gallery/helpers/gallery_event.php | 54 +++++++++++++++++++++++++++++++ themes/wind/views/photo.html.php | 1 - 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index c77ed9d4..d01b2956 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -227,6 +227,60 @@ class gallery_event_Core { } } } + + if ($item->is_photo() && graphics::can("rotate")) { + $options_menu + ->append( + Menu::factory("ajax_link") + ->id("rotate_ccw") + ->label(t("Rotate 90° counter clockwise")) + ->css_class("ui-icon-rotate-ccw") + ->ajax_handler("function(data) { " . + "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") + ->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))) + ->append( + Menu::factory("ajax_link") + ->id("rotate_cw") + ->label(t("Rotate 90° clockwise")) + ->css_class("ui-icon-rotate-cw") + ->ajax_handler("function(data) { " . + "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") + ->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))); + } + + if ($item->id != item::root()->id) { + $parent = $item->parent(); + if (access::can("edit", $parent)) { + // We can't make this item the highlight if it's an album with no album cover, or if it's + // already the album cover. + if (($item->type == "album" && empty($item->album_cover_item_id)) || + ($item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id) || + $parent->album_cover_item_id == $item->id) { + $disabledState = " ui-state-disabled"; + } else { + $disabledState = " "; + } + + if ($item->parent()->id != 1) { + $options_menu + ->append( + Menu::factory("ajax_link") + ->id("make_album_cover") + ->label(t("Choose as the album cover")) + ->css_class("ui-icon-star") + ->ajax_handler("function(data) { window.location.reload() }") + ->url(url::site("quick/make_album_cover/$item->id?csrf=$csrf"))); + } + $options_menu + ->append( + Menu::factory("dialog") + ->id("delete") + ->label(t("Delete this photo")) + ->css_class("ui-icon-trash") + ->css_class("g-quick-delete") + ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))); + } + } } if (identity::active_user()->admin) { diff --git a/themes/wind/views/photo.html.php b/themes/wind/views/photo.html.php index e0fae3f1..07952c94 100644 --- a/themes/wind/views/photo.html.php +++ b/themes/wind/views/photo.html.php @@ -27,7 +27,6 @@ </a> <? endif ?> <?= $theme->resize_bottom($item) ?> - <?= $theme->context_menu($item, "#g-photo-id-{$item->id}") ?> </div> <div id="g-info"> -- cgit v1.2.3 From ad0e7254eb6e6a763c9b4d0a7252dc5982a814be Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Fri, 14 May 2010 16:19:53 -0700 Subject: Require a well-formed email address for all comments. --- modules/comment/controllers/comments.php | 3 ++- modules/comment/helpers/comment.php | 10 +++++++-- modules/comment/models/comment.php | 15 +++++++++++++- modules/comment/tests/Comment_Event_Test.php | 1 + modules/comment/tests/Comment_Model_Test.php | 31 ++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 4 deletions(-) diff --git a/modules/comment/controllers/comments.php b/modules/comment/controllers/comments.php index 9e0f86d2..465b1bcd 100644 --- a/modules/comment/controllers/comments.php +++ b/modules/comment/controllers/comments.php @@ -58,6 +58,7 @@ class Comments_Controller extends Controller { "view" => (string) $view, "form" => (string) comment::get_add_form($item))); } else { + $form = comment::prefill_add_form($form); print json_encode(array("result" => "error", "form" => (string) $form)); } } @@ -69,6 +70,6 @@ class Comments_Controller extends Controller { $item = ORM::factory("item", $item_id); access::required("view", $item); - print comment::get_add_form($item); + print comment::prefill_add_form(comment::get_add_form($item)); } } diff --git a/modules/comment/helpers/comment.php b/modules/comment/helpers/comment.php index e3486e83..94b14d0d 100644 --- a/modules/comment/helpers/comment.php +++ b/modules/comment/helpers/comment.php @@ -33,7 +33,9 @@ class comment_Core { ->error_messages("required", t("You must enter a name for yourself")); $group->input("email") ->label(t("Email (hidden)")) - ->id("g-email"); + ->id("g-email") + ->error_messages("required", t("You must enter a valid email address")) + ->error_messages("invalid", t("You must enter a valid email address")); $group->input("url") ->label(t("Website (hidden)")) ->id("g-url"); @@ -45,13 +47,17 @@ class comment_Core { module::event("comment_add_form", $form); $group->submit("")->value(t("Add"))->class("ui-state-default ui-corner-all"); + return $form; + } + + static function prefill_add_form($form) { $active = identity::active_user(); if (!$active->guest) { + $group = $form->add_comment; $group->inputs["name"]->value($active->full_name)->disabled("disabled"); $group->email->value($active->email)->disabled("disabled"); $group->url->value($active->url)->disabled("disabled"); } - return $form; } } diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php index 48084340..fb70c79a 100644 --- a/modules/comment/models/comment.php +++ b/modules/comment/models/comment.php @@ -61,7 +61,7 @@ class Comment_Model extends ORM { if (!$array) { $this->rules = array( "guest_name" => array("callbacks" => array(array($this, "valid_author"))), - "guest_email" => array("rules" => array("email")), + "guest_email" => array("callbacks" => array(array($this, "valid_email"))), "guest_url" => array("rules" => array("url")), "item_id" => array("callbacks" => array(array($this, "valid_item"))), "state" => array("rules" => array("Comment_Model::valid_state")), @@ -144,6 +144,19 @@ class Comment_Model extends ORM { } } + /** + * Make sure that the email address is legal. + */ + public function valid_email(Validation $v, $field) { + if ($this->author_id == identity::guest()->id) { + if (empty($v->guest_email)) { + $v->add_error("guest_email", "required"); + } else if (!valid::email($v->guest_email)) { + $v->add_error("guest_email", "invalid"); + } + } + } + /** * Make sure we have a valid associated item id. */ diff --git a/modules/comment/tests/Comment_Event_Test.php b/modules/comment/tests/Comment_Event_Test.php index 62ffec2f..7cae9297 100644 --- a/modules/comment/tests/Comment_Event_Test.php +++ b/modules/comment/tests/Comment_Event_Test.php @@ -25,6 +25,7 @@ class Comment_Event_Test extends Gallery_Unit_Test_Case { $comment->item_id = $album->id; $comment->author_id = identity::guest()->id; $comment->guest_name = "test"; + $comment->guest_email = "test@test.com"; $comment->text = "text"; $comment->save(); diff --git a/modules/comment/tests/Comment_Model_Test.php b/modules/comment/tests/Comment_Model_Test.php index f4e944f0..ee4d3d3c 100644 --- a/modules/comment/tests/Comment_Model_Test.php +++ b/modules/comment/tests/Comment_Model_Test.php @@ -22,6 +22,37 @@ class Comment_Model_Test extends Gallery_Unit_Test_Case { identity::set_active_user(identity::admin_user()); } + public function guest_name_and_email_is_required_test() { + try { + $comment = ORM::factory("comment"); + $comment->item_id = item::root()->id; + $comment->author_id = identity::guest()->id; + $comment->text = "text"; + $comment->save(); + } catch (ORM_Validation_Exception $e) { + $this->assert_equal(array("guest_name" => "required", + "guest_email" => "required"), + $e->validation->errors()); + return; + } + } + + public function guest_email_must_be_well_formed_test() { + try { + $comment = ORM::factory("comment"); + $comment->item_id = item::root()->id; + $comment->author_id = identity::guest()->id; + $comment->guest_name = "guest"; + $comment->guest_email = "bogus"; + $comment->text = "text"; + $comment->save(); + } catch (ORM_Validation_Exception $e) { + $this->assert_equal(array("guest_email" => "invalid"), + $e->validation->errors()); + return; + } + } + public function cant_view_comments_for_unviewable_items_test() { $album = test::random_album(); -- cgit v1.2.3 From 3422185938436b44ee48515cd3cfa3df55bca3c8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Fri, 14 May 2010 16:51:51 -0700 Subject: Remove "rnd=" param from quick changes since we have the m= cache-buster already. --- modules/gallery/controllers/quick.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index 813d1a93..6cfbbc62 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -58,12 +58,12 @@ class Quick_Controller extends Controller { if (Input::instance()->get("page_type") == "collection") { print json_encode( - array("src" => $item->thumb_url() . "?rnd=" . rand(), + array("src" => $item->thumb_url(), "width" => $item->thumb_width, "height" => $item->thumb_height)); } else { print json_encode( - array("src" => $item->resize_url() . "?rnd=" . rand(), + array("src" => $item->resize_url(), "width" => $item->resize_width, "height" => $item->resize_height)); } -- cgit v1.2.3 From dc4fdca2ab1160e6fea1d51694a7b66ae18ef5e9 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Fri, 14 May 2010 16:54:50 -0700 Subject: Localize "Gallery Admin" --- themes/admin_wind/views/admin.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/admin_wind/views/admin.html.php b/themes/admin_wind/views/admin.html.php index 6446deeb..ff7b930f 100644 --- a/themes/admin_wind/views/admin.html.php +++ b/themes/admin_wind/views/admin.html.php @@ -6,7 +6,7 @@ <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title> <? if ($page_title): ?> - Gallery Admin: <?= $page_title ?> + <?= t("Gallery Admin: %page_title", array("page_title" => $page_title)) ?> <? else: ?> <?= t("Admin dashboard") ?> <? endif ?> -- cgit v1.2.3 From 1240878df0f4a2b0ad0cdb32814717038ff2773f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Fri, 14 May 2010 16:55:15 -0700 Subject: Fix-ups for d98b85f7d3142676e6b4f407a18ed81564823f88 - Pass the CSS selector of the active image in as an arg to site_menu so that quick operations know what they're operating on. - Change the ids from g-{photo,movie}-id to the generic g-item-id - Initialize ajax handlers for site menu on the photo and movie page - Drop the movie context menu, it's now in the site menu --- modules/gallery/helpers/gallery_event.php | 9 ++++++--- modules/gallery/libraries/Theme_View.php | 4 ++-- modules/gallery/models/item.php | 2 +- themes/wind/js/ui.init.js | 3 +++ themes/wind/views/movie.html.php | 3 +-- themes/wind/views/page.html.php | 2 +- themes/wind/views/photo.html.php | 2 +- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 9b3aa82d..89ad6a4c 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -167,7 +167,7 @@ class gallery_event_Core { } } - static function site_menu($menu, $theme) { + static function site_menu($menu, $theme, $item_css_selector) { if ($theme->page_subtype != "login") { $menu->append(Menu::factory("link") ->id("home") @@ -239,6 +239,9 @@ class gallery_event_Core { } } + $csrf = access::csrf_token(); + $theme_item = $theme->item(); + $page_type = $theme->page_type(); if ($item->is_photo() && graphics::can("rotate")) { $options_menu ->append( @@ -247,7 +250,7 @@ class gallery_event_Core { ->label(t("Rotate 90° counter clockwise")) ->css_class("ui-icon-rotate-ccw") ->ajax_handler("function(data) { " . - "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") + "\$.gallery_replace_image(data, \$('$item_css_selector')) }") ->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))) ->append( Menu::factory("ajax_link") @@ -255,7 +258,7 @@ class gallery_event_Core { ->label(t("Rotate 90° clockwise")) ->css_class("ui-icon-rotate-cw") ->ajax_handler("function(data) { " . - "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") + "\$.gallery_replace_image(data, \$('$item_css_selector')) }") ->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))); } diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 8b432fb6..6246c6f1 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -86,9 +86,9 @@ class Theme_View_Core extends Gallery_View { return $menu->render(); } - public function site_menu() { + public function site_menu($item_css_selector) { $menu = Menu::factory("root"); - module::event("site_menu", $menu, $this); + module::event("site_menu", $menu, $this, $item_css_selector); return $menu->render(); } diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 7fc37325..409ed3cc 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -674,7 +674,7 @@ class Item_Model extends ORM_MPTT { $v->attrs = array_merge($extra_attrs, array("style" => "display:block;width:{$this->width}px;height:{$this->height}px")); if (empty($v->attrs["id"])) { - $v->attrs["id"] = "g-movie-id-{$this->id}"; + $v->attrs["id"] = "g-item-id-{$this->id}"; } return $v; } diff --git a/themes/wind/js/ui.init.js b/themes/wind/js/ui.init.js index 6edf6be4..53b58516 100644 --- a/themes/wind/js/ui.init.js +++ b/themes/wind/js/ui.init.js @@ -108,6 +108,9 @@ $(document).ready(function() { duration: 1000, hash: true }); + + $(this).find(".g-dialog-link").gallery_dialog(); + $(this).find(".g-ajax-link").gallery_ajax(); } // Initialize button hover effect diff --git a/themes/wind/views/movie.html.php b/themes/wind/views/movie.html.php index 27c293ce..8481c7ce 100644 --- a/themes/wind/views/movie.html.php +++ b/themes/wind/views/movie.html.php @@ -5,8 +5,7 @@ <?= $theme->paginator() ?> <div id="g-movie" class="ui-helper-clearfix"> - <?= $item->movie_img(array("class" => "g-movie", "id" => "g-movie-id-{$item->id}")) ?> - <?= $theme->context_menu($item, "#g-movie-id-{$item->id}") ?> + <?= $item->movie_img(array("class" => "g-movie", "id" => "g-item-id-{$item->id}")) ?> </div> <div id="g-info"> diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index ebfbf700..4cc949ce 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -89,7 +89,7 @@ <!-- hide the menu and make it visible after the page has loaded, to minimize menu flicker --> <div id="g-site-menu" style="visibility: hidden"> - <?= $theme->site_menu() ?> + <?= $theme->site_menu($theme->item() ? "#g-item-id-{$theme->item()->id}" : "") ?> </div> <script type="text/javascript"> $(document).ready(function() { $("#g-site-menu").css("visibility", "visible"); }) </script> diff --git a/themes/wind/views/photo.html.php b/themes/wind/views/photo.html.php index 07952c94..f8b5511c 100644 --- a/themes/wind/views/photo.html.php +++ b/themes/wind/views/photo.html.php @@ -22,7 +22,7 @@ <? if (access::can("view_full", $item)): ?> <a href="<?= $item->file_url() ?>" class="g-fullsize-link" title="<?= t("View full size")->for_html_attr() ?>"> <? endif ?> - <?= $item->resize_img(array("id" => "g-photo-id-{$item->id}", "class" => "g-resize")) ?> + <?= $item->resize_img(array("id" => "g-item-id-{$item->id}", "class" => "g-resize")) ?> <? if (access::can("view_full", $item)): ?> </a> <? endif ?> -- cgit v1.2.3 From 48b66f2d675bf204b62909721cb398ceb0e2bd01 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Sat, 15 May 2010 23:42:55 -0700 Subject: Remove the item id from the rest/gallery/items url as that was inconsistent. Add the query parameter ancestors_for=<url> to provide a restful way to retrieve the ancestors of an item. (cherry picked from commit e9c8a8ae532e785ab95e6b43864c93b485785d6c) Conflicts: modules/gallery/helpers/items_rest.php --- modules/gallery/helpers/items_rest.php | 60 ++++++++++--- modules/gallery/tests/Items_Rest_Helper_Test.php | 103 +++++++++++++++++++++++ 2 files changed, 149 insertions(+), 14 deletions(-) create mode 100644 modules/gallery/tests/Items_Rest_Helper_Test.php diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 5d8e80b2..4f50e434 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -18,28 +18,60 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class items_rest_Core { + /** + * To retrieve a collection of items, you can specify the following query parameters to specify the + * type of the collection. If both are specified, then the url parameter is used and the + * ancestor_for is ignored. + * + * urls=url1,url2,url3 + * return items that match the specified urls. Typically used to return the member detail + * + * ancestor_for=url + * return the ancestors of the specified item + */ static function get($request) { - $items = array(); - if (isset($request->params->url)) { - foreach (json_decode($request->params->url) as $url) { + if (isset($request->params->urls)) { + foreach (json_decode($request->params->urls) as $url) { $item = rest::resolve($url); if (access::can("view", $item)) { - $item_rest = array("url" => $url, - "entity" => $item->as_restful_array(), - "relationship" => rest::relationships("item", $item)); - if ($item->type == "album") { - $members = array(); - foreach ($item->children() as $child) { - $members[] = rest::url("item", $child); - } - $item_rest["members"] = $members; - } - $items[] = $item_rest; + $items[] = items_rest::format_restful_item($item); } } + } else if (isset($request->params->ancestor_for)) { + $item = rest::resolve($request->params->ancestor_for); + if (!access::can("view", $item)) { + throw new Kohana_404_Exception(); + } + $items[] = items_rest::format_restful_item($item); + while (($item = $item->parent()) != null) { + array_unshift($items, items_rest::format_restful_item($item)); + }; } return $items; } + + static function resolve($id) { + $item = ORM::factory("item", $id); + if (!access::can("view", $item)) { + throw new Kohana_404_Exception(); + } + return $item; + } + + private static function format_restful_item($item) { + $item_rest = array("url" => rest::url("item", $item), + "entity" => $item->as_restful_array(), + "relationships" => rest::relationships("item", $item)); + if ($item->type == "album") { + $members = array(); + foreach ($item->children() as $child) { + $members[] = rest::url("item", $child); + } + $item_rest["members"] = $members; + } + + return $item_rest; + } } diff --git a/modules/gallery/tests/Items_Rest_Helper_Test.php b/modules/gallery/tests/Items_Rest_Helper_Test.php new file mode 100644 index 00000000..cd01ae0c --- /dev/null +++ b/modules/gallery/tests/Items_Rest_Helper_Test.php @@ -0,0 +1,103 @@ +<?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 Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { + public function get_url_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->urls = json_encode(array( + rest::url("item", $photo1), + rest::url("item", $album2))); + $this->assert_equal_array( + array( + array("url" => rest::url("item", $photo1), + "entity" => $photo1->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $photo1), + "members" => array()))), + array("url" => rest::url("item", $album2), + "entity" => $album2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album2), + "members" => array())), + "members" => array( + rest::url("item", $photo2)))), + items_rest::get($request)); + } + + public function get_ancestor_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $root = ORM::factory("item", 1); + $restful_root = array( + "url" => rest::url("item", $root), + "entity" => $root->as_restful_array(), + "relationships" => rest::relationships("item", $root)); + $restful_root["members"] = array(); + foreach ($root->children() as $child) { + $restful_root["members"][] = rest::url("item", $child); + } + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->ancestor_for = rest::url("item", $photo2); + $this->assert_equal_array( + array( + $restful_root, + array("url" => rest::url("item", $album1), + "entity" => $album1->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album1), + "members" => array())), + "members" => array( + rest::url("item", $photo1), + rest::url("item", $album2)), + ), + array("url" => rest::url("item", $album2), + "entity" => $album2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album2), + "members" => array())), + "members" => array( + rest::url("item", $photo2))), + array("url" => rest::url("item", $photo2), + "entity" => $photo2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $photo2), + "members" => array())))), + items_rest::get($request)); + } +} -- cgit v1.2.3 From 83ce637ce3171a012515b2e20e8592d22e9929f8 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Mon, 10 May 2010 06:31:38 -0700 Subject: Allow the use of the type query parameter to filter the results of a rest/gallery/items?urls=... request. This allows the client to pass the entire list of member urls and have the rest server filter the results based on the specified types. (cherry picked from commit 3fe10b15cf9359b66452c24965df575203e8af8e) --- modules/gallery/helpers/items_rest.php | 22 ++++-- modules/gallery/tests/Items_Rest_Helper_Test.php | 85 ++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 4 deletions(-) diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 4f50e434..32597a65 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -19,23 +19,37 @@ */ class items_rest_Core { /** - * To retrieve a collection of items, you can specify the following query parameters to specify the - * type of the collection. If both are specified, then the url parameter is used and the - * ancestor_for is ignored. + * To retrieve a collection of items, you can specify the following query parameters to specify + * the type of the collection. If both are specified, then the url parameter is used and the + * ancestor_for is ignored. Specifying the "type" parameter with the urls parameter, will + * filter the results based on the specified type. Using the type parameter with the + * ancestor_for parameter makes no sense and will be ignored. * * urls=url1,url2,url3 * return items that match the specified urls. Typically used to return the member detail * * ancestor_for=url * return the ancestors of the specified item + * + * type=<comma separate list of photo, movie or album> + * limit the type to types in this list. eg, "type=photo,movie" */ static function get($request) { $items = array(); if (isset($request->params->urls)) { foreach (json_decode($request->params->urls) as $url) { + if (isset($request->params->type)) { + $types = explode(",", $request->params->type); + } $item = rest::resolve($url); if (access::can("view", $item)) { - $items[] = items_rest::format_restful_item($item); + if (isset($types)) { + if (in_array($item->type, $types)) { + $items[] = items_rest::format_restful_item($item); + } + } else { + $items[] = items_rest::format_restful_item($item); + } } } } else if (isset($request->params->ancestor_for)) { diff --git a/modules/gallery/tests/Items_Rest_Helper_Test.php b/modules/gallery/tests/Items_Rest_Helper_Test.php index cd01ae0c..94bf912a 100644 --- a/modules/gallery/tests/Items_Rest_Helper_Test.php +++ b/modules/gallery/tests/Items_Rest_Helper_Test.php @@ -50,6 +50,91 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { items_rest::get($request)); } + public function get_url_filter_album_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->urls = json_encode(array( + rest::url("item", $photo1), + rest::url("item", $album2))); + $request->params->type = "album"; + $this->assert_equal_array( + array( + array("url" => rest::url("item", $album2), + "entity" => $album2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album2), + "members" => array())), + "members" => array( + rest::url("item", $photo2)))), + items_rest::get($request)); + } + + public function get_url_filter_photo_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->urls = json_encode(array( + rest::url("item", $photo1), + rest::url("item", $album2))); + $request->params->type = "photo"; + $this->assert_equal_array( + array( + array("url" => rest::url("item", $photo1), + "entity" => $photo1->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $photo1), + "members" => array())))), + items_rest::get($request)); + } + + public function get_url_filter_albums_photos_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->urls = json_encode(array( + rest::url("item", $photo1), + rest::url("item", $album2))); + $request->params->type = "photo,album"; + $this->assert_equal_array( + array( + array("url" => rest::url("item", $photo1), + "entity" => $photo1->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $photo1), + "members" => array()))), + array("url" => rest::url("item", $album2), + "entity" => $album2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album2), + "members" => array())), + "members" => array( + rest::url("item", $photo2)))), + items_rest::get($request)); + } + public function get_ancestor_test() { $album1 = test::random_album(); $photo1 = test::random_photo($album1); -- cgit v1.2.3 From c682ba86bdc6b7661e35e3913be73b4cba5c0896 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sun, 16 May 2010 22:37:10 -0700 Subject: Make sure that $item exists in site_menu(). --- modules/digibug/helpers/digibug_event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/digibug/helpers/digibug_event.php b/modules/digibug/helpers/digibug_event.php index 4c842615..413bf586 100644 --- a/modules/digibug/helpers/digibug_event.php +++ b/modules/digibug/helpers/digibug_event.php @@ -28,7 +28,7 @@ class digibug_event_Core { static function site_menu($menu, $theme) { $item = $theme->item(); - if ($item->type == "photo") { + if ($item && $item->type == "photo") { $menu->get("options_menu") ->append(Menu::factory("link") ->id("digibug") -- cgit v1.2.3 From 2157285d9bc3373e9bd2f4d86f558a1b2554f412 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sun, 16 May 2010 22:53:19 -0700 Subject: Rename admin/comments to admin/manage_comments to make room for admin/comments to be a settings page. --- modules/comment/controllers/admin_comments.php | 133 --------------------- .../comment/controllers/admin_manage_comments.php | 133 +++++++++++++++++++++ modules/comment/helpers/comment_event.php | 10 +- modules/comment/views/admin_comments.html.php | 8 +- 4 files changed, 146 insertions(+), 138 deletions(-) delete mode 100644 modules/comment/controllers/admin_comments.php create mode 100644 modules/comment/controllers/admin_manage_comments.php diff --git a/modules/comment/controllers/admin_comments.php b/modules/comment/controllers/admin_comments.php deleted file mode 100644 index 68794638..00000000 --- a/modules/comment/controllers/admin_comments.php +++ /dev/null @@ -1,133 +0,0 @@ -<?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 Admin_Comments_Controller extends Admin_Controller { - private static $items_per_page = 20; - - public function index() { - // Get rid of old deleted/spam comments once in a while - db::build() - ->delete("comments") - ->where("state", "IN", array("deleted", "spam")) - ->where("updated", "<", "UNIX_TIMESTAMP() - 86400 * 7") - ->execute(); - - // Redirect to the appropriate queue - url::redirect("admin/comments/queue/unpublished"); - } - - public function menu_labels() { - $menu = $this->_menu($this->_counts()); - print json_encode(array((string) $menu->get("unpublished")->label, - (string) $menu->get("published")->label, - (string) $menu->get("spam")->label, - (string) $menu->get("deleted")->label)); - } - - public function queue($state) { - $page = max(Input::instance()->get("page"), 1); - - $view = new Admin_View("admin.html"); - $view->page_title = t("Manage comments"); - $view->content = new View("admin_comments.html"); - $view->content->counts = $this->_counts(); - $view->content->menu = $this->_menu($view->content->counts); - $view->content->state = $state; - $view->content->comments = ORM::factory("comment") - ->order_by("created", "DESC") - ->where("state", "=", $state) - ->limit(self::$items_per_page, ($page - 1) * self::$items_per_page) - ->find_all(); - $view->content->pager = new Pagination(); - $view->content->pager->initialize( - array("query_string" => "page", - "total_items" => $view->content->counts->$state, - "items_per_page" => self::$items_per_page, - "style" => "classic")); - - print $view; - } - - private function _menu($counts) { - return Menu::factory("root") - ->append(Menu::factory("link") - ->id("unpublished") - ->label(t2("Awaiting Moderation (%count)", - "Awaiting Moderation (%count)", - $counts->unpublished)) - ->url(url::site("admin/comments/queue/unpublished"))) - ->append(Menu::factory("link") - ->id("published") - ->label(t2("Approved (%count)", - "Approved (%count)", - $counts->published)) - ->url(url::site("admin/comments/queue/published"))) - ->append(Menu::factory("link") - ->id("spam") - ->label(t2("Spam (%count)", - "Spam (%count)", - $counts->spam)) - ->url(url::site("admin/comments/queue/spam"))) - ->append(Menu::factory("link") - ->id("deleted") - ->label(t2("Recently Deleted (%count)", - "Recently Deleted (%count)", - $counts->deleted)) - ->url(url::site("admin/comments/queue/deleted"))); - } - - private function _counts() { - $counts = new stdClass(); - $counts->unpublished = 0; - $counts->published = 0; - $counts->spam = 0; - $counts->deleted = 0; - foreach (db::build() - ->select("state") - ->select(array("c" => 'COUNT("*")')) - ->from("comments") - ->group_by("state") - ->execute() as $row) { - $counts->{$row->state} = $row->c; - } - return $counts; - } - - public function set_state($id, $state) { - access::verify_csrf(); - - $comment = ORM::factory("comment", $id); - $orig = clone $comment; - if ($comment->loaded()) { - $comment->state = $state; - $comment->save(); - } - } - - public function delete_all_spam() { - access::verify_csrf(); - - db::build() - ->delete("comments") - ->where("state", "=", "spam") - ->execute(); - url::redirect("admin/comments/queue/spam"); - } -} - diff --git a/modules/comment/controllers/admin_manage_comments.php b/modules/comment/controllers/admin_manage_comments.php new file mode 100644 index 00000000..338e4799 --- /dev/null +++ b/modules/comment/controllers/admin_manage_comments.php @@ -0,0 +1,133 @@ +<?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 Admin_Manage_Comments_Controller extends Admin_Controller { + private static $items_per_page = 20; + + public function index() { + // Get rid of old deleted/spam comments once in a while + db::build() + ->delete("comments") + ->where("state", "IN", array("deleted", "spam")) + ->where("updated", "<", "UNIX_TIMESTAMP() - 86400 * 7") + ->execute(); + + // Redirect to the appropriate queue + url::redirect("admin/manage_comments/queue/unpublished"); + } + + public function menu_labels() { + $menu = $this->_menu($this->_counts()); + print json_encode(array((string) $menu->get("unpublished")->label, + (string) $menu->get("published")->label, + (string) $menu->get("spam")->label, + (string) $menu->get("deleted")->label)); + } + + public function queue($state) { + $page = max(Input::instance()->get("page"), 1); + + $view = new Admin_View("admin.html"); + $view->page_title = t("Manage comments"); + $view->content = new View("admin_comments.html"); + $view->content->counts = $this->_counts(); + $view->content->menu = $this->_menu($view->content->counts); + $view->content->state = $state; + $view->content->comments = ORM::factory("comment") + ->order_by("created", "DESC") + ->where("state", "=", $state) + ->limit(self::$items_per_page, ($page - 1) * self::$items_per_page) + ->find_all(); + $view->content->pager = new Pagination(); + $view->content->pager->initialize( + array("query_string" => "page", + "total_items" => $view->content->counts->$state, + "items_per_page" => self::$items_per_page, + "style" => "classic")); + + print $view; + } + + private function _menu($counts) { + return Menu::factory("root") + ->append(Menu::factory("link") + ->id("unpublished") + ->label(t2("Awaiting Moderation (%count)", + "Awaiting Moderation (%count)", + $counts->unpublished)) + ->url(url::site("admin/manage_comments/queue/unpublished"))) + ->append(Menu::factory("link") + ->id("published") + ->label(t2("Approved (%count)", + "Approved (%count)", + $counts->published)) + ->url(url::site("admin/manage_comments/queue/published"))) + ->append(Menu::factory("link") + ->id("spam") + ->label(t2("Spam (%count)", + "Spam (%count)", + $counts->spam)) + ->url(url::site("admin/manage_comments/queue/spam"))) + ->append(Menu::factory("link") + ->id("deleted") + ->label(t2("Recently Deleted (%count)", + "Recently Deleted (%count)", + $counts->deleted)) + ->url(url::site("admin/manage_comments/queue/deleted"))); + } + + private function _counts() { + $counts = new stdClass(); + $counts->unpublished = 0; + $counts->published = 0; + $counts->spam = 0; + $counts->deleted = 0; + foreach (db::build() + ->select("state") + ->select(array("c" => 'COUNT("*")')) + ->from("comments") + ->group_by("state") + ->execute() as $row) { + $counts->{$row->state} = $row->c; + } + return $counts; + } + + public function set_state($id, $state) { + access::verify_csrf(); + + $comment = ORM::factory("comment", $id); + $orig = clone $comment; + if ($comment->loaded()) { + $comment->state = $state; + $comment->save(); + } + } + + public function delete_all_spam() { + access::verify_csrf(); + + db::build() + ->delete("comments") + ->where("state", "=", "spam") + ->execute(); + url::redirect("admin/manage_comments/queue/spam"); + } +} + diff --git a/modules/comment/helpers/comment_event.php b/modules/comment/helpers/comment_event.php index 51e663e6..25fd4171 100644 --- a/modules/comment/helpers/comment_event.php +++ b/modules/comment/helpers/comment_event.php @@ -51,11 +51,19 @@ class comment_event_Core { } static function admin_menu($menu, $theme) { + /* + $menu->get("settings_menu") + ->append(Menu::factory("link") + ->id("comment") + ->label(t("Comments")) + ->url(url::site("admin/comments"))); + */ + $menu->get("content_menu") ->append(Menu::factory("link") ->id("comments") ->label(t("Comments")) - ->url(url::site("admin/comments"))); + ->url(url::site("admin/manage_comments"))); } static function photo_menu($menu, $theme) { diff --git a/modules/comment/views/admin_comments.html.php b/modules/comment/views/admin_comments.html.php index f58267bd..34a28986 100644 --- a/modules/comment/views/admin_comments.html.php +++ b/modules/comment/views/admin_comments.html.php @@ -1,7 +1,7 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <script type="text/javascript"> var set_state_url = - <?= html::js_string(url::site("admin/comments/set_state/__ID__/__STATE__?csrf=$csrf")) ?>; + <?= html::js_string(url::site("admin/manage_comments/set_state/__ID__/__STATE__?csrf=$csrf")) ?>; function set_state(state, id) { $.get(set_state_url.replace("__STATE__", state).replace("__ID__", id), {}, @@ -12,7 +12,7 @@ } var delete_url = - <?= html::js_string(url::site("admin/comments/delete/__ID__?csrf=$csrf")) ?>; + <?= html::js_string(url::site("admin/manage_comments/delete/__ID__?csrf=$csrf")) ?>; function del(id) { $.get(delete_url.replace("__ID__", id), @@ -24,7 +24,7 @@ } function update_menu() { - $.get(<?= html::js_string(url::site("admin/comments/menu_labels")) ?>, {}, + $.get(<?= html::js_string(url::site("admin/manage_comments/menu_labels")) ?>, {}, function(data) { for (var i = 0; i < data.length; i++) { $("#g-admin-comments-menu li:eq(" + i + ") a").html(data[i]); @@ -73,7 +73,7 @@ $counts->spam) ?> </p> <p> - <a href="<?= url::site("admin/comments/delete_all_spam?csrf=$csrf") ?>"> + <a href="<?= url::site("admin/manage_comments/delete_all_spam?csrf=$csrf") ?>"> <?= t("Delete all spam") ?> </a> <? else: ?> -- cgit v1.2.3 From ab204d27201951c7915cf0eb871751b145e398aa Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sun, 16 May 2010 23:01:57 -0700 Subject: Rename the admin_comments view to admin_manage_comments to match the controller. --- .../comment/controllers/admin_manage_comments.php | 2 +- modules/comment/views/admin_comments.html.php | 201 --------------------- .../comment/views/admin_manage_comments.html.php | 201 +++++++++++++++++++++ 3 files changed, 202 insertions(+), 202 deletions(-) delete mode 100644 modules/comment/views/admin_comments.html.php create mode 100644 modules/comment/views/admin_manage_comments.html.php diff --git a/modules/comment/controllers/admin_manage_comments.php b/modules/comment/controllers/admin_manage_comments.php index 338e4799..bc1c9e64 100644 --- a/modules/comment/controllers/admin_manage_comments.php +++ b/modules/comment/controllers/admin_manage_comments.php @@ -45,7 +45,7 @@ class Admin_Manage_Comments_Controller extends Admin_Controller { $view = new Admin_View("admin.html"); $view->page_title = t("Manage comments"); - $view->content = new View("admin_comments.html"); + $view->content = new View("admin_manage_comments.html"); $view->content->counts = $this->_counts(); $view->content->menu = $this->_menu($view->content->counts); $view->content->state = $state; diff --git a/modules/comment/views/admin_comments.html.php b/modules/comment/views/admin_comments.html.php deleted file mode 100644 index 34a28986..00000000 --- a/modules/comment/views/admin_comments.html.php +++ /dev/null @@ -1,201 +0,0 @@ -<?php defined("SYSPATH") or die("No direct script access.") ?> -<script type="text/javascript"> - var set_state_url = - <?= html::js_string(url::site("admin/manage_comments/set_state/__ID__/__STATE__?csrf=$csrf")) ?>; - function set_state(state, id) { - $.get(set_state_url.replace("__STATE__", state).replace("__ID__", id), - {}, - function() { - $("#g-comment-" + id).slideUp(); - update_menu(); - }); - } - - var delete_url = - <?= html::js_string(url::site("admin/manage_comments/delete/__ID__?csrf=$csrf")) ?>; - - function del(id) { - $.get(delete_url.replace("__ID__", id), - {}, - function() { - $("#g-comment-" + id).slideUp(); - update_menu(); - }); - } - - function update_menu() { - $.get(<?= html::js_string(url::site("admin/manage_comments/menu_labels")) ?>, {}, - function(data) { - for (var i = 0; i < data.length; i++) { - $("#g-admin-comments-menu li:eq(" + i + ") a").html(data[i]); - } - }, - "json"); - } -</script> - -<div id="g-admin-comments" class="g-block"> - <h1> <?= t("Manage comments") ?> </h1> - - <div class="g-block-content"> - <!-- @todo: Highlight active menu option --> - <div id="g-admin-comments-menu" class="ui-helper-clearfix"> - <?= $menu->render() ?> - </div> - - <!-- @todo: Remove after setting active option? --> - <h2> - <? if ($state == "published"): ?> - <?= t("Approved comments") ?> - <? elseif ($state == "unpublished"): ?> - <?= t("Comments awaiting moderation") ?> - <? elseif ($state == "spam"): ?> - <?= t("Spam comments") ?> - <? elseif ($state == "deleted"): ?> - <?= t("Recently deleted comments") ?> - <? endif ?> - </h2> - - <? if ($state == "spam"): ?> - <div> - <? $spam_caught = module::get_var("comment", "spam_caught") ?> - <? if ($spam_caught > 0): ?> - <p> - <?= t2("Gallery has caught %count spam for you since you installed spam filtering.", - "Gallery has caught %count spam for you since you installed spam filtering.", - $spam_caught) ?> - </p> - <? endif ?> - <p> - <? if ($counts->spam): ?> - <?= t2("There is currently one comment in your spam queue. You can delete it with a single click, but there is no undo operation so you may want to check the message first to make sure that it really is spam.", - "There are currently %count comments in your spam queue. You can delete them all with a single click, but there is no undo operation so you may want to check the messages first to make sure that they really are spam. All spam messages will be deleted after 7 days automatically.", - $counts->spam) ?> - </p> - <p> - <a href="<?= url::site("admin/manage_comments/delete_all_spam?csrf=$csrf") ?>"> - <?= t("Delete all spam") ?> - </a> - <? else: ?> - <?= t("Your spam queue is empty!") ?> - <? endif ?> - </p> - </div> - <? endif ?> - - <? if ($state == "deleted"): ?> - <div> - <p> - <?= t("These are messages that have been recently deleted. They will be permanently erased automatically after 7 days.") ?> - </p> - </div> - <? endif ?> - - <table id="g-admin-comments-list"> - <tr> - <th> - <?= t("Author") ?> - </th> - <th> - <?= t("Comment") ?> - </th> - <th> - <?= t("Actions") ?> - </th> - </tr> - <? foreach ($comments as $comment): ?> - <tr id="g-comment-<?= $comment->id ?>" class="<?= text::alternate("g-odd", "g-even") ?>"> - <td> - <a href="#"> - <img src="<?= $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true)) ?>" - class="g-avatar" - alt="<?= html::clean_attribute($comment->author_name()) ?>" - width="40" - height="40" /> - </a> - <p><a href="mailto:<?= html::clean_attribute($comment->author_email()) ?>" - title="<?= html::clean_attribute($comment->author_email()) ?>"> <?= html::clean($comment->author_name()) ?> </a></p> - </td> - <td> - <div class="g-right"> - <? $item = $comment->item() ?> - <div class="g-item g-photo"> - <a href="<?= $item->url() ?>"> - <? if ($item->has_thumb()): ?> - <img src="<?= $item->thumb_url() ?>" - alt="<?= html::purify($item->title)->for_html_attr() ?>" - <?= photo::img_dimensions($item->thumb_width, $item->thumb_height, 75) ?> - /> - <? else: ?> - <?= t("No thumbnail") ?> - <? endif ?> - </a> - </div> - </div> - <p><?= gallery::date($comment->created) ?></p> - <?= nl2br(html::purify($comment->text)) ?> - </td> - <td> - <ul class="g-buttonset-vertical"> - <? if ($comment->state != "unpublished"): ?> - <li> - <a href="javascript:set_state('unpublished',<?=$comment->id?>)" - class="g-button ui-state-default ui-icon-left"> - <span class="ui-icon ui-icon-check"></span> - <?= t("Unapprove") ?> - </a> - </li> - <? endif ?> - <? if ($comment->state != "published"): ?> - <li> - <a href="javascript:set_state('published',<?=$comment->id?>)" - class="g-button ui-state-default ui-icon-left"> - <span class="ui-icon ui-icon-check"></span> - <?= t("Approve") ?> - </a> - </li> - <? endif ?> - <? if ($comment->state != "spam"): ?> - <li> - <a href="javascript:set_state('spam',<?=$comment->id?>)" - class="g-button ui-state-default ui-icon-left"> - <span class="ui-icon ui-icon-cancel"></span> - <?= t("Spam") ?> - </a> - </li> - <? endif ?> - <!-- - <li> - <a href="javascript:reply(<?=$comment->id?>)" - class="g-button ui-state-default ui-icon-left"> - <span class="ui-icon ui-icon-arrowreturnthick-1-w"></span> - <?= t("Reply") ?> - </a> - </li> - <li> - <a href="javascript:Edit(<?=$comment->id?>)" - class="g-button ui-state-default ui-icon-left"> - <span class="ui-icon ui-icon-pencil"></span> - <?= t("Edit") ?> - </a> - </li> - --> - <li> - <a href="javascript:set_state('deleted',<?=$comment->id?>)" - class="g-button ui-state-default ui-icon-left"> - <span class="ui-icon ui-icon-trash"></span> - <?= t("Delete") ?> - </a> - </li> - </ul> - </td> - </tr> - <? endforeach ?> - </table> - - <div class="g-paginator"> - <?= $pager ?> - </div> - - </div> -</div> diff --git a/modules/comment/views/admin_manage_comments.html.php b/modules/comment/views/admin_manage_comments.html.php new file mode 100644 index 00000000..34a28986 --- /dev/null +++ b/modules/comment/views/admin_manage_comments.html.php @@ -0,0 +1,201 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<script type="text/javascript"> + var set_state_url = + <?= html::js_string(url::site("admin/manage_comments/set_state/__ID__/__STATE__?csrf=$csrf")) ?>; + function set_state(state, id) { + $.get(set_state_url.replace("__STATE__", state).replace("__ID__", id), + {}, + function() { + $("#g-comment-" + id).slideUp(); + update_menu(); + }); + } + + var delete_url = + <?= html::js_string(url::site("admin/manage_comments/delete/__ID__?csrf=$csrf")) ?>; + + function del(id) { + $.get(delete_url.replace("__ID__", id), + {}, + function() { + $("#g-comment-" + id).slideUp(); + update_menu(); + }); + } + + function update_menu() { + $.get(<?= html::js_string(url::site("admin/manage_comments/menu_labels")) ?>, {}, + function(data) { + for (var i = 0; i < data.length; i++) { + $("#g-admin-comments-menu li:eq(" + i + ") a").html(data[i]); + } + }, + "json"); + } +</script> + +<div id="g-admin-comments" class="g-block"> + <h1> <?= t("Manage comments") ?> </h1> + + <div class="g-block-content"> + <!-- @todo: Highlight active menu option --> + <div id="g-admin-comments-menu" class="ui-helper-clearfix"> + <?= $menu->render() ?> + </div> + + <!-- @todo: Remove after setting active option? --> + <h2> + <? if ($state == "published"): ?> + <?= t("Approved comments") ?> + <? elseif ($state == "unpublished"): ?> + <?= t("Comments awaiting moderation") ?> + <? elseif ($state == "spam"): ?> + <?= t("Spam comments") ?> + <? elseif ($state == "deleted"): ?> + <?= t("Recently deleted comments") ?> + <? endif ?> + </h2> + + <? if ($state == "spam"): ?> + <div> + <? $spam_caught = module::get_var("comment", "spam_caught") ?> + <? if ($spam_caught > 0): ?> + <p> + <?= t2("Gallery has caught %count spam for you since you installed spam filtering.", + "Gallery has caught %count spam for you since you installed spam filtering.", + $spam_caught) ?> + </p> + <? endif ?> + <p> + <? if ($counts->spam): ?> + <?= t2("There is currently one comment in your spam queue. You can delete it with a single click, but there is no undo operation so you may want to check the message first to make sure that it really is spam.", + "There are currently %count comments in your spam queue. You can delete them all with a single click, but there is no undo operation so you may want to check the messages first to make sure that they really are spam. All spam messages will be deleted after 7 days automatically.", + $counts->spam) ?> + </p> + <p> + <a href="<?= url::site("admin/manage_comments/delete_all_spam?csrf=$csrf") ?>"> + <?= t("Delete all spam") ?> + </a> + <? else: ?> + <?= t("Your spam queue is empty!") ?> + <? endif ?> + </p> + </div> + <? endif ?> + + <? if ($state == "deleted"): ?> + <div> + <p> + <?= t("These are messages that have been recently deleted. They will be permanently erased automatically after 7 days.") ?> + </p> + </div> + <? endif ?> + + <table id="g-admin-comments-list"> + <tr> + <th> + <?= t("Author") ?> + </th> + <th> + <?= t("Comment") ?> + </th> + <th> + <?= t("Actions") ?> + </th> + </tr> + <? foreach ($comments as $comment): ?> + <tr id="g-comment-<?= $comment->id ?>" class="<?= text::alternate("g-odd", "g-even") ?>"> + <td> + <a href="#"> + <img src="<?= $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true)) ?>" + class="g-avatar" + alt="<?= html::clean_attribute($comment->author_name()) ?>" + width="40" + height="40" /> + </a> + <p><a href="mailto:<?= html::clean_attribute($comment->author_email()) ?>" + title="<?= html::clean_attribute($comment->author_email()) ?>"> <?= html::clean($comment->author_name()) ?> </a></p> + </td> + <td> + <div class="g-right"> + <? $item = $comment->item() ?> + <div class="g-item g-photo"> + <a href="<?= $item->url() ?>"> + <? if ($item->has_thumb()): ?> + <img src="<?= $item->thumb_url() ?>" + alt="<?= html::purify($item->title)->for_html_attr() ?>" + <?= photo::img_dimensions($item->thumb_width, $item->thumb_height, 75) ?> + /> + <? else: ?> + <?= t("No thumbnail") ?> + <? endif ?> + </a> + </div> + </div> + <p><?= gallery::date($comment->created) ?></p> + <?= nl2br(html::purify($comment->text)) ?> + </td> + <td> + <ul class="g-buttonset-vertical"> + <? if ($comment->state != "unpublished"): ?> + <li> + <a href="javascript:set_state('unpublished',<?=$comment->id?>)" + class="g-button ui-state-default ui-icon-left"> + <span class="ui-icon ui-icon-check"></span> + <?= t("Unapprove") ?> + </a> + </li> + <? endif ?> + <? if ($comment->state != "published"): ?> + <li> + <a href="javascript:set_state('published',<?=$comment->id?>)" + class="g-button ui-state-default ui-icon-left"> + <span class="ui-icon ui-icon-check"></span> + <?= t("Approve") ?> + </a> + </li> + <? endif ?> + <? if ($comment->state != "spam"): ?> + <li> + <a href="javascript:set_state('spam',<?=$comment->id?>)" + class="g-button ui-state-default ui-icon-left"> + <span class="ui-icon ui-icon-cancel"></span> + <?= t("Spam") ?> + </a> + </li> + <? endif ?> + <!-- + <li> + <a href="javascript:reply(<?=$comment->id?>)" + class="g-button ui-state-default ui-icon-left"> + <span class="ui-icon ui-icon-arrowreturnthick-1-w"></span> + <?= t("Reply") ?> + </a> + </li> + <li> + <a href="javascript:Edit(<?=$comment->id?>)" + class="g-button ui-state-default ui-icon-left"> + <span class="ui-icon ui-icon-pencil"></span> + <?= t("Edit") ?> + </a> + </li> + --> + <li> + <a href="javascript:set_state('deleted',<?=$comment->id?>)" + class="g-button ui-state-default ui-icon-left"> + <span class="ui-icon ui-icon-trash"></span> + <?= t("Delete") ?> + </a> + </li> + </ul> + </td> + </tr> + <? endforeach ?> + </table> + + <div class="g-paginator"> + <?= $pager ?> + </div> + + </div> +</div> -- cgit v1.2.3 From 73c7ec53102c24de248d1424fdf8d5ba347c2200 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Tue, 18 May 2010 06:16:47 -0700 Subject: Save the item before updating the order of the children. Also always increment the weight count (even if it is equal to the weight of the current child) --- modules/gallery/helpers/item_rest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 36d2ca62..298c2f4a 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -126,18 +126,19 @@ class item_rest_Core { } } } + $item->save(); - $weight = 0; if (isset($request->params->members)) { + $weight = 0; foreach ($request->params->members as $url) { $child = rest::resolve($url); if ($child->parent_id == $item->id && $child->weight != $weight) { - $child->weight = $weight++; + $child->weight = $weight; $child->save(); } + $weight++; } } - $item->save(); } static function post($request) { -- cgit v1.2.3 From ffc3f9f41c3d8d6df08d9ad6138f4ad74749ccec Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> 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 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 @@ <script type="text/javascript"> $("#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"); } @@ -37,12 +39,10 @@ "rollOverColor": colorToHex($("#g-organize-hover").css("backgroundColor")), "selectionColor": colorToHex($("#g-organize-active").css("backgroundColor")) }; - console.dir(styles); return styles; } function colorToHex(color) { - console.log("color: " + color); var digits = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(color); var red = parseInt(digits[2]); @@ -81,13 +81,13 @@ /* To use express install, set to playerProductInstall.swf, otherwise the empty string.*/ var xiSwfUrlStr = ""; var flashvars = { - selectedAlbum: "<?= $album->id?>", 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") ?>/' }; @@ -103,7 +103,7 @@ attributes.id = "g-organize-object"; attributes.name = "organize"; attributes.align = "middle"; - swfobject.embedSWF("<?= url::file("modules/organize/lib/organize.swf") ?>", + swfobject.embedSWF("<?= url::file("modules/organize/lib/Gallery3WebClient.swf") ?>", "flashContent", size.width() - 100, size.height() - 135, swfVersionStr, xiSwfUrlStr, flashvars, params, attributes); </script> -- cgit v1.2.3 From e4ff302e3b1d64de2864e7fcd64f26e6d012089b Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> 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(-) 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 a1181c5a49631b77b7ed9200a8730aed464bf46e Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 21 May 2010 07:29:17 -0700 Subject: Renamed GalleryRestRequestBuilder to GalleryRestRequest. Refactored the sendRequest method out of the GalleryResource class and moved it to the GalleryRestRequest class. Converted the properties captureDate, updatedDate, and createdDate to return a flex date object instead of a string representing a unix timestamp. --- modules/organize/lib/Gallery3WebClient.swf | Bin 136657 -> 135882 bytes .../organize/source/Gallery3Organize_source.zip | Bin 937810 -> 936852 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index 1069eae0..e4b40e4a 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 133a7fcf..45fda930 100644 Binary files a/modules/organize/source/Gallery3Organize_source.zip and b/modules/organize/source/Gallery3Organize_source.zip differ -- cgit v1.2.3 From 56587febfff2955c09b5b82a63c31cf547066f32 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 28 May 2010 09:36:54 -0700 Subject: Add a progress dialog box when deleting, uploading or updating items. --- modules/organize/lib/Gallery3WebClient.swf | Bin 135882 -> 137214 bytes .../organize/source/Gallery3Organize_source.zip | Bin 936852 -> 938411 bytes modules/organize/views/organize_dialog.html.php | 7 +++++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index e4b40e4a..4f55c455 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 45fda930..6a0a8c7f 100644 Binary files a/modules/organize/source/Gallery3Organize_source.zip and b/modules/organize/source/Gallery3Organize_source.zip differ diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 5da4aca4..da135857 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -61,12 +61,15 @@ "deleteSelected": <?= t("Delete")->for_js() ?>, "uploadedText": <?= t("Uploaded {0}")->for_js() ?>, "removeFileText": <?= t("Remove")->for_js() ?>, - "totalFiles": <?= t("Total Files: {0}")->for_js() ?>, - "totalSize": <?= t("Total Size: {0}")->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() ?> }; -- cgit v1.2.3 From ae595795f09edbe0883d233a7a8483f6445b9ed7 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 28 May 2010 09:41:42 -0700 Subject: If the file is empty (i.e. the upload failed, then throw a 'bad request' exception before trying to create the item. --- modules/gallery/helpers/item_rest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 298c2f4a..ec86ce93 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); -- cgit v1.2.3 From c4d85721fc0a3b9aad45451fb917d6e23b804c05 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 28 May 2010 16:43:10 -0700 Subject: Change the rearrange processing to use the ProcessItemQueue when moving children, so a progress dialog is displayed --- modules/organize/lib/Gallery3WebClient.swf | Bin 137214 -> 137234 bytes .../organize/source/Gallery3Organize_source.zip | Bin 938411 -> 938397 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index 4f55c455..0a4d6383 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 6a0a8c7f..4cf5c13b 100644 Binary files a/modules/organize/source/Gallery3Organize_source.zip and b/modules/organize/source/Gallery3Organize_source.zip differ -- cgit v1.2.3 From 8c351b12266a63dc2ef68d895cd2a21250a41cd8 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 4 Jun 2010 11:22:51 -0700 Subject: Change the name of the private format_restful_item to _format_restful_item so that the File_Structure_Test will pass. --- modules/gallery/helpers/items_rest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 32597a65..32f6c036 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -45,10 +45,10 @@ class items_rest_Core { if (access::can("view", $item)) { if (isset($types)) { if (in_array($item->type, $types)) { - $items[] = items_rest::format_restful_item($item); + $items[] = items_rest::_format_restful_item($item); } } else { - $items[] = items_rest::format_restful_item($item); + $items[] = items_rest::_format_restful_item($item); } } } @@ -57,9 +57,9 @@ class items_rest_Core { if (!access::can("view", $item)) { throw new Kohana_404_Exception(); } - $items[] = items_rest::format_restful_item($item); + $items[] = items_rest::_format_restful_item($item); while (($item = $item->parent()) != null) { - array_unshift($items, items_rest::format_restful_item($item)); + array_unshift($items, items_rest::_format_restful_item($item)); }; } @@ -74,7 +74,7 @@ class items_rest_Core { return $item; } - private static function format_restful_item($item) { + private static function _format_restful_item($item) { $item_rest = array("url" => rest::url("item", $item), "entity" => $item->as_restful_array(), "relationships" => rest::relationships("item", $item)); -- cgit v1.2.3 From 04b90c3bdef9b2f4daf8bffc1e814b0bac9912f4 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Sat, 15 May 2010 23:42:55 -0700 Subject: Remove the item id from the rest/gallery/items url as that was inconsistent. Add the query parameter ancestors_for=<url> to provide a restful way to retrieve the ancestors of an item. (cherry picked from commit e9c8a8ae532e785ab95e6b43864c93b485785d6c) Conflicts: modules/gallery/helpers/items_rest.php --- modules/gallery/helpers/items_rest.php | 60 ++++++++++--- modules/gallery/tests/Items_Rest_Helper_Test.php | 103 +++++++++++++++++++++++ 2 files changed, 149 insertions(+), 14 deletions(-) create mode 100644 modules/gallery/tests/Items_Rest_Helper_Test.php diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 5d8e80b2..4f50e434 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -18,28 +18,60 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class items_rest_Core { + /** + * To retrieve a collection of items, you can specify the following query parameters to specify the + * type of the collection. If both are specified, then the url parameter is used and the + * ancestor_for is ignored. + * + * urls=url1,url2,url3 + * return items that match the specified urls. Typically used to return the member detail + * + * ancestor_for=url + * return the ancestors of the specified item + */ static function get($request) { - $items = array(); - if (isset($request->params->url)) { - foreach (json_decode($request->params->url) as $url) { + if (isset($request->params->urls)) { + foreach (json_decode($request->params->urls) as $url) { $item = rest::resolve($url); if (access::can("view", $item)) { - $item_rest = array("url" => $url, - "entity" => $item->as_restful_array(), - "relationship" => rest::relationships("item", $item)); - if ($item->type == "album") { - $members = array(); - foreach ($item->children() as $child) { - $members[] = rest::url("item", $child); - } - $item_rest["members"] = $members; - } - $items[] = $item_rest; + $items[] = items_rest::format_restful_item($item); } } + } else if (isset($request->params->ancestor_for)) { + $item = rest::resolve($request->params->ancestor_for); + if (!access::can("view", $item)) { + throw new Kohana_404_Exception(); + } + $items[] = items_rest::format_restful_item($item); + while (($item = $item->parent()) != null) { + array_unshift($items, items_rest::format_restful_item($item)); + }; } return $items; } + + static function resolve($id) { + $item = ORM::factory("item", $id); + if (!access::can("view", $item)) { + throw new Kohana_404_Exception(); + } + return $item; + } + + private static function format_restful_item($item) { + $item_rest = array("url" => rest::url("item", $item), + "entity" => $item->as_restful_array(), + "relationships" => rest::relationships("item", $item)); + if ($item->type == "album") { + $members = array(); + foreach ($item->children() as $child) { + $members[] = rest::url("item", $child); + } + $item_rest["members"] = $members; + } + + return $item_rest; + } } diff --git a/modules/gallery/tests/Items_Rest_Helper_Test.php b/modules/gallery/tests/Items_Rest_Helper_Test.php new file mode 100644 index 00000000..cd01ae0c --- /dev/null +++ b/modules/gallery/tests/Items_Rest_Helper_Test.php @@ -0,0 +1,103 @@ +<?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 Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { + public function get_url_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->urls = json_encode(array( + rest::url("item", $photo1), + rest::url("item", $album2))); + $this->assert_equal_array( + array( + array("url" => rest::url("item", $photo1), + "entity" => $photo1->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $photo1), + "members" => array()))), + array("url" => rest::url("item", $album2), + "entity" => $album2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album2), + "members" => array())), + "members" => array( + rest::url("item", $photo2)))), + items_rest::get($request)); + } + + public function get_ancestor_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $root = ORM::factory("item", 1); + $restful_root = array( + "url" => rest::url("item", $root), + "entity" => $root->as_restful_array(), + "relationships" => rest::relationships("item", $root)); + $restful_root["members"] = array(); + foreach ($root->children() as $child) { + $restful_root["members"][] = rest::url("item", $child); + } + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->ancestor_for = rest::url("item", $photo2); + $this->assert_equal_array( + array( + $restful_root, + array("url" => rest::url("item", $album1), + "entity" => $album1->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album1), + "members" => array())), + "members" => array( + rest::url("item", $photo1), + rest::url("item", $album2)), + ), + array("url" => rest::url("item", $album2), + "entity" => $album2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album2), + "members" => array())), + "members" => array( + rest::url("item", $photo2))), + array("url" => rest::url("item", $photo2), + "entity" => $photo2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $photo2), + "members" => array())))), + items_rest::get($request)); + } +} -- cgit v1.2.3 From a600185b605a37ca1b60cb6d9814d5441f54cd88 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Mon, 10 May 2010 06:31:38 -0700 Subject: Allow the use of the type query parameter to filter the results of a rest/gallery/items?urls=... request. This allows the client to pass the entire list of member urls and have the rest server filter the results based on the specified types. (cherry picked from commit 3fe10b15cf9359b66452c24965df575203e8af8e) --- modules/gallery/helpers/items_rest.php | 22 ++++-- modules/gallery/tests/Items_Rest_Helper_Test.php | 85 ++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 4 deletions(-) diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 4f50e434..32597a65 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -19,23 +19,37 @@ */ class items_rest_Core { /** - * To retrieve a collection of items, you can specify the following query parameters to specify the - * type of the collection. If both are specified, then the url parameter is used and the - * ancestor_for is ignored. + * To retrieve a collection of items, you can specify the following query parameters to specify + * the type of the collection. If both are specified, then the url parameter is used and the + * ancestor_for is ignored. Specifying the "type" parameter with the urls parameter, will + * filter the results based on the specified type. Using the type parameter with the + * ancestor_for parameter makes no sense and will be ignored. * * urls=url1,url2,url3 * return items that match the specified urls. Typically used to return the member detail * * ancestor_for=url * return the ancestors of the specified item + * + * type=<comma separate list of photo, movie or album> + * limit the type to types in this list. eg, "type=photo,movie" */ static function get($request) { $items = array(); if (isset($request->params->urls)) { foreach (json_decode($request->params->urls) as $url) { + if (isset($request->params->type)) { + $types = explode(",", $request->params->type); + } $item = rest::resolve($url); if (access::can("view", $item)) { - $items[] = items_rest::format_restful_item($item); + if (isset($types)) { + if (in_array($item->type, $types)) { + $items[] = items_rest::format_restful_item($item); + } + } else { + $items[] = items_rest::format_restful_item($item); + } } } } else if (isset($request->params->ancestor_for)) { diff --git a/modules/gallery/tests/Items_Rest_Helper_Test.php b/modules/gallery/tests/Items_Rest_Helper_Test.php index cd01ae0c..94bf912a 100644 --- a/modules/gallery/tests/Items_Rest_Helper_Test.php +++ b/modules/gallery/tests/Items_Rest_Helper_Test.php @@ -50,6 +50,91 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { items_rest::get($request)); } + public function get_url_filter_album_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->urls = json_encode(array( + rest::url("item", $photo1), + rest::url("item", $album2))); + $request->params->type = "album"; + $this->assert_equal_array( + array( + array("url" => rest::url("item", $album2), + "entity" => $album2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album2), + "members" => array())), + "members" => array( + rest::url("item", $photo2)))), + items_rest::get($request)); + } + + public function get_url_filter_photo_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->urls = json_encode(array( + rest::url("item", $photo1), + rest::url("item", $album2))); + $request->params->type = "photo"; + $this->assert_equal_array( + array( + array("url" => rest::url("item", $photo1), + "entity" => $photo1->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $photo1), + "members" => array())))), + items_rest::get($request)); + } + + public function get_url_filter_albums_photos_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + $album2 = test::random_album($album1); + $photo2 = test::random_photo($album2); + $album1->reload(); + $album2->reload(); + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->urls = json_encode(array( + rest::url("item", $photo1), + rest::url("item", $album2))); + $request->params->type = "photo,album"; + $this->assert_equal_array( + array( + array("url" => rest::url("item", $photo1), + "entity" => $photo1->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $photo1), + "members" => array()))), + array("url" => rest::url("item", $album2), + "entity" => $album2->as_restful_array(), + "relationships" => array( + "tags" => array( + "url" => rest::url("item_tags", $album2), + "members" => array())), + "members" => array( + rest::url("item", $photo2)))), + items_rest::get($request)); + } + public function get_ancestor_test() { $album1 = test::random_album(); $photo1 = test::random_photo($album1); -- cgit v1.2.3 From 686da5a3e069d180e198fcc8dc3e2ed422f725b9 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Tue, 18 May 2010 06:16:47 -0700 Subject: Save the item before updating the order of the children. Also always increment the weight count (even if it is equal to the weight of the current child) --- modules/gallery/helpers/item_rest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 36d2ca62..298c2f4a 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -126,18 +126,19 @@ class item_rest_Core { } } } + $item->save(); - $weight = 0; if (isset($request->params->members)) { + $weight = 0; foreach ($request->params->members as $url) { $child = rest::resolve($url); if ($child->parent_id == $item->id && $child->weight != $weight) { - $child->weight = $weight++; + $child->weight = $weight; $child->save(); } + $weight++; } } - $item->save(); } static function post($request) { -- cgit v1.2.3 From ed1905d3f94847a64656e52858de8c363c001df7 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 4 Jun 2010 11:22:51 -0700 Subject: Change the name of the private format_restful_item to _format_restful_item so that the File_Structure_Test will pass. --- modules/gallery/helpers/items_rest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 32597a65..32f6c036 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -45,10 +45,10 @@ class items_rest_Core { if (access::can("view", $item)) { if (isset($types)) { if (in_array($item->type, $types)) { - $items[] = items_rest::format_restful_item($item); + $items[] = items_rest::_format_restful_item($item); } } else { - $items[] = items_rest::format_restful_item($item); + $items[] = items_rest::_format_restful_item($item); } } } @@ -57,9 +57,9 @@ class items_rest_Core { if (!access::can("view", $item)) { throw new Kohana_404_Exception(); } - $items[] = items_rest::format_restful_item($item); + $items[] = items_rest::_format_restful_item($item); while (($item = $item->parent()) != null) { - array_unshift($items, items_rest::format_restful_item($item)); + array_unshift($items, items_rest::_format_restful_item($item)); }; } @@ -74,7 +74,7 @@ class items_rest_Core { return $item; } - private static function format_restful_item($item) { + private static function _format_restful_item($item) { $item_rest = array("url" => rest::url("item", $item), "entity" => $item->as_restful_array(), "relationships" => rest::relationships("item", $item)); -- cgit v1.2.3 From fd437aec2bbd3e65b330b0790af970ca7e078636 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 4 Jun 2010 13:58:49 -0700 Subject: Correct XSS Security Test golden file for recent changes. Update the controller_auth data file for the rename of admin_comments to admin_manage_comments. --- modules/gallery/tests/controller_auth_data.txt | 2 +- modules/gallery/tests/xss_data.txt | 37 +++++++++++++------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/modules/gallery/tests/controller_auth_data.txt b/modules/gallery/tests/controller_auth_data.txt index 0aa26057..94e7a07f 100644 --- a/modules/gallery/tests/controller_auth_data.txt +++ b/modules/gallery/tests/controller_auth_data.txt @@ -1,4 +1,4 @@ -modules/comment/controllers/admin_comments.php queue DIRTY_CSRF +modules/comment/controllers/admin_manage_comments.php queue DIRTY_CSRF modules/comment/helpers/comment_rss.php feed DIRTY_AUTH modules/digibug/controllers/digibug.php print_proxy DIRTY_CSRF|DIRTY_AUTH modules/digibug/controllers/digibug.php close_window DIRTY_AUTH diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index afad9e13..0a75d6f7 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -4,21 +4,21 @@ modules/akismet/views/admin_akismet_stats.html.php 9 DIRTY_ATTR urle modules/comment/views/admin_block_recent_comments.html.php 4 DIRTY_ATTR text::alternate("g-even","g-odd") modules/comment/views/admin_block_recent_comments.html.php 5 DIRTY_ATTR $comment->author()->avatar_url(32,$theme->url(,true)) modules/comment/views/admin_block_recent_comments.html.php 10 DIRTY gallery::date_time($comment->created) -modules/comment/views/admin_comments.html.php 43 DIRTY $menu->render() -modules/comment/views/admin_comments.html.php 107 DIRTY_ATTR $comment->id -modules/comment/views/admin_comments.html.php 107 DIRTY_ATTR text::alternate("g-odd","g-even") -modules/comment/views/admin_comments.html.php 110 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) -modules/comment/views/admin_comments.html.php 123 DIRTY_JS $item->url() -modules/comment/views/admin_comments.html.php 125 DIRTY_ATTR $item->thumb_url() -modules/comment/views/admin_comments.html.php 127 DIRTY photo::img_dimensions($item->thumb_width,$item->thumb_height,75) -modules/comment/views/admin_comments.html.php 135 DIRTY gallery::date($comment->created) -modules/comment/views/admin_comments.html.php 142 DIRTY_JS $comment->id -modules/comment/views/admin_comments.html.php 151 DIRTY_JS $comment->id -modules/comment/views/admin_comments.html.php 160 DIRTY_JS $comment->id -modules/comment/views/admin_comments.html.php 169 DIRTY_JS $comment->id -modules/comment/views/admin_comments.html.php 176 DIRTY_JS $comment->id -modules/comment/views/admin_comments.html.php 184 DIRTY_JS $comment->id -modules/comment/views/admin_comments.html.php 197 DIRTY $pager +modules/comment/views/admin_manage_comments.html.php 43 DIRTY $menu->render() +modules/comment/views/admin_manage_comments.html.php 107 DIRTY_ATTR $comment->id +modules/comment/views/admin_manage_comments.html.php 107 DIRTY_ATTR text::alternate("g-odd","g-even") +modules/comment/views/admin_manage_comments.html.php 110 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) +modules/comment/views/admin_manage_comments.html.php 123 DIRTY_JS $item->url() +modules/comment/views/admin_manage_comments.html.php 125 DIRTY_ATTR $item->thumb_url() +modules/comment/views/admin_manage_comments.html.php 127 DIRTY photo::img_dimensions($item->thumb_width,$item->thumb_height,75) +modules/comment/views/admin_manage_comments.html.php 135 DIRTY gallery::date($comment->created) +modules/comment/views/admin_manage_comments.html.php 142 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments.html.php 151 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments.html.php 160 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments.html.php 169 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments.html.php 176 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments.html.php 184 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments.html.php 197 DIRTY $pager modules/comment/views/comment.html.php 2 DIRTY_ATTR $comment->id; modules/comment/views/comment.html.php 5 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) modules/comment/views/comment.mrss.php 10 DIRTY $feed->uri @@ -175,7 +175,7 @@ modules/gallery/views/move_tree.html.php 15 DIRTY_JS $child modules/gallery/views/movieplayer.html.php 2 DIRTY html::anchor($item->file_url(true),"",$attrs) modules/gallery/views/movieplayer.html.php 5 DIRTY_JS $attrs["id"] modules/gallery/views/movieplayer.html.php 7 DIRTY_JS url::abs_file("lib/flowplayer.swf") -modules/gallery/views/movieplayer.html.php 13 DIRTY_JS url::abs_file("lib/flowplayer.h264streaming.swf") +modules/gallery/views/movieplayer.html.php 14 DIRTY_JS url::abs_file("lib/flowplayer.pseudostreaming.swf") modules/gallery/views/permissions_browse.html.php 3 DIRTY_JS url::site("permissions/form/__ITEM__") modules/gallery/views/permissions_browse.html.php 16 DIRTY_JS url::site("permissions/change/__CMD__/__GROUP__/__PERM__/__ITEM__?csrf=$csrf") modules/gallery/views/permissions_browse.html.php 43 DIRTY_ATTR $parent->id @@ -320,7 +320,6 @@ modules/user/views/admin_users_group.html.php 24 DIRTY_JS $group modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $width modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $height modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $url -themes/admin_wind/views/admin.html.php 9 DIRTY $page_title themes/admin_wind/views/admin.html.php 22 DIRTY_JS $theme->url() themes/admin_wind/views/admin.html.php 39 DIRTY $theme->admin_head() themes/admin_wind/views/admin.html.php 43 DIRTY $theme->admin_page_top() @@ -363,7 +362,7 @@ themes/wind/views/dynamic.html.php 16 DIRTY_ATTR $chi themes/wind/views/dynamic.html.php 17 DIRTY_ATTR $child->thumb_height themes/wind/views/dynamic.html.php 29 DIRTY $theme->paginator() themes/wind/views/movie.html.php 5 DIRTY $theme->paginator() -themes/wind/views/movie.html.php 8 DIRTY $item->movie_img(array("class"=>"g-movie","id"=>"g-movie-id-{$item->id}")) +themes/wind/views/movie.html.php 8 DIRTY $item->movie_img(array("class"=>"g-movie","id"=>"g-item-id-{$item->id}")) themes/wind/views/page.html.php 9 DIRTY $page_title themes/wind/views/page.html.php 33 DIRTY_JS $theme->url() themes/wind/views/page.html.php 42 DIRTY $new_width @@ -384,4 +383,4 @@ themes/wind/views/photo.html.php 8 DIRTY_JS $theme themes/wind/views/photo.html.php 8 DIRTY_JS $theme->item()->height themes/wind/views/photo.html.php 18 DIRTY $theme->paginator() themes/wind/views/photo.html.php 23 DIRTY_JS $item->file_url() -themes/wind/views/photo.html.php 25 DIRTY $item->resize_img(array("id"=>"g-photo-id-{$item->id}","class"=>"g-resize")) +themes/wind/views/photo.html.php 25 DIRTY $item->resize_img(array("id"=>"g-item-id-{$item->id}","class"=>"g-resize")) -- cgit v1.2.3 From 481ef823dd04daff736b5a98472322e28bd4e756 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 5 Jun 2010 19:45:15 -0700 Subject: Add an advanced setting to allow developers to allow guest access to REST entities. --- modules/rest/helpers/rest.php | 7 ++++++- modules/rest/helpers/rest_installer.php | 8 +++++++- modules/rest/module.info | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php index 49999520..72927c71 100644 --- a/modules/rest/helpers/rest.php +++ b/modules/rest/helpers/rest.php @@ -39,7 +39,12 @@ class rest_Core { static function set_active_user($access_key) { if (empty($access_key)) { - throw new Rest_Exception("Forbidden", 403); + if (module::get_var("rest", "allow_guest_access")) { + identity::set_active_user(identity::guest()); + return; + } else { + throw new Rest_Exception("Forbidden", 403); + } } $key = ORM::factory("user_access_key") diff --git a/modules/rest/helpers/rest_installer.php b/modules/rest/helpers/rest_installer.php index aeb9573e..c2694a29 100644 --- a/modules/rest/helpers/rest_installer.php +++ b/modules/rest/helpers/rest_installer.php @@ -28,7 +28,8 @@ class rest_installer { UNIQUE KEY(`access_key`), UNIQUE KEY(`user_id`)) DEFAULT CHARSET=utf8;"); - module::set_version("rest", 2); + module::set_var("rest", "allow_guest_access", false); + module::set_version("rest", 3); } static function upgrade($version) { @@ -37,6 +38,11 @@ class rest_installer { $db->query("RENAME TABLE {user_access_tokens} TO {user_access_keys}"); module::set_version("rest", $version = 2); } + + if ($version == 2) { + module::set_var("rest", "allow_guest_access", false); + module::set_version("rest", $version = 3); + } } static function uninstall() { diff --git a/modules/rest/module.info b/modules/rest/module.info index 3ab7e165..4b6b5464 100644 --- a/modules/rest/module.info +++ b/modules/rest/module.info @@ -1,4 +1,4 @@ name = "REST Access Module" description = "The RESTful implementation/interface to Gallery3" -version = 2 +version = 3 -- cgit v1.2.3 From 0350cf3cd85d0ca89d3a9fb1385d43350d3df9aa Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 5 Jun 2010 22:50:20 -0700 Subject: Fix a comment typo. --- modules/gallery/helpers/module.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index 18d65ed5..12cec38c 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -215,7 +215,7 @@ class module_Core { } } - // Now the module is upgraded so deactivate it, but we can'it deactivae gallery or the + // Now the module is upgraded so deactivate it, but we can't deactivate gallery or the // current identity provider. $identity_provider = module::get_var("gallery", "identity_provider", "user"); if (!in_array($module_name, array("gallery", $identity_provider)) ) { -- cgit v1.2.3 From 10895ca5298dc71410cfd87fe8a28c4f976c2234 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 5 Jun 2010 23:04:23 -0700 Subject: Undo the change added in e4eedbce2298535540cb651d75ba6f1bf42cf02b which deactivates modules on upgrade. No idea why we did that, but it breaks upgrading because it deactivates any module that's been upgraded. --- modules/gallery/helpers/module.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index 12cec38c..5134c7b3 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -214,13 +214,6 @@ class module_Core { throw new Exception("@todo UNKNOWN_MODULE"); } } - - // Now the module is upgraded so deactivate it, but we can't deactivate gallery or the - // current identity provider. - $identity_provider = module::get_var("gallery", "identity_provider", "user"); - if (!in_array($module_name, array("gallery", $identity_provider)) ) { - self::deactivate($module_name); - } module::load_modules(); $version_after = module::get_version($module_name); -- cgit v1.2.3 From 87fde3f360d557d48241d09cae4f25949e748d4f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 5 Jun 2010 23:35:32 -0700 Subject: Create a UI under Admin > Settings > Comments where you can limit comments only to registered users. It's simplistic, but is better than adding a permission since generally this setting will be used Gallery-wide. Fixes ticket #1002 --- modules/comment/controllers/admin_comments.php | 52 ++++++++++++++++++++++++++ modules/comment/controllers/comments.php | 6 +++ modules/comment/helpers/comment.php | 5 +++ modules/comment/helpers/comment_event.php | 2 - modules/comment/helpers/comment_installer.php | 8 +++- modules/comment/module.info | 2 +- modules/comment/views/admin_comments.html.php | 7 ++++ modules/comment/views/comments.html.php | 5 ++- 8 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 modules/comment/controllers/admin_comments.php create mode 100644 modules/comment/views/admin_comments.html.php diff --git a/modules/comment/controllers/admin_comments.php b/modules/comment/controllers/admin_comments.php new file mode 100644 index 00000000..fda3873c --- /dev/null +++ b/modules/comment/controllers/admin_comments.php @@ -0,0 +1,52 @@ +<?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 Admin_Comments_Controller extends Admin_Controller { + public function index() { + $view = new Admin_View("admin.html"); + $view->page_title = t("Comment settings"); + $view->content = new View("admin_comments.html"); + $view->content->form = $this->_get_admin_form(); + print $view; + } + + public function save() { + access::verify_csrf(); + $form = $this->_get_admin_form(); + $form->validate(); + module::set_var("comment", "access_permissions", + $form->comment_settings->access_permissions->value); + message::success(t("Comment settings updated")); + url::redirect("admin/comments"); + } + + private function _get_admin_form() { + $form = new Forge("admin/comments/save", "", "post", + array("id" => "g-comments-admin-form")); + $comment_settings = $form->group("comment_settings")->label(t("Permissions")); + $comment_settings->dropdown("access_permissions") + ->label(t("Who can leave comments?")) + ->options(array("everybody" => t("Everybody"), + "registered_users" => t("Only registered users"))) + ->selected(module::get_var("comment", "access_permissions")); + $comment_settings->submit("save")->value(t("Save")); + return $form; + } +} + diff --git a/modules/comment/controllers/comments.php b/modules/comment/controllers/comments.php index 465b1bcd..c42ad24e 100644 --- a/modules/comment/controllers/comments.php +++ b/modules/comment/controllers/comments.php @@ -24,6 +24,9 @@ class Comments_Controller extends Controller { public function create($id) { $item = ORM::factory("item", $id); access::required("view", $item); + if (!comment::can_comment()) { + access::forbidden(); + } $form = comment::get_add_form($item); try { @@ -69,6 +72,9 @@ class Comments_Controller extends Controller { public function form_add($item_id) { $item = ORM::factory("item", $item_id); access::required("view", $item); + if (!comment::can_comment()) { + access::forbidden(); + } print comment::prefill_add_form(comment::get_add_form($item)); } diff --git a/modules/comment/helpers/comment.php b/modules/comment/helpers/comment.php index 94b14d0d..92a286c7 100644 --- a/modules/comment/helpers/comment.php +++ b/modules/comment/helpers/comment.php @@ -60,5 +60,10 @@ class comment_Core { } return $form; } + + static function can_comment() { + return !identity::active_user()->guest || + module::get_var("comment", "access_permissions") == "everybody"; + } } diff --git a/modules/comment/helpers/comment_event.php b/modules/comment/helpers/comment_event.php index 25fd4171..33d4cd05 100644 --- a/modules/comment/helpers/comment_event.php +++ b/modules/comment/helpers/comment_event.php @@ -51,13 +51,11 @@ class comment_event_Core { } static function admin_menu($menu, $theme) { - /* $menu->get("settings_menu") ->append(Menu::factory("link") ->id("comment") ->label(t("Comments")) ->url(url::site("admin/comments"))); - */ $menu->get("content_menu") ->append(Menu::factory("link") diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index 9ca47f1a..7a32bf67 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -47,7 +47,8 @@ class comment_installer { DEFAULT CHARSET=utf8;"); module::set_var("comment", "spam_caught", 0); - module::set_version("comment", 2); + module::set_var("comment", "access_permissions", "everybody"); + module::set_version("comment", 3); } static function upgrade($version) { @@ -56,6 +57,11 @@ class comment_installer { $db->query("ALTER TABLE {comments} CHANGE `state` `state` varchar(15) default 'unpublished'"); module::set_version("comment", 2); } + + if ($version == 2) { + module::set_var("comment", "access_permissions", "everybody"); + module::set_version("comment", 3); + } } static function uninstall() { diff --git a/modules/comment/module.info b/modules/comment/module.info index c371cf27..cd34f140 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -1,3 +1,3 @@ name = "Comments" description = "Allows users and guests to leave comments on photos and albums." -version = 2 +version = 3 diff --git a/modules/comment/views/admin_comments.html.php b/modules/comment/views/admin_comments.html.php new file mode 100644 index 00000000..dc6985b2 --- /dev/null +++ b/modules/comment/views/admin_comments.html.php @@ -0,0 +1,7 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<div class="g-block"> + <h1> <?= t("Comment settings") ?> </h1> + <div class="g-block-content"> + <?= $form ?> + </div> +</div> diff --git a/modules/comment/views/comments.html.php b/modules/comment/views/comments.html.php index e4322e08..9a608a43 100644 --- a/modules/comment/views/comments.html.php +++ b/modules/comment/views/comments.html.php @@ -1,9 +1,12 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> - <a href="<?= url::site("form/add/comments/{$item->id}") ?>#comment-form" id="g-add-comment" +<? if (comment::can_comment()): ?> +<a href="<?= url::site("form/add/comments/{$item->id}") ?>#comment-form" id="g-add-comment" class="g-button ui-corner-all ui-icon-left ui-state-default"> <span class="ui-icon ui-icon-comment"></span> <?= t("Add a comment") ?> </a> +<? endif ?> + <div id="g-comment-detail"> <? if (!$comments->count()): ?> <p class="g-no-comments"> -- cgit v1.2.3 From 4e56176f35fe624d2d3a587636a4a45ea387be09 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 5 Jun 2010 23:47:47 -0700 Subject: item::random_query() doesn't need to take a "where" clause because it's returning a query, so the caller can add the where clause himself. This makes for a cleaner API. --- modules/gallery/helpers/item.php | 5 +---- modules/image_block/helpers/image_block_block.php | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 43c93225..bbbe1058 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -209,17 +209,14 @@ class item_Core { /** * Return a query to get a random Item_Model, with optional filters - * - * @param array (optional) where tuple */ - static function random_query($where=null) { + static function random_query() { // Pick a random number and find the item that's got nearest smaller number. // This approach works best when the random numbers in the system are roughly evenly // distributed so this is going to be more efficient with larger data sets. return ORM::factory("item") ->viewable() ->where("rand_key", "<", ((float)mt_rand()) / (float)mt_getrandmax()) - ->merge_where($where) ->order_by("rand_key", "DESC"); } } \ No newline at end of file diff --git a/modules/image_block/helpers/image_block_block.php b/modules/image_block/helpers/image_block_block.php index 51ccc4a0..da6e8782 100644 --- a/modules/image_block/helpers/image_block_block.php +++ b/modules/image_block/helpers/image_block_block.php @@ -31,7 +31,7 @@ class image_block_block_Core { // @todo Consider another fallback if further optimizations are necessary. $attempts = 0; do { - $item = item::random_query(array(array("type", "!=", "album")))->find_all(1)->current(); + $item = item::random_query()->where("type", "!=", "album")->find_all(1)->current(); } while (!$item && $attempts++ < 3); if ($item && $item->loaded()) { $block = new Block(); -- cgit v1.2.3 From e1d3b0295d0f6d098a7b5563aa1f5b6af247319f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sun, 6 Jun 2010 12:42:16 -0700 Subject: Change "ancestor_for" to "ancestors_for" for consistency. --- modules/gallery/helpers/items_rest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 32f6c036..9cca9a54 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -21,14 +21,14 @@ class items_rest_Core { /** * To retrieve a collection of items, you can specify the following query parameters to specify * the type of the collection. If both are specified, then the url parameter is used and the - * ancestor_for is ignored. Specifying the "type" parameter with the urls parameter, will + * ancestors_for is ignored. Specifying the "type" parameter with the urls parameter, will * filter the results based on the specified type. Using the type parameter with the - * ancestor_for parameter makes no sense and will be ignored. + * ancestors_for parameter makes no sense and will be ignored. * * urls=url1,url2,url3 * return items that match the specified urls. Typically used to return the member detail * - * ancestor_for=url + * ancestors_for=url * return the ancestors of the specified item * * type=<comma separate list of photo, movie or album> @@ -52,8 +52,8 @@ class items_rest_Core { } } } - } else if (isset($request->params->ancestor_for)) { - $item = rest::resolve($request->params->ancestor_for); + } else if (isset($request->params->ancestors_for)) { + $item = rest::resolve($request->params->ancestors_for); if (!access::can("view", $item)) { throw new Kohana_404_Exception(); } -- cgit v1.2.3 From aeee88031fed7029c3320800d237b69993e8b6d4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sun, 6 Jun 2010 13:06:08 -0700 Subject: Fix an unused variable caused by converting straight query params to $entity based params. --- modules/gallery/helpers/item_rest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 298c2f4a..c88f92d9 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -152,7 +152,7 @@ class item_rest_Core { $item->type = "album"; $item->parent_id = $parent->id; $item->name = $entity->name; - $item->title = isset($entity->title) ? $entity->title : $name; + $item->title = isset($entity->title) ? $entity->title : $entity->name; $item->description = isset($entity->description) ? $entity->description : null; $item->slug = isset($entity->slug) ? $entity->slug : null; $item->save(); -- cgit v1.2.3 From a63b0e8e8ba94288169aa673f3319711fc097b61 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sun, 6 Jun 2010 19:04:15 -0700 Subject: Whitespace fixes --- installer/installer.php | 62 ++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/installer/installer.php b/installer/installer.php index bd5fbff1..f9fd8827 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -187,45 +187,45 @@ class installer { } static function check_environment() { - if (!function_exists("mysql_query") && !function_exists("mysqli_set_charset")) { - $errors[] = "Gallery 3 requires a MySQL database, but PHP doesn't have either the <a href=\"http://php.net/mysql\">MySQL</a> or the <a href=\"http://php.net/mysqli\">MySQLi</a> extension."; - } + if (!function_exists("mysql_query") && !function_exists("mysqli_set_charset")) { + $errors[] = "Gallery 3 requires a MySQL database, but PHP doesn't have either the <a href=\"http://php.net/mysql\">MySQL</a> or the <a href=\"http://php.net/mysqli\">MySQLi</a> extension."; + } - if (!@preg_match("/^.$/u", utf8_encode("\xF1"))) { - $errors[] = "PHP is missing <a href=\"http://php.net/pcre\">Perl-Compatible Regular Expression</a> support."; - } + if (!@preg_match("/^.$/u", utf8_encode("\xF1"))) { + $errors[] = "PHP is missing <a href=\"http://php.net/pcre\">Perl-Compatible Regular Expression</a> support."; + } - if (!(function_exists("spl_autoload_register"))) { - $errors[] = "PHP is missing <a href=\"http://php.net/spl\">Standard PHP Library (SPL)</a> support"; - } + if (!(function_exists("spl_autoload_register"))) { + $errors[] = "PHP is missing <a href=\"http://php.net/spl\">Standard PHP Library (SPL)</a> support"; + } - if (!(class_exists("ReflectionClass"))) { - $errors[] = "PHP is missing <a href=\"http://php.net/reflection\">reflection</a> support"; - } + if (!(class_exists("ReflectionClass"))) { + $errors[] = "PHP is missing <a href=\"http://php.net/reflection\">reflection</a> support"; + } - if (!(function_exists("filter_list"))) { - $errors[] = "PHP is missing the <a href=\"http://php.net/filter\">filter extension</a>"; - } + if (!(function_exists("filter_list"))) { + $errors[] = "PHP is missing the <a href=\"http://php.net/filter\">filter extension</a>"; + } - if (!(extension_loaded("iconv"))) { - $errors[] = "PHP is missing the <a href=\"http://php.net/iconv\">iconv extension</a>"; - } + if (!(extension_loaded("iconv"))) { + $errors[] = "PHP is missing the <a href=\"http://php.net/iconv\">iconv extension</a>"; + } - if (!(extension_loaded("simplexml"))) { - $errors[] = "PHP is missing the <a href=\"http://php.net/simplexml\">SimpleXML extension</a>"; - } + if (!(extension_loaded("simplexml"))) { + $errors[] = "PHP is missing the <a href=\"http://php.net/simplexml\">SimpleXML extension</a>"; + } - if (!extension_loaded("mbstring")) { - $errors[] = "PHP is missing the <a href=\"http://php.net/mbstring\">mbstring extension</a>"; - } else if (ini_get("mbstring.func_overload") & MB_OVERLOAD_STRING) { - $errors[] = "The <a href=\"http://php.net/mbstring\">mbstring extension</a> is overloading PHP's native string functions. Please disable it."; - } + if (!extension_loaded("mbstring")) { + $errors[] = "PHP is missing the <a href=\"http://php.net/mbstring\">mbstring extension</a>"; + } else if (ini_get("mbstring.func_overload") & MB_OVERLOAD_STRING) { + $errors[] = "The <a href=\"http://php.net/mbstring\">mbstring extension</a> is overloading PHP's native string functions. Please disable it."; + } - if (!function_exists("json_encode")) { - $errors[] = "PHP is missing the <a href=\"http://php.net/manual/en/book.json.php\">JavaScript Object Notation (JSON) extension</a>. Please install it."; - } + if (!function_exists("json_encode")) { + $errors[] = "PHP is missing the <a href=\"http://php.net/manual/en/book.json.php\">JavaScript Object Notation (JSON) extension</a>. Please install it."; + } - return @$errors; -} + return @$errors; + } } -- cgit v1.2.3 From c31e9f1188934d0515210c6c0c4b6bb23ca437f0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sun, 6 Jun 2010 19:06:24 -0700 Subject: Add a check for short_open_tag --- installer/installer.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/installer/installer.php b/installer/installer.php index f9fd8827..53a5e3db 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -225,6 +225,10 @@ class installer { $errors[] = "PHP is missing the <a href=\"http://php.net/manual/en/book.json.php\">JavaScript Object Notation (JSON) extension</a>. Please install it."; } + if (!ini_get("short_open_tag")) { + $errors[] = "Gallery requires <a href=\"http://php.net/manual/en/ini.core.php\">short_open_tag</a> to be on. Please enable it in your php.ini."; + } + return @$errors; } -- cgit v1.2.3 From 0c1fb039145c824147fbd587edc9332d82c1ac4b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sun, 6 Jun 2010 21:01:36 -0700 Subject: Updated to Exifer --- modules/exif/lib/exif.php | 602 +++++++++++++++++++--------------- modules/exif/lib/makers/canon.php | 15 +- modules/exif/lib/makers/fujifilm.php | 13 +- modules/exif/lib/makers/gps.php | 128 +++----- modules/exif/lib/makers/nikon.php | 301 ++++++++++------- modules/exif/lib/makers/olympus.php | 13 +- modules/exif/lib/makers/panasonic.php | 12 +- modules/exif/lib/makers/sanyo.php | 13 +- 8 files changed, 584 insertions(+), 513 deletions(-) diff --git a/modules/exif/lib/exif.php b/modules/exif/lib/exif.php index 189f61b5..8ba85c8e 100644 --- a/modules/exif/lib/exif.php +++ b/modules/exif/lib/exif.php @@ -140,6 +140,8 @@ + Fixed bug with newer Olympus cameras where number of fields was miscalculated leading to bad performance. + More logical fraction calculation for shutter speed. + +2009: For all further changes, see the Zenphoto change logs. */ @@ -160,13 +162,11 @@ function intel2Moto($intel) { $cache[$intel] = ''; $len = strlen($intel); - if ($len > 1000) { - debugLogBacktrace('intel2Moto called with unreasonable data string: length='.$len); - trigger_error(sprintf((string) t('intel2Moto called with unreasonable data string: length=%s. See debug log for details. (Setting DEBUG_EXIF to true might help locate problem images.)'),$len)); - } else { - for($i = 0; $i <= $len; $i += 2) { - $cache[$intel] .= substr($intel, $len-$i, 2); - } + if ($len > 1000) { // an unreasonable length, override it. + $len = 1000; + } + for($i = 0; $i <= $len; $i += 2) { + $cache[$intel] .= substr($intel, $len-$i, 2); } return $cache[$intel]; } @@ -212,7 +212,7 @@ function lookup_tag($tag) { case '8827': $tag = 'ISOSpeedRatings'; break; // integer 0-65535 case '9000': $tag = 'ExifVersion'; break; // ?? case '9003': $tag = 'DateTimeOriginal'; break; // YYYY:MM:DD HH:MM:SS - case '9004': $tag = 'DateTimedigitized'; break; // YYYY:MM:DD HH:MM:SS + case '9004': $tag = 'DateTimeDigitized'; break; // YYYY:MM:DD HH:MM:SS case '9101': $tag = 'ComponentsConfiguration'; break; // ?? case '9102': $tag = 'CompressedBitsPerPixel'; break; // positive rational number case '9201': $tag = 'ShutterSpeedValue'; break; // seconds or fraction of seconds 1/x @@ -348,258 +348,321 @@ function lookup_type(&$type,&$size) { } //================================================================================================ -// Formats Data for the data type +// processes a irrational number //================================================================================================ -function formatData($type,$tag,$intel,$data) { - - if ($type == 'ASCII') { - // Search for a null byte and stop there. - if (($pos = strpos($data, chr(0))) !== false) { - $data = substr($data, 0, $pos); - } - // Format certain kinds of strings nicely (Camera make etc.) - if ($tag == '010f') $data = ucwords(strtolower(trim($data))); - - } else if ($type == 'URATIONAL' || $type == 'SRATIONAL') { +function unRational($data, $type, $intel) { $data = bin2hex($data); - if ($intel == 1) $data = intel2Moto($data); - - if ($intel == 1) $top = hexdec(substr($data,8,8)); // intel stores them bottom-top - else $top = hexdec(substr($data,0,8)); // motorola stores them top-bottom - - if ($intel == 1) $bottom = hexdec(substr($data,0,8)); // intel stores them bottom-top - else $bottom = hexdec(substr($data,8,8)); // motorola stores them top-bottom + if ($intel == 1) { + $data = intel2Moto($data); + $top = hexdec(substr($data,8,8)); // intel stores them bottom-top + $bottom = hexdec(substr($data,0,8)); // intel stores them bottom-top + } else { + $top = hexdec(substr($data,0,8)); // motorola stores them top-bottom + $bottom = hexdec(substr($data,8,8)); // motorola stores them top-bottom + } if ($type == 'SRATIONAL' && $top > 2147483647) $top = $top - 4294967296; // this makes the number signed instead of unsigned - if ($bottom != 0) $data=$top/$bottom; - else if ($top == 0) $data = 0; - else $data = $top.'/'.$bottom; - - if (($tag == '011a' || $tag == '011b') && $bottom == 1) { // XResolution YResolution - $data = $top.' dots per ResolutionUnit'; - } else if ($tag == '829a') { // Exposure Time - if ($bottom != 0) { - $data = $top / $bottom; - } else { + if ($bottom != 0) + $data=$top/$bottom; + else + if ($top == 0) $data = 0; + else + $data = $top.'/'.$bottom; + return $data; +} + +//================================================================================================ +// processes a rational number +//================================================================================================ +function rational($data,$type,$intel) { + if (($type == 'USHORT' || $type == 'SSHORT')) { + $data = substr($data,0,2); + } + $data = bin2hex($data); + if ($intel == 1) { + $data = intel2Moto($data); + } + $data = hexdec($data); + if ($type == 'SSHORT' && $data > 32767) $data = $data - 65536; // this makes the number signed instead of unsigned + if ($type == 'SLONG' && $data > 2147483647) $data = $data - 4294967296; // this makes the number signed instead of unsigned + return $data; +} + +//================================================================================================ +// Formats Data for the data type +//================================================================================================ +function formatData($type,$tag,$intel,$data) { + switch ($type) { + case 'ASCII': + if (($pos = strpos($data, chr(0))) !== false) { // Search for a null byte and stop there. + $data = substr($data, 0, $pos); } - $data = formatExposure($data); - } else if ($tag == '829d') { // FNumber - $data = 'f/'.$data; - } else if ($tag == '9204') { // ExposureBiasValue - $data = round($data, 2) . ' EV'; - } else if ($tag == '9205' || $tag == '9202') { // ApertureValue and MaxApertureValue - // ApertureValue is given in the APEX Mode. Many thanks to Matthieu Froment for this code - // The formula is : Aperture = 2*log2(FNumber) <=> FNumber = e((Aperture.ln(2))/2) - $data = exp(($data*log(2))/2); - $data = round($data, 1);// Focal is given with a precision of 1 digit. - $data='f/'.$data; - } else if ($tag == '920a') { // FocalLength - $data = $data.' mm'; - } else if ($tag == '9201') { // ShutterSpeedValue - // The ShutterSpeedValue is given in the APEX mode. Many thanks to Matthieu Froment for this code - // The formula is : Shutter = - log2(exposureTime) (Appendix C of EXIF spec.) - // Where shutter is in APEX, log2(exposure) = ln(exposure)/ln(2) - // So final formula is : exposure = exp(-ln(2).shutter) - // The formula can be developed : exposure = 1/(exp(ln(2).shutter)) - $data = exp($data * log(2)); - if ($data != 0) $data = 1/$data; - $data = formatExposure($data); - } - - } else if ($type == 'USHORT' || $type == 'SSHORT' || $type == 'ULONG' || $type == 'SLONG' || $type == 'FLOAT' || $type == 'DOUBLE') { - $data = bin2hex($data); - if ($intel == 1) $data = intel2Moto($data); - if ($intel == 0 && ($type == 'USHORT' || $type == 'SSHORT')) $data = substr($data,0,4); - $data = hexdec($data); - - if ($type == 'SSHORT' && $data > 32767) $data = $data - 65536; // this makes the number signed instead of unsigned - if ($type == 'SLONG' && $data > 2147483647) $data = $data - 4294967296; // this makes the number signed instead of unsigned - - if ($tag == '0112') { // Orientation - // Example of how all of these tag formatters should be... - switch ($data) { - case 1 : $data = (string) t('1: Normal (0 deg)'); break; - case 2 : $data = (string) t('2: Mirrored'); break; - case 3 : $data = (string) t('3: Upsidedown'); break; - case 4 : $data = (string) t('4: Upsidedown Mirrored'); break; - case 5 : $data = (string) t('5: 90 deg CW Mirrored'); break; - case 6 : $data = (string) t('6: 90 deg CCW'); break; - case 7 : $data = (string) t('7: 90 deg CCW Mirrored'); break; - case 8 : $data = (string) t('8: 90 deg CW'); break; - default : $data = (string) t('Unknown').': '.$data; + if ($tag == '010f') $data = ucwords(strtolower(trim($data))); // Format certain kinds of strings nicely (Camera make etc.) + break; + case 'URATIONAL': + case 'SRATIONAL': + switch ($tag) { + case '011a': // XResolution + case '011b': // YResolution + $data = round(unRational($data,$type,$intel)).' dots per ResolutionUnit'; + break; + case '829a': // Exposure Time + $data = formatExposure(unRational($data,$type,$intel)); + break; + case '829d': // FNumber + $data = 'f/'.unRational($data,$type,$intel); + break; + case '9204': // ExposureBiasValue + $data = round(unRational($data,$type,$intel), 2) . ' EV'; + break; + case '9205': // ApertureValue + case '9202': // MaxApertureValue + // ApertureValue is given in the APEX Mode. Many thanks to Matthieu Froment for this code + // The formula is : Aperture = 2*log2(FNumber) <=> FNumber = e((Aperture.ln(2))/2) + $datum = exp((unRational($data,$type,$intel)*log(2))/2); + $data = round($datum, 1);// Focal is given with a precision of 1 digit. + $data='f/'.$datum; + break; + case '920a': // FocalLength + $data = unRational($data,$type,$intel).' mm'; + break; + case '9201': // ShutterSpeedValue + // The ShutterSpeedValue is given in the APEX mode. Many thanks to Matthieu Froment for this code + // The formula is : Shutter = - log2(exposureTime) (Appendix C of EXIF spec.) + // Where shutter is in APEX, log2(exposure) = ln(exposure)/ln(2) + // So final formula is : exposure = exp(-ln(2).shutter) + // The formula can be developed : exposure = 1/(exp(ln(2).shutter)) + $datum = exp(unRational($data,$type,$intel) * log(2)); + if ($datum != 0) $datum = 1/$datum; + $data = formatExposure($datum); + break; + default: + $data = unRational($data,$type,$intel); + break; } - - } else if ($tag == '0128' || $tag == 'a210' || $tag == '0128') { // ResolutionUnit and FocalPlaneResolutionUnit and ThumbnailResolutionUnit - if ($data == 1) $data = (string) t('No Unit'); - else if ($data == 2) $data = (string) t('Inch'); - else if ($data == 3) $data = (string) t('Centimeter'); - - } else if ($tag == '0213') { // YCbCrPositioning - if ($data == 1) $data = (string) t('Center of Pixel Array'); - else if ($data == 2) $data = (string) t('Datum Point'); - - } else if ($tag == '8822') { // ExposureProgram - if ($data == 1) $data = (string) t('Manual'); - else if ($data == 2) $data = (string) t('Program'); - else if ($data == 3) $data = (string) t('Aperture Priority'); - else if ($data == 4) $data = (string) t('Shutter Priority'); - else if ($data == 5) $data = (string) t('Program Creative'); - else if ($data == 6) $data = (string) t('Program Action'); - else if ($data == 7) $data = (string) t('Portrat'); - else if ($data == 8) $data = (string) t('Landscape'); - else $data = (string) t('Unknown').': '.$data; - - } else if ($tag == '9207') { // MeteringMode - if ($data == 0) $data = (string) t('Unknown'); - else if ($data == 1) $data = (string) t('Average'); - else if ($data == 2) $data = (string) t('Center Weighted Average'); - else if ($data == 3) $data = (string) t('Spot'); - else if ($data == 4) $data = (string) t('Multi-Spot'); - else if ($data == 5) $data = (string) t('Multi-Segment'); - else if ($data == 6) $data = (string) t('Partial'); - else if ($data == 255) $data = (string) t('Other'); - else $data = (string) t('Unknown').': '.$data; - - } else if ($tag == '9208') { // LightSource - if ($data == 0) $data = (string) t('Unknown or Auto'); - else if ($data == 1) $data = (string) t('Daylight'); - else if ($data == 2) $data = (string) t('Flourescent'); - else if ($data == 3) $data = (string) t('Tungsten'); // 3 Tungsten (Incandescent light) - // 4 Flash - // 9 Fine Weather - else if ($data == 10) $data = (string) t('Flash'); // 10 Cloudy Weather - // 11 Shade - // 12 Daylight Fluorescent (D 5700 - 7100K) - // 13 Day White Fluorescent (N 4600 - 5400K) - // 14 Cool White Fluorescent (W 3900 -4500K) - // 15 White Fluorescent (WW 3200 - 3700K) - // 10 Flash - else if ($data == 17) $data = (string) t('Standard Light A'); - else if ($data == 18) $data = (string) t('Standard Light B'); - else if ($data == 19) $data = (string) t('Standard Light C'); - else if ($data == 20) $data = (string) t('D55'); - else if ($data == 21) $data = (string) t('D65'); - else if ($data == 22) $data = (string) t('D75'); - else if ($data == 23) $data = (string) t('D50'); - else if ($data == 24) $data = (string) t('ISO Studio Tungsten'); - else if ($data == 255) $data = (string) t('Other'); - else $data = (string) t('Unknown').': '.$data; - - } else if ($tag == '9209') { // Flash - if ($data == 0) $data = (string) t('No Flash'); - else if ($data == 1) $data = (string) t('Flash'); - else if ($data == 5) $data = (string) t('Flash, strobe return light not detected'); - else if ($data == 7) $data = (string) t('Flash, strobe return light detected'); - else if ($data == 9) $data = (string) t('Compulsory Flash'); - else if ($data == 13) $data = (string) t('Compulsory Flash, Return light not detected'); - else if ($data == 15) $data = (string) t('Compulsory Flash, Return light detected'); - else if ($data == 16) $data = (string) t('No Flash'); - else if ($data == 24) $data = (string) t('No Flash'); - else if ($data == 25) $data = (string) t('Flash, Auto-Mode'); - else if ($data == 29) $data = (string) t('Flash, Auto-Mode, Return light not detected'); - else if ($data == 31) $data = (string) t('Flash, Auto-Mode, Return light detected'); - else if ($data == 32) $data = (string) t('No Flash'); - else if ($data == 65) $data = (string) t('Red Eye'); - else if ($data == 69) $data = (string) t('Red Eye, Return light not detected'); - else if ($data == 71) $data = (string) t('Red Eye, Return light detected'); - else if ($data == 73) $data = (string) t('Red Eye, Compulsory Flash'); - else if ($data == 77) $data = (string) t('Red Eye, Compulsory Flash, Return light not detected'); - else if ($data == 79) $data = (string) t('Red Eye, Compulsory Flash, Return light detected'); - else if ($data == 89) $data = (string) t('Red Eye, Auto-Mode'); - else if ($data == 93) $data = (string) t('Red Eye, Auto-Mode, Return light not detected'); - else if ($data == 95) $data = (string) t('Red Eye, Auto-Mode, Return light detected'); - else $data = (string) t('Unknown').': '.$data; - - } else if ($tag == 'a001') { // ColorSpace - if ($data == 1) $data = (string) t('sRGB'); - else $data = (string) t('Uncalibrated'); - - } else if ($tag == 'a002' || $tag == 'a003') { // ExifImageWidth/Height - $data = $data. ' '.(string) t('pixels'); - - } else if ($tag == '0103') { // Compression - if ($data == 1) $data = (string) t('No Compression'); - else if ($data == 6) $data = (string) t('Jpeg Compression'); - else $data = (string) t('Unknown').': '.$data; - - } else if ($tag == 'a217') { // SensingMethod - if ($data == 1) $data = (string) t('Not defined'); - if ($data == 2) $data = (string) t('One Chip Color Area Sensor'); - if ($data == 3) $data = (string) t('Two Chip Color Area Sensor'); - if ($data == 4) $data = (string) t('Three Chip Color Area Sensor'); - if ($data == 5) $data = (string) t('Color Sequential Area Sensor'); - if ($data == 7) $data = (string) t('Trilinear Sensor'); - if ($data == 8) $data = (string) t('Color Sequential Linear Sensor'); - else $data = (string) t('Unknown').': '.$data; - - } else if ($tag == '0106') { // PhotometricInterpretation - if ($data == 1) $data = (string) t('Monochrome'); - else if ($data == 2) $data = (string) t('RGB'); - else if ($data == 6) $data = (string) t('YCbCr'); - else $data = (string) t('Unknown').': '.$data; - } - //} else if($tag=="a408" || $tag=="a40a") { // Contrast, Sharpness - // switch($data) { - // case 0: $data="Normal"; break; - // case 1: $data="Soft"; break; - // case 2: $data="Hard"; break; - // default: $data="Unknown"; break; - // } - //} else if($tag=="a409") { // Saturation - // switch($data) { - // case 0: $data="Normal"; break; - // case 1: $data="Low saturation"; break; - // case 2: $data="High saturation"; break; - // default: $data="Unknown"; break; - // } - //} else if($tag=="a402") { // Exposure Mode - // switch($data) { - // case 0: $data="Auto exposure"; break; - // case 1: $data="Manual exposure"; break; - // case 2: $data="Auto bracket"; break; - // default: $data="Unknown"; break; - // } - - } else if ($type == 'UNDEFINED') { - - if ($tag == '9000' || $tag == 'a000' || $tag == '0002') { // ExifVersion,FlashPixVersion,InteroperabilityVersion - $data=(string) t('version').' '.$data/100; - } - if ($tag == 'a300') { // FileSource - $data = bin2hex($data); - $data = str_replace('00','',$data); - $data = str_replace('03',(string) t('Digital Still Camera'),$data); - } - if ($tag == 'a301') { // SceneType - $data = bin2hex($data); - $data = str_replace('00','',$data); - $data = str_replace('01',(string) t('Directly Photographed'),$data); - } - if ($tag == '9101') { // ComponentsConfiguration + break; + case 'USHORT': + case 'SSHORT': + case 'ULONG': + case 'SLONG': + case 'FLOAT': + case 'DOUBLE': + $data = rational($data,$type,$intel); + switch ($tag) { + case '0112': // Orientation + // Example of how all of these tag formatters should be... + switch ($data) { + case 0 : // not set, presume normal + case 1 : $data = (string) t('1: Normal (0 deg)'); break; + case 2 : $data = (string) t('2: Mirrored'); break; + case 3 : $data = (string) t('3: Upside-down'); break; + case 4 : $data = (string) t('4: Upside-down Mirrored'); break; + case 5 : $data = (string) t('5: 90 deg CW Mirrored'); break; + case 6 : $data = (string) t('6: 90 deg CCW'); break; + case 7 : $data = (string) t('7: 90 deg CCW Mirrored'); break; + case 8 : $data = (string) t('8: 90 deg CW'); break; + default : $data = sprintf((string) t('%d: Unknown'),$data); break; + } + break; + case '0128': // ResolutionUnit + case 'a210': // FocalPlaneResolutionUnit + case '0128': // ThumbnailResolutionUnit + switch ($data) { + case 1: $data = (string) t('No Unit'); break; + case 2: $data = (string) t('Inch'); break; + case 3: $data = (string) t('Centimeter'); break; + } + break; + case '0213': // YCbCrPositioning + switch ($data) { + case 1: $data = (string) t('Center of Pixel Array'); break; + case 2: $data = (string) t('Datum Point'); break; + } + break; + case '8822': // ExposureProgram + switch ($data) { + case 1: $data = (string) t('Manual'); break; + case 2: $data = (string) t('Program'); break; + case 3: $data = (string) t('Aperture Priority'); break; + case 4: $data = (string) t('Shutter Priority'); break; + case 5: $data = (string) t('Program Creative'); break; + case 6: $data = (string) t('Program Action'); break; + case 7: $data = (string) t('Portrait'); break; + case 8: $data = (string) t('Landscape'); break; + default: $data = (string) t('Unknown').': '.$data; break; + } + break; + case '9207': // MeteringMode + switch ($data) { + case 1: $data = (string) t('Average'); break; + case 2: $data = (string) t('Center Weighted Average'); break; + case 3: $data = (string) t('Spot'); break; + case 4: $data = (string) t('Multi-Spot'); break; + case 5: $data = (string) t('Pattern'); break; + case 6: $data = (string) t('Partial'); break; + case 255: $data = (string) t('Other'); break; + default: $data = (string) t('Unknown').': '.$data; break; + } + break; + case '9208': // LightSource + switch ($data) { + case 1: $data = (string) t('Daylight'); break; + case 2: $data = (string) t('Fluorescent'); break; + case 3: $data = (string) t('Tungsten'); break; // 3 Tungsten (Incandescent light) + // 4 Flash + // 9 Fine Weather + case 10: $data = (string) t('Flash'); break; // 10 Cloudy Weather + // 11 Shade + // 12 Daylight Fluorescent (D 5700 - 7100K) + // 13 Day White Fluorescent (N 4600 - 5400K) + // 14 Cool White Fluorescent (W 3900 -4500K) + // 15 White Fluorescent (WW 3200 - 3700K) + // 10 Flash + case 17: $data = (string) t('Standard Light A'); break; + case 18: $data = (string) t('Standard Light B'); break; + case 19: $data = (string) t('Standard Light C'); break; + case 20: $data = (string) t('D55'); break; + case 21: $data = (string) t('D65'); break; + case 22: $data = (string) t('D75'); break; + case 23: $data = (string) t('D50'); break; + case 24: $data = (string) t('ISO Studio Tungsten'); break; + case 255: $data = (string) t('Other'); break; + default: $data = (string) t('Unknown').': '.$data; break; + } + break; + case '9209': // Flash + switch ($data) { + case 0: $data = (string) t('No Flash'); break; + case 1: $data = (string) t('Flash'); break; + case 5: $data = (string) t('Flash, strobe return light not detected'); break; + case 7: $data = (string) t('Flash, strobe return light detected'); break; + case 9: $data = (string) t('Compulsory Flash'); break; + case 13: $data = (string) t('Compulsory Flash, Return light not detected'); break; + case 15: $data = (string) t('Compulsory Flash, Return light detected'); break; + case 16: $data = (string) t('No Flash'); break; + case 24: $data = (string) t('No Flash'); break; + case 25: $data = (string) t('Flash, Auto-Mode'); break; + case 29: $data = (string) t('Flash, Auto-Mode, Return light not detected'); break; + case 31: $data = (string) t('Flash, Auto-Mode, Return light detected'); break; + case 32: $data = (string) t('No Flash'); break; + case 65: $data = (string) t('Red Eye'); break; + case 69: $data = (string) t('Red Eye, Return light not detected'); break; + case 71: $data = (string) t('Red Eye, Return light detected'); break; + case 73: $data = (string) t('Red Eye, Compulsory Flash'); break; + case 77: $data = (string) t('Red Eye, Compulsory Flash, Return light not detected'); break; + case 79: $data = (string) t('Red Eye, Compulsory Flash, Return light detected'); break; + case 89: $data = (string) t('Red Eye, Auto-Mode'); break; + case 93: $data = (string) t('Red Eye, Auto-Mode, Return light not detected'); break; + case 95: $data = (string) t('Red Eye, Auto-Mode, Return light detected'); break; + default: $data = (string) t('Unknown').': '.$data; break; + } + break; + case 'a001': // ColorSpace + if ($data == 1) $data = (string) t('sRGB'); + else $data = (string) t('Uncalibrated'); + break; + case 'a002': // ExifImageWidth + case 'a003': // ExifImageHeight + $data = $data. ' '.(string) t('pixels'); + break; + case '0103': // Compression + switch ($data) { + case 1: $data = (string) t('No Compression'); break; + case 6: $data = (string) t('Jpeg Compression'); break; + default: $data = (string) t('Unknown').': '.$data; break; + } + break; + case 'a217': // SensingMethod + switch ($data) { + case 1: $data = (string) t('Not defined'); break; + case 2: $data = (string) t('One Chip Color Area Sensor'); break; + case 3: $data = (string) t('Two Chip Color Area Sensor'); break; + case 4: $data = (string) t('Three Chip Color Area Sensor'); break; + case 5: $data = (string) t('Color Sequential Area Sensor'); break; + case 7: $data = (string) t('Trilinear Sensor'); break; + case 8: $data = (string) t('Color Sequential Linear Sensor'); break; + default: $data = (string) t('Unknown').': '.$data; break; + } + break; + case '0106': // PhotometricInterpretation + switch ($data) { + case 1: $data = (string) t('Monochrome'); break; + case 2: $data = (string) t('RGB'); break; + case 6: $data = (string) t('YCbCr'); break; + default: $data = (string) t('Unknown').': '.$data; break; + } + break; + //case "a408": // Contrast + //case "a40a": //Sharpness + // switch($data) { + // case 0: $data="Normal"; break; + // case 1: $data="Soft"; break; + // case 2: $data="Hard"; break; + // default: $data="Unknown"; break; + // } + // break; + //case "a409": // Saturation + // switch($data) { + // case 0: $data="Normal"; break; + // case 1: $data="Low saturation"; break; + // case 2: $data="High saturation"; break; + // default: $data="Unknown"; break; + // } + // break; + //case "a402": // Exposure Mode + // switch($data) { + // case 0: $data="Auto exposure"; break; + // case 1: $data="Manual exposure"; break; + // case 2: $data="Auto bracket"; break; + // default: $data="Unknown"; break; + // } + // break; + } + break; + case 'UNDEFINED': + switch ($tag) { + case '9000': // ExifVersion + case 'a000': // FlashPixVersion + case '0002': // InteroperabilityVersion + $data=(string) t('version').' '.$data/100; + break; + case 'a300': // FileSource + $data = bin2hex($data); + $data = str_replace('00','',$data); + $data = str_replace('03',(string) t('Digital Still Camera'),$data); + break; + case 'a301': // SceneType + $data = bin2hex($data); + $data = str_replace('00','',$data); + $data = str_replace('01',(string) t('Directly Photographed'),$data); + break; + case '9101': // ComponentsConfiguration + $data = bin2hex($data); + $data = str_replace('01','Y',$data); + $data = str_replace('02','Cb',$data); + $data = str_replace('03','Cr',$data); + $data = str_replace('04','R',$data); + $data = str_replace('05','G',$data); + $data = str_replace('06','B',$data); + $data = str_replace('00','',$data); + break; + //case "9286": //UserComment + // $encoding = rtrim(substr($data, 0, 8)); + // $data = rtrim(substr($data, 8)); + // break; + } + break; + default: $data = bin2hex($data); - $data = str_replace('01','Y',$data); - $data = str_replace('02','Cb',$data); - $data = str_replace('03','Cr',$data); - $data = str_replace('04','R',$data); - $data = str_replace('05','G',$data); - $data = str_replace('06','B',$data); - $data = str_replace('00','',$data); - } - //if($tag=="9286") { //UserComment - // $encoding = rtrim(substr($data, 0, 8)); - // $data = rtrim(substr($data, 8)); - //} - } else { - $data = bin2hex($data); - if ($intel == 1) $data = intel2Moto($data); + if ($intel == 1) $data = intel2Moto($data); + break; } - return $data; } function formatExposure($data) { - if ($data > 0) { + if (strpos($data,'/')===false) { if ($data > 1) { return round($data, 2).' '.(string) t('sec'); } else { @@ -666,30 +729,30 @@ function read_entry(&$result,$in,$seek,$intel,$ifd_name,$globalOffset) { if ($result['VerboseOutput'] == 1) { $result[$ifd_name]['MakerNote']['RawData'] = $data; } - if (eregi('NIKON',$make)) { + if (preg_match('/NIKON/i',$make)) { require_once(dirname(__FILE__).'/makers/nikon.php'); parseNikon($data,$result); $result[$ifd_name]['KnownMaker'] = 1; - } else if (eregi('OLYMPUS',$make)) { + } else if (preg_match('/OLYMPUS/i',$make)) { require_once(dirname(__FILE__).'/makers/olympus.php'); parseOlympus($data,$result,$seek,$globalOffset); $result[$ifd_name]['KnownMaker'] = 1; - } else if (eregi('Canon',$make)) { + } else if (preg_match('/Canon/i',$make)) { require_once(dirname(__FILE__).'/makers/canon.php'); parseCanon($data,$result,$seek,$globalOffset); $result[$ifd_name]['KnownMaker'] = 1; - } else if (eregi('FUJIFILM',$make)) { + } else if (preg_match('/FUJIFILM/i',$make)) { require_once(dirname(__FILE__).'/makers/fujifilm.php'); parseFujifilm($data,$result); $result[$ifd_name]['KnownMaker'] = 1; - } else if (eregi('SANYO',$make)) { + } else if (preg_match('/SANYO/i',$make)) { require_once(dirname(__FILE__).'/makers/sanyo.php'); parseSanyo($data,$result,$seek,$globalOffset); $result[$ifd_name]['KnownMaker'] = 1; - } else if (eregi('Panasonic',$make)) { - require_once(dirname(__FILE__).'/makers/panasonic.php'); - parsePanasonic($data,$result,$seek,$globalOffset); - $result[$ifd_name]['KnownMaker'] = 1; + } else if (preg_match('/Panasonic/i',$make)) { + require_once(dirname(__FILE__).'/makers/panasonic.php'); + parsePanasonic($data,$result,$seek,$globalOffset); + $result[$ifd_name]['KnownMaker'] = 1; } else { $result[$ifd_name]['KnownMaker'] = 0; } @@ -709,9 +772,9 @@ function read_entry(&$result,$in,$seek,$intel,$ifd_name,$globalOffset) { $data = bin2hex($data); if ($intel == 1) $data = intel2Moto($data); } - $result[$ifd_name][$tag_name.'_Verbose']['RawData'] = $data; + $result[$ifd_name][$tag_name.'_Verbose']['RawData'] = $data; $result[$ifd_name][$tag_name.'_Verbose']['Type'] = $type; - $result[$ifd_name][$tag_name.'_Verbose']['Bytes'] = $bytesofdata; + $result[$ifd_name][$tag_name.'_Verbose']['Bytes'] = $bytesofdata; } } } @@ -912,7 +975,7 @@ if ($result['ValidJpeg'] == 1) { $v = fseek($in,$globalOffset+$ExitOffset); if ($v == -1) { $result['Errors'] = $result['Errors']+1; - $result['Error'][$result['Errors']] = (string) t('Couldnt Find SubIFD'); + $result['Error'][$result['Errors']] = (string) t('Could not Find SubIFD'); } //=========================================================== @@ -932,7 +995,12 @@ if ($result['ValidJpeg'] == 1) { } // Add the 35mm equivalent focal length: - $result['SubIFD']['FocalLength35mmEquiv'] = get35mmEquivFocalLength($result); + if (isset($result['IFD0']['FocalLengthIn35mmFilm']) && !isset($result['SubIFD']['FocalLengthIn35mmFilm'])) { // found in the wrong place + $result['SubIFD']['FocalLengthIn35mmFilm'] = $result['IFD0']['FocalLengthIn35mmFilm']; + } + if (!isset($result['SubIFD']['FocalLengthIn35mmFilm'])) { + $result['SubIFD']['FocalLengthIn35mmFilm'] = get35mmEquivFocalLength($result); + } // Check for IFD1 if (!isset($result['IFD1Offset']) || $result['IFD1Offset'] == 0) { @@ -944,7 +1012,7 @@ if ($result['ValidJpeg'] == 1) { $v = fseek($in,$globalOffset+$result['IFD1Offset']); if ($v == -1) { $result['Errors'] = $result['Errors']+1; - $result['Error'][$result['Errors']] = (string) t('Couldnt Find IFD1'); + $result['Error'][$result['Errors']] = (string) t('Could not Find IFD1'); } //=========================================================== @@ -984,7 +1052,7 @@ if ($result['ValidJpeg'] == 1) { $v = fseek($in,$globalOffset+$result['SubIFD']['ExifInteroperabilityOffset']); if ($v == -1) { $result['Errors'] = $result['Errors']+1; - $result['Error'][$result['Errors']] = (string) t('Couldnt Find InteroperabilityIFD'); + $result['Error'][$result['Errors']] = (string) t('Could not Find InteroperabilityIFD'); } //=========================================================== @@ -1029,7 +1097,7 @@ function ConvertToFraction($v, &$n, &$d) //================================================================================================ function get35mmEquivFocalLength(&$result) { if (isset($result['SubIFD']['ExifImageWidth'])) { - $width = $result['SubIFD']['ExifImageWidth']; + $width = $result['SubIFD']['ExifImageWidth']; } else { $width = 0; } @@ -1055,7 +1123,7 @@ function get35mmEquivFocalLength(&$result) { } else { $fl = 0; } - + if (($width != 0) && !empty($units) && !empty($xres) && !empty($fl) && !empty($width)) { $ccdwidth = ($width * $unitfactor) / $xres; $equivfl = $fl / $ccdwidth*36+0.5; @@ -1064,10 +1132,4 @@ function get35mmEquivFocalLength(&$result) { return null; } -if (!function_exists('debugLogBacktrace')) { - // define this function for stand-alone uses if exifier - function debugLogBacktrace($msg) { - } -} - ?> diff --git a/modules/exif/lib/makers/canon.php b/modules/exif/lib/makers/canon.php index 75cf0b7b..aecd266d 100644 --- a/modules/exif/lib/makers/canon.php +++ b/modules/exif/lib/makers/canon.php @@ -40,6 +40,7 @@ function lookup_Canon_tag($tag) { case "0009": $tag = "OwnerName";break; case "000c": $tag = "CameraSerialNumber";break; case "000f": $tag = "CustomFunctions";break; + case "0095": $tag = "LensInfo";break; default: $tag = "unknown:".$tag;break; } @@ -57,13 +58,7 @@ function formatCanonData($type,$tag,$intel,$data,$exif,&$result) { if($type=="ASCII") { $result = $data = str_replace("\0", "", $data); } else if($type=="URATIONAL" || $type=="SRATIONAL") { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - $top = hexdec(substr($data,8,8)); - $bottom = hexdec(substr($data,0,8)); - if($bottom!=0) $data=$top/$bottom; - else if($top==0) $data = 0; - else $data=$top."/".$bottom; + $data = unRational($data,$type,$intel); if($tag=="0204") { //DigitalZoom $data=$data."x"; @@ -71,7 +66,7 @@ function formatCanonData($type,$tag,$intel,$data,$exif,&$result) { } else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") { - $data = bin2hex($data); + $data = rational($data,$type,$intel); $result['RAWDATA'] = $data; if($tag=="0001") { //first chunk @@ -377,20 +372,18 @@ function parseCanon($block,&$result,$seek, $globalOffset) { //2 byte type $type = bin2hex(substr($block,$place,2));$place+=2; if($intel==1) $type = intel2Moto($type); - lookup_type($type,$size); + lookup_type($type,$size); //4 byte count of number of data units $count = bin2hex(substr($block,$place,4));$place+=4; if($intel==1) $count = intel2Moto($count); $bytesofdata = $size*hexdec($count); - if($bytesofdata<=0) { return; //if this value is 0 or less then we have read all the tags we can } //4 byte value of data or pointer to data $value = substr($block,$place,4);$place+=4; - if($bytesofdata<=4) { $data = $value; } else { diff --git a/modules/exif/lib/makers/fujifilm.php b/modules/exif/lib/makers/fujifilm.php index a88e51c3..a1f2f416 100644 --- a/modules/exif/lib/makers/fujifilm.php +++ b/modules/exif/lib/makers/fujifilm.php @@ -44,7 +44,6 @@ function lookup_Fujifilm_tag($tag) { case "1021": $tag = "FocusMode";break; case "1030": $tag = "SlowSync";break; case "1031": $tag = "PictureMode";break; - case "1032": $tag = "Unknown";break; case "1100": $tag = "ContinuousTakingBracket";break; case "1200": $tag = "Unknown";break; case "1300": $tag = "BlurWarning";break; @@ -66,22 +65,14 @@ function formatFujifilmData($type,$tag,$intel,$data) { } else if($type=="URATIONAL" || $type=="SRATIONAL") { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - $top = hexdec(substr($data,8,8)); - $bottom = hexdec(substr($data,0,8)); - if($bottom!=0) $data=$top/$bottom; - else if($top==0) $data = 0; - else $data=$top."/".$bottom; + $data = unRational($data,$type,$intel); if($tag=="1011") { //FlashStrength $data=$data." EV"; } } else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - $data=hexdec($data); + $data =rational($data,$type,$intel); if($tag=="1001") { //Sharpness if($data == 1) $data = (string) t("Soft"); diff --git a/modules/exif/lib/makers/gps.php b/modules/exif/lib/makers/gps.php index 9a6ab137..462aae68 100644 --- a/modules/exif/lib/makers/gps.php +++ b/modules/exif/lib/makers/gps.php @@ -72,103 +72,66 @@ function lookup_GPS_tag($tag) { return $tag; } -//================= -// Formats a rational number -//==================================================================== -function GPSRational($data, $intel) { - - if($intel==1) $top = hexdec(substr($data,8,8)); //intel stores them bottom-top - else $top = hexdec(substr($data,0,8)); //motorola stores them top-bottom - - if($intel==1) $bottom = hexdec(substr($data,0,8)); //intel stores them bottom-top - else $bottom = hexdec(substr($data,8,8)); //motorola stores them top-bottom - - if($bottom!=0) $data=$top/$bottom; - else if($top==0) $data = 0; - else $data=$top."/".$bottom; - - return $data; -} //================= // Formats Data for the data type //==================================================================== function formatGPSData($type,$tag,$intel,$data) { if($type=="ASCII") { - if($tag=="0001" || $tag=="0003"){ // Latitude Reference, Longitude Reference - $data = ($data{1} == $data{2} && $data{1} == $data{3}) ? $data{0} : $data; - } - + if($tag=="0001" || $tag=="0003"){ // Latitude Reference, Longitude Reference + $data = ($data{1} == $data{2} && $data{1} == $data{3}) ? $data{0} : $data; + } + } else if($type=="URATIONAL" || $type=="SRATIONAL") { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - - if($intel==1) $top = hexdec(substr($data,8,8)); //intel stores them bottom-top - else $top = hexdec(substr($data,0,8)); //motorola stores them top-bottom - - if($intel==1) $bottom = hexdec(substr($data,0,8)); //intel stores them bottom-top - else $bottom = hexdec(substr($data,8,8)); //motorola stores them top-bottom - - if($type=="SRATIONAL" && $top>2147483647) $top = $top - 4294967296; //this makes the number signed instead of unsigned - - if($tag=="0002" || $tag=="0004") { //Latitude, Longitude - - if($intel==1){ - $seconds = GPSRational(substr($data,0,16),$intel); - $hour = GPSRational(substr($data,32,16),$intel); - } else { - $hour= GPSRational(substr($data,0,16),$intel); - $seconds = GPSRational(substr($data,32,16),$intel); + if($tag=="0002" || $tag=="0004" || $tag=='0007') { //Latitude, Longitude, Time + $datum = array(); + for ($i=0;$i<strlen($data);$i=$i+8) { + array_push($datum,substr($data, $i, 8)); + } + $hour = unRational($datum[0],$type,$intel); + $minutes = unRational($datum[1],$type,$intel); + $seconds = unRational($datum[2],$type,$intel); + if($tag=="0007") { //Time + $data = $hour.":".$minutes.":".$seconds; + } else { + $data = $hour+$minutes/60+$seconds/3600; } - $minutes = GPSRational(substr($data,16,16),$intel); - - $data = $hour+$minutes/60+$seconds/3600; - } else if($tag=="0007") { //Time - $seconds = GPSRational(substr($data,0,16),$intel); - $minutes = GPSRational(substr($data,16,16),$intel); - $hour = GPSRational(substr($data,32,16),$intel); - - $data = $hour.":".$minutes.":".$seconds; } else { - if($bottom!=0) $data=$top/$bottom; - else if($top==0) $data = 0; - else $data=$top."/".$bottom; - - if($tag=="0006"){ - $data .= 'm'; - } + $data = unRational($data,$type,$intel); + + if($tag=="0006"){ + $data .= 'm'; + } } } else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - $data=hexdec($data); - - + $data = rational($data,$type,$intel); + + } else if($type=="UNDEFINED") { - - - + + + } else if($type=="UBYTE") { $data = bin2hex($data); if($intel==1) $num = intel2Moto($data); if($tag=="0000") { // VersionID - $data = hexdec(substr($data,0,2)) . + $data = hexdec(substr($data,0,2)) . ".". hexdec(substr($data,2,2)) . ".". hexdec(substr($data,4,2)) . ".". hexdec(substr($data,6,2)); - } else if($tag=="0005"){ // Altitude Reference - if($data == "00000000"){ $data = 'Above Sea Level'; } - else if($data == "01000000"){ $data = 'Below Sea Level'; } - } - + } else if($tag=="0005"){ // Altitude Reference + if($data == "00000000"){ $data = '+'; } + else if($data == "01000000"){ $data = '-'; } + } + } else { $data = bin2hex($data); if($intel==1) $data = intel2Moto($data); } - + return $data; } @@ -220,21 +183,26 @@ function parseGPS($block,&$result,$offset,$seek, $globalOffset) { //4 byte value or pointer to value if larger than 4 bytes $value = substr($block,$place,4);$place+=4; - if($bytesofdata<=4) { $data = $value; } else { - $value = bin2hex($value); - if($intel==1) $value = intel2Moto($value); - - $v = fseek($seek,$globalOffset+hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file - if($v==0) { - $data = fread($seek, $bytesofdata); - } else if($v==-1) { + if (strpos('unknown',$tag_name) !== false || $bytesofdata > 1024) { $result['Errors'] = $result['Errors']++; + $data = ''; + $type = 'ASCII'; + } else { + $value = bin2hex($value); + if($intel==1) $value = intel2Moto($value); + $v = fseek($seek,$globalOffset+hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file + if($v==0) { + $data = fread($seek, $bytesofdata); + } else { + $result['Errors'] = $result['Errors']++; + $data = ''; + $type = 'ASCII'; + } } } - if($result['VerboseOutput']==1) { $result['GPS'][$tag_name] = formatGPSData($type,$tag,$intel,$data); $result['GPS'][$tag_name."_Verbose"]['RawData'] = bin2hex($data); diff --git a/modules/exif/lib/makers/nikon.php b/modules/exif/lib/makers/nikon.php index ebc2af7c..d2fff9a2 100644 --- a/modules/exif/lib/makers/nikon.php +++ b/modules/exif/lib/makers/nikon.php @@ -57,8 +57,32 @@ function lookup_Nikon_tag($tag,$model) { case "0008": $tag = "FlashSetting";break; case "0009": $tag = "FlashMode";break; case "000b": $tag = "WhiteBalanceFine";break; + case "000c": $tag = "WB_RBLevels";break; + case "000d": $tag = "ProgramShift";break; + case "000e": $tag = "ExposureDifference";break; case "000f": $tag = "ISOSelection";break; - case "0013": $tag = "ISOSelection2";break; + case "0010": $tag = "DataDump";break; + case "0011": $tag = "NikonPreview";break; + case "0012": $tag = "FlashExposureComp";break; + case "0013": $tag = "ISOSetting2";break; + case "0014": $tag = "ColorBalanceA";break; + case "0016": $tag = "ImageBoundary";break; + case "0017": $tag = "FlashExposureComp";break; + case "0018": $tag = "FlashExposureBracketValue";break; + case "0019": $tag = "ExposureBracketValue";break; + case "001a": $tag = "ImageProcessing";break; + case "001b": $tag = "CropHiSpeed";break; + case "001c": $tag = "ExposureTuning";break; + case "001d": $tag = "SerialNumber";break; + case "001e": $tag = "ColorSpace";break; + case "001f": $tag = "VRInfo";break; + case "0020": $tag = "ImageAuthentication";break; + case "0022": $tag = "ActiveD-Lighting";break; + case "0023": $tag = "PictureControl";break; + case "0024": $tag = "WorldTime";break; + case "0025": $tag = "ISOInfo";break; + case "002a": $tag = "VignetteControl";break; + case "002b": $tag = "DistortInfo";break; case "0080": $tag = "ImageAdjustment";break; case "0081": $tag = "ToneCompensation";break; case "0082": $tag = "Adapter";break; @@ -68,11 +92,16 @@ function lookup_Nikon_tag($tag,$model) { case "0086": $tag = "DigitalZoom";break; case "0087": $tag = "FlashUsed";break; case "0088": $tag = "AFFocusPosition";break; + case "0089": $tag = "ShootingMode";break; + case "008b": $tag = "LensFStops";break; + case "008c": $tag = "ContrastCurve";break; case "008d": $tag = "ColorMode";break; case "0090": $tag = "LightType";break; + case "0092": $tag = "HueAdjustment";break; + case "0093": $tag = "NEFCompression";break; case "0094": $tag = "Saturation";break; case "0095": $tag = "NoiseReduction";break; - case "0010": $tag = "DataDump";break; + case "009a": $tag = "SensorPixelSize";break; default: $tag = "unknown:".$tag;break; } @@ -81,120 +110,172 @@ function lookup_Nikon_tag($tag,$model) { return $tag; } + //================= // Formats Data for the data type //==================================================================== function formatNikonData($type,$tag,$intel,$model,$data) { - - if($type=="ASCII") { - - - } else if($type=="URATIONAL" || $type=="SRATIONAL") { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - $top = hexdec(substr($data,8,8)); - $bottom = hexdec(substr($data,0,8)); - if($bottom!=0) $data=$top/$bottom; - else if($top==0) $data = 0; - else $data=$top."/".$bottom; - - if($tag=="0085" && $model==1) { //ManualFocusDistance - $data=$data." m"; - } - if($tag=="0086" && $model==1) { //DigitalZoom - $data=$data."x"; - } - if($tag=="000a" && $model==0) { //DigitalZoom - $data=$data."x"; - } - } else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - $data=hexdec($data); - - if($tag=="0003" && $model==0) { //Quality - if($data == 1) $data = (string) t("VGA Basic"); - else if($data == 2) $data = (string) t("VGA Normal"); - else if($data == 3) $data = (string) t("VGA Fine"); - else if($data == 4) $data = (string) t("SXGA Basic"); - else if($data == 5) $data = (string) t("SXGA Normal"); - else if($data == 6) $data = (string) t("SXGA Fine"); - else $data = (string) t("Unknown").": ".$data; - } - if($tag=="0004" && $model==0) { //Color - if($data == 1) $data = (string) t("Color"); - else if($data == 2) $data = (string) t("Monochrome"); - else $data = (string) t("Unknown").": ".$data; - } - if($tag=="0005" && $model==0) { //Image Adjustment - if($data == 0) $data = (string) t("Normal"); - else if($data == 1) $data = (string) t("Bright+"); - else if($data == 2) $data = (string) t("Bright-"); - else if($data == 3) $data = (string) t("Contrast+"); - else if($data == 4) $data = (string) t("Contrast-"); - else $data = (string) t("Unknown").": ".$data; - } - if($tag=="0006" && $model==0) { //CCD Sensitivity - if($data == 0) $data = "ISO-80"; - else if($data == 2) $data = "ISO-160"; - else if($data == 4) $data = "ISO-320"; - else if($data == 5) $data = "ISO-100"; - else $data = (string) t("Unknown").": ".$data; - } - if($tag=="0007" && $model==0) { //White Balance - if($data == 0) $data = (string) t("Auto"); - else if($data == 1) $data = (string) t("Preset"); - else if($data == 2) $data = (string) t("Daylight"); - else if($data == 3) $data = (string) t("Incandescense"); - else if($data == 4) $data = (string) t("Flourescence"); - else if($data == 5) $data = (string) t("Cloudy"); - else if($data == 6) $data = (string) t("SpeedLight"); - else $data = (string) t("Unknown").": ".$data; - } - if($tag=="000b" && $model==0) { //Converter - if($data == 0) $data = (string) t("None"); - else if($data == 1) $data = (string) t("Fisheye"); - else $data = (string) t("Unknown").": ".$data; - } - } else if($type=="UNDEFINED") { - - if($tag=="0001" && $model==1) { //Unknown (Version?) - $data=$data/100; - } - if($tag=="0088" && $model==1) { //AF Focus Position - $temp = (string) t("Center"); + switch ($type) { + case "ASCII": + break; // do nothing! + case "URATIONAL": + case"SRATIONAL": + switch ($tag) { + case '0084': // LensInfo + $minFL = unRational(substr($data,0,8),$type,$intel); + $maxFL = unRational(substr($data,8,8),$type,$intel); + $minSP = unRational(substr($data,16,8),$type,$intel); + $maxSP = unRational(substr($data,24,8),$type,$intel); + if ($minFL == $maxFL) { + $data = sprintf('%0.0f f/%0.0f',$minFL,$minSP); + } elseif ($minSP == $maxSP) { + $data = sprintf('%0.0f-%0.0fmm f/%0.1f',$minFL,$maxFL,$minSP); + } else { + $data = sprintf('%0.0f-%0.0fmm f/%0.1f-%0.1f',$minFL,$maxFL,$minSP,$maxSP); + } + break; + case "0085": + if ($model==1) $data=unRational($data,$type,$intel)." m"; //ManualFocusDistance + break; + case "0086": + if ($model==1) $data=unRational($data,$type,$intel)."x"; //DigitalZoom + break; + case "000a": + if ($model==0) $data=unRational($data,$type,$intel)."x"; //DigitalZoom + break; + default: + $data=unRational($data,$type,$intel); + break; + } + break; + case "USHORT": + case $type=="SSHORT": + case $type=="ULONG": + case $type=="SLONG": + case $type=="FLOAT": + case $type=="DOUBLE": + $data = rational($data,$type,$intel); + switch ($tag) { + case "0003": + if ($model==0) { //Quality + switch ($data) { + case 1: $data = (string) t("VGA Basic"); break; + case 2: $data = (string) t("VGA Normal"); break; + case 3: $data = (string) t("VGA Fine"); break; + case 4: $data = (string) t("SXGA Basic"); break; + case 5: $data = (string) t("SXGA Normal"); break; + case 6: $data = (string) t("SXGA Fine"); break; + default: $data = (string) t("Unknown").": ".$data; break; + } + } + break; + case "0004": + if ($model==0) { //Color + switch ($data) { + case 1: $data = (string) t("Color"); break; + case 2: $data = (string) t("Monochrome"); break; + default: $data = (string) t("Unknown").": ".$data; break; + } + } + break; + case "0005": + if ($model==0) { //Image Adjustment + switch ($data) { + case 0: $data = (string) t("Normal"); break; + case 1: $data = (string) t("Bright+"); break; + case 2: $data = (string) t("Bright-"); break; + case 3: $data = (string) t("Contrast+"); break; + case 4: $data = (string) t("Contrast-"); break; + default: $data = (string) t("Unknown").": ".$data; break; + } + } + break; + case "0006": + if ($model==0) { //CCD Sensitivity + switch($data) { + case 0: $data = "ISO-80"; break; + case 2: $data = "ISO-160"; break; + case 4: $data = "ISO-320"; break; + case 5: $data = "ISO-100"; break; + default: $data = (string) t("Unknown").": ".$data; break; + } + } + break; + case "0007": + if ($model==0) { //White Balance + switch ($data) { + case 0: $data = (string) t("Auto"); break; + case 1: $data = (string) t("Preset"); break; + case 2: $data = (string) t("Daylight"); break; + case 3: $data = (string) t("Incandescence"); break; + case 4: $data = (string) t("Fluorescence"); break; + case 5: $data = (string) t("Cloudy"); break; + case 6: $data = (string) t("SpeedLight"); break; + default: $data = (string) t("Unknown").": ".$data; break; + } + } + break; + case "000b": + if ($model==0) { //Converter + switch ($data) { + case 0: $data = (string) t("None"); break; + case 1: $data = (string) t("Fisheye"); break; + default: $data = (string) t("Unknown").": ".$data; break; + } + } + break; + } + break; + case "UNDEFINED": + switch ($tag) { + case "0001": + if ($model==1) $data=$data/100; break; //Unknown (Version?) + break; + case "0088": + if ($model==1) { //AF Focus Position + $temp = (string) t("Center"); + $data = bin2hex($data); + $data = str_replace("01","Top",$data); + $data = str_replace("02","Bottom",$data); + $data = str_replace("03","Left",$data); + $data = str_replace("04","Right",$data); + $data = str_replace("00","",$data); + if(strlen($data)==0) $data = $temp; + } + break; + } + break; + default: $data = bin2hex($data); - $data = str_replace("01","Top",$data); - $data = str_replace("02","Bottom",$data); - $data = str_replace("03","Left",$data); - $data = str_replace("04","Right",$data); - $data = str_replace("00","",$data); - if(strlen($data)==0) $data = $temp; - } - - } else { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - - if($tag=="0083" && $model==1) { //Lens Type - $data = hexdec(substr($data,0,2)); - if($data == 0) $data = (string) t("AF non D"); - else if($data == 1) $data = (string) t("Manual"); - else if($data == 2) $data = "AF-D or AF-S"; - else if($data == 6) $data = "AF-D G"; - else if($data == 10) $data = "AF-D VR"; - else $data = (string) t("Unknown").": ".$data; - } - if($tag=="0087" && $model==1) { //Flash type - $data = hexdec(substr($data,0,2)); - if($data == 0) $data = (string) t("Did Not Fire"); - else if($data == 4) $data = (string) t("Unknown"); - else if($data == 7) $data = (string) t("External"); - else if($data == 9) $data = (string) t("On Camera"); - else $data = (string) t("Unknown").": ".$data; - } + if($intel==1) $data = intel2Moto($data); + switch ($tag) { + case "0083": + if ($model==1) { //Lens Type + $data = hexdec(substr($data,0,2)); + switch ($data) { + case 0: $data = (string) t("AF non D"); break; + case 1: $data = (string) t("Manual"); break; + case 2: $data = "AF-D or AF-S"; break; + case 6: $data = "AF-D G"; break; + case 10: $data = "AF-D VR"; break; + case 14: $data = "AF-D G VR"; break; + default: $data = (string) t("Unknown").": ".$data; break; + } + } + break; + case "0087": + if ($model==1) { //Flash type + $data = hexdec(substr($data,0,2)); + if($data == 0) $data = (string) t("Did Not Fire"); + else if($data == 4) $data = (string) t("Unknown"); + else if($data == 7) $data = (string) t("External"); + else if($data == 9) $data = (string) t("On Camera"); + else $data = (string) t("Unknown").": ".$data; + } + break; + } + break; } - return $data; } diff --git a/modules/exif/lib/makers/olympus.php b/modules/exif/lib/makers/olympus.php index 17334bd8..3382fc79 100644 --- a/modules/exif/lib/makers/olympus.php +++ b/modules/exif/lib/makers/olympus.php @@ -57,24 +57,17 @@ function formatOlympusData($type,$tag,$intel,$data) { if($type=="ASCII") { } else if($type=="URATIONAL" || $type=="SRATIONAL") { - $data = bin2hex($data); + $data = unRational($data,$type,$intel); if($intel==1) $data = intel2Moto($data); - $top = hexdec(substr($data,8,8)); - $bottom = hexdec(substr($data,0,8)); - if($bottom!=0) $data=$top/$bottom; - else if($top==0) $data = 0; - else $data=$top."/".$bottom; if($tag=="0204") { //DigitalZoom $data=$data."x"; } if($tag=="0205") { //Unknown2 - $data=$top."/".$bottom; + } } else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - $data=hexdec($data); + $data = rational($data,$type,$intel); if($tag=="0201") { //JPEGQuality if($data == 1) $data = "SQ"; diff --git a/modules/exif/lib/makers/panasonic.php b/modules/exif/lib/makers/panasonic.php index d82d374d..47a05996 100644 --- a/modules/exif/lib/makers/panasonic.php +++ b/modules/exif/lib/makers/panasonic.php @@ -85,18 +85,10 @@ function formatPanasonicData($type,$tag,$intel,$data) { } } else if($type=="URATIONAL" || $type=="SRATIONAL") { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - $top = hexdec(substr($data,8,8)); - $bottom = hexdec(substr($data,0,8)); - if($bottom!=0) $data=$top/$bottom; - else if($top==0) $data = 0; - else $data=$top."/".$bottom; + $data = unRational($data,$type,$intel); } else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - $data=hexdec($data); + $data = rational($data,$type,$intel); if($tag=="0001") { //Image Quality if($data == 2) $data = (string) t("High"); diff --git a/modules/exif/lib/makers/sanyo.php b/modules/exif/lib/makers/sanyo.php index 661741dd..3eef201e 100644 --- a/modules/exif/lib/makers/sanyo.php +++ b/modules/exif/lib/makers/sanyo.php @@ -54,19 +54,10 @@ function formatSanyoData($type,$tag,$intel,$data) { } else if($type=="URATIONAL" || $type=="SRATIONAL") { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - $top = hexdec(substr($data,8,8)); - $bottom = hexdec(substr($data,0,8)); - if($bottom!=0) $data=$top/$bottom; - else if($top==0) $data = 0; - else $data=$top."/".$bottom; - + $data = unRational($data,$type,$intel); } else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") { - $data = bin2hex($data); - if($intel==1) $data = intel2Moto($data); - $data=hexdec($data); + $data = rational($data,$type,$intel); if($tag=="0200") { //SpecialMode if($data == 0) $data = (string) t("Normal"); -- cgit v1.2.3 From ab0bef14be78701aedd647dd4eaccab641b6d01d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sun, 6 Jun 2010 21:08:10 -0700 Subject: Try to adjust for situations where /proc/loadavg is_readable() but generates an error if we call file() on it. Fixes ticket #1149. --- modules/gallery/helpers/gallery_block.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index 08ce21b7..cb28cbcd 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -70,9 +70,9 @@ class gallery_block_Core { $block->css_id = "g-platform"; $block->title = t("Platform information"); $block->content = new View("admin_block_platform.html"); - if (@is_readable("/proc/loadavg")) { + if (@is_readable("/proc/loadavg") && $first_line = current(@file("/proc/loadavg"))) { $block->content->load_average = - join(" ", array_slice(explode(" ", current(file("/proc/loadavg"))), 0, 3)); + join(" ", array_slice(explode(" ", $first_line), 0, 3)); } else { $block->content->load_average = t("Unavailable"); } -- cgit v1.2.3 From 1d91e1b2dc8456681f9e38baaca1d191cff1ac7a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sun, 6 Jun 2010 23:19:02 -0700 Subject: Don't show the rotate links if the active user can't edit the photo. Fixes ticket #1157. Thanks to psvo. --- modules/gallery/helpers/gallery_event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 89ad6a4c..ae7131ae 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -242,7 +242,7 @@ class gallery_event_Core { $csrf = access::csrf_token(); $theme_item = $theme->item(); $page_type = $theme->page_type(); - if ($item->is_photo() && graphics::can("rotate")) { + if ($can_edit && $item->is_photo() && graphics::can("rotate")) { $options_menu ->append( Menu::factory("ajax_link") -- cgit v1.2.3 From af240a34982c07dd2d3caa79c67222cfbb8e4f4a Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Mon, 7 Jun 2010 05:25:26 -0700 Subject: Update the rest client to use ancestors_for instead of ancestor_for. --- modules/organize/lib/Gallery3WebClient.swf | Bin 137234 -> 137234 bytes .../organize/source/Gallery3Organize_source.zip | Bin 938397 -> 933143 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index 0a4d6383..54169a5b 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 4cf5c13b..09a73acf 100644 Binary files a/modules/organize/source/Gallery3Organize_source.zip and b/modules/organize/source/Gallery3Organize_source.zip differ -- cgit v1.2.3 From fef5cf9865962ce9fed583752c0671a0a5e090cf Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Mon, 7 Jun 2010 07:09:39 -0700 Subject: If the identity provider changes then delete all the rest user_access_keys, as they are no longer valid. (i.e. all the related users have been deleted.) --- modules/rest/helpers/rest_event.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/rest/helpers/rest_event.php b/modules/rest/helpers/rest_event.php index e4e53ef6..f23b9a58 100644 --- a/modules/rest/helpers/rest_event.php +++ b/modules/rest/helpers/rest_event.php @@ -29,6 +29,13 @@ class rest_event { ->execute(); } + + static function change_provider($new_provider) { + db::build() + ->delete("user_access_keys") + ->execute(); + } + /** * Called after a user has been added. Just add a remote access key * on every add. -- cgit v1.2.3 From 4ba02ad720de146ad2558ae67870986925e0a2a2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Mon, 7 Jun 2010 22:03:54 -0700 Subject: Don't recreate test/var/logs if it already exists. This fixes a rather circuitous problem where if we have a failure early enough in the cycle, the failure is masked by our mkdir attempt. Even though we use @ to mask the error, the error handler still picks it up and turns it into an exception in Kohana_PHP_Exception::shutdown_handler() which obscures the real problem. --- index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 6ef215ab..dbd17149 100644 --- a/index.php +++ b/index.php @@ -64,9 +64,11 @@ if (PHP_SAPI == "cli") { case "test": array_splice($_SERVER["argv"], 1, 1, "gallery_unit_test"); define("TEST_MODE", 1); - @mkdir("test/var/logs", 0777, true); define("VARPATH", realpath("test/var") . "/"); - @copy("var/database.php", VARPATH . "database.php"); + if (!is_dir("test/var/logs")) { + @mkdir("test/var/logs", 0777, true); + @copy("var/database.php", VARPATH . "database.php"); + } break; default: -- cgit v1.2.3 From f1eed778e47604670e186d48c02659050aadf566 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Mon, 7 Jun 2010 22:14:04 -0700 Subject: Tweak the test setup code to always copy database.php; something is going wrong that's nuking test/var/database.php -- I'll figure that out, but in the meantime we can make this code more robust. --- index.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index dbd17149..4ef3d943 100644 --- a/index.php +++ b/index.php @@ -64,11 +64,12 @@ if (PHP_SAPI == "cli") { case "test": array_splice($_SERVER["argv"], 1, 1, "gallery_unit_test"); define("TEST_MODE", 1); - define("VARPATH", realpath("test/var") . "/"); - if (!is_dir("test/var/logs")) { + if (!is_dir("test/var")) { + @mkdir("test/var", 0777, true); @mkdir("test/var/logs", 0777, true); - @copy("var/database.php", VARPATH . "database.php"); } + @copy("var/database.php", "test/var/database.php"); + define("VARPATH", realpath("test/var") . "/"); break; default: -- cgit v1.2.3 From 5151f0b86526f619cb171a599f79a883addcf343 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Mon, 7 Jun 2010 22:18:09 -0700 Subject: Improve a comment. --- modules/gallery_unit_test/controllers/gallery_unit_test.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/gallery_unit_test/controllers/gallery_unit_test.php b/modules/gallery_unit_test/controllers/gallery_unit_test.php index 80ee16d9..e241e1dd 100644 --- a/modules/gallery_unit_test/controllers/gallery_unit_test.php +++ b/modules/gallery_unit_test/controllers/gallery_unit_test.php @@ -89,7 +89,9 @@ class Gallery_Unit_Test_Controller extends Controller { } } - // Clean out the filesystem + // Clean out the filesystem. Note that this cleans out test/var/database.php, but that's ok + // because we technically don't need it anymore. If this is confusing, we could always + // arrange to preserve that one file. @system("rm -rf test/var"); @mkdir('test/var/logs', 0777, true); -- cgit v1.2.3 From 98fce83de5f772482382bfabdbcd94c25ecdbb1a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Mon, 7 Jun 2010 22:23:46 -0700 Subject: Add a "convert_ids" parameter to Item_Model::as_restful_array(), which we can turn on with a query parameter. --- modules/gallery/models/item.php | 20 ++++++++++++-------- modules/gallery/tests/Item_Model_Test.php | 12 ++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 409ed3cc..dfcbdd70 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -924,17 +924,21 @@ class Item_Model extends ORM_MPTT { /** * Same as ORM::as_array() but convert id fields into their RESTful form. */ - public function as_restful_array() { + public function as_restful_array($convert_ids=true) { // Convert item ids to rest URLs for consistency $data = $this->as_array(); - if ($tmp = $this->parent()) { - $data["parent"] = rest::url("item", $tmp); - } - unset($data["parent_id"]); - if ($tmp = $this->album_cover()) { - $data["album_cover"] = rest::url("item", $tmp); + + if ($convert_ids) { + if ($tmp = $this->parent()) { + $data["parent"] = rest::url("item", $tmp); + } + unset($data["parent_id"]); + + if ($tmp = $this->album_cover()) { + $data["album_cover"] = rest::url("item", $tmp); + } + unset($data["album_cover_item_id"]); } - unset($data["album_cover_item_id"]); if (access::can("view_full", $this) && $this->is_photo()) { $data["file_url"] = $this->file_url(true); diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index 15aa2d8c..9d3f54f2 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -364,6 +364,18 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $this->assert_true(!array_key_exists("album_cover_item_id", $result)); } + public function as_restful_array_with_ids_test() { + $album = test::random_album(); + $photo = test::random_photo($album); + $album->reload(); + + $result = $album->as_restful_array(false); + $this->assert_same(item::root()->id, $result["parent_id"]); + $this->assert_same($photo->id, $result["album_cover_item_id"]); + $this->assert_true(!array_key_exists("parent", $result)); + $this->assert_true(!array_key_exists("album_cover_item", $result)); + } + public function first_photo_becomes_album_cover() { $album = test::random_album(); $photo = test::random_photo($album); -- cgit v1.2.3 From 6425d41eddd44091b2d83ba3c3734cc6990ca581 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Mon, 7 Jun 2010 23:12:52 -0700 Subject: Add a "preserve_ids" global query parameter for REST requests that indicates that we shouldn't opportunistically convert ids into REST urls. --- modules/gallery/helpers/item_rest.php | 3 +- modules/gallery/helpers/items_rest.php | 14 ++++++---- modules/gallery/models/item.php | 7 +++-- modules/gallery/tests/Item_Model_Test.php | 4 +-- modules/gallery/tests/Item_Rest_Helper_Test.php | 21 ++++++++++---- modules/gallery/tests/Items_Rest_Helper_Test.php | 35 ++++++++++++++++-------- 6 files changed, 57 insertions(+), 27 deletions(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index c88f92d9..1d19d9f1 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -78,9 +78,10 @@ class item_rest_Core { } $orm->order_by($order_by); + $preserve_ids = isset($p->preserve_ids) ? (bool)$p->preserve_ids : false; $result = array( "url" => $request->url, - "entity" => $item->as_restful_array(), + "entity" => $item->as_restful_array($preserve_ids), "relationships" => rest::relationships("item", $item)); if ($item->is_album()) { $result["members"] = array(); diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index 9cca9a54..e9773745 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -36,6 +36,8 @@ class items_rest_Core { */ static function get($request) { $items = array(); + $preserve_ids = isset($request->params->preserve_ids) ? + (bool)$request->params->preserve_ids : false; if (isset($request->params->urls)) { foreach (json_decode($request->params->urls) as $url) { if (isset($request->params->type)) { @@ -45,10 +47,10 @@ class items_rest_Core { if (access::can("view", $item)) { if (isset($types)) { if (in_array($item->type, $types)) { - $items[] = items_rest::_format_restful_item($item); + $items[] = items_rest::_format_restful_item($item, $preserve_ids); } } else { - $items[] = items_rest::_format_restful_item($item); + $items[] = items_rest::_format_restful_item($item, $preserve_ids); } } } @@ -57,9 +59,9 @@ class items_rest_Core { if (!access::can("view", $item)) { throw new Kohana_404_Exception(); } - $items[] = items_rest::_format_restful_item($item); + $items[] = items_rest::_format_restful_item($item, $preserve_ids); while (($item = $item->parent()) != null) { - array_unshift($items, items_rest::_format_restful_item($item)); + array_unshift($items, items_rest::_format_restful_item($item, $preserve_ids)); }; } @@ -74,9 +76,9 @@ class items_rest_Core { return $item; } - private static function _format_restful_item($item) { + private static function _format_restful_item($item, $preserve_ids) { $item_rest = array("url" => rest::url("item", $item), - "entity" => $item->as_restful_array(), + "entity" => $item->as_restful_array($preserve_ids), "relationships" => rest::relationships("item", $item)); if ($item->type == "album") { $members = array(); diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index dfcbdd70..f59caa65 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -923,12 +923,15 @@ class Item_Model extends ORM_MPTT { /** * Same as ORM::as_array() but convert id fields into their RESTful form. + * Convert any item ids into REST urls + * + * @param bool preserve_ids true if we should preserve ids */ - public function as_restful_array($convert_ids=true) { + public function as_restful_array($preserve_ids) { // Convert item ids to rest URLs for consistency $data = $this->as_array(); - if ($convert_ids) { + if (!$preserve_ids) { if ($tmp = $this->parent()) { $data["parent"] = rest::url("item", $tmp); } diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index 9d3f54f2..6c5882c4 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -357,7 +357,7 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $photo = test::random_photo($album); $album->reload(); - $result = $album->as_restful_array(); + $result = $album->as_restful_array(false); $this->assert_same(rest::url("item", item::root()), $result["parent"]); $this->assert_same(rest::url("item", $photo), $result["album_cover"]); $this->assert_true(!array_key_exists("parent_id", $result)); @@ -369,7 +369,7 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $photo = test::random_photo($album); $album->reload(); - $result = $album->as_restful_array(false); + $result = $album->as_restful_array(true); $this->assert_same(item::root()->id, $result["parent_id"]); $this->assert_same($photo->id, $result["album_cover_item_id"]); $this->assert_true(!array_key_exists("parent", $result)); diff --git a/modules/gallery/tests/Item_Rest_Helper_Test.php b/modules/gallery/tests/Item_Rest_Helper_Test.php index 0b5e0471..5a80d66b 100644 --- a/modules/gallery/tests/Item_Rest_Helper_Test.php +++ b/modules/gallery/tests/Item_Rest_Helper_Test.php @@ -28,6 +28,17 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { $this->assert_equal($album->id, $resolved->id); } + public function get_with_ids_test() { + $photo1 = test::random_photo(item::root()); + $request = new stdClass(); + $request->url = rest::url("item", $photo1); + $request->params = new stdClass(); + $request->params->preserve_ids = 1; + + $response = item_rest::get($request); + $this->assert_equal(item::root()->id, $response["entity"]["parent_id"]); // Spot check + } + public function get_scope_test() { $album1 = test::random_album(); $photo1 = test::random_photo($album1); @@ -41,7 +52,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { $request->params = new stdClass(); $this->assert_equal_array( array("url" => rest::url("item", $album1), - "entity" => $album1->as_restful_array(), + "entity" => $album1->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album1), @@ -56,7 +67,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { $request->params->scope = "direct"; $this->assert_equal_array( array("url" => rest::url("item", $album1), - "entity" => $album1->as_restful_array(), + "entity" => $album1->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album1), @@ -71,7 +82,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { $request->params->scope = "all"; $this->assert_equal_array( array("url" => rest::url("item", $album1), - "entity" => $album1->as_restful_array(), + "entity" => $album1->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album1), @@ -98,7 +109,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { $request->params->name = "foo"; $this->assert_equal_array( array("url" => rest::url("item", $album1), - "entity" => $album1->as_restful_array(), + "entity" => $album1->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album1), @@ -121,7 +132,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { $request->params->type = "album"; $this->assert_equal_array( array("url" => rest::url("item", $album1), - "entity" => $album1->as_restful_array(), + "entity" => $album1->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album1), diff --git a/modules/gallery/tests/Items_Rest_Helper_Test.php b/modules/gallery/tests/Items_Rest_Helper_Test.php index 94bf912a..3efd677d 100644 --- a/modules/gallery/tests/Items_Rest_Helper_Test.php +++ b/modules/gallery/tests/Items_Rest_Helper_Test.php @@ -34,13 +34,13 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { $this->assert_equal_array( array( array("url" => rest::url("item", $photo1), - "entity" => $photo1->as_restful_array(), + "entity" => $photo1->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $photo1), "members" => array()))), array("url" => rest::url("item", $album2), - "entity" => $album2->as_restful_array(), + "entity" => $album2->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album2), @@ -67,7 +67,7 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { $this->assert_equal_array( array( array("url" => rest::url("item", $album2), - "entity" => $album2->as_restful_array(), + "entity" => $album2->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album2), @@ -94,7 +94,7 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { $this->assert_equal_array( array( array("url" => rest::url("item", $photo1), - "entity" => $photo1->as_restful_array(), + "entity" => $photo1->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $photo1), @@ -119,13 +119,13 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { $this->assert_equal_array( array( array("url" => rest::url("item", $photo1), - "entity" => $photo1->as_restful_array(), + "entity" => $photo1->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $photo1), "members" => array()))), array("url" => rest::url("item", $album2), - "entity" => $album2->as_restful_array(), + "entity" => $album2->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album2), @@ -146,7 +146,7 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { $root = ORM::factory("item", 1); $restful_root = array( "url" => rest::url("item", $root), - "entity" => $root->as_restful_array(), + "entity" => $root->as_restful_array(false), "relationships" => rest::relationships("item", $root)); $restful_root["members"] = array(); foreach ($root->children() as $child) { @@ -155,12 +155,12 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { $request = new stdClass(); $request->params = new stdClass(); - $request->params->ancestor_for = rest::url("item", $photo2); + $request->params->ancestors_for = rest::url("item", $photo2); $this->assert_equal_array( array( $restful_root, array("url" => rest::url("item", $album1), - "entity" => $album1->as_restful_array(), + "entity" => $album1->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album1), @@ -170,7 +170,7 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { rest::url("item", $album2)), ), array("url" => rest::url("item", $album2), - "entity" => $album2->as_restful_array(), + "entity" => $album2->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album2), @@ -178,11 +178,24 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { "members" => array( rest::url("item", $photo2))), array("url" => rest::url("item", $photo2), - "entity" => $photo2->as_restful_array(), + "entity" => $photo2->as_restful_array(false), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $photo2), "members" => array())))), items_rest::get($request)); } + + public function get_ancestor_with_ids_test() { + $album1 = test::random_album(); + $photo1 = test::random_photo($album1); + + $request = new stdClass(); + $request->params = new stdClass(); + $request->params->ancestors_for = rest::url("item", $photo1); + $request->params->preserve_ids = 1; + + $response = items_rest::get($request); + $this->assert_same(item::root()->id, $response[1]["entity"]["parent_id"]); // Spot check + } } -- cgit v1.2.3 From 0aafec0e59c3ef48e8e2e6fc4a0b8aa458798619 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Tue, 8 Jun 2010 14:32:53 -0700 Subject: The status message for an HTTP 400 status should always be 'Bad Request', if I'm reading the specification right. --- modules/rest/libraries/Rest_Exception.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rest/libraries/Rest_Exception.php b/modules/rest/libraries/Rest_Exception.php index 505c2e7a..aa5b3281 100644 --- a/modules/rest/libraries/Rest_Exception.php +++ b/modules/rest/libraries/Rest_Exception.php @@ -24,7 +24,7 @@ class Rest_Exception_Core extends Kohana_Exception { public function sendHeaders() { if (!headers_sent()) { - header("HTTP/1.1 " . $this->getCode() . " " . $this->getMessage()); + header("HTTP/1.1 " . $this->getCode() . "Bad Request"); } } } \ No newline at end of file -- cgit v1.2.3 From d5b80f29444e03aadc1130ab1624a09c0689fb93 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Tue, 8 Jun 2010 14:35:35 -0700 Subject: Don't use the standard error formatting for exceptions that have occurred as part of a REST request. Format the exception as a json encoded text string so the client can extract the fault information if they so choose. --- modules/gallery/helpers/item_rest.php | 2 +- modules/rest/controllers/rest.php | 102 ++++++++++++++++++++++------------ 2 files changed, 66 insertions(+), 38 deletions(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index f99afbc2..763e586f 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -161,7 +161,7 @@ class item_rest_Core { case "photo": case "movie": if (empty($request->file)) { - throw new Rest_Exception("Bad Request: Upload failed", 400); + throw new Rest_Exception("file: Upload failed", 400); } $item->type = $entity->type; $item->parent_id = $parent->id; diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php index 38f28171..6392838f 100644 --- a/modules/rest/controllers/rest.php +++ b/modules/rest/controllers/rest.php @@ -39,54 +39,82 @@ 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; - - default: - $request->params = (object) $input->post(); - if (isset($_FILES["file"])) { - $request->file = upload::save("file"); + try { + $input = Input::instance(); + $request = new stdClass(); + + switch ($method = strtolower($input->server("REQUEST_METHOD"))) { + case "get": + $request->params = (object) $input->get(); + break; + + default: + $request->params = (object) $input->post(); + if (isset($_FILES["file"])) { + $request->file = upload::save("file"); + } + break; } - break; - } - if (isset($request->params->entity)) { - $request->params->entity = json_decode($request->params->entity); - } - if (isset($request->params->members)) { - $request->params->members = json_decode($request->params->members); - } + if (isset($request->params->entity)) { + $request->params->entity = json_decode($request->params->entity); + } + if (isset($request->params->members)) { + $request->params->members = json_decode($request->params->members); + } - $request->method = strtolower($input->server("HTTP_X_GALLERY_REQUEST_METHOD", $method)); - $request->access_key = $input->server("HTTP_X_GALLERY_REQUEST_KEY"); + $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; - } + if (empty($request->access_key) && !empty($request->params->access_key)) { + $request->access_key = $request->params->access_key; + } + + $request->url = url::abs_current(true); - $request->url = url::abs_current(true); + rest::set_active_user($request->access_key); - rest::set_active_user($request->access_key); + $handler_class = "{$function}_rest"; + $handler_method = $request->method; - $handler_class = "{$function}_rest"; - $handler_method = $request->method; + if (!method_exists($handler_class, $handler_method)) { + throw new Rest_Exception("Bad Request", 400); + } - if (!method_exists($handler_class, $handler_method)) { - throw new Rest_Exception("Bad Request", 400); + $response = call_user_func(array($handler_class, $handler_method), $request); + } catch (Exception $e) { + $response = $this->_format_exception_response($e); } - try { - rest::reply(call_user_func(array($handler_class, $handler_method), $request)); - } catch (ORM_Validation_Exception $e) { - foreach ($e->validation->errors() as $key => $value) { - $msgs[] = "$key: $value"; + rest::reply($response); + } + + private function _format_exception_response($e) { + // Add this exception to the log + Kohana_Log::add('error', Kohana_Exception::text($e)); + + $e->sendHeaders(); + + $rest_exception = array(); + if ($e instanceof ORM_Validation_Exception) { + $detail_response = true; + $rest_exception["code"] = 400; + $rest_exception["message"] = t("Validation errors"); + $rest_exception["fields"] = $e->validation->errors; + } else if ($e instanceof Rest_Exception) { + $rest_exception["code"] = $e->getCode(); + if ($e->getMessage() != "Bad Request") { + $rest_exception["message"] = "Bad Request"; + $rest_exception["fields"] = array("type", $e->getMessage()); + } else { + $rest_exception["message"] = $e->getMessage(); } - throw new Rest_Exception("Bad Request: " . join(", ", $msgs), 400); + header("HTTP/1.1 400 Bad Request"); + } else { + $rest_exception["code"] = 500; + $rest_exception["message"] = t("Remote server call failed. Please contact the Adminstrator."); } + + return $rest_exception; } } \ No newline at end of file -- cgit v1.2.3 From b40057283e1dfbb3bbb41a6dfc8ccc8e2111d810 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Tue, 8 Jun 2010 20:59:24 -0700 Subject: Add a "can_edit" field to the Item_Model's REST output. It's applicable to the current user. --- modules/gallery/models/item.php | 1 + modules/gallery/tests/Item_Model_Test.php | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index f59caa65..a0866934 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -951,6 +951,7 @@ class Item_Model extends ORM_MPTT { $data["resize_url"] = $tmp; } $data["thumb_url"] = $this->thumb_url(true); + $data["can_edit"] = access::can("edit", $this); // Elide some internal-only data that is going to cause confusion in the client. foreach (array("relative_path_cache", "relative_url_cache", "left_ptr", "right_ptr", diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index 6c5882c4..3df6197d 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -18,6 +18,10 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Item_Model_Test extends Gallery_Unit_Test_Case { + public function teardown() { + identity::set_active_user(identity::admin_user()); + } + public function saving_sets_created_and_updated_dates_test() { $item = test::random_photo(); $this->assert_true(!empty($item->created)); @@ -376,6 +380,15 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $this->assert_true(!array_key_exists("album_cover_item", $result)); } + public function as_restful_array_with_edit_bit_test() { + $response = item::root()->as_restful_array(true); + $this->assert_true($response["can_edit"]); + + identity::set_active_user(identity::guest()); + $response = item::root()->as_restful_array(true); + $this->assert_false($response["can_edit"]); + } + public function first_photo_becomes_album_cover() { $album = test::random_album(); $photo = test::random_photo($album); -- cgit v1.2.3 From 3dacafb7182dd915c4c6d4e7d75722976e231465 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Wed, 9 Jun 2010 20:49:32 -0700 Subject: Revert the "preserve_ids" global query parameter. We decided that it was a bad idea. This reverts commit 6425d41eddd44091b2d83ba3c3734cc6990ca581. --- modules/gallery/helpers/item_rest.php | 3 +- modules/gallery/helpers/items_rest.php | 14 ++++------ modules/gallery/models/item.php | 7 ++--- modules/gallery/tests/Item_Model_Test.php | 4 +-- modules/gallery/tests/Item_Rest_Helper_Test.php | 21 ++++---------- modules/gallery/tests/Items_Rest_Helper_Test.php | 35 ++++++++---------------- 6 files changed, 27 insertions(+), 57 deletions(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 1d19d9f1..c88f92d9 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -78,10 +78,9 @@ class item_rest_Core { } $orm->order_by($order_by); - $preserve_ids = isset($p->preserve_ids) ? (bool)$p->preserve_ids : false; $result = array( "url" => $request->url, - "entity" => $item->as_restful_array($preserve_ids), + "entity" => $item->as_restful_array(), "relationships" => rest::relationships("item", $item)); if ($item->is_album()) { $result["members"] = array(); diff --git a/modules/gallery/helpers/items_rest.php b/modules/gallery/helpers/items_rest.php index e9773745..9cca9a54 100644 --- a/modules/gallery/helpers/items_rest.php +++ b/modules/gallery/helpers/items_rest.php @@ -36,8 +36,6 @@ class items_rest_Core { */ static function get($request) { $items = array(); - $preserve_ids = isset($request->params->preserve_ids) ? - (bool)$request->params->preserve_ids : false; if (isset($request->params->urls)) { foreach (json_decode($request->params->urls) as $url) { if (isset($request->params->type)) { @@ -47,10 +45,10 @@ class items_rest_Core { if (access::can("view", $item)) { if (isset($types)) { if (in_array($item->type, $types)) { - $items[] = items_rest::_format_restful_item($item, $preserve_ids); + $items[] = items_rest::_format_restful_item($item); } } else { - $items[] = items_rest::_format_restful_item($item, $preserve_ids); + $items[] = items_rest::_format_restful_item($item); } } } @@ -59,9 +57,9 @@ class items_rest_Core { if (!access::can("view", $item)) { throw new Kohana_404_Exception(); } - $items[] = items_rest::_format_restful_item($item, $preserve_ids); + $items[] = items_rest::_format_restful_item($item); while (($item = $item->parent()) != null) { - array_unshift($items, items_rest::_format_restful_item($item, $preserve_ids)); + array_unshift($items, items_rest::_format_restful_item($item)); }; } @@ -76,9 +74,9 @@ class items_rest_Core { return $item; } - private static function _format_restful_item($item, $preserve_ids) { + private static function _format_restful_item($item) { $item_rest = array("url" => rest::url("item", $item), - "entity" => $item->as_restful_array($preserve_ids), + "entity" => $item->as_restful_array(), "relationships" => rest::relationships("item", $item)); if ($item->type == "album") { $members = array(); diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index a0866934..009457c1 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -923,15 +923,12 @@ class Item_Model extends ORM_MPTT { /** * Same as ORM::as_array() but convert id fields into their RESTful form. - * Convert any item ids into REST urls - * - * @param bool preserve_ids true if we should preserve ids */ - public function as_restful_array($preserve_ids) { + public function as_restful_array($convert_ids=true) { // Convert item ids to rest URLs for consistency $data = $this->as_array(); - if (!$preserve_ids) { + if ($convert_ids) { if ($tmp = $this->parent()) { $data["parent"] = rest::url("item", $tmp); } diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index 3df6197d..f9e6a4e3 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -361,7 +361,7 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $photo = test::random_photo($album); $album->reload(); - $result = $album->as_restful_array(false); + $result = $album->as_restful_array(); $this->assert_same(rest::url("item", item::root()), $result["parent"]); $this->assert_same(rest::url("item", $photo), $result["album_cover"]); $this->assert_true(!array_key_exists("parent_id", $result)); @@ -373,7 +373,7 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $photo = test::random_photo($album); $album->reload(); - $result = $album->as_restful_array(true); + $result = $album->as_restful_array(false); $this->assert_same(item::root()->id, $result["parent_id"]); $this->assert_same($photo->id, $result["album_cover_item_id"]); $this->assert_true(!array_key_exists("parent", $result)); diff --git a/modules/gallery/tests/Item_Rest_Helper_Test.php b/modules/gallery/tests/Item_Rest_Helper_Test.php index 5a80d66b..0b5e0471 100644 --- a/modules/gallery/tests/Item_Rest_Helper_Test.php +++ b/modules/gallery/tests/Item_Rest_Helper_Test.php @@ -28,17 +28,6 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { $this->assert_equal($album->id, $resolved->id); } - public function get_with_ids_test() { - $photo1 = test::random_photo(item::root()); - $request = new stdClass(); - $request->url = rest::url("item", $photo1); - $request->params = new stdClass(); - $request->params->preserve_ids = 1; - - $response = item_rest::get($request); - $this->assert_equal(item::root()->id, $response["entity"]["parent_id"]); // Spot check - } - public function get_scope_test() { $album1 = test::random_album(); $photo1 = test::random_photo($album1); @@ -52,7 +41,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { $request->params = new stdClass(); $this->assert_equal_array( array("url" => rest::url("item", $album1), - "entity" => $album1->as_restful_array(false), + "entity" => $album1->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album1), @@ -67,7 +56,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { $request->params->scope = "direct"; $this->assert_equal_array( array("url" => rest::url("item", $album1), - "entity" => $album1->as_restful_array(false), + "entity" => $album1->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album1), @@ -82,7 +71,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { $request->params->scope = "all"; $this->assert_equal_array( array("url" => rest::url("item", $album1), - "entity" => $album1->as_restful_array(false), + "entity" => $album1->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album1), @@ -109,7 +98,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { $request->params->name = "foo"; $this->assert_equal_array( array("url" => rest::url("item", $album1), - "entity" => $album1->as_restful_array(false), + "entity" => $album1->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album1), @@ -132,7 +121,7 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { $request->params->type = "album"; $this->assert_equal_array( array("url" => rest::url("item", $album1), - "entity" => $album1->as_restful_array(false), + "entity" => $album1->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album1), diff --git a/modules/gallery/tests/Items_Rest_Helper_Test.php b/modules/gallery/tests/Items_Rest_Helper_Test.php index 3efd677d..94bf912a 100644 --- a/modules/gallery/tests/Items_Rest_Helper_Test.php +++ b/modules/gallery/tests/Items_Rest_Helper_Test.php @@ -34,13 +34,13 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { $this->assert_equal_array( array( array("url" => rest::url("item", $photo1), - "entity" => $photo1->as_restful_array(false), + "entity" => $photo1->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $photo1), "members" => array()))), array("url" => rest::url("item", $album2), - "entity" => $album2->as_restful_array(false), + "entity" => $album2->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album2), @@ -67,7 +67,7 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { $this->assert_equal_array( array( array("url" => rest::url("item", $album2), - "entity" => $album2->as_restful_array(false), + "entity" => $album2->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album2), @@ -94,7 +94,7 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { $this->assert_equal_array( array( array("url" => rest::url("item", $photo1), - "entity" => $photo1->as_restful_array(false), + "entity" => $photo1->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $photo1), @@ -119,13 +119,13 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { $this->assert_equal_array( array( array("url" => rest::url("item", $photo1), - "entity" => $photo1->as_restful_array(false), + "entity" => $photo1->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $photo1), "members" => array()))), array("url" => rest::url("item", $album2), - "entity" => $album2->as_restful_array(false), + "entity" => $album2->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album2), @@ -146,7 +146,7 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { $root = ORM::factory("item", 1); $restful_root = array( "url" => rest::url("item", $root), - "entity" => $root->as_restful_array(false), + "entity" => $root->as_restful_array(), "relationships" => rest::relationships("item", $root)); $restful_root["members"] = array(); foreach ($root->children() as $child) { @@ -155,12 +155,12 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { $request = new stdClass(); $request->params = new stdClass(); - $request->params->ancestors_for = rest::url("item", $photo2); + $request->params->ancestor_for = rest::url("item", $photo2); $this->assert_equal_array( array( $restful_root, array("url" => rest::url("item", $album1), - "entity" => $album1->as_restful_array(false), + "entity" => $album1->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album1), @@ -170,7 +170,7 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { rest::url("item", $album2)), ), array("url" => rest::url("item", $album2), - "entity" => $album2->as_restful_array(false), + "entity" => $album2->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $album2), @@ -178,24 +178,11 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { "members" => array( rest::url("item", $photo2))), array("url" => rest::url("item", $photo2), - "entity" => $photo2->as_restful_array(false), + "entity" => $photo2->as_restful_array(), "relationships" => array( "tags" => array( "url" => rest::url("item_tags", $photo2), "members" => array())))), items_rest::get($request)); } - - public function get_ancestor_with_ids_test() { - $album1 = test::random_album(); - $photo1 = test::random_photo($album1); - - $request = new stdClass(); - $request->params = new stdClass(); - $request->params->ancestors_for = rest::url("item", $photo1); - $request->params->preserve_ids = 1; - - $response = items_rest::get($request); - $this->assert_same(item::root()->id, $response[1]["entity"]["parent_id"]); // Spot check - } } -- cgit v1.2.3 From aff0f6eca85e1a9aec83e13c29746f58010a56f6 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Wed, 9 Jun 2010 20:55:39 -0700 Subject: Fix get_ancestor_test() since the parameter was renamed to ancestors_for. --- modules/gallery/tests/Items_Rest_Helper_Test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gallery/tests/Items_Rest_Helper_Test.php b/modules/gallery/tests/Items_Rest_Helper_Test.php index 94bf912a..17e979a5 100644 --- a/modules/gallery/tests/Items_Rest_Helper_Test.php +++ b/modules/gallery/tests/Items_Rest_Helper_Test.php @@ -135,7 +135,7 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { items_rest::get($request)); } - public function get_ancestor_test() { + public function get_ancestors_test() { $album1 = test::random_album(); $photo1 = test::random_photo($album1); $album2 = test::random_album($album1); @@ -155,7 +155,7 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { $request = new stdClass(); $request->params = new stdClass(); - $request->params->ancestor_for = rest::url("item", $photo2); + $request->params->ancestors_for = rest::url("item", $photo2); $this->assert_equal_array( array( $restful_root, -- cgit v1.2.3 From 6556ca88339c78824f3de64c85a57e30a679431c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Wed, 9 Jun 2010 21:23:42 -0700 Subject: In GalleryCodeFilterIterator::accept(), ignore . and .., and stop caring about .svn --- modules/gallery/tests/Gallery_Filters.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/gallery/tests/Gallery_Filters.php b/modules/gallery/tests/Gallery_Filters.php index 4e32553b..debbe846 100644 --- a/modules/gallery/tests/Gallery_Filters.php +++ b/modules/gallery/tests/Gallery_Filters.php @@ -28,8 +28,10 @@ class GalleryCodeFilterIterator extends FilterIterator { public function accept() { // Skip anything that we didn"t write $path_name = $this->getInnerIterator()->getPathName(); + $file_name = $this->getInnerIterator()->getFileName(); return !( - strpos($path_name, ".svn") || + $file_name == "." || + $file_name == ".." || strpos($path_name, DOCROOT . "test") !== false || strpos($path_name, DOCROOT . "var") !== false || strpos($path_name, MODPATH . "forge") !== false || -- cgit v1.2.3 From ab93767e4d39764f103545efb6ac64ff942eb187 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Wed, 9 Jun 2010 21:26:36 -0700 Subject: Update golden file --- modules/gallery/tests/xss_data.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 0a75d6f7..68dca9cb 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -4,6 +4,7 @@ modules/akismet/views/admin_akismet_stats.html.php 9 DIRTY_ATTR urle modules/comment/views/admin_block_recent_comments.html.php 4 DIRTY_ATTR text::alternate("g-even","g-odd") modules/comment/views/admin_block_recent_comments.html.php 5 DIRTY_ATTR $comment->author()->avatar_url(32,$theme->url(,true)) modules/comment/views/admin_block_recent_comments.html.php 10 DIRTY gallery::date_time($comment->created) +modules/comment/views/admin_comments.html.php 5 DIRTY $form modules/comment/views/admin_manage_comments.html.php 43 DIRTY $menu->render() modules/comment/views/admin_manage_comments.html.php 107 DIRTY_ATTR $comment->id modules/comment/views/admin_manage_comments.html.php 107 DIRTY_ATTR text::alternate("g-odd","g-even") @@ -32,8 +33,8 @@ modules/comment/views/comment.mrss.php 29 DIRTY $child modules/comment/views/comment.mrss.php 34 DIRTY_ATTR $child->thumb_url modules/comment/views/comment.mrss.php 35 DIRTY_ATTR $child->thumb_height modules/comment/views/comment.mrss.php 35 DIRTY_ATTR $child->thumb_width -modules/comment/views/comments.html.php 18 DIRTY_ATTR $comment->id -modules/comment/views/comments.html.php 21 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) +modules/comment/views/comments.html.php 21 DIRTY_ATTR $comment->id +modules/comment/views/comments.html.php 24 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) modules/comment/views/user_profile_comments.html.php 5 DIRTY_ATTR $comment->id modules/comment/views/user_profile_comments.html.php 10 DIRTY_JS $comment->item()->url() modules/comment/views/user_profile_comments.html.php 11 DIRTY $comment->item()->thumb_img(array(),50) -- cgit v1.2.3 From 26d0af45eabe962c5366cb1e95de7e252b831796 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Wed, 9 Jun 2010 21:45:05 -0700 Subject: New version of EXIF gets ISO and Metering Mode right. Yay! --- modules/exif/tests/Exif_Test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/exif/tests/Exif_Test.php b/modules/exif/tests/Exif_Test.php index cf5af851..404b6cde 100644 --- a/modules/exif/tests/Exif_Test.php +++ b/modules/exif/tests/Exif_Test.php @@ -33,8 +33,8 @@ class Exif_Test extends Gallery_Unit_Test_Case { array("caption" => "Exposure Time", "value" => "1/60 sec"), array("caption" => "Flash", "value" => "No Flash"), array("caption" => "Focal Length", "value" => "50 mm"), - array("caption" => "ISO", "value" => "6553700"), - array("caption" => "Metering Mode", "value" => "Multi-Segment"), + array("caption" => "ISO", "value" => "100"), + array("caption" => "Metering Mode", "value" => "Pattern"), array("caption" => "Date/Time", "value" => "2008:03:17 17:41:25"), array("caption" => "Copyright", "value" => "(C) 2008 - T. Almdal"), array("caption" => "Orientation", "value" => "1: Normal (0 deg)"), -- cgit v1.2.3 From 30849d10b151582fff67fd41fef1177396e47996 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Thu, 10 Jun 2010 08:18:15 -0700 Subject: Tweak the error response for rest requests to make it easier for the client to extract error information. --- modules/rest/controllers/rest.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php index 6392838f..3e364bff 100644 --- a/modules/rest/controllers/rest.php +++ b/modules/rest/controllers/rest.php @@ -93,28 +93,30 @@ class Rest_Controller extends Controller { // Add this exception to the log Kohana_Log::add('error', Kohana_Exception::text($e)); - $e->sendHeaders(); - $rest_exception = array(); if ($e instanceof ORM_Validation_Exception) { $detail_response = true; $rest_exception["code"] = 400; - $rest_exception["message"] = t("Validation errors"); - $rest_exception["fields"] = $e->validation->errors; + $rest_exception["message"] = "Validation errors"; + $rest_exception["fields"] = $e->validation->errors(); } else if ($e instanceof Rest_Exception) { $rest_exception["code"] = $e->getCode(); if ($e->getMessage() != "Bad Request") { $rest_exception["message"] = "Bad Request"; $rest_exception["fields"] = array("type", $e->getMessage()); - } else { + } else { $rest_exception["message"] = $e->getMessage(); } - header("HTTP/1.1 400 Bad Request"); } else { $rest_exception["code"] = 500; $rest_exception["message"] = t("Remote server call failed. Please contact the Adminstrator."); } + if (!headers_sent()) { + header($rest_exception["code"] == 500 ? "HTTP/1.1 500 Internal Server Error" : + "HTTP/1.1 400 Bad Request"); + } + return $rest_exception; } } \ No newline at end of file -- cgit v1.2.3 From 38e8ab3d718d31dee7c8c27064e45c018540f358 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Thu, 10 Jun 2010 09:14:13 -0700 Subject: Provide better handling and a progress dialog when loading or updating files. --- modules/organize/lib/Gallery3WebClient.swf | Bin 137234 -> 144465 bytes .../organize/source/Gallery3Organize_source.zip | Bin 933143 -> 945619 bytes modules/organize/views/organize_dialog.html.php | 4 ++++ 3 files changed, 4 insertions(+) diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index 54169a5b..d983760d 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 09a73acf..ce3bbdf3 100644 Binary files a/modules/organize/source/Gallery3Organize_source.zip and b/modules/organize/source/Gallery3Organize_source.zip differ diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index da135857..574117e5 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -56,6 +56,10 @@ function getTextStrings() { var strings = { "statusText": <?= t("Drag and drop photos to re-order or move between album")->for_js() ?>, + "remoteError": + <?= t("Remote server error, please contact your gallery administrator")->for_js() ?>, + "addAlbumError": <?= t("The above highlighted fields are invalid")->for_js() ?>, + "errorOccurred": <?= t("Remote error ocurred")->for_js() ?>, "addAlbum": <?= t("Add album")->for_js() ?>, "addImages": <?= t("Add photo")->for_js() ?>, "deleteSelected": <?= t("Delete")->for_js() ?>, -- cgit v1.2.3 From 6aab0cbec6da442199ca13ecf6078f77b203dd00 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Thu, 10 Jun 2010 13:12:10 -0700 Subject: Review the code for xss exposures and provide the functionality to update the organize dialog bar when the selected album changes. --- modules/organize/lib/Gallery3WebClient.swf | Bin 144465 -> 145294 bytes .../organize/source/Gallery3Organize_source.zip | Bin 945619 -> 945080 bytes modules/organize/views/organize_dialog.html.php | 6 +++++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index d983760d..271888c1 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 ce3bbdf3..9a64222f 100644 Binary files a/modules/organize/source/Gallery3Organize_source.zip and b/modules/organize/source/Gallery3Organize_source.zip differ diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 574117e5..2d340f13 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -31,6 +31,10 @@ $("#g-dialog").dialog("close"); } + function setTitle(title) { + $("#ui-dialog-title-g-dialog").text(<?= t("Organize: ")->for_js() ?> + title); + } + function getOrganizeStyles() { var styles = { "color": colorToHex($("#g-organize").css("color")), @@ -117,6 +121,6 @@ <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> + <h1 style="display:none"><?= t("Organize: %name", array("name" => html::purify($album->title))) ?></h1> <div id="flashContent"> </div> </div> -- cgit v1.2.3 From cbcb7432b3ddd5bc08f0d127b2f138a5df2b378b Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Thu, 10 Jun 2010 14:10:19 -0700 Subject: Correct a problem with the sort order and sort direction fields being ignored. --- modules/organize/lib/Gallery3WebClient.swf | Bin 145294 -> 145339 bytes .../organize/source/Gallery3Organize_source.zip | Bin 945080 -> 945159 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index 271888c1..6ff0d5ba 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 9a64222f..d4494dc2 100644 Binary files a/modules/organize/source/Gallery3Organize_source.zip and b/modules/organize/source/Gallery3Organize_source.zip differ -- cgit v1.2.3 From 58b21e909d8ba628ddb8a19e732989821abb0283 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Thu, 10 Jun 2010 18:49:29 -0700 Subject: Change the pattern used to convert the file name to a title. Fixes ticket#1061 --- modules/gallery/helpers/item.php | 2 +- modules/gallery/tests/Item_Helper_Test.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index bbbe1058..15bbe977 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -136,7 +136,7 @@ class item_Core { */ static function convert_filename_to_title($filename) { $title = strtr($filename, "_", " "); - $title = preg_replace("/\..*?$/", "", $title); + $title = preg_replace("/\..{3,4}$/", "", $title); $title = preg_replace("/ +/", " ", $title); return $title; } diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php index 4771b11a..00229973 100644 --- a/modules/gallery/tests/Item_Helper_Test.php +++ b/modules/gallery/tests/Item_Helper_Test.php @@ -41,6 +41,11 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case { ORM::factory("item")->viewable()->where("id", "=", $item->id)->count_all()); } + public function convert_filename_to_title_test() { + $this->assert_equal("foo", item::convert_filename_to_title("foo.jpg")); + $this->assert_equal("foo.bar", item::convert_filename_to_title("foo.bar.jpg")); + } + public function convert_filename_to_slug_test() { $this->assert_equal("foo", item::convert_filename_to_slug("{[foo]}")); $this->assert_equal("foo-bar", item::convert_filename_to_slug("{[foo!@#!$@#^$@($!(@bar]}")); -- cgit v1.2.3 From 0ebc36b4e5ef5578791c00b8a64021d3aad96068 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 11 Jun 2010 08:15:25 -0700 Subject: Actually execute the database query that updates the album view count. Fixes ticket #1092. Thanks to shinta for pointing the way. --- modules/gallery/controllers/albums.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index ea15418f..eaa09be5 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -73,8 +73,8 @@ class Albums_Controller extends Items_Controller { // We can't use math in ORM or the query builder, so do this by hand. It's important // that we do this with math, otherwise concurrent accesses will damage accuracy. - db::query( - "UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $album->id"); + db::query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $album->id") + ->execute(); print $template; } -- cgit v1.2.3 From 30f4e143e8fbec928661dcbe75898465e7eff29c Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 11 Jun 2010 08:15:25 -0700 Subject: Actually execute the database query that updates the album view count. Fixes ticket #1092. Thanks to shinta for pointing the way. --- modules/gallery/controllers/albums.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index ea15418f..eaa09be5 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -73,8 +73,8 @@ class Albums_Controller extends Items_Controller { // We can't use math in ORM or the query builder, so do this by hand. It's important // that we do this with math, otherwise concurrent accesses will damage accuracy. - db::query( - "UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $album->id"); + db::query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $album->id") + ->execute(); print $template; } -- cgit v1.2.3 From bb35aefffbc287efc9823abd4b0e451b86c37378 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 11 Jun 2010 12:36:23 -0700 Subject: Fix for ticket #797 When load a file is uploaded using a dialog box and the jquery plugin ajaxForm, the ajaxForm plugin uses an hidden iFrame element to send the multi-part form and this is where the response goes. The ajaxForm plugin then retrieves the document body and parses the result as a json string. If the file uploads properly everything is fine, but if it fails Gallery3 return the input form with the the error fields highlighted as part of the json response. As this response is returned to a hidden iframe, the browser attempts to manipulate it and all hell breaks loose. We lose the trailing brace, we start getting escaping of form tags. When the ajaxForm plugin retrieves the iFrame body its no longer a valid json frame and the parsing fails and the user sees no indication that it failed. --- lib/gallery.dialog.js | 3 ++- modules/watermark/controllers/admin_watermarks.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index 3587108c..f280a525 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -114,7 +114,8 @@ }, success: function(data) { if (data.form) { - $("#g-dialog form").replaceWith(data.form); + var formData = unescape(data.form); + $("#g-dialog form").replaceWith(formData); $("#g-dialog form :submit").removeClass("ui-state-disabled") .attr("disabled", null); self._ajaxify_dialog(); diff --git a/modules/watermark/controllers/admin_watermarks.php b/modules/watermark/controllers/admin_watermarks.php index d26919d5..18b463ca 100644 --- a/modules/watermark/controllers/admin_watermarks.php +++ b/modules/watermark/controllers/admin_watermarks.php @@ -124,7 +124,7 @@ class Admin_Watermarks_Controller extends Admin_Controller { array("result" => "success", "location" => url::site("admin/watermarks"))); } else { - print json_encode(array("result" => "error", "form" => (string) $form)); + print json_encode(array("result" => "error", "form" => rawurlencode((string) $form))); } } -- cgit v1.2.3 From 2c1e3800ef41f2aabd61b7d6d39751d2d157409e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Fri, 11 Jun 2010 14:57:39 -0700 Subject: Send back the REST API version as a header. It's on every request, which sucks, but it's totally unobtrusive because it's a header so that's ok. Decided that the current version is "3.0" although it will surely change before the final 3.0 release. Fixes ticket #1148 --- modules/rest/helpers/rest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php index 72927c71..3229330a 100644 --- a/modules/rest/helpers/rest.php +++ b/modules/rest/helpers/rest.php @@ -18,9 +18,12 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class rest_Core { + const API_VERSION = "3.0"; + static function reply($data=array()) { Session::instance()->abort_save(); + header("X-Gallery-API-Version: " . rest::API_VERSION); if (Input::instance()->get("output") == "html") { header("Content-type: text/html"); if ($data) { -- cgit v1.2.3 From bbbb35675acefc6b0b1b78dea9fd3a983189d772 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 11 Jun 2010 15:40:54 -0700 Subject: Fix for ticket #1039. The problem was, as Bryan76 pointed out, with passing the full url in the continue parameter. In the logout controller, we tried to get the item from the url so we could check the permission of the item to insure that the guest user had access. But url::get_item_from_url expects a relative url. --- modules/gallery/controllers/logout.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/gallery/controllers/logout.php b/modules/gallery/controllers/logout.php index 967dad49..fdbadf1b 100644 --- a/modules/gallery/controllers/logout.php +++ b/modules/gallery/controllers/logout.php @@ -22,13 +22,16 @@ class Logout_Controller extends Controller { access::verify_csrf(); auth::logout(); if ($continue_url = Input::instance()->get("continue")) { - $item = url::get_item_from_uri($continue_url); + $components = explode("/", parse_url($continue_url, PHP_URL_PATH), 4); + $item = url::get_item_from_uri($components[3]); if (access::can("view", $item)) { // Don't use url::redirect() because it'll call url::site() and munge the continue url. - header("Location: $continue_url"); + header("Location: {$item->relative_url()}"); } else { url::redirect(item::root()->abs_url()); } + } else { + url::redirect(item::root()->abs_url()); } } } \ No newline at end of file -- cgit v1.2.3 From 41c18929cd23cf142df75ec9f9666102c593fcae Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 11 Jun 2010 15:54:08 -0700 Subject: Remove the duplicate query when searching as pointed out by joe7 on ticket #844 --- modules/search/helpers/search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index 22f83218..24c4ed2b 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -42,7 +42,7 @@ class search_Core { $data = $db->query($query); $count = $db->query("SELECT FOUND_ROWS() as c")->current()->c; - return array($count, new ORM_Iterator(ORM::factory("item"), $db->query($query))); + return array($count, new ORM_Iterator(ORM::factory("item"), $data)); } /** -- cgit v1.2.3 From cb01f4017d70a7d73273052b424e8b78b794bc1c Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 11 Jun 2010 16:37:45 -0700 Subject: Fix for ticket #1118. The item validation was flagging duplicate slugs as errors. There was already code in the item save to insure that any duplicates were made unique, so this patch removes the validation as unnecessary. --- modules/gallery/models/item.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 009457c1..a4f264bb 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -767,13 +767,6 @@ class Item_Model extends ORM_MPTT { public function valid_slug(Validation $v, $field) { if (preg_match("/[^A-Za-z0-9-_]/", $this->slug)) { $v->add_error("slug", "not_url_safe"); - } else if (db::build() - ->from("items") - ->where("parent_id", "=", $this->parent_id) - ->where("id", "<>", $this->id) - ->where("slug", "=", $this->slug) - ->count_records()) { - $v->add_error("slug", "conflict"); } } -- cgit v1.2.3 From a4586bc0c01fac6e86163fd119aaa64d95fb5e8e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 12 Jun 2010 13:05:40 -0700 Subject: Revert "Fix for ticket #1118. The item validation was flagging duplicate slugs as errors. There was already code in the item save to insure that any" This introduces a bug where you can create two items with the same slug. This reverts commit cb01f4017d70a7d73273052b424e8b78b794bc1c. --- modules/gallery/models/item.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index a4f264bb..009457c1 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -767,6 +767,13 @@ class Item_Model extends ORM_MPTT { public function valid_slug(Validation $v, $field) { if (preg_match("/[^A-Za-z0-9-_]/", $this->slug)) { $v->add_error("slug", "not_url_safe"); + } else if (db::build() + ->from("items") + ->where("parent_id", "=", $this->parent_id) + ->where("id", "<>", $this->id) + ->where("slug", "=", $this->slug) + ->count_records()) { + $v->add_error("slug", "conflict"); } } -- cgit v1.2.3 From 63d95087bf0f24d4e880843cd2841906c6f91b38 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 12 Jun 2010 13:35:12 -0700 Subject: Stop trying to parse the continue url in the logout controller because it requires us to reproduce a bunch of complex routing logic. Instead, just have the logout link generating code generate a link that's visible to guests. --- modules/gallery/controllers/logout.php | 12 ++---------- modules/gallery/helpers/gallery_event.php | 13 ++++++++++++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/modules/gallery/controllers/logout.php b/modules/gallery/controllers/logout.php index fdbadf1b..9caafec8 100644 --- a/modules/gallery/controllers/logout.php +++ b/modules/gallery/controllers/logout.php @@ -22,16 +22,8 @@ class Logout_Controller extends Controller { access::verify_csrf(); auth::logout(); if ($continue_url = Input::instance()->get("continue")) { - $components = explode("/", parse_url($continue_url, PHP_URL_PATH), 4); - $item = url::get_item_from_uri($components[3]); - if (access::can("view", $item)) { - // Don't use url::redirect() because it'll call url::site() and munge the continue url. - header("Location: {$item->relative_url()}"); - } else { - url::redirect(item::root()->abs_url()); - } - } else { - url::redirect(item::root()->abs_url()); + url::redirect($continue_url); } + url::redirect(item::root()->abs_url()); } } \ No newline at end of file diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index ae7131ae..1b688843 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -157,11 +157,22 @@ class gallery_event_Core { ->view("login_current_user.html") ->url(user_profile::url($user->id)) ->label($user->display_name())); + + if (isset($theme->item)) { + if (access::user_can(identity::guest(), "view", $theme->item)) { + $continue_url = $theme->item->abs_url(); + } else { + $continue_url = item::root()->abs_url(); + } + } else { + $continue_url = url::abs_current(); + } + $menu->append(Menu::factory("link") ->id("user_menu_logout") ->css_id("g-logout-link") ->url(url::site("logout?csrf=$csrf&continue=" . - urlencode(url::abs_current()))) + urlencode($continue_url))) ->label(t("Logout"))); } } -- cgit v1.2.3 From b61b50604bfffc25a395df3a1aedf84d3c557ff4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 12 Jun 2010 15:09:16 -0700 Subject: Push the continue url into the form for consistency with other login/continue code. --- modules/gallery/controllers/admin.php | 2 +- modules/gallery/controllers/reauthenticate.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php index 787a2138..0aeaa876 100644 --- a/modules/gallery/controllers/admin.php +++ b/modules/gallery/controllers/admin.php @@ -78,7 +78,7 @@ class Admin_Controller extends Controller { private static function _prompt_for_reauth($controller_name, $args) { if (request::method() == "get" && !request::is_ajax()) { // Avoid anti-phishing protection by passing the url as session variable. - Session::instance()->set("continue_url", url::current(true)); + Session::instance()->set("continue_url", url::abs_current(true)); } url::redirect("reauthenticate"); } diff --git a/modules/gallery/controllers/reauthenticate.php b/modules/gallery/controllers/reauthenticate.php index 3503d80a..acb27f6a 100644 --- a/modules/gallery/controllers/reauthenticate.php +++ b/modules/gallery/controllers/reauthenticate.php @@ -37,8 +37,7 @@ class Reauthenticate_Controller extends Controller { if ($valid) { message::success(t("Successfully re-authenticated!")); module::event("user_auth", $user); - $continue_url = Session::instance()->get_once("continue_url", "admin"); - url::redirect($continue_url); + url::redirect($form->continue_url->value); } else { $name = $user->name; log::warning("user", t("Failed re-authentication for %name", array("name" => $name))); @@ -59,6 +58,7 @@ class Reauthenticate_Controller extends Controller { private static function _form() { $form = new Forge("reauthenticate/auth", "", "post", array("id" => "g-reauthenticate-form")); $form->set_attr('class', "g-narrow"); + $form->hidden("continue_url")->value(Session::instance()->get("continue_url", "admin")); $group = $form->group("reauthenticate")->label(t("Re-authenticate")); $group->password("password")->label(t("Password"))->id("g-password")->class(null) ->callback("auth::validate_too_many_failed_auth_attempts") -- cgit v1.2.3 From c026da85cdbac9e9566045f8de2718cae985f0ec Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 12 Jun 2010 15:10:34 -0700 Subject: Use "continue_url" instead of "continue" for consistency with the reauth code. --- modules/gallery/controllers/logout.php | 2 +- modules/gallery/helpers/gallery_event.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gallery/controllers/logout.php b/modules/gallery/controllers/logout.php index 9caafec8..20fa8074 100644 --- a/modules/gallery/controllers/logout.php +++ b/modules/gallery/controllers/logout.php @@ -21,7 +21,7 @@ class Logout_Controller extends Controller { public function index() { access::verify_csrf(); auth::logout(); - if ($continue_url = Input::instance()->get("continue")) { + if ($continue_url = Input::instance()->get("continue_url")) { url::redirect($continue_url); } url::redirect(item::root()->abs_url()); diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 1b688843..55db47ce 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -171,7 +171,7 @@ class gallery_event_Core { $menu->append(Menu::factory("link") ->id("user_menu_logout") ->css_id("g-logout-link") - ->url(url::site("logout?csrf=$csrf&continue=" . + ->url(url::site("logout?csrf=$csrf&continue_url=" . urlencode($continue_url))) ->label(t("Logout"))); } -- cgit v1.2.3 From dceecabbf1b736604ceb2e08e803b12c99dc4509 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 12 Jun 2010 15:16:47 -0700 Subject: Make login/logout continuation url code consistent. Where necessary, we specify the continue_url in the session, but we store it in the login form so that we can propagate it across the session creation that happens at login time. --- modules/gallery/controllers/login.php | 4 ++-- modules/gallery/helpers/auth.php | 1 + modules/gallery/libraries/MY_Kohana_Exception.php | 4 +--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php index 40125476..19335d88 100644 --- a/modules/gallery/controllers/login.php +++ b/modules/gallery/controllers/login.php @@ -44,10 +44,10 @@ class Login_Controller extends Controller { public function auth_html() { access::verify_csrf(); - $continue_url = Session::instance()->get("continue_url", null); list ($valid, $form) = $this->_auth("login/auth_html"); if ($valid) { - url::redirect($continue_url ? $continue_url : item::root()->abs_url()); + url::redirect($form->continue_url->value ? $form->continue_url_value : + item::root()->abs_url()); } else { $view = new Theme_View("page.html", "other", "login"); $view->page_title = t("Log in to Gallery"); diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php index 1a9fe869..48b5fc32 100644 --- a/modules/gallery/helpers/auth.php +++ b/modules/gallery/helpers/auth.php @@ -21,6 +21,7 @@ class auth_Core { static function get_login_form($url) { $form = new Forge($url, "", "post", array("id" => "g-login-form")); $form->set_attr("class", "g-narrow"); + $form->hidden("continue_url")->value(Session::instance()->get("continue_url")); $group = $form->group("login")->label(t("Login")); $group->input("name")->label(t("Username"))->id("g-username")->class(null) ->callback("auth::validate_too_many_failed_logins") diff --git a/modules/gallery/libraries/MY_Kohana_Exception.php b/modules/gallery/libraries/MY_Kohana_Exception.php index e7ebdb1f..df7557ae 100644 --- a/modules/gallery/libraries/MY_Kohana_Exception.php +++ b/modules/gallery/libraries/MY_Kohana_Exception.php @@ -59,7 +59,7 @@ class Kohana_Exception extends Kohana_Exception_Core { private static function _show_themed_error_page(Exception $e) { // Create a text version of the exception $error = Kohana_Exception::text($e); - + // Add this exception to the log Kohana_Log::add('error', $error); @@ -83,8 +83,6 @@ class Kohana_Exception extends Kohana_Exception_Core { if ($view->content->is_guest) { $view->content->login_form = new View("login_ajax.html"); $view->content->login_form->form = auth::get_login_form("login/auth_html"); - // Avoid anti-phishing protection by passing the url as session variable. - Session::instance()->set("continue_url", url::current(true)); } } else { $view->page_title = t("Dang... Something went wrong!"); -- cgit v1.2.3 From 87f8b6ff0a76f51183f14515723a8345f7c14fa6 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 12 Jun 2010 15:28:03 -0700 Subject: Bounce the user to the login page if they try to get to part of the admin site as a guest. Also, theme the login/html page. --- modules/gallery/controllers/admin.php | 7 ++++++- modules/gallery/controllers/login.php | 9 ++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php index 0aeaa876..c460f58c 100644 --- a/modules/gallery/controllers/admin.php +++ b/modules/gallery/controllers/admin.php @@ -22,7 +22,12 @@ class Admin_Controller extends Controller { public function __construct($theme=null) { if (!identity::active_user()->admin) { - access::forbidden(); + if (identity::active_user()->guest) { + Session::instance()->set("continue_url", url::abs_current(true)); + url::redirect("login"); + } else { + access::forbidden(); + } } parent::__construct(); diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php index 19335d88..2b60316b 100644 --- a/modules/gallery/controllers/login.php +++ b/modules/gallery/controllers/login.php @@ -38,7 +38,10 @@ class Login_Controller extends Controller { } public function html() { - print auth::get_login_form("login/auth_html"); + $view = new Theme_View("page.html", "other", "login"); + $view->page_title = t("Login"); + $view->content = auth::get_login_form("login/auth_html"); + print $view; } public function auth_html() { @@ -46,8 +49,8 @@ class Login_Controller extends Controller { list ($valid, $form) = $this->_auth("login/auth_html"); if ($valid) { - url::redirect($form->continue_url->value ? $form->continue_url_value : - item::root()->abs_url()); + $continue_url = $form->continue_url->value; + url::redirect($continue_url ? $continue_url : item::root()->abs_url()); } else { $view = new Theme_View("page.html", "other", "login"); $view->page_title = t("Log in to Gallery"); -- cgit v1.2.3 From db0966a9bce0396b0c98f3532bca8613f77cdb05 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 12 Jun 2010 15:39:38 -0700 Subject: Fix up some indentation and comment style. --- modules/gallery/js/l10n_client.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/modules/gallery/js/l10n_client.js b/modules/gallery/js/l10n_client.js index a1170e2d..a1b970e7 100644 --- a/modules/gallery/js/l10n_client.js +++ b/modules/gallery/js/l10n_client.js @@ -60,25 +60,21 @@ jQuery.extend(Gallery, { $('#l10n-client').height('22em').removeClass('hidden'); //$('#l10n-client').slideUp(); $('#g-minimize-l10n').text("_"); - /* - * This CSS clashes with Gallery's CSS, probably due to - * YUI's grid / floats. - if(!$.browser.msie) { - $('body').css('border-bottom', '22em solid #fff'); - } - */ + // This CSS clashes with Gallery's CSS, probably due to + // YUI's grid / floats. + // if(!$.browser.msie) { + // $('body').css('border-bottom', '22em solid #fff'); + // } $.cookie('Gallery_l10n_client', '1', {expires: 7, path: '/'}); break; case 0: $('#l10n-client-string-select, #l10n-client-string-editor, #l10n-client .labels .label').hide(); $('#l10n-client').height('2em').addClass('hidden'); // TODO: Localize this message - $('#g-minimize-l10n').text(MSG_TRANSLATE_TEXT); - /* - if(!$.browser.msie) { - $('body').css('border-bottom', '0px'); - } - */ + $('#g-minimize-l10n').text(MSG_TRANSLATE_TEXT); + // if(!$.browser.msie) { + // $('body').css('border-bottom', '0px'); + // } $.cookie('Gallery_l10n_client', '0', {expires: 7, path: '/'}); break; } -- cgit v1.2.3 From 47aa65143060ff376d95ca182c55132d821917fb Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> 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(-) 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(<?= t("Organize: ")->for_js() ?> + title); + $("#ui-dialog-title-g-dialog").text(<?= t("Organize :: ")->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": <?= t("Drag and drop photos to re-order or move between album")->for_js() ?>, - "remoteError": + return { + statusText: <?= t("Drag and drop photos to re-order or move between album")->for_js() ?>, + remoteError: <?= t("Remote server error, please contact your gallery administrator")->for_js() ?>, - "addAlbumError": <?= t("The above highlighted fields are invalid")->for_js() ?>, - "errorOccurred": <?= t("Remote error ocurred")->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() ?> + addAlbumError: <?= t("The above highlighted fields are invalid")->for_js() ?>, + errorOccurred: <?= t("Remote error ocurred")->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() ?>, + 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; } + function getGalleryParameters() { + return { + fileFilter: "<?= $file_filter ?>", + domain: "<?= $domain ?>", + sortOrder: "<?= $sort_order ?>", + sortFields: "<?= $sort_fields ?>", + baseUrl: "<?= $base_url ?>", + accessKey: "<?= $access_key ?>", + albumId: "<?= $album->id ?>", + controller: "<?= url::abs_site("organize") ?>/" + }; + }; /* 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: '<?= $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 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("<?= url::file("modules/organize/lib/Gallery3WebClient.swf") ?>", "flashContent", size.width() - 100, size.height() - 135, @@ -121,6 +125,6 @@ <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> + <h1 style="display:none"><?= t("Organize :: %name", array("name" => html::purify($album->title))) ?></h1> <div id="flashContent"> </div> </div> -- cgit v1.2.3 From 5decb3b252ef7966da0c9ac82e0630d202a13b5f Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Sun, 13 Jun 2010 19:31:48 -0700 Subject: Move the source to the gallery3-flex repository. --- modules/organize/source/Gallery3Organize_source.zip | Bin 945159 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 modules/organize/source/Gallery3Organize_source.zip diff --git a/modules/organize/source/Gallery3Organize_source.zip b/modules/organize/source/Gallery3Organize_source.zip deleted file mode 100644 index d4494dc2..00000000 Binary files a/modules/organize/source/Gallery3Organize_source.zip and /dev/null differ -- cgit v1.2.3 From 821d3f7854d76922b53df7e523eeaa8d4dca8c7b Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> 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(-) 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 6b01022a97e5fbd30d8f9a14b785e3e25ec7c2d4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sun, 13 Jun 2010 20:44:13 -0700 Subject: Hide the admin menu and show it after it's loaded to minimize flicker. Normalize the comment text about this interaction between admin_wind and wind. --- themes/admin_wind/views/admin.html.php | 4 +++- themes/wind/views/page.html.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/themes/admin_wind/views/admin.html.php b/themes/admin_wind/views/admin.html.php index ff7b930f..f9ef18c7 100644 --- a/themes/admin_wind/views/admin.html.php +++ b/themes/admin_wind/views/admin.html.php @@ -53,9 +53,11 @@ ← <?= t("back to the ...") ?> </a> <?= $theme->user_menu() ?> - <div id="g-site-admin-menu" class="ui-helper-clearfix"> + <!-- hide the menu until after the page has loaded, to minimize menu flicker --> + <div id="g-site-admin-menu" class="ui-helper-clearfix" style="visibility: hidden"> <?= $theme->admin_menu() ?> </div> + <script type="text/javascript"> $(document).ready(function() { $("#g-site-admin-menu").css("visibility", "visible"); }) </script> <?= $theme->admin_header_bottom() ?> </div> <div id="bd"> diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index 4cc949ce..6ce2a559 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -87,7 +87,7 @@ <?= $theme->user_menu() ?> <?= $theme->header_top() ?> - <!-- hide the menu and make it visible after the page has loaded, to minimize menu flicker --> + <!-- hide the menu until after the page has loaded, to minimize menu flicker --> <div id="g-site-menu" style="visibility: hidden"> <?= $theme->site_menu($theme->item() ? "#g-item-id-{$theme->item()->id}" : "") ?> </div> -- cgit v1.2.3 From 6f443a819b360a89c53004d3bf860fcedd88ae2e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sun, 13 Jun 2010 20:49:50 -0700 Subject: Change single to double quotes. --- modules/gallery/helpers/site_status.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/helpers/site_status.php b/modules/gallery/helpers/site_status.php index 759eb382..13c42dda 100644 --- a/modules/gallery/helpers/site_status.php +++ b/modules/gallery/helpers/site_status.php @@ -100,7 +100,7 @@ class site_status_Core { } $buf = array(); foreach (ORM::factory("message")->find_all() as $msg) { - $value = str_replace('__CSRF__', access::csrf_token(), $msg->value); + $value = str_replace("__CSRF__", access::csrf_token(), $msg->value); $buf[] = "<li class=\"" . self::severity_class($msg->severity) . "\">$value</li>"; } -- cgit v1.2.3 From 793780daa7665f7f86994235c4263fcb63554eb8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sun, 13 Jun 2010 20:51:11 -0700 Subject: Replace __CSRF__ with the actual csrf token. --- modules/gallery/helpers/message.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/gallery/helpers/message.php b/modules/gallery/helpers/message.php index 047eb2c7..1f69e2a9 100644 --- a/modules/gallery/helpers/message.php +++ b/modules/gallery/helpers/message.php @@ -78,6 +78,7 @@ class message_Core { $messages = Session::instance()->get_once("messages", array()); foreach ($messages as $msg) { + $msg[0] = str_replace("__CSRF__", access::csrf_token(), $msg[0]); $buf[] = "<li class=\"" . self::severity_class($msg[1]) . "\">$msg[0]</li>"; } if ($buf) { -- cgit v1.2.3 From 782c1e0ae0bc597629abcd88f844d863da45901a Mon Sep 17 00:00:00 2001 From: ckieffer <ckieffer@10.211.55.2> Date: Mon, 14 Jun 2010 13:50:02 -0400 Subject: Removed self-closing slash from opening <li> tag. --- modules/user/views/admin_users.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index 270a7207..b2526bd8 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -120,7 +120,7 @@ <div class="g-block-content"> <ul> <? foreach ($groups as $i => $group): ?> - <li id="g-group-<?= $group->id ?>" class="g-group g-left <?= ($group->special ? "g-default-group" : "") ?>" /> + <li id="g-group-<?= $group->id ?>" class="g-group g-left <?= ($group->special ? "g-default-group" : "") ?>"> <? $v = new View("admin_users_group.html"); $v->group = $group; ?> <?= $v ?> </li> -- cgit v1.2.3 From f10d641044fe31224af5b42b148a8ee77d9a34db Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> 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(-) 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: "<?= $file_filter ?>", + dialogWidth: $("#g-dialog:parent").width(), + dialogHeight: $("#g-dialog").height(), domain: "<?= $domain ?>", + accessKey: "<?= $access_key ?>", + protocol: "<?= $protocol ?>", + fileFilter: "<?= $file_filter ?>", sortOrder: "<?= $sort_order ?>", sortFields: "<?= $sort_fields ?>", - baseUrl: "<?= $base_url ?>", - accessKey: "<?= $access_key ?>", albumId: "<?= $album->id ?>", - controller: "<?= url::abs_site("organize") ?>/" + restUri: "<?= url::site("rest") ?>/", + controller: "<?= url::site("organize") ?>/" }; }; /* -- cgit v1.2.3 From 4ed60d6755944923ace336ffc3e61881ce14411f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Mon, 14 Jun 2010 21:20:33 -0700 Subject: The fact that we have a path to a G2 embed file doesn't mean that it's still valid so check to see that it's ok before proceeding. This should resolve #458. --- modules/g2_import/controllers/admin_g2_import.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index b1018560..cc60f757 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -33,7 +33,7 @@ class Admin_g2_import_Controller extends Admin_Controller { $view->page_title = t("Gallery 2 import"); $view->content = new View("admin_g2_import.html"); $view->content->form = $this->_get_import_form(); - $view->content->version = ''; + $view->content->version = ""; if (g2_import::is_initialized()) { $view->content->g2_stats = $g2_stats; @@ -41,6 +41,8 @@ class Admin_g2_import_Controller extends Admin_Controller { $view->content->thumb_size = module::get_var("gallery", "thumb_size"); $view->content->resize_size = module::get_var("gallery", "resize_size"); $view->content->version = g2_import::version(); + } else if (g2_import::is_configured()) { + $view->content->form->configure_g2_import->embed_path->add_error("invalid", 1); } g2_import::restore_error_reporting(); print $view; -- cgit v1.2.3 From 22470d98e7a4cbe1a78898e56e4e201948f94122 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Mon, 14 Jun 2010 22:42:32 -0700 Subject: Add a simple/cheap test to make sure that the database config is ok. Fixes ticket #1029. --- modules/gallery/hooks/init_gallery.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/gallery/hooks/init_gallery.php b/modules/gallery/hooks/init_gallery.php index 10383e9a..64e44b56 100644 --- a/modules/gallery/hooks/init_gallery.php +++ b/modules/gallery/hooks/init_gallery.php @@ -24,6 +24,15 @@ if (!file_exists(VARPATH . "database.php")) { url::redirect(url::abs_file("installer")); } +// Simple and cheap test to make sure that the database config is ok. Do this before we do +// anything else database related. +try { + Database::instance()->connect(); +} catch (Kohana_PHP_Exception $e) { + print "Database configuration error. Please check var/database.php"; + exit; +} + Event::add("system.ready", array("Gallery_I18n", "instance")); Event::add("system.ready", array("module", "load_modules")); Event::add("system.ready", array("gallery", "ready")); -- cgit v1.2.3 From 9911372d5819f637294d7565ba78cef786f604da Mon Sep 17 00:00:00 2001 From: ckieffer <ckieffer@10.211.55.2> Date: Mon, 14 Jun 2010 13:50:02 -0400 Subject: Removed self-closing slash from opening <li> tag. --- modules/user/views/admin_users.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index 270a7207..b2526bd8 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -120,7 +120,7 @@ <div class="g-block-content"> <ul> <? foreach ($groups as $i => $group): ?> - <li id="g-group-<?= $group->id ?>" class="g-group g-left <?= ($group->special ? "g-default-group" : "") ?>" /> + <li id="g-group-<?= $group->id ?>" class="g-group g-left <?= ($group->special ? "g-default-group" : "") ?>"> <? $v = new View("admin_users_group.html"); $v->group = $group; ?> <?= $v ?> </li> -- cgit v1.2.3 From f5eb5d5d7014e1d09194803d3839f0077bc9f890 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Mon, 14 Jun 2010 14:17:56 -0700 Subject: add an 'icon' to identify albums in the organize dialog. --- modules/organize/lib/Gallery3WebClient.swf | Bin 147590 -> 147955 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index c51fa4e8..04de2a1d 100644 Binary files a/modules/organize/lib/Gallery3WebClient.swf and b/modules/organize/lib/Gallery3WebClient.swf differ -- cgit v1.2.3 From b2afba1db1184fcf491bbdf7f0a50ddb5615e26f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Mon, 14 Jun 2010 21:20:33 -0700 Subject: The fact that we have a path to a G2 embed file doesn't mean that it's still valid so check to see that it's ok before proceeding. This should resolve #458. --- modules/g2_import/controllers/admin_g2_import.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index b1018560..cc60f757 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -33,7 +33,7 @@ class Admin_g2_import_Controller extends Admin_Controller { $view->page_title = t("Gallery 2 import"); $view->content = new View("admin_g2_import.html"); $view->content->form = $this->_get_import_form(); - $view->content->version = ''; + $view->content->version = ""; if (g2_import::is_initialized()) { $view->content->g2_stats = $g2_stats; @@ -41,6 +41,8 @@ class Admin_g2_import_Controller extends Admin_Controller { $view->content->thumb_size = module::get_var("gallery", "thumb_size"); $view->content->resize_size = module::get_var("gallery", "resize_size"); $view->content->version = g2_import::version(); + } else if (g2_import::is_configured()) { + $view->content->form->configure_g2_import->embed_path->add_error("invalid", 1); } g2_import::restore_error_reporting(); print $view; -- cgit v1.2.3 From 7e5661cf49aa2239fb71e7feb289e2dfee926e3d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Mon, 14 Jun 2010 22:42:32 -0700 Subject: Add a simple/cheap test to make sure that the database config is ok. Fixes ticket #1029. --- modules/gallery/hooks/init_gallery.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/gallery/hooks/init_gallery.php b/modules/gallery/hooks/init_gallery.php index 10383e9a..64e44b56 100644 --- a/modules/gallery/hooks/init_gallery.php +++ b/modules/gallery/hooks/init_gallery.php @@ -24,6 +24,15 @@ if (!file_exists(VARPATH . "database.php")) { url::redirect(url::abs_file("installer")); } +// Simple and cheap test to make sure that the database config is ok. Do this before we do +// anything else database related. +try { + Database::instance()->connect(); +} catch (Kohana_PHP_Exception $e) { + print "Database configuration error. Please check var/database.php"; + exit; +} + Event::add("system.ready", array("Gallery_I18n", "instance")); Event::add("system.ready", array("module", "load_modules")); Event::add("system.ready", array("gallery", "ready")); -- cgit v1.2.3 From 81f176cf8e313c8c700bd38045dab870fbfc77bb Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Tue, 15 Jun 2010 07:14:17 -0700 Subject: url::site(...) adds a leading slash to the uri it generates. Take this into account when creating the base url for accessing rest requests. Update the sort dropdown box to manual when album items are rearranged. --- modules/organize/lib/Gallery3WebClient.swf | Bin 147955 -> 150666 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index 04de2a1d..3c871e8a 100644 Binary files a/modules/organize/lib/Gallery3WebClient.swf and b/modules/organize/lib/Gallery3WebClient.swf differ -- cgit v1.2.3 From 603d4640141a43350f50da747d747456b28fdd93 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Tue, 15 Jun 2010 11:20:04 -0700 Subject: Change the item rest update processing to call the itemm::move(source, target) helper when the parent member has changed. Using the move method insures that names and slugs that could conflict in the target album are resolved properly. Also, only change the weights of the album children if the item sort_column is set to weight. --- modules/gallery/helpers/item_rest.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 763e586f..27542dea 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -99,7 +99,7 @@ class item_rest_Core { if ($entity = $request->params->entity) { // Only change fields from a whitelist. foreach (array("album_cover", "captured", "description", - "height", "mime_type", "name", "parent", "rand_key", "resize_dirty", + "height", "mime_type", "name", "rand_key", "resize_dirty", "resize_height", "resize_width", "slug", "sort_column", "sort_order", "thumb_dirty", "thumb_height", "thumb_width", "title", "view_count", "width") as $key) { @@ -112,23 +112,21 @@ class item_rest_Core { } break; - case "parent": - if (property_exists($entity, "parent")) { - $parent = rest::resolve($entity->parent); - access::required("edit", $parent); - $item->parent_id = $parent->id; - } - break; default: if (property_exists($entity, $key)) { $item->$key = $entity->$key; } } } + + $item->save(); + if (property_exists($entity, "parent")) { + $parent = rest::resolve($entity->parent); + item::move($item, $parent); + } } - $item->save(); - if (isset($request->params->members)) { + if (isset($request->params->members) && $item->sort_column == "weight") { $weight = 0; foreach ($request->params->members as $url) { $child = rest::resolve($url); -- cgit v1.2.3 From 00c4cb3f6399319326cd3393ee2f15fc8b111088 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Tue, 15 Jun 2010 11:38:46 -0700 Subject: Revert "Change the item rest update processing to call the itemm::move(source, target) helper when the parent member has changed. Using the move method insures that names and slugs that could conflict in the target album are resolved properly. Also, only change the weights of the album children if the item sort_column is set to weight." This reverts commit 603d4640141a43350f50da747d747456b28fdd93. --- modules/gallery/helpers/item_rest.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 27542dea..763e586f 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -99,7 +99,7 @@ class item_rest_Core { if ($entity = $request->params->entity) { // Only change fields from a whitelist. foreach (array("album_cover", "captured", "description", - "height", "mime_type", "name", "rand_key", "resize_dirty", + "height", "mime_type", "name", "parent", "rand_key", "resize_dirty", "resize_height", "resize_width", "slug", "sort_column", "sort_order", "thumb_dirty", "thumb_height", "thumb_width", "title", "view_count", "width") as $key) { @@ -112,21 +112,23 @@ class item_rest_Core { } break; + case "parent": + if (property_exists($entity, "parent")) { + $parent = rest::resolve($entity->parent); + access::required("edit", $parent); + $item->parent_id = $parent->id; + } + break; default: if (property_exists($entity, $key)) { $item->$key = $entity->$key; } } } - - $item->save(); - if (property_exists($entity, "parent")) { - $parent = rest::resolve($entity->parent); - item::move($item, $parent); - } } + $item->save(); - if (isset($request->params->members) && $item->sort_column == "weight") { + if (isset($request->params->members)) { $weight = 0; foreach ($request->params->members as $url) { $child = rest::resolve($url); -- cgit v1.2.3 From 207f6beb61cf2969d07bbc6f959bba967f54b271 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Tue, 15 Jun 2010 11:40:01 -0700 Subject: Only change the weights of the album children if the item sort_column is set to weight. --- modules/gallery/helpers/item_rest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 763e586f..0839b144 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -128,7 +128,7 @@ class item_rest_Core { } $item->save(); - if (isset($request->params->members)) { + if (isset($request->params->members) && $item->sort_column == "weight") { $weight = 0; foreach ($request->params->members as $url) { $child = rest::resolve($url); -- cgit v1.2.3 From 2492280cc0ec9eb64a8daeccc7b5698ece7fea66 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Tue, 15 Jun 2010 12:52:28 -0700 Subject: Change the item rest update processing to call the item::move(source, target) helper when the parent member has changed. Using the move method insures that names and slugs that could conflict in the target album are resolved properly. Changed the item::move method so it returns a message to be displayed if the caller chooses. And changed the move controller to display the message returned by the move if the item name was renamed as part of the move. --- modules/gallery/controllers/move.php | 10 ++++------ modules/gallery/helpers/item.php | 15 +++++++++------ modules/gallery/helpers/item_rest.php | 16 +++++++++------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/modules/gallery/controllers/move.php b/modules/gallery/controllers/move.php index f8b85b6f..3ce44546 100644 --- a/modules/gallery/controllers/move.php +++ b/modules/gallery/controllers/move.php @@ -34,12 +34,10 @@ class Move_Controller extends Controller { $source = ORM::factory("item", $source_id); $target = ORM::factory("item", Input::instance()->post("target_id")); - access::required("view", $source); - access::required("edit", $source); - access::required("view", $target); - access::required("edit", $target); - - item::move($source, $target); + $message = item::move($source, $target); + if (!empty($message)) { + message.info($message); + } print json_encode( array("result" => "success", diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 15bbe977..6a740de4 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -47,27 +47,28 @@ class item_Core { $orig_name_filename = pathinfo($source->name, PATHINFO_FILENAME); $orig_name_extension = pathinfo($source->name, PATHINFO_EXTENSION); $orig_slug = $source->slug; + $message = ""; for ($i = 0; $i < 5; $i++) { try { $source->save(); if ($orig_name != $source->name) { switch ($source->type) { case "album": - message::info( + $message = t("Album <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", - array("old_name" => $orig_name, "new_name" => $source->name))); + array("old_name" => $orig_name, "new_name" => $source->name)); break; case "photo": - message::info( + $message = t("Photo <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", - array("old_name" => $orig_name, "new_name" => $source->name))); + array("old_name" => $orig_name, "new_name" => $source->name)); break; case "movie": - message::info( + $message = t("Movie <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", - array("old_name" => $orig_name, "new_name" => $source->name))); + array("old_name" => $orig_name, "new_name" => $source->name)); break; } } @@ -95,6 +96,8 @@ class item_Core { if ($target->album_cover_item_id == null) { item::make_album_cover($source); } + + return $message; } static function make_album_cover($item) { diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 0839b144..692d0895 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -99,7 +99,7 @@ class item_rest_Core { if ($entity = $request->params->entity) { // Only change fields from a whitelist. foreach (array("album_cover", "captured", "description", - "height", "mime_type", "name", "parent", "rand_key", "resize_dirty", + "height", "mime_type", "name", "rand_key", "resize_dirty", "resize_height", "resize_width", "slug", "sort_column", "sort_order", "thumb_dirty", "thumb_height", "thumb_width", "title", "view_count", "width") as $key) { @@ -113,11 +113,6 @@ class item_rest_Core { break; case "parent": - if (property_exists($entity, "parent")) { - $parent = rest::resolve($entity->parent); - access::required("edit", $parent); - $item->parent_id = $parent->id; - } break; default: if (property_exists($entity, $key)) { @@ -125,8 +120,15 @@ class item_rest_Core { } } } + + // There is an explicit save in item::move + if (property_exists($entity, "parent")) { + $parent = rest::resolve($entity->parent); + item::move($item, $parent); + } else { + $item->save(); + } } - $item->save(); if (isset($request->params->members) && $item->sort_column == "weight") { $weight = 0; -- cgit v1.2.3 From 9504f71efcadc7ed27f6f09e5d663e8025bf3b86 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Tue, 15 Jun 2010 14:18:23 -0700 Subject: Fix for ticket #1118. Create a item::save_with_retries helper method, which encapsulates saving an item and handling name and slug conflicts. Call this instead of doing a save directly. --- modules/gallery/controllers/simple_uploader.php | 10 +++++++--- modules/gallery/helpers/item.php | 17 +++++++++++------ modules/gallery/helpers/item_rest.php | 8 +++----- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index c7e5031b..8ac1fc8b 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -65,12 +65,16 @@ class Simple_Uploader_Controller extends Controller { if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) { $item->type = "movie"; - $item->save(); + } else { + $item->type = "photo"; + } + + item::save_with_retries($item); + + if ($item->type == "movie") { log::success("content", t("Added a movie"), html::anchor("movies/$item->id", t("view movie"))); } else { - $item->type = "photo"; - $item->save(); log::success("content", t("Added a photo"), html::anchor("photos/$item->id", t("view photo"))); } diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 6a740de4..0710d8b2 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -43,6 +43,17 @@ class item_Core { // Moving may result in name or slug conflicts. If that happens, try up to 5 times to pick a // random name (or slug) to avoid the conflict. + $message = item::save_with_retries($source); + + // If the target has no cover item, make this it. + if ($target->album_cover_item_id == null) { + item::make_album_cover($source); + } + + return $message; + } + + static function save_with_retries($source, $retries=5) { $orig_name = $source->name; $orig_name_filename = pathinfo($source->name, PATHINFO_FILENAME); $orig_name_extension = pathinfo($source->name, PATHINFO_EXTENSION); @@ -91,12 +102,6 @@ class item_Core { } } } - - // If the target has no cover item, make this it. - if ($target->album_cover_item_id == null) { - item::make_album_cover($source); - } - return $message; } diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 692d0895..74fab2e7 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -112,8 +112,6 @@ class item_rest_Core { } break; - case "parent": - break; default: if (property_exists($entity, $key)) { $item->$key = $entity->$key; @@ -126,7 +124,7 @@ class item_rest_Core { $parent = rest::resolve($entity->parent); item::move($item, $parent); } else { - $item->save(); + $item::save_with_retries($item); } } @@ -157,7 +155,7 @@ class item_rest_Core { $item->title = isset($entity->title) ? $entity->title : $entity->name; $item->description = isset($entity->description) ? $entity->description : null; $item->slug = isset($entity->slug) ? $entity->slug : null; - $item->save(); + $item::save_with_retries($item); break; case "photo": @@ -172,7 +170,7 @@ class item_rest_Core { $item->title = isset($entity->title) ? $entity->title : $entity->name; $item->description = isset($entity->description) ? $entity->description : null; $item->slug = isset($entity->slug) ? $entity->slug : null; - $item->save(); + $item::save_with_retries($item); break; default: -- cgit v1.2.3 From d96ce71f1a35b8659bec7226f3902a052485b0f9 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Tue, 15 Jun 2010 15:29:45 -0700 Subject: Remove a stray period. --- modules/organize/helpers/organize_event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/organize/helpers/organize_event.php b/modules/organize/helpers/organize_event.php index c7d08893..ae05fb5d 100644 --- a/modules/organize/helpers/organize_event.php +++ b/modules/organize/helpers/organize_event.php @@ -51,7 +51,7 @@ class organize_event_Core { 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.. " . + 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"); -- cgit v1.2.3 From 4d40cf62e98e7e2f103740a401a08606c73fe72d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Tue, 15 Jun 2010 15:50:10 -0700 Subject: Sort files by path in _dump_var() for consistent output. Skip . and .. (PHP 5.3 iterators seem to include those now). --- modules/gallery/controllers/packager.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php index 6eafd9df..0ccfe743 100644 --- a/modules/gallery/controllers/packager.php +++ b/modules/gallery/controllers/packager.php @@ -163,9 +163,11 @@ class Packager_Controller extends Controller { $paths = array(); foreach($objects as $name => $file){ - if ($file->getBasename() == "database.php") { + $path = $file->getPath(); + $basename = $file->getBasename(); + if ($basename == "database.php" || $basename == "." || $basename == "..") { continue; - } else if (basename($file->getPath()) == "logs" && $file->getBasename() != ".htaccess") { + } else if (basename($path) == "logs" && $basename != ".htaccess") { continue; } @@ -186,6 +188,7 @@ class Packager_Controller extends Controller { foreach ($paths as $path) { fwrite($fd, "!file_exists($path) && mkdir($path);\n"); } + ksort($files); foreach ($files as $file => $contents) { fwrite($fd, "file_put_contents($file, base64_decode(\"$contents\"));\n"); } -- cgit v1.2.3 From b02ab4153dc3460ded6dcf63b237a6f6774f6681 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Tue, 15 Jun 2010 15:56:45 -0700 Subject: New dump generated by new mysqladmin has a slightly different format: mysqladmin Ver 8.42 Distrib 5.1.47, for debian-linux-gnu on i486 Also, updated for comment module v2. --- installer/install.sql | 437 +++++++++++++++++++++++++------------------------- 1 file changed, 219 insertions(+), 218 deletions(-) diff --git a/installer/install.sql b/installer/install.sql index ebe3651d..d3ba4419 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -1,248 +1,248 @@ DROP TABLE IF EXISTS {access_caches}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {access_caches} ( - `id` int(9) NOT NULL auto_increment, - `item_id` int(9) default NULL, - `view_full_1` binary(1) NOT NULL default '0', - `edit_1` binary(1) NOT NULL default '0', - `add_1` binary(1) NOT NULL default '0', - `view_full_2` binary(1) NOT NULL default '0', - `edit_2` binary(1) NOT NULL default '0', - `add_2` binary(1) NOT NULL default '0', - PRIMARY KEY (`id`) + `id` int(9) NOT NULL AUTO_INCREMENT, + `item_id` int(9) DEFAULT NULL, + `view_full_1` binary(1) NOT NULL DEFAULT '0', + `edit_1` binary(1) NOT NULL DEFAULT '0', + `add_1` binary(1) NOT NULL DEFAULT '0', + `view_full_2` binary(1) NOT NULL DEFAULT '0', + `edit_2` binary(1) NOT NULL DEFAULT '0', + `add_2` binary(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {access_caches} VALUES (1,1,'1','0','0','1','0','0'); DROP TABLE IF EXISTS {access_intents}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {access_intents} ( - `id` int(9) NOT NULL auto_increment, - `item_id` int(9) default NULL, - `view_1` binary(1) default NULL, - `view_full_1` binary(1) default NULL, - `edit_1` binary(1) default NULL, - `add_1` binary(1) default NULL, - `view_2` binary(1) default NULL, - `view_full_2` binary(1) default NULL, - `edit_2` binary(1) default NULL, - `add_2` binary(1) default NULL, - PRIMARY KEY (`id`) + `id` int(9) NOT NULL AUTO_INCREMENT, + `item_id` int(9) DEFAULT NULL, + `view_1` binary(1) DEFAULT NULL, + `view_full_1` binary(1) DEFAULT NULL, + `edit_1` binary(1) DEFAULT NULL, + `add_1` binary(1) DEFAULT NULL, + `view_2` binary(1) DEFAULT NULL, + `view_full_2` binary(1) DEFAULT NULL, + `edit_2` binary(1) DEFAULT NULL, + `add_2` binary(1) DEFAULT NULL, + PRIMARY KEY (`id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {access_intents} VALUES (1,1,'1','1','0','0','1','1','0','0'); DROP TABLE IF EXISTS {caches}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {caches} ( - `id` int(9) NOT NULL auto_increment, + `id` int(9) NOT NULL AUTO_INCREMENT, `key` varchar(255) NOT NULL, - `tags` varchar(255) default NULL, + `tags` varchar(255) DEFAULT NULL, `expiration` int(9) NOT NULL, `cache` longblob, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`), KEY `key` (`key`), KEY `tags` (`tags`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {comments}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {comments} ( - `author_id` int(9) default NULL, + `author_id` int(9) DEFAULT NULL, `created` int(9) NOT NULL, - `guest_email` varchar(128) default NULL, - `guest_name` varchar(128) default NULL, - `guest_url` varchar(255) default NULL, - `id` int(9) NOT NULL auto_increment, + `guest_email` varchar(128) DEFAULT NULL, + `guest_name` varchar(128) DEFAULT NULL, + `guest_url` varchar(255) DEFAULT NULL, + `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) NOT NULL, - `server_http_accept_charset` varchar(64) default NULL, - `server_http_accept_encoding` varchar(64) default NULL, - `server_http_accept_language` varchar(64) default NULL, - `server_http_accept` varchar(128) default NULL, - `server_http_connection` varchar(64) default NULL, - `server_http_host` varchar(64) default NULL, - `server_http_referer` varchar(255) default NULL, - `server_http_user_agent` varchar(128) default NULL, - `server_query_string` varchar(64) default NULL, - `server_remote_addr` varchar(32) default NULL, - `server_remote_host` varchar(64) default NULL, - `server_remote_port` varchar(16) default NULL, - `state` varchar(15) default 'unpublished', + `server_http_accept_charset` varchar(64) DEFAULT NULL, + `server_http_accept_encoding` varchar(64) DEFAULT NULL, + `server_http_accept_language` varchar(64) DEFAULT NULL, + `server_http_accept` varchar(128) DEFAULT NULL, + `server_http_connection` varchar(64) DEFAULT NULL, + `server_http_host` varchar(64) DEFAULT NULL, + `server_http_referer` varchar(255) DEFAULT NULL, + `server_http_user_agent` varchar(128) DEFAULT NULL, + `server_query_string` varchar(64) DEFAULT NULL, + `server_remote_addr` varchar(32) DEFAULT NULL, + `server_remote_host` varchar(64) DEFAULT NULL, + `server_remote_port` varchar(16) DEFAULT NULL, + `state` varchar(15) DEFAULT 'unpublished', `text` text, `updated` int(9) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {failed_auths}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {failed_auths} ( - `id` int(9) NOT NULL auto_increment, + `id` int(9) NOT NULL AUTO_INCREMENT, `count` int(9) NOT NULL, `name` varchar(255) NOT NULL, `time` int(9) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {graphics_rules}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {graphics_rules} ( - `id` int(9) NOT NULL auto_increment, - `active` tinyint(1) default '0', - `args` varchar(255) default NULL, + `id` int(9) NOT NULL AUTO_INCREMENT, + `active` tinyint(1) DEFAULT '0', + `args` varchar(255) DEFAULT NULL, `module_name` varchar(64) NOT NULL, `operation` varchar(64) NOT NULL, `priority` int(9) NOT NULL, `target` varchar(32) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'thumb'); INSERT INTO {graphics_rules} VALUES (2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:640;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'resize'); DROP TABLE IF EXISTS {groups}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {groups} ( - `id` int(9) NOT NULL auto_increment, - `name` char(64) default NULL, - `special` tinyint(1) default '0', - PRIMARY KEY (`id`), + `id` int(9) NOT NULL AUTO_INCREMENT, + `name` char(64) DEFAULT NULL, + `special` tinyint(1) DEFAULT '0', + PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {groups} VALUES (1,'Everybody',1); INSERT INTO {groups} VALUES (2,'Registered Users',1); DROP TABLE IF EXISTS {groups_users}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {groups_users} ( `group_id` int(9) NOT NULL, `user_id` int(9) NOT NULL, - PRIMARY KEY (`group_id`,`user_id`), + PRIMARY KEY (`group_id`,`user_id`), UNIQUE KEY `user_id` (`user_id`,`group_id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {groups_users} VALUES (1,1); INSERT INTO {groups_users} VALUES (1,2); INSERT INTO {groups_users} VALUES (2,2); DROP TABLE IF EXISTS {incoming_translations}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {incoming_translations} ( - `id` int(9) NOT NULL auto_increment, + `id` int(9) NOT NULL AUTO_INCREMENT, `key` char(32) NOT NULL, `locale` char(10) NOT NULL, `message` text NOT NULL, - `revision` int(9) default NULL, + `revision` int(9) DEFAULT NULL, `translation` text, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`), UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {items}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {items} ( - `id` int(9) NOT NULL auto_increment, - `album_cover_item_id` int(9) default NULL, - `captured` int(9) default NULL, - `created` int(9) default NULL, - `description` varchar(2048) default NULL, - `height` int(9) default NULL, + `id` int(9) NOT NULL AUTO_INCREMENT, + `album_cover_item_id` int(9) DEFAULT NULL, + `captured` int(9) DEFAULT NULL, + `created` int(9) DEFAULT NULL, + `description` varchar(2048) DEFAULT NULL, + `height` int(9) DEFAULT NULL, `left_ptr` int(9) NOT NULL, `level` int(9) NOT NULL, - `mime_type` varchar(64) default NULL, - `name` varchar(255) default NULL, - `owner_id` int(9) default NULL, + `mime_type` varchar(64) DEFAULT NULL, + `name` varchar(255) DEFAULT NULL, + `owner_id` int(9) DEFAULT NULL, `parent_id` int(9) NOT NULL, - `rand_key` float default NULL, - `relative_path_cache` varchar(255) default NULL, - `relative_url_cache` varchar(255) default NULL, - `resize_dirty` tinyint(1) default '1', - `resize_height` int(9) default NULL, - `resize_width` int(9) default NULL, + `rand_key` float DEFAULT NULL, + `relative_path_cache` varchar(255) DEFAULT NULL, + `relative_url_cache` varchar(255) DEFAULT NULL, + `resize_dirty` tinyint(1) DEFAULT '1', + `resize_height` int(9) DEFAULT NULL, + `resize_width` int(9) DEFAULT NULL, `right_ptr` int(9) NOT NULL, - `slug` varchar(255) default NULL, - `sort_column` varchar(64) default NULL, - `sort_order` char(4) default 'ASC', - `thumb_dirty` tinyint(1) default '1', - `thumb_height` int(9) default NULL, - `thumb_width` int(9) default NULL, - `title` varchar(255) default NULL, + `slug` varchar(255) DEFAULT NULL, + `sort_column` varchar(64) DEFAULT NULL, + `sort_order` char(4) DEFAULT 'ASC', + `thumb_dirty` tinyint(1) DEFAULT '1', + `thumb_height` int(9) DEFAULT NULL, + `thumb_width` int(9) DEFAULT NULL, + `title` varchar(255) DEFAULT NULL, `type` varchar(32) NOT NULL, - `updated` int(9) default NULL, - `view_count` int(9) default '0', - `weight` int(9) NOT NULL default '0', - `width` int(9) default NULL, - `view_1` binary(1) default '0', - `view_2` binary(1) default '0', - PRIMARY KEY (`id`), + `updated` int(9) DEFAULT NULL, + `view_count` int(9) DEFAULT '0', + `weight` int(9) NOT NULL DEFAULT '0', + `width` int(9) DEFAULT NULL, + `view_1` binary(1) DEFAULT '0', + `view_2` binary(1) DEFAULT '0', + PRIMARY KEY (`id`), KEY `parent_id` (`parent_id`), KEY `type` (`type`), KEY `random` (`rand_key`), KEY `weight` (`weight`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {items} VALUES (1,NULL,NULL,UNIX_TIMESTAMP(),'',NULL,1,1,NULL,NULL,2,0,NULL,'','',1,NULL,NULL,2,NULL,'weight','ASC',1,NULL,NULL,'Gallery','album',UNIX_TIMESTAMP(),0,1,NULL,'1','1'); DROP TABLE IF EXISTS {items_tags}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {items_tags} ( - `id` int(9) NOT NULL auto_increment, + `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) NOT NULL, `tag_id` int(9) NOT NULL, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`), KEY `tag_id` (`tag_id`,`id`), KEY `item_id` (`item_id`,`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {logs}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {logs} ( - `id` int(9) NOT NULL auto_increment, - `category` varchar(64) default NULL, - `html` varchar(255) default NULL, + `id` int(9) NOT NULL AUTO_INCREMENT, + `category` varchar(64) DEFAULT NULL, + `html` varchar(255) DEFAULT NULL, `message` text, - `referer` varchar(255) default NULL, - `severity` int(9) default '0', - `timestamp` int(9) default '0', - `url` varchar(255) default NULL, - `user_id` int(9) default '0', - PRIMARY KEY (`id`) + `referer` varchar(255) DEFAULT NULL, + `severity` int(9) DEFAULT '0', + `timestamp` int(9) DEFAULT '0', + `url` varchar(255) DEFAULT NULL, + `user_id` int(9) DEFAULT '0', + PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {messages}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {messages} ( - `id` int(9) NOT NULL auto_increment, - `key` varchar(255) default NULL, - `severity` varchar(32) default NULL, - `value` varchar(255) default NULL, - PRIMARY KEY (`id`), + `id` int(9) NOT NULL AUTO_INCREMENT, + `key` varchar(255) DEFAULT NULL, + `severity` varchar(32) DEFAULT NULL, + `value` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), UNIQUE KEY `key` (`key`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {modules}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {modules} ( - `id` int(9) NOT NULL auto_increment, - `active` tinyint(1) default '0', - `name` varchar(64) default NULL, - `version` int(9) default NULL, - PRIMARY KEY (`id`), + `id` int(9) NOT NULL AUTO_INCREMENT, + `active` tinyint(1) DEFAULT '0', + `name` varchar(64) DEFAULT NULL, + `version` int(9) DEFAULT NULL, + PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {modules} VALUES (1,1,'gallery',30); INSERT INTO {modules} VALUES (2,1,'user',3); -INSERT INTO {modules} VALUES (3,1,'comment',2); +INSERT INTO {modules} VALUES (3,1,'comment',3); INSERT INTO {modules} VALUES (4,1,'organize',1); INSERT INTO {modules} VALUES (5,1,'info',1); INSERT INTO {modules} VALUES (6,1,'rss',1); @@ -250,136 +250,136 @@ INSERT INTO {modules} VALUES (7,1,'search',1); INSERT INTO {modules} VALUES (8,1,'slideshow',2); INSERT INTO {modules} VALUES (9,1,'tag',1); DROP TABLE IF EXISTS {outgoing_translations}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {outgoing_translations} ( - `id` int(9) NOT NULL auto_increment, - `base_revision` int(9) default NULL, + `id` int(9) NOT NULL AUTO_INCREMENT, + `base_revision` int(9) DEFAULT NULL, `key` char(32) NOT NULL, `locale` char(10) NOT NULL, `message` text NOT NULL, `translation` text, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`), UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {permissions}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {permissions} ( - `id` int(9) NOT NULL auto_increment, - `display_name` varchar(64) default NULL, - `name` varchar(64) default NULL, - PRIMARY KEY (`id`), + `id` int(9) NOT NULL AUTO_INCREMENT, + `display_name` varchar(64) DEFAULT NULL, + `name` varchar(64) DEFAULT NULL, + PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {permissions} VALUES (1,'View','view'); INSERT INTO {permissions} VALUES (2,'View full size','view_full'); INSERT INTO {permissions} VALUES (3,'Edit','edit'); INSERT INTO {permissions} VALUES (4,'Add','add'); DROP TABLE IF EXISTS {search_records}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {search_records} ( - `id` int(9) NOT NULL auto_increment, - `item_id` int(9) default NULL, - `dirty` tinyint(1) default '1', + `id` int(9) NOT NULL AUTO_INCREMENT, + `item_id` int(9) DEFAULT NULL, + `dirty` tinyint(1) DEFAULT '1', `data` longtext, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`), KEY `item_id` (`item_id`), FULLTEXT KEY `data` (`data`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {search_records} VALUES (1,1,0,' Gallery'); DROP TABLE IF EXISTS {sessions}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {sessions} ( `session_id` varchar(127) NOT NULL, `data` text NOT NULL, `last_activity` int(10) unsigned NOT NULL, - PRIMARY KEY (`session_id`) + PRIMARY KEY (`session_id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {tags}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {tags} ( - `id` int(9) NOT NULL auto_increment, + `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(64) NOT NULL, - `count` int(10) unsigned NOT NULL default '0', - PRIMARY KEY (`id`), + `count` int(10) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {tasks}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {tasks} ( - `id` int(9) NOT NULL auto_increment, - `callback` varchar(128) default NULL, + `id` int(9) NOT NULL AUTO_INCREMENT, + `callback` varchar(128) DEFAULT NULL, `context` text NOT NULL, - `done` tinyint(1) default '0', - `name` varchar(128) default NULL, - `owner_id` int(9) default NULL, - `percent_complete` int(9) default '0', - `state` varchar(32) default NULL, - `status` varchar(255) default NULL, - `updated` int(9) default NULL, - PRIMARY KEY (`id`), + `done` tinyint(1) DEFAULT '0', + `name` varchar(128) DEFAULT NULL, + `owner_id` int(9) DEFAULT NULL, + `percent_complete` int(9) DEFAULT '0', + `state` varchar(32) DEFAULT NULL, + `status` varchar(255) DEFAULT NULL, + `updated` int(9) DEFAULT NULL, + PRIMARY KEY (`id`), KEY `owner_id` (`owner_id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {themes}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {themes} ( - `id` int(9) NOT NULL auto_increment, - `name` varchar(64) default NULL, - `version` int(9) default NULL, - PRIMARY KEY (`id`), + `id` int(9) NOT NULL AUTO_INCREMENT, + `name` varchar(64) DEFAULT NULL, + `version` int(9) DEFAULT NULL, + PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {themes} VALUES (1,'wind',1); INSERT INTO {themes} VALUES (2,'admin_wind',1); DROP TABLE IF EXISTS {users}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {users} ( - `id` int(9) NOT NULL auto_increment, + `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(32) NOT NULL, `full_name` varchar(255) NOT NULL, `password` varchar(64) NOT NULL, - `login_count` int(10) unsigned NOT NULL default '0', - `last_login` int(10) unsigned NOT NULL default '0', - `email` varchar(64) default NULL, - `admin` tinyint(1) default '0', - `guest` tinyint(1) default '0', - `hash` char(32) default NULL, - `url` varchar(255) default NULL, - `locale` char(10) default NULL, - PRIMARY KEY (`id`), + `login_count` int(10) unsigned NOT NULL DEFAULT '0', + `last_login` int(10) unsigned NOT NULL DEFAULT '0', + `email` varchar(64) DEFAULT NULL, + `admin` tinyint(1) DEFAULT '0', + `guest` tinyint(1) DEFAULT '0', + `hash` char(32) DEFAULT NULL, + `url` varchar(255) DEFAULT NULL, + `locale` char(10) DEFAULT NULL, + PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), UNIQUE KEY `hash` (`hash`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {users} VALUES (1,'guest','Guest User','',0,0,NULL,0,1,NULL,NULL,NULL); INSERT INTO {users} VALUES (2,'admin','Gallery Administrator','',0,0,'unknown@unknown.com',1,0,NULL,NULL,NULL); DROP TABLE IF EXISTS {vars}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {vars} ( - `id` int(9) NOT NULL auto_increment, + `id` int(9) NOT NULL AUTO_INCREMENT, `module_name` varchar(64) NOT NULL, `name` varchar(64) NOT NULL, `value` text, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`), UNIQUE KEY `module_name` (`module_name`,`name`) -) AUTO_INCREMENT=40 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +) AUTO_INCREMENT=41 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind'); INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind'); INSERT INTO {vars} VALUES (NULL,'gallery','page_size','9'); @@ -400,6 +400,7 @@ INSERT INTO {vars} VALUES (NULL,'gallery','blocks_dashboard_center','a:3:{i:6;a: INSERT INTO {vars} VALUES (NULL,'gallery','choose_default_tookit','1'); INSERT INTO {vars} VALUES (NULL,'gallery','identity_provider','user'); INSERT INTO {vars} VALUES (NULL,'user','mininum_password_length','5'); +INSERT INTO {vars} VALUES (NULL,'comment','access_permissions','everybody'); INSERT INTO {vars} VALUES (NULL,'comment','spam_caught','0'); INSERT INTO {vars} VALUES (NULL,'gallery','blocks_site_sidebar','a:3:{i:9;a:2:{i:0;s:4:\"info\";i:1;s:8:\"metadata\";}i:10;a:2:{i:0;s:3:\"rss\";i:1;s:9:\"rss_feeds\";}i:11;a:2:{i:0;s:3:\"tag\";i:1;s:3:\"tag\";}}'); INSERT INTO {vars} VALUES (NULL,'slideshow','max_scale','0'); -- cgit v1.2.3 From ae6af2f9b61d69a3adc36f52257cdbd9c4fedf4e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Tue, 15 Jun 2010 16:01:41 -0700 Subject: Install the rest module by default. --- installer/install.sql | 26 ++++++++++++++++++++------ modules/gallery/controllers/packager.php | 4 ++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/installer/install.sql b/installer/install.sql index d3ba4419..2d0cac0f 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -238,17 +238,18 @@ CREATE TABLE {modules} ( `version` int(9) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) -) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {modules} VALUES (1,1,'gallery',30); INSERT INTO {modules} VALUES (2,1,'user',3); INSERT INTO {modules} VALUES (3,1,'comment',3); INSERT INTO {modules} VALUES (4,1,'organize',1); INSERT INTO {modules} VALUES (5,1,'info',1); -INSERT INTO {modules} VALUES (6,1,'rss',1); -INSERT INTO {modules} VALUES (7,1,'search',1); -INSERT INTO {modules} VALUES (8,1,'slideshow',2); -INSERT INTO {modules} VALUES (9,1,'tag',1); +INSERT INTO {modules} VALUES (6,1,'rest',3); +INSERT INTO {modules} VALUES (7,1,'rss',1); +INSERT INTO {modules} VALUES (8,1,'search',1); +INSERT INTO {modules} VALUES (9,1,'slideshow',2); +INSERT INTO {modules} VALUES (10,1,'tag',1); DROP TABLE IF EXISTS {outgoing_translations}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -345,6 +346,18 @@ CREATE TABLE {themes} ( /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {themes} VALUES (1,'wind',1); INSERT INTO {themes} VALUES (2,'admin_wind',1); +DROP TABLE IF EXISTS {user_access_keys}; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE {user_access_keys} ( + `id` int(9) NOT NULL AUTO_INCREMENT, + `user_id` int(9) NOT NULL, + `access_key` char(32) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `access_key` (`access_key`), + UNIQUE KEY `user_id` (`user_id`) +) DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {users}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -378,7 +391,7 @@ CREATE TABLE {vars} ( `value` text, PRIMARY KEY (`id`), UNIQUE KEY `module_name` (`module_name`,`name`) -) AUTO_INCREMENT=41 DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=42 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind'); INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind'); @@ -402,5 +415,6 @@ INSERT INTO {vars} VALUES (NULL,'gallery','identity_provider','user'); INSERT INTO {vars} VALUES (NULL,'user','mininum_password_length','5'); INSERT INTO {vars} VALUES (NULL,'comment','access_permissions','everybody'); INSERT INTO {vars} VALUES (NULL,'comment','spam_caught','0'); +INSERT INTO {vars} VALUES (NULL,'rest','allow_guest_access','0'); INSERT INTO {vars} VALUES (NULL,'gallery','blocks_site_sidebar','a:3:{i:9;a:2:{i:0;s:4:\"info\";i:1;s:8:\"metadata\";}i:10;a:2:{i:0;s:3:\"rss\";i:1;s:9:\"rss_feeds\";}i:11;a:2:{i:0;s:3:\"tag\";i:1;s:3:\"tag\";}}'); INSERT INTO {vars} VALUES (NULL,'slideshow','max_scale','0'); diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php index 0ccfe743..835cb903 100644 --- a/modules/gallery/controllers/packager.php +++ b/modules/gallery/controllers/packager.php @@ -63,8 +63,8 @@ class Packager_Controller extends Controller { module::load_modules(); - foreach (array("user", "comment", "organize", "info", "rss", - "search", "slideshow", "tag") as $module_name) { + foreach (array("user", "comment", "organize", "info", "rest", + "rss", "search", "slideshow", "tag") as $module_name) { module::install($module_name); module::activate($module_name); } -- cgit v1.2.3 From 78186c262c1ab87500cb8d6a1bebae35c2dfbf40 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Tue, 15 Jun 2010 16:09:45 -0700 Subject: Update the description. --- modules/rest/module.info | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/rest/module.info b/modules/rest/module.info index 4b6b5464..5aaffc28 100644 --- a/modules/rest/module.info +++ b/modules/rest/module.info @@ -1,4 +1,4 @@ -name = "REST Access Module" -description = "The RESTful implementation/interface to Gallery3" +name = "REST API Module" +description = "A REST-based API that allows desktop clients and other apps to interact with Gallery 3" version = 3 -- cgit v1.2.3 From 1df752a2f2aba75358d9bb627bc6da9fad7ca889 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Tue, 15 Jun 2010 16:11:21 -0700 Subject: Make the "name" column a little wider. --- modules/gallery/views/admin_modules.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/views/admin_modules.html.php b/modules/gallery/views/admin_modules.html.php index c5015e68..4d6fe5f0 100644 --- a/modules/gallery/views/admin_modules.html.php +++ b/modules/gallery/views/admin_modules.html.php @@ -52,7 +52,7 @@ <table> <tr> <th> <?= t("Installed") ?> </th> - <th> <?= t("Name") ?> </th> + <th style="width: 8em"> <?= t("Name") ?> </th> <th> <?= t("Version") ?> </th> <th> <?= t("Description") ?> </th> </tr> -- cgit v1.2.3 From 94ada2361df1132d83fa5b14d1b6843725b29166 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Tue, 15 Jun 2010 16:14:30 -0700 Subject: Fix a bug in the upgrader where we weren't bumping the version number during the upgrade path, so the 2nd stanza (version 2 to version 3) was never getting executed. --- modules/comment/helpers/comment_installer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index 7a32bf67..18d51758 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -55,12 +55,12 @@ class comment_installer { $db = Database::instance(); if ($version == 1) { $db->query("ALTER TABLE {comments} CHANGE `state` `state` varchar(15) default 'unpublished'"); - module::set_version("comment", 2); + module::set_version("comment", $version = 2); } if ($version == 2) { module::set_var("comment", "access_permissions", "everybody"); - module::set_version("comment", 3); + module::set_version("comment", $version = 3); } } -- cgit v1.2.3 From 8fb56abf034dd1f5c561e7af12bf6e097a3de6f6 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Tue, 15 Jun 2010 16:30:02 -0700 Subject: Bump the organize module to version 2, and check to make sure that the REST module is active. --- modules/organize/helpers/organize_installer.php | 14 ++++++++++++++ modules/organize/module.info | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/organize/helpers/organize_installer.php b/modules/organize/helpers/organize_installer.php index 7585438f..bbe6fc65 100644 --- a/modules/organize/helpers/organize_installer.php +++ b/modules/organize/helpers/organize_installer.php @@ -22,6 +22,20 @@ class organize_installer { site_status::clear("organize_needs_rest"); } + static function upgrade($version) { + if ($version == 1) { + if (!module::is_active("rest")) { + 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"); + } + + module::set_version("organize", $version = 2); + } + } + static function can_activate() { $messages = array(); if (!module::is_active("rest")) { diff --git a/modules/organize/module.info b/modules/organize/module.info index 5c6b1de0..d7199571 100644 --- a/modules/organize/module.info +++ b/modules/organize/module.info @@ -1,3 +1,3 @@ name = "Organize" description = "Organize your gallery by apply tags or moving images" -version = 1 +version = 2 -- cgit v1.2.3 From 48dc07dbc8189eb16f97b7013b0481982286ab2c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Tue, 15 Jun 2010 17:17:25 -0700 Subject: Revert "Fix for ticket #1118. Create a item::save_with_retries helper method, which encapsulates saving an item and handling name and slug conflicts. Call this instead of doing a save directly." Rolled this back because it fails KISS. We already have an API for saving models with Item_Model::save() that's consistent with all of our other model code. Adding a new way to save items is confusing and inconsistent. This reverts commit 9504f71efcadc7ed27f6f09e5d663e8025bf3b86. --- modules/gallery/controllers/simple_uploader.php | 10 +++------- modules/gallery/helpers/item.php | 17 ++++++----------- modules/gallery/helpers/item_rest.php | 8 +++++--- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index 8ac1fc8b..c7e5031b 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -65,16 +65,12 @@ class Simple_Uploader_Controller extends Controller { if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) { $item->type = "movie"; - } else { - $item->type = "photo"; - } - - item::save_with_retries($item); - - if ($item->type == "movie") { + $item->save(); log::success("content", t("Added a movie"), html::anchor("movies/$item->id", t("view movie"))); } else { + $item->type = "photo"; + $item->save(); log::success("content", t("Added a photo"), html::anchor("photos/$item->id", t("view photo"))); } diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 0710d8b2..6a740de4 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -43,17 +43,6 @@ class item_Core { // Moving may result in name or slug conflicts. If that happens, try up to 5 times to pick a // random name (or slug) to avoid the conflict. - $message = item::save_with_retries($source); - - // If the target has no cover item, make this it. - if ($target->album_cover_item_id == null) { - item::make_album_cover($source); - } - - return $message; - } - - static function save_with_retries($source, $retries=5) { $orig_name = $source->name; $orig_name_filename = pathinfo($source->name, PATHINFO_FILENAME); $orig_name_extension = pathinfo($source->name, PATHINFO_EXTENSION); @@ -102,6 +91,12 @@ class item_Core { } } } + + // If the target has no cover item, make this it. + if ($target->album_cover_item_id == null) { + item::make_album_cover($source); + } + return $message; } diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 74fab2e7..692d0895 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -112,6 +112,8 @@ class item_rest_Core { } break; + case "parent": + break; default: if (property_exists($entity, $key)) { $item->$key = $entity->$key; @@ -124,7 +126,7 @@ class item_rest_Core { $parent = rest::resolve($entity->parent); item::move($item, $parent); } else { - $item::save_with_retries($item); + $item->save(); } } @@ -155,7 +157,7 @@ class item_rest_Core { $item->title = isset($entity->title) ? $entity->title : $entity->name; $item->description = isset($entity->description) ? $entity->description : null; $item->slug = isset($entity->slug) ? $entity->slug : null; - $item::save_with_retries($item); + $item->save(); break; case "photo": @@ -170,7 +172,7 @@ class item_rest_Core { $item->title = isset($entity->title) ? $entity->title : $entity->name; $item->description = isset($entity->description) ? $entity->description : null; $item->slug = isset($entity->slug) ? $entity->slug : null; - $item::save_with_retries($item); + $item->save(); break; default: -- cgit v1.2.3 From a432a43b3b39fbec70d4cece1eb0ba5625b2679c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Tue, 15 Jun 2010 17:18:22 -0700 Subject: Revert "Change the item rest update processing to call the item::move(source, target) helper when the parent member has changed. Using the move method insures that names and slugs that could conflict in the target album are resolved properly. Changed the item::move method so it returns a message to be displayed if the caller chooses. And changed the move controller to display the message returned by the move if the item name was renamed as part of the move." Rolling this back for a couple of reasons: 1) Bug in move.php ("message.info" is not a function name) 2) Having the message come back from the API call as a side-effect is sloppy. We should find a cleaner way to do this checking. 3) having item::move() call save() on any changed values in the ORM is counter-intuitive. Move should move, save should save. I think the right approach here is to roll the move() code properly into save(). This reverts commit 2492280cc0ec9eb64a8daeccc7b5698ece7fea66. --- modules/gallery/controllers/move.php | 10 ++++++---- modules/gallery/helpers/item.php | 15 ++++++--------- modules/gallery/helpers/item_rest.php | 16 +++++++--------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/modules/gallery/controllers/move.php b/modules/gallery/controllers/move.php index 3ce44546..f8b85b6f 100644 --- a/modules/gallery/controllers/move.php +++ b/modules/gallery/controllers/move.php @@ -34,10 +34,12 @@ class Move_Controller extends Controller { $source = ORM::factory("item", $source_id); $target = ORM::factory("item", Input::instance()->post("target_id")); - $message = item::move($source, $target); - if (!empty($message)) { - message.info($message); - } + access::required("view", $source); + access::required("edit", $source); + access::required("view", $target); + access::required("edit", $target); + + item::move($source, $target); print json_encode( array("result" => "success", diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 6a740de4..15bbe977 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -47,28 +47,27 @@ class item_Core { $orig_name_filename = pathinfo($source->name, PATHINFO_FILENAME); $orig_name_extension = pathinfo($source->name, PATHINFO_EXTENSION); $orig_slug = $source->slug; - $message = ""; for ($i = 0; $i < 5; $i++) { try { $source->save(); if ($orig_name != $source->name) { switch ($source->type) { case "album": - $message = + message::info( t("Album <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", - array("old_name" => $orig_name, "new_name" => $source->name)); + array("old_name" => $orig_name, "new_name" => $source->name))); break; case "photo": - $message = + message::info( t("Photo <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", - array("old_name" => $orig_name, "new_name" => $source->name)); + array("old_name" => $orig_name, "new_name" => $source->name))); break; case "movie": - $message = + message::info( t("Movie <b>%old_name</b> renamed to <b>%new_name</b> to avoid a conflict", - array("old_name" => $orig_name, "new_name" => $source->name)); + array("old_name" => $orig_name, "new_name" => $source->name))); break; } } @@ -96,8 +95,6 @@ class item_Core { if ($target->album_cover_item_id == null) { item::make_album_cover($source); } - - return $message; } static function make_album_cover($item) { diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 692d0895..0839b144 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -99,7 +99,7 @@ class item_rest_Core { if ($entity = $request->params->entity) { // Only change fields from a whitelist. foreach (array("album_cover", "captured", "description", - "height", "mime_type", "name", "rand_key", "resize_dirty", + "height", "mime_type", "name", "parent", "rand_key", "resize_dirty", "resize_height", "resize_width", "slug", "sort_column", "sort_order", "thumb_dirty", "thumb_height", "thumb_width", "title", "view_count", "width") as $key) { @@ -113,6 +113,11 @@ class item_rest_Core { break; case "parent": + if (property_exists($entity, "parent")) { + $parent = rest::resolve($entity->parent); + access::required("edit", $parent); + $item->parent_id = $parent->id; + } break; default: if (property_exists($entity, $key)) { @@ -120,15 +125,8 @@ class item_rest_Core { } } } - - // There is an explicit save in item::move - if (property_exists($entity, "parent")) { - $parent = rest::resolve($entity->parent); - item::move($item, $parent); - } else { - $item->save(); - } } + $item->save(); if (isset($request->params->members) && $item->sort_column == "weight") { $weight = 0; -- cgit v1.2.3 From 57b53e6193cc6baf12bf58d8e528518a93bff03c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Tue, 15 Jun 2010 20:21:10 -0700 Subject: Guard against relationships() not returning an array. --- modules/rest/helpers/rest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php index 3229330a..b382cb29 100644 --- a/modules/rest/helpers/rest.php +++ b/modules/rest/helpers/rest.php @@ -137,9 +137,9 @@ class rest_Core { foreach (glob(MODPATH . "{$module->name}/helpers/*_rest.php") as $filename) { $class = str_replace(".php", "", basename($filename)); if (method_exists($class, "relationships")) { - $results = array_merge( - $results, - call_user_func(array($class, "relationships"), $resource_type, $resource)); + if ($tmp = call_user_func(array($class, "relationships"), $resource_type, $resource)) { + $results = array_merge($results, $tmp); + } } } } -- cgit v1.2.3 From e3535349abb6e955a75d97f57971f4ea4913da6f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Tue, 15 Jun 2010 20:25:35 -0700 Subject: Revert "Add a "convert_ids" parameter to Item_Model::as_restful_array(), which" This reverts commit 98fce83de5f772482382bfabdbcd94c25ecdbb1a. Conflicts: modules/gallery/tests/Item_Model_Test.php --- modules/gallery/models/item.php | 20 ++++++++------------ modules/gallery/tests/Item_Model_Test.php | 12 ------------ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 009457c1..e42430bf 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -924,21 +924,17 @@ class Item_Model extends ORM_MPTT { /** * Same as ORM::as_array() but convert id fields into their RESTful form. */ - public function as_restful_array($convert_ids=true) { + public function as_restful_array() { // Convert item ids to rest URLs for consistency $data = $this->as_array(); - - if ($convert_ids) { - if ($tmp = $this->parent()) { - $data["parent"] = rest::url("item", $tmp); - } - unset($data["parent_id"]); - - if ($tmp = $this->album_cover()) { - $data["album_cover"] = rest::url("item", $tmp); - } - unset($data["album_cover_item_id"]); + if ($tmp = $this->parent()) { + $data["parent"] = rest::url("item", $tmp); + } + unset($data["parent_id"]); + if ($tmp = $this->album_cover()) { + $data["album_cover"] = rest::url("item", $tmp); } + unset($data["album_cover_item_id"]); if (access::can("view_full", $this) && $this->is_photo()) { $data["file_url"] = $this->file_url(true); diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index f9e6a4e3..907cfe24 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -368,18 +368,6 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $this->assert_true(!array_key_exists("album_cover_item_id", $result)); } - public function as_restful_array_with_ids_test() { - $album = test::random_album(); - $photo = test::random_photo($album); - $album->reload(); - - $result = $album->as_restful_array(false); - $this->assert_same(item::root()->id, $result["parent_id"]); - $this->assert_same($photo->id, $result["album_cover_item_id"]); - $this->assert_true(!array_key_exists("parent", $result)); - $this->assert_true(!array_key_exists("album_cover_item", $result)); - } - public function as_restful_array_with_edit_bit_test() { $response = item::root()->as_restful_array(true); $this->assert_true($response["can_edit"]); -- cgit v1.2.3 From 1fb33393269d3a1d32048898545c5ef812383f2e Mon Sep 17 00:00:00 2001 From: Jan Koprowski <jan.koprowski@gmail.com> Date: Wed, 16 Jun 2010 14:29:28 +0800 Subject: Fix issue1068. Fill from_id field in photo with indetificator --- modules/gallery/helpers/photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index f20d37a3..73cd60c0 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -26,7 +26,7 @@ class photo_Core { static function get_edit_form($photo) { $form = new Forge("photos/update/$photo->id", "", "post", array("id" => "g-edit-photo-form")); - $form->hidden("from_id"); + $form->hidden("from_id")->value($photo->id); $group = $form->group("edit_item")->label(t("Edit Photo")); $group->input("title")->label(t("Title"))->value($photo->title) ->error_messages("required", t("You must provide a title")) -- cgit v1.2.3 From ea8653f9470ceb09a4d5ddca2aec023f2f7fe5a2 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Wed, 16 Jun 2010 08:39:09 -0700 Subject: Fix for ticket #1131. If the rss feed is for an item, then retrieve the item. Using the left and right pointers find all the comments for the child items. Thanks to jankoprowski for the initial investigation. --- modules/comment/helpers/comment_rss.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index eee6f750..a18beb9b 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -33,13 +33,20 @@ class comment_rss_Core { return; } + Kohana_Log::add("error", "feed($feed_id, $offset, $limit, $id)"); $comments = ORM::factory("comment") ->viewable() ->where("state", "=", "published") ->order_by("created", "DESC"); if ($feed_id == "item") { - $comments->where("item_id", "=", $id); + $item = ORM::factory("item", $id); + $subquery = db::select("id") + ->from("items") + ->where("left_ptr", ">=", $item->left_ptr) + ->where("right_ptr", "<=", $item->right_ptr); + $comments + ->where("item_id", "in", $subquery); } $feed = new stdClass(); -- cgit v1.2.3 From 8ee60e6b5d694a8117c94595a0f03090cd41cca8 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Wed, 16 Jun 2010 11:17:18 -0700 Subject: slap my wrist... i forgot a debugging statement --- modules/comment/helpers/comment_rss.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index a18beb9b..479023bd 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -33,7 +33,6 @@ class comment_rss_Core { return; } - Kohana_Log::add("error", "feed($feed_id, $offset, $limit, $id)"); $comments = ORM::factory("comment") ->viewable() ->where("state", "=", "published") -- cgit v1.2.3 From 179161d05ee037292202a15507d38166f8a7ee4a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Wed, 16 Jun 2010 15:07:13 -0700 Subject: Fix two bugs: #1161: guest comments get dropped because of a missing email address. #1075: G2 comments with " get turned into " --- modules/g2_import/helpers/g2_import.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 575d02bb..2a549146 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -826,6 +826,7 @@ class g2_import_Core { $text .= " "; } $text .= $g2_comment->getComment(); + $text = html_entity_decode($text); // Just import the fields we know about. Do this outside of the comment API for now so that // we don't trigger spam filtering events @@ -835,6 +836,7 @@ class g2_import_Core { if ($comment->author_id == identity::guest()->id) { $comment->guest_name = $g2_comment->getAuthor(); $comment->guest_name or $comment->guest_name = (string) t("Anonymous coward"); + $comment->guest_email = "unknown@nobody.com"; } $comment->item_id = $item_id; $comment->text = self::_transform_bbcode($text); -- cgit v1.2.3 From 8d1c6887a5120e7fe1302a327043f512c8b5da7d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Wed, 16 Jun 2010 15:12:00 -0700 Subject: Fix a bug introduced in 1077477a9032d5a4855e19e2dd4ce923472b711c where we don't generate album highlights correctly. Possible fix for #1054. --- modules/g2_import/helpers/g2_import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 2a549146..f0e62854 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -502,7 +502,7 @@ class g2_import_Core { } try { $g3_album->save(); - graphics::generate($g2_album); + graphics::generate($g3_album); } catch (Exception $e) { return (string) new G2_Import_Exception( t("Failed to generate an album highlight for album '%name'.", -- cgit v1.2.3 From 2025c2c37d8607fa5f296a9b6912577989e90bc3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Wed, 16 Jun 2010 15:53:07 -0700 Subject: If the G2 orderBy or orderDirection fields are blank, use the G2 defaults. Second half of fix for #1054. --- modules/g2_import/helpers/g2_import.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index f0e62854..c0ea09d6 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -438,8 +438,15 @@ class g2_import_Core { // Only consider G2's first sort order $g2_order = explode("|", $g2_album->getOrderBy() . ""); $g2_order = $g2_order[0]; + if (empty($g2_order)) { + $g2_order = g2(GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderBy')); + } $g2_order_direction = explode("|", $g2_album->getOrderDirection() . ""); $g2_order_direction = $g2_order_direction[0]; + if (empty($g2_order_direction)) { + $g2_order_direction = + g2(GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderDirection')); + } if (array_key_exists($g2_order, $order_map)) { $album->sort_column = $order_map[$g2_order]; $album->sort_order = $direction_map[$g2_order_direction]; -- cgit v1.2.3 From bd496cc95c01d8058cacfd79347f626652d42464 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Wed, 16 Jun 2010 16:09:29 -0700 Subject: Add start/num query parameters to tags::get() --- modules/tag/helpers/tags_rest.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/tag/helpers/tags_rest.php b/modules/tag/helpers/tags_rest.php index 434e774a..975cf140 100644 --- a/modules/tag/helpers/tags_rest.php +++ b/modules/tag/helpers/tags_rest.php @@ -18,9 +18,22 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class tags_rest_Core { + /** + * Possible request parameters: + * start=# + * start at the Nth comment (zero based) + * + * num=# + * return up to N comments (max 100) + */ static function get($request) { $tags = array(); - foreach (ORM::factory("tag")->find_all() as $tag) { + + $p = $request->params; + $num = isset($p->num) ? min((int)$p->num, 100) : 10; + $start = isset($p->start) ? (int)$p->start : 0; + + foreach (ORM::factory("tag")->find_all($num, $start) as $tag) { $tags[] = rest::url("tag", $tag); } return array("url" => rest::url("tags"), -- cgit v1.2.3 From 172c3fd209d81f9242d388ca0faf4f302bb08405 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Wed, 16 Jun 2010 17:31:31 -0700 Subject: Fix a typo... The controller parameter to the flex organize module should be controllerUri instead. --- modules/organize/views/organize_dialog.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 8160a339..8113a1af 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -97,7 +97,7 @@ sortFields: "<?= $sort_fields ?>", albumId: "<?= $album->id ?>", restUri: "<?= url::site("rest") ?>/", - controller: "<?= url::site("organize") ?>/" + controllerUri: "<?= url::site("organize") ?>/" }; }; /* -- cgit v1.2.3 From 1aeaa7daabf2c00df45088f4a90615b463fb9f90 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Wed, 16 Jun 2010 18:05:15 -0700 Subject: Add REST support for comments. You can view, add, edit and delete comments. --- modules/comment/helpers/comment_rest.php | 85 ++++++++++++++++++++++++++ modules/comment/helpers/comments_rest.php | 62 +++++++++++++++++++ modules/comment/helpers/item_comments_rest.php | 50 +++++++++++++++ modules/comment/models/comment.php | 16 +++++ 4 files changed, 213 insertions(+) create mode 100644 modules/comment/helpers/comment_rest.php create mode 100644 modules/comment/helpers/comments_rest.php create mode 100644 modules/comment/helpers/item_comments_rest.php diff --git a/modules/comment/helpers/comment_rest.php b/modules/comment/helpers/comment_rest.php new file mode 100644 index 00000000..cfdf9fa3 --- /dev/null +++ b/modules/comment/helpers/comment_rest.php @@ -0,0 +1,85 @@ +<?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 comment_rest_Core { + static function get($request) { + $comment = rest::resolve($request->url); + access::required("view", $comment->item()); + + return array( + "url" => $request->url, + "entity" => $comment->as_restful_array(), + "relationships" => rest::relationships("comment", $comment)); + } + + static function put($request) { + // Only admins can edit comments, for now + if (!identity::active_user()->admin) { + access::forbidden(); + } + + $comment = rest::resolve($request->url); + $comment = ORM::factory("comment"); + $comment->text = $request->params->text; + $comment->save(); + } + + static function post($request) { + $item = rest::resolve($request->url); + access::required("edit", $item); + + $entity = $request->params->entity; + $comment->text = $request->params->text; + $comment->save(); + + return array("url" => rest::url("comment", $comment)); + } + + static function delete($request) { + if (!identity::active_user()->admin) { + access::forbidden(); + } + + $comment = rest::resolve($request->url); + access::required("edit", $comment->item()); + + $comment->delete(); + } + + static function relationships($resource_type, $resource) { + switch ($resource_type) { + case "item": + return array( + "comments" => array( + "url" => rest::url("item_comments", $resource))); + } + } + + static function resolve($id) { + $comment = ORM::factory("comment", $id); + if (!access::can("view", $comment->item())) { + throw new Kohana_404_Exception(); + } + return $comment; + } + + static function url($comment) { + return url::abs_site("rest/comment/{$comment->id}"); + } +} diff --git a/modules/comment/helpers/comments_rest.php b/modules/comment/helpers/comments_rest.php new file mode 100644 index 00000000..1cedb80b --- /dev/null +++ b/modules/comment/helpers/comments_rest.php @@ -0,0 +1,62 @@ +<?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 comments_rest_Core { + /** + * Possible request parameters: + * start=# + * start at the Nth comment (zero based) + * + * num=# + * return up to N comments (max 100) + */ + static function get($request) { + $comments = array(); + + $p = $request->params; + $num = isset($p->num) ? min((int)$p->num, 100) : 10; + $start = isset($p->start) ? (int)$p->start : 0; + + foreach (ORM::factory("comment")->viewable()->find_all($num, $start) as $comment) { + $comments[] = rest::url("comment", $comment); + } + return array("url" => rest::url("comments"), + "members" => $comments); + } + + + static function post($request) { + $entity = $request->params->entity; + + $item = rest::resolve($entity->item); + access::required("edit", $item); + + $comment = ORM::factory("comment"); + $comment->author_id = identity::active_user()->id; + $comment->item_id = $item->id; + $comment->text = $entity->text; + $comment->save(); + + return array("url" => rest::url("comment", $comment)); + } + + static function url() { + return url::abs_site("rest/comments"); + } +} diff --git a/modules/comment/helpers/item_comments_rest.php b/modules/comment/helpers/item_comments_rest.php new file mode 100644 index 00000000..1fe5c35f --- /dev/null +++ b/modules/comment/helpers/item_comments_rest.php @@ -0,0 +1,50 @@ +<?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 item_comments_rest_Core { + static function get($request) { + $item = rest::resolve($request->url); + access::required("view", $item); + + $comments = array(); + foreach (ORM::factory("comment") + ->viewable() + ->where("item_id", "=", $item->id) + ->order_by("created", "DESC") + ->find_all() as $comment) { + $comments[] = rest::url("comment", $comment); + } + + return array( + "url" => $request->url, + "members" => $comments); + } + + static function resolve($id) { + $item = ORM::factory("item", $id); + if (!access::can("view", $item)) { + throw new Kohana_404_Exception(); + } + return $item; + } + + static function url($item) { + return url::abs_site("rest/item_comments/{$item->id}"); + } +} diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php index fb70c79a..772e8b60 100644 --- a/modules/comment/models/comment.php +++ b/modules/comment/models/comment.php @@ -175,4 +175,20 @@ class Comment_Model extends ORM { static function valid_state($value) { return in_array($value, array("published", "unpublished", "spam", "deleted")); } + + /** + * Same as ORM::as_array() but convert id fields into their RESTful form. + */ + public function as_restful_array() { + $data = array(); + foreach ($this->as_array() as $key => $value) { + if (strncmp($key, "server_", 7)) { + $data[$key] = $value; + } + } + $data["item"] = rest::url("item", $this->item()); + unset($data["item_id"]); + + return $data; + } } -- cgit v1.2.3 From a27189ce9f771251f89947e4264e503596f0b2dd Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Wed, 16 Jun 2010 20:02:52 -0700 Subject: Remove comment_rest::post() -- that's in comments_rest now. --- modules/comment/helpers/comment_rest.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/modules/comment/helpers/comment_rest.php b/modules/comment/helpers/comment_rest.php index cfdf9fa3..bd3011cc 100644 --- a/modules/comment/helpers/comment_rest.php +++ b/modules/comment/helpers/comment_rest.php @@ -40,17 +40,6 @@ class comment_rest_Core { $comment->save(); } - static function post($request) { - $item = rest::resolve($request->url); - access::required("edit", $item); - - $entity = $request->params->entity; - $comment->text = $request->params->text; - $comment->save(); - - return array("url" => rest::url("comment", $comment)); - } - static function delete($request) { if (!identity::active_user()->admin) { access::forbidden(); -- cgit v1.2.3 From 3d4f04e827f54c3e4dec6a7d1e8e3bf78cf9603a Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Thu, 17 Jun 2010 06:14:24 -0700 Subject: Change the add album dialog to not replace the internet address or name fields if they already contain values. --- modules/organize/lib/Gallery3WebClient.swf | Bin 150666 -> 150760 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index 3c871e8a..82735217 100644 Binary files a/modules/organize/lib/Gallery3WebClient.swf and b/modules/organize/lib/Gallery3WebClient.swf differ -- cgit v1.2.3 From 38d09c5d1adae211d61b16d82448b616318b951e Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Thu, 17 Jun 2010 08:03:08 -0700 Subject: Scale a movie to the resize size so that it doesn't overflow into the sidebar. --- modules/gallery/models/item.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index e42430bf..5e8a2d09 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -671,8 +671,21 @@ class Item_Model extends ORM_MPTT { */ public function movie_img($extra_attrs) { $v = new View("movieplayer.html"); + $max_size = module::get_var("gallery", "resize_size", 640); + $width = $this->width; + $height = $this->height; + if ($width > $max_size || $height > $max_size) { + if ($width > $height) { + $height *= $max_size / $width; + $width = $max_size; + } else { + $width *= $max_size / $height; + $height = $max_size; + } + } + $v->attrs = array_merge($extra_attrs, - array("style" => "display:block;width:{$this->width}px;height:{$this->height}px")); + array("style" => "display:block;width:{$width}px;height:{$height}px")); if (empty($v->attrs["id"])) { $v->attrs["id"] = "g-item-id-{$this->id}"; } -- cgit v1.2.3 From 6e54286ef25d02910e69ce553ab1c719dc7299cc Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Thu, 17 Jun 2010 09:03:39 -0700 Subject: Add the theme::resize_top and theme::resize_bottom to the movie view to be consistent with the photo view. --- themes/wind/views/movie.html.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/wind/views/movie.html.php b/themes/wind/views/movie.html.php index 8481c7ce..158857db 100644 --- a/themes/wind/views/movie.html.php +++ b/themes/wind/views/movie.html.php @@ -5,7 +5,9 @@ <?= $theme->paginator() ?> <div id="g-movie" class="ui-helper-clearfix"> + <?= $theme->resize_top($item) ?> <?= $item->movie_img(array("class" => "g-movie", "id" => "g-item-id-{$item->id}")) ?> + <?= $theme->resize_bottom($item) ?> </div> <div id="g-info"> -- cgit v1.2.3 From 2bbce8dddb0ab0a00aee727e2f639b793988a1d1 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Thu, 17 Jun 2010 09:10:01 -0700 Subject: Fix for ticket #1117 align videos to the center. --- modules/gallery/models/item.php | 4 ++-- themes/wind/css/screen.css | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 5e8a2d09..4d05e4da 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -684,8 +684,8 @@ class Item_Model extends ORM_MPTT { } } - $v->attrs = array_merge($extra_attrs, - array("style" => "display:block;width:{$width}px;height:{$height}px")); + $v->attrs = array_merge($extra_attrs, array("style" => "width:{$width}px;height:{$height}px", + "class" => "g-movie")); if (empty($v->attrs["id"])) { $v->attrs["id"] = "g-item-id-{$this->id}"; } diff --git a/themes/wind/css/screen.css b/themes/wind/css/screen.css index f8e26073..1e55a967 100644 --- a/themes/wind/css/screen.css +++ b/themes/wind/css/screen.css @@ -302,7 +302,7 @@ td { } #g-item img.g-resize, -#g-item a.g-movie object { +#g-item a.g-movie { display: block; margin: 0 auto; } -- cgit v1.2.3 From a03e3d1dc1b59e45e5b0dbf4cf23eed91d545c25 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Thu, 17 Jun 2010 09:38:36 -0700 Subject: Fix for ticket #1110. Need to use the encode_path with a movie extension to find the item. Thanks to samdavidoff for the initial fix. --- modules/gallery/controllers/file_proxy.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index fff90ec5..32690fc0 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -60,12 +60,12 @@ class File_Proxy_Controller extends Controller { foreach (explode("/", $path) as $path_part) { $encoded_path[] = rawurlencode($path_part); } - + $encoded_path = implode("/", $encoded_path); // We now have the relative path to the item. Search for it in the path cache // The patch cache is urlencoded so re-encode the path. (it was decoded earlier to // insure that the paths are normalized. $item = ORM::factory("item") - ->where("relative_path_cache", "=", implode("/", $encoded_path))->find(); + ->where("relative_path_cache", "=", $encoded_path)->find(); if (!$item->loaded()) { // We didn't turn it up. It's possible that the relative_path_cache is out of date here. // There was fallback code, but bharat deleted it in 8f1bca74. If it turns out to be @@ -76,7 +76,7 @@ class File_Proxy_Controller extends Controller { // So try some alternate types: if (preg_match('/.jpg$/', $path)) { foreach (array("flv", "mp4") as $ext) { - $movie_path = preg_replace('/.jpg$/', ".$ext", $path); + $movie_path = preg_replace('/.jpg$/', ".$ext", $encoded_path); $item = ORM::factory("item")->where("relative_path_cache", "=", $movie_path)->find(); if ($item->loaded()) { break; -- cgit v1.2.3 From 359235182ebb14c75b495a889a2298d1e0130d77 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> 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(-) 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("<?= url::file("modules/organize/lib/Gallery3WebClient.swf") ?>", + swfobject.embedSWF("<?= $swf_url ?>", "flashContent", size.width() - 100, size.height() - 135, swfVersionStr, xiSwfUrlStr, flashvars, params, attributes); </script> -- cgit v1.2.3 From 070db2a97ab3e508456780639faa643934081966 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> 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(-) 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: "<?= $sort_order ?>", sortFields: "<?= $sort_fields ?>", albumId: "<?= $album->id ?>", - restUri: "<?= url::site("rest") ?>/", - controllerUri: "<?= url::site("organize") ?>/" + restUri: "<?= $rest_uri ?>", + controllerUri: "<?= $controller_uri ?>/" }; }; /* -- cgit v1.2.3 From e82aa6dcd80ce0c41a04e3331b0a63e25c25216f Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Thu, 17 Jun 2010 10:22:19 -0700 Subject: Update the xss gold file with changes to views in the last couple of commits. --- modules/gallery/tests/xss_data.txt | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 68dca9cb..7fce42a1 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -235,27 +235,16 @@ modules/notification/views/item_updated.html.php 20 DIRTY_JS $item- modules/notification/views/item_updated.html.php 20 DIRTY $item->abs_url() modules/notification/views/user_profile_notification.html.php 5 DIRTY_ATTR $subscription->id modules/notification/views/user_profile_notification.html.php 6 DIRTY_JS $subscription->url -modules/organize/views/organize_dialog.html.php 3 DIRTY_JS url::site("organize/move_to/__ALBUM_ID__?csrf=$csrf") -modules/organize/views/organize_dialog.html.php 4 DIRTY_JS url::site("organize/rearrange/__TARGET_ID__/__BEFORE__?csrf=$csrf") -modules/organize/views/organize_dialog.html.php 5 DIRTY_JS url::site("organize/sort_order/__ALBUM_ID__/__COL__/__DIR__?csrf=$csrf") -modules/organize/views/organize_dialog.html.php 6 DIRTY_JS url::site("organize/tree/__ALBUM_ID__") -modules/organize/views/organize_dialog.html.php 14 DIRTY $album_tree -modules/organize/views/organize_dialog.html.php 23 DIRTY $micro_thumb_grid -modules/organize/views/organize_dialog.html.php 32 DIRTY form::dropdown(array("id"=>"g-organize-sort-column"),album::get_sort_order_options(),$album->sort_column) -modules/organize/views/organize_thumb_grid.html.php 3 DIRTY_ATTR $child->is_album()?"g-album":"g-photo" -modules/organize/views/organize_thumb_grid.html.php 4 DIRTY_ATTR $child->id -modules/organize/views/organize_thumb_grid.html.php 5 DIRTY $child->thumb_img(array("class"=>"g-thumbnail","ref"=>$child->id),90,true) -modules/organize/views/organize_thumb_grid.html.php 6 DIRTY $child->is_album()?" class=\"ui-icon ui-icon-note\"":"" -modules/organize/views/organize_thumb_grid.html.php 13 DIRTY_JS url::site("organize/album/$album->id/".($offset+25)) -modules/organize/views/organize_tree.html.php 2 DIRTY_ATTR access::can("edit",$album)?"":"g-view-only" -modules/organize/views/organize_tree.html.php 3 DIRTY_ATTR $album->id -modules/organize/views/organize_tree.html.php 6 DIRTY_ATTR $selected&&$album->id==$selected->id?"ui-state-focus":"" -modules/organize/views/organize_tree.html.php 7 DIRTY_ATTR $album->id -modules/organize/views/organize_tree.html.php 15 DIRTY View::factory("organize_tree.html",array("selected"=>$selected,"album"=>$child)); -modules/organize/views/organize_tree.html.php 17 DIRTY_ATTR access::can("edit",$child)?"":"g-view-only" -modules/organize/views/organize_tree.html.php 18 DIRTY_ATTR $child->id -modules/organize/views/organize_tree.html.php 20 DIRTY_ATTR $selected&&$child->id==$selected->id?"ui-state-focus":"" -modules/organize/views/organize_tree.html.php 20 DIRTY_ATTR $child->id +modules/organize/views/organize_dialog.html.php 92 DIRTY_JS $domain +modules/organize/views/organize_dialog.html.php 93 DIRTY_JS $access_key +modules/organize/views/organize_dialog.html.php 94 DIRTY_JS $protocol +modules/organize/views/organize_dialog.html.php 95 DIRTY_JS $file_filter +modules/organize/views/organize_dialog.html.php 96 DIRTY_JS $sort_order +modules/organize/views/organize_dialog.html.php 97 DIRTY_JS $sort_fields +modules/organize/views/organize_dialog.html.php 98 DIRTY_JS $album->id +modules/organize/views/organize_dialog.html.php 99 DIRTY_JS $rest_uri +modules/organize/views/organize_dialog.html.php 100 DIRTY_JS $controller_uri +modules/organize/views/organize_dialog.html.php 124 DIRTY_JS $swf_url modules/recaptcha/views/admin_recaptcha.html.php 11 DIRTY $form modules/recaptcha/views/admin_recaptcha.html.php 23 DIRTY_JS $public_key modules/recaptcha/views/form_recaptcha.html.php 7 DIRTY_JS $public_key @@ -363,7 +352,7 @@ themes/wind/views/dynamic.html.php 16 DIRTY_ATTR $chi themes/wind/views/dynamic.html.php 17 DIRTY_ATTR $child->thumb_height themes/wind/views/dynamic.html.php 29 DIRTY $theme->paginator() themes/wind/views/movie.html.php 5 DIRTY $theme->paginator() -themes/wind/views/movie.html.php 8 DIRTY $item->movie_img(array("class"=>"g-movie","id"=>"g-item-id-{$item->id}")) +themes/wind/views/movie.html.php 9 DIRTY $item->movie_img(array("class"=>"g-movie","id"=>"g-item-id-{$item->id}")) themes/wind/views/page.html.php 9 DIRTY $page_title themes/wind/views/page.html.php 33 DIRTY_JS $theme->url() themes/wind/views/page.html.php 42 DIRTY $new_width -- cgit v1.2.3 From 70f56ba43aa77568d96fbc8003619007b01acf8e Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Thu, 17 Jun 2010 14:22:35 -0700 Subject: Fix for ticket #1163. Don't all guests to a comment when there are no comments and the comment access permission is register users. --- modules/comment/views/comments.html.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/comment/views/comments.html.php b/modules/comment/views/comments.html.php index 9a608a43..1b9f8bbb 100644 --- a/modules/comment/views/comments.html.php +++ b/modules/comment/views/comments.html.php @@ -10,12 +10,16 @@ <div id="g-comment-detail"> <? if (!$comments->count()): ?> <p class="g-no-comments"> + <? if (comment::can_comment()): ?> <?= t("No comments yet. Be the first to <a %attrs>comment</a>!", array("attrs" => html::mark_clean("href=\"" . url::site("form/add/comments/{$item->id}") . "\" class=\"showCommentForm\""))) ?> + <? else: ?> + <?= t("No comments yet.") ?> + <? endif ?> </p> <ul><li class="g-no-comments"> </li></ul> - <? endif ?> - <? if ($comments->count()): ?> + <? else: ?> + <ul> <? foreach ($comments as $comment): ?> <li id="g-comment-<?= $comment->id ?>"> -- cgit v1.2.3 From fce95785beabb499381d722160d000df2d693b2a Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Thu, 17 Jun 2010 17:41:35 -0700 Subject: Remove duplicate trailing slash on the controllerUri parameter --- modules/organize/views/organize_dialog.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index a4fdc071..4224c10b 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -97,7 +97,7 @@ sortFields: "<?= $sort_fields ?>", albumId: "<?= $album->id ?>", restUri: "<?= $rest_uri ?>", - controllerUri: "<?= $controller_uri ?>/" + controllerUri: "<?= $controller_uri ?>" }; }; /* -- cgit v1.2.3 From d84cdcb8fcd424c961fa28bf1829ee828cb431cc Mon Sep 17 00:00:00 2001 From: mamouneyya <mamoun.diraneyya@gmail.com> Date: Fri, 18 Jun 2010 14:06:41 +0300 Subject: (1) Correct the margin direction for checkboxes in RTL (2) Update the id of adding comment button for RTL (3) Flip the corner radiuses for any buttons set, which solves the issue of flipped corners in the comments admin page. Also, add the CSS3 selector of the round corners so they work in Opera (4) Fix ticket #1052 --- lib/gallery.common.css | 81 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/lib/gallery.common.css b/lib/gallery.common.css index 31988b67..10a1f35d 100644 --- a/lib/gallery.common.css +++ b/lib/gallery.common.css @@ -690,14 +690,91 @@ div#g-action-status { } .rtl input.checkbox { - margin-right: .4em; + margin-left: .4em; } -.rtl #g-admin-comment-button { +.rtl #g-add-comment { right: inherit; left: 0; } +.rtl .ui-icon-left .ui-icon { + margin-left: .2em; +} + +.rtl .ui-icon-right .ui-icon { + margin-right: .2em; +} + +/* RTL Corner radius ~~~~~~~~~~~~~~~~~~~~~~ */ +.rtl .g-buttonset .ui-corner-tl { + -moz-border-radius-topleft: 0; + -moz-border-radius-topright: 5px; + -webkit-border-top-left-radius: 0; + -webkit-border-top-right-radius: 5px; + border-top-left-radius: 0; + border-top-right-radius: 5px; +} + +.rtl .g-buttonset .ui-corner-tr { + -moz-border-radius-topright: 0; + -moz-border-radius-topleft: 5px; + -webkit-border-top-right-radius: 0; + -webkit-border-top-left-radius: 5px; + border-top-right-radius: 0; + border-top-left-radius: 5px; +} + +.rtl .g-buttonset .ui-corner-bl { + -moz-border-radius-bottomleft: 0; + -moz-border-radius-bottomright: 5px; + -webkit-border-bottom-left-radius: 0; + -webkit-border-bottom-right-radius: 5px; + border-bottom-left-radius: 0; + border-bottom-right-radius: 5px; +} + +.rtl .g-buttonset .ui-corner-br { + -moz-border-radius-bottomright: 0; + -moz-border-radius-bottomleft: 5px; + -webkit-border-bottom-right-radius: 0; + -webkit-border-bottom-left-radius: 5px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 5px; +} + +.rtl .g-buttonset .ui-corner-right, +.rtl .ui-progressbar .ui-corner-right { + -moz-border-radius-topright: 0; + -webkit-border-top-right-radius: 0; + border-top-right-radius: 0; + -moz-border-radius-topleft: 5px; + -webkit-border-top-left-radius: 5px; + border-top-left-radius: 5px; + -moz-border-radius-bottomright: 0; + -webkit-border-bottom-right-radius: 0; + border-bottom-right-radius: 0; + -moz-border-radius-bottomleft: 5px; + -webkit-border-bottom-left-radius: 5px; + border-bottom-left-radius: 5px; +} + +.rtl .g-buttonset .ui-corner-left, +.rtl .ui-progressbar .ui-corner-left { + -moz-border-radius-topleft: 0; + -webkit-border-top-left-radius: 0; + border-top-left-radius: 0; + -moz-border-radius-topright: 5px; + -webkit-border-top-right-radius: 5px; + border-top-right-radius: 5px; + -moz-border-radius-bottomleft: 0; + -webkit-border-bottom-left-radius: 0; + border-bottom-left-radius: 0; + -moz-border-radius-bottomright: 5px; + -webkit-border-bottom-right-radius: 5px; + border-bottom-right-radius: 5px; +} + /* RTL Superfish ~~~~~~~~~~~~~~~~~~~~~~~~~ */ .rtl .sf-menu a { -- cgit v1.2.3 From 9173ea81676ef6b8abbdefd641b1a572faf13eab Mon Sep 17 00:00:00 2001 From: mamouneyya <mamoun.diraneyya@gmail.com> Date: Fri, 18 Jun 2010 14:07:16 +0300 Subject: Add the CSS3 selector of the round corners so they work in Opera --- lib/themeroller/ui.theme.css | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/themeroller/ui.theme.css b/lib/themeroller/ui.theme.css index 21ece290..477252e5 100644 --- a/lib/themeroller/ui.theme.css +++ b/lib/themeroller/ui.theme.css @@ -228,15 +228,15 @@ ----------------------------------*/ /* Corner radius */ -.ui-corner-tl { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; } -.ui-corner-tr { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; } -.ui-corner-bl { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; } -.ui-corner-br { -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; } -.ui-corner-top { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; } -.ui-corner-bottom { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; } -.ui-corner-right { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; } -.ui-corner-left { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; } -.ui-corner-all { -moz-border-radius: 5px; -webkit-border-radius: 5px; } +.ui-corner-tl { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; } +.ui-corner-tr { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } +.ui-corner-bl { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } +.ui-corner-br { -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-top { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } +.ui-corner-bottom { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-right { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-left { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } +.ui-corner-all { -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } /* Overlays */ .ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); } -- cgit v1.2.3 From 7f8e2786b38ec6f4f57ef865c803742fa5089fb8 Mon Sep 17 00:00:00 2001 From: mamouneyya <mamoun.diraneyya@gmail.com> Date: Fri, 18 Jun 2010 14:07:38 +0300 Subject: Mirror the cancel button for RTL --- lib/uploadify/uploadify.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/uploadify/uploadify.css b/lib/uploadify/uploadify.css index a0279443..7eaa9e93 100644 --- a/lib/uploadify/uploadify.css +++ b/lib/uploadify/uploadify.css @@ -51,3 +51,8 @@ THE SOFTWARE. width: 1px; height: 3px; } + +/* RTL support ~~~~~~~~~~~~~~~~~~~~~~~~~ */ +.rtl .uploadifyQueueItem .cancel { + float: left; +} \ No newline at end of file -- cgit v1.2.3 From 562fb174a763aef748842aae2903e1c0f77deefd Mon Sep 17 00:00:00 2001 From: mamouneyya <mamoun.diraneyya@gmail.com> Date: Fri, 18 Jun 2010 14:08:08 +0300 Subject: Flip some margin/padding values for RTL --- modules/gallery/css/gallery.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index c2fb97e8..e2ad7458 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -197,3 +197,11 @@ .rtl #g-user-profile .g-avatar { margin-left: .6em; } + +.rtl #g-languages-form table { + margin: 0 0 1em 3em; +} + +.rtl #g-translations ol { + margin: 0 2em 1em 0; +} \ No newline at end of file -- cgit v1.2.3 From 3b89a56caf594392c2d45b43932ecb070893588b Mon Sep 17 00:00:00 2001 From: mamouneyya <mamoun.diraneyya@gmail.com> Date: Fri, 18 Jun 2010 14:10:05 +0300 Subject: Flip some margin/padding values for RTL --- themes/admin_wind/css/screen.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/themes/admin_wind/css/screen.css b/themes/admin_wind/css/screen.css index ac47a3db..dbfb59e8 100644 --- a/themes/admin_wind/css/screen.css +++ b/themes/admin_wind/css/screen.css @@ -483,3 +483,8 @@ th { padding-left: 0; padding-right: 1.2em; } + +.rtl .g-selected img, +.rtl .g-available .g-block img { + margin: 0 0 1em 1em; +} \ No newline at end of file -- cgit v1.2.3 From 84c8d1c79a07aa72bb0a22cd3c0673df6f5886f2 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 18 Jun 2010 06:51:02 -0700 Subject: Fix ticket #1155. For compatibility with gallery2 increase the size of the tag name field from 64 bytes to 128 bytes. --- installer/install.sql | 2 +- modules/tag/helpers/tag_installer.php | 12 ++++++++++-- modules/tag/module.info | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/installer/install.sql b/installer/install.sql index 2d0cac0f..0e09101e 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -309,7 +309,7 @@ DROP TABLE IF EXISTS {tags}; /*!40101 SET character_set_client = utf8 */; CREATE TABLE {tags} ( `id` int(9) NOT NULL AUTO_INCREMENT, - `name` varchar(64) NOT NULL, + `name` varchar(128) NOT NULL, `count` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) diff --git a/modules/tag/helpers/tag_installer.php b/modules/tag/helpers/tag_installer.php index 6ccaf835..df6f0c65 100644 --- a/modules/tag/helpers/tag_installer.php +++ b/modules/tag/helpers/tag_installer.php @@ -22,7 +22,7 @@ class tag_installer { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {tags} ( `id` int(9) NOT NULL auto_increment, - `name` varchar(64) NOT NULL, + `name` varchar(128) NOT NULL, `count` int(10) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY(`name`)) @@ -36,7 +36,15 @@ class tag_installer { KEY(`tag_id`, `id`), KEY(`item_id`, `id`)) DEFAULT CHARSET=utf8;"); - module::set_version("tag", 1); + module::set_version("tag", 2); + } + + static function upgrade($version) { + $db = Database::instance(); + if ($version == 1) { + $db->query("ALTER TABLE {tags} MODIFY COLUMN `name` VARCHAR(128)"); + module::set_version("tag", $version = 2); + } } static function uninstall() { diff --git a/modules/tag/module.info b/modules/tag/module.info index e505dd81..8851d119 100644 --- a/modules/tag/module.info +++ b/modules/tag/module.info @@ -1,3 +1,3 @@ name = "Tags" description = "Allows users to tag photos and albums" -version = 1 +version = 2 -- cgit v1.2.3 From 6078eb6264346eba221897f3ddefea1d9ec73821 Mon Sep 17 00:00:00 2001 From: mamouneyya <mamoun.diraneyya@gmail.com> Date: Fri, 18 Jun 2010 23:29:37 +0300 Subject: Add '! important' to the round corners properties with values, force them to be shown even with the case the element has two or more of them (e.g. class='ui-corner-left ui-corner-right'.) Don't know if there was a better solution.. --- lib/gallery.common.css | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/gallery.common.css b/lib/gallery.common.css index 10a1f35d..c5290622 100644 --- a/lib/gallery.common.css +++ b/lib/gallery.common.css @@ -709,38 +709,38 @@ div#g-action-status { /* RTL Corner radius ~~~~~~~~~~~~~~~~~~~~~~ */ .rtl .g-buttonset .ui-corner-tl { -moz-border-radius-topleft: 0; - -moz-border-radius-topright: 5px; -webkit-border-top-left-radius: 0; - -webkit-border-top-right-radius: 5px; border-top-left-radius: 0; - border-top-right-radius: 5px; + -moz-border-radius-topright: 5px !important; + -webkit-border-top-right-radius: 5px !important; + border-top-right-radius: 5px !important; } .rtl .g-buttonset .ui-corner-tr { -moz-border-radius-topright: 0; - -moz-border-radius-topleft: 5px; -webkit-border-top-right-radius: 0; - -webkit-border-top-left-radius: 5px; border-top-right-radius: 0; - border-top-left-radius: 5px; + -moz-border-radius-topleft: 5px !important; + -webkit-border-top-left-radius: 5px !important; + border-top-left-radius: 5px !important; } .rtl .g-buttonset .ui-corner-bl { -moz-border-radius-bottomleft: 0; - -moz-border-radius-bottomright: 5px; -webkit-border-bottom-left-radius: 0; - -webkit-border-bottom-right-radius: 5px; border-bottom-left-radius: 0; - border-bottom-right-radius: 5px; + -moz-border-radius-bottomright: 5px !important; + -webkit-border-bottom-right-radius: 5px !important; + border-bottom-right-radius: 5px !important; } .rtl .g-buttonset .ui-corner-br { -moz-border-radius-bottomright: 0; - -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-right-radius: 0; - -webkit-border-bottom-left-radius: 5px; border-bottom-right-radius: 0; - border-bottom-left-radius: 5px; + -moz-border-radius-bottomleft: 5px !important; + -webkit-border-bottom-left-radius: 5px !important; + border-bottom-left-radius: 5px !important; } .rtl .g-buttonset .ui-corner-right, @@ -748,15 +748,15 @@ div#g-action-status { -moz-border-radius-topright: 0; -webkit-border-top-right-radius: 0; border-top-right-radius: 0; - -moz-border-radius-topleft: 5px; - -webkit-border-top-left-radius: 5px; - border-top-left-radius: 5px; + -moz-border-radius-topleft: 5px !important; + -webkit-border-top-left-radius: 5px !important; + border-top-left-radius: 5px !important; -moz-border-radius-bottomright: 0; -webkit-border-bottom-right-radius: 0; border-bottom-right-radius: 0; - -moz-border-radius-bottomleft: 5px; - -webkit-border-bottom-left-radius: 5px; - border-bottom-left-radius: 5px; + -moz-border-radius-bottomleft: 5px !important; + -webkit-border-bottom-left-radius: 5px !important; + border-bottom-left-radius: 5px !important; } .rtl .g-buttonset .ui-corner-left, @@ -764,15 +764,15 @@ div#g-action-status { -moz-border-radius-topleft: 0; -webkit-border-top-left-radius: 0; border-top-left-radius: 0; - -moz-border-radius-topright: 5px; - -webkit-border-top-right-radius: 5px; - border-top-right-radius: 5px; + -moz-border-radius-topright: 5px !important; + -webkit-border-top-right-radius: 5px !important; + border-top-right-radius: 5px !important; -moz-border-radius-bottomleft: 0; -webkit-border-bottom-left-radius: 0; border-bottom-left-radius: 0; - -moz-border-radius-bottomright: 5px; - -webkit-border-bottom-right-radius: 5px; - border-bottom-right-radius: 5px; + -moz-border-radius-bottomright: 5px !important; + -webkit-border-bottom-right-radius: 5px !important; + border-bottom-right-radius: 5px !important; } /* RTL Superfish ~~~~~~~~~~~~~~~~~~~~~~~~~ */ -- cgit v1.2.3 From f0a99ffc2764a64712a5c5c3abc9a4b3f3c09616 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Fri, 18 Jun 2010 14:31:04 -0700 Subject: Undo "else" clause -- we should keep the logic simple and easy to follow, even if it's redundant. Expand a <ul> to multiple lines. --- modules/comment/views/comments.html.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/comment/views/comments.html.php b/modules/comment/views/comments.html.php index 1b9f8bbb..da45f57b 100644 --- a/modules/comment/views/comments.html.php +++ b/modules/comment/views/comments.html.php @@ -16,10 +16,13 @@ <? else: ?> <?= t("No comments yet.") ?> <? endif ?> - </p> - <ul><li class="g-no-comments"> </li></ul> - <? else: ?> + </p> + <ul> + <li class="g-no-comments"> </li> + </ul> + <? endif ?> + <? if ($comments->count()): ?> <ul> <? foreach ($comments as $comment): ?> <li id="g-comment-<?= $comment->id ?>"> -- cgit v1.2.3 From b1a6fd3e596ebee6714b37c9a108fafac377a540 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Fri, 18 Jun 2010 15:18:56 -0700 Subject: Use request::protocol(). --- modules/slideshow/helpers/slideshow_theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/slideshow/helpers/slideshow_theme.php b/modules/slideshow/helpers/slideshow_theme.php index c23326cf..3203b7bc 100644 --- a/modules/slideshow/helpers/slideshow_theme.php +++ b/modules/slideshow/helpers/slideshow_theme.php @@ -19,7 +19,7 @@ */ class slideshow_theme_Core { static function page_bottom($theme) { - $proto = (empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] === "off") ? "http" : "https"; + $proto = request::protocol(); return "<script src=\"$proto://apps.cooliris.com/slideshow/go.js\" " . "type=\"text/javascript\"></script>"; } -- cgit v1.2.3 From ec40e03a377a8a5cd74b448135307c77a2b9e0e9 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> 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(-) 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: "<?= $domain ?>", accessKey: "<?= $access_key ?>", - protocol: "<?= $protocol ?>", + protocol: "<?= request::protocol() ?>", fileFilter: "<?= $file_filter ?>", sortOrder: "<?= $sort_order ?>", sortFields: "<?= $sort_fields ?>", -- cgit v1.2.3 From bc70ff498d73e0f38f749ea6cd28484ca1a05f83 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Fri, 18 Jun 2010 15:25:33 -0700 Subject: Use request::protocol() --- modules/gallery/helpers/MY_url.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php index 57ce9623..877c5ada 100644 --- a/modules/gallery/helpers/MY_url.php +++ b/modules/gallery/helpers/MY_url.php @@ -70,8 +70,7 @@ class url extends url_Core { * Just like url::file() except that it returns an absolute URI */ static function abs_file($path) { - return url::base( - false, (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off') ? 'http' : 'https') . $path; + return url::base(false, request::protocol()) . $path; } /** @@ -79,8 +78,7 @@ class url extends url_Core { * doesn't take a protocol parameter. */ static function abs_site($path) { - return url::site( - $path, (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off') ? 'http' : 'https'); + return url::site($path, request::protocol()); } /** -- cgit v1.2.3 From ba19c03aebb91335ca64913256e46df0a55aac36 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 18 Jun 2010 16:52:05 -0700 Subject: Update the installer/install.sql properly. --- installer/install.sql | 444 +++++++++++++++++++++++++------------------------- 1 file changed, 222 insertions(+), 222 deletions(-) diff --git a/installer/install.sql b/installer/install.sql index 0e09101e..687da129 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -1,245 +1,245 @@ DROP TABLE IF EXISTS {access_caches}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {access_caches} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `item_id` int(9) DEFAULT NULL, - `view_full_1` binary(1) NOT NULL DEFAULT '0', - `edit_1` binary(1) NOT NULL DEFAULT '0', - `add_1` binary(1) NOT NULL DEFAULT '0', - `view_full_2` binary(1) NOT NULL DEFAULT '0', - `edit_2` binary(1) NOT NULL DEFAULT '0', - `add_2` binary(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) + `id` int(9) NOT NULL auto_increment, + `item_id` int(9) default NULL, + `view_full_1` binary(1) NOT NULL default '0', + `edit_1` binary(1) NOT NULL default '0', + `add_1` binary(1) NOT NULL default '0', + `view_full_2` binary(1) NOT NULL default '0', + `edit_2` binary(1) NOT NULL default '0', + `add_2` binary(1) NOT NULL default '0', + PRIMARY KEY (`id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {access_caches} VALUES (1,1,'1','0','0','1','0','0'); DROP TABLE IF EXISTS {access_intents}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {access_intents} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `item_id` int(9) DEFAULT NULL, - `view_1` binary(1) DEFAULT NULL, - `view_full_1` binary(1) DEFAULT NULL, - `edit_1` binary(1) DEFAULT NULL, - `add_1` binary(1) DEFAULT NULL, - `view_2` binary(1) DEFAULT NULL, - `view_full_2` binary(1) DEFAULT NULL, - `edit_2` binary(1) DEFAULT NULL, - `add_2` binary(1) DEFAULT NULL, - PRIMARY KEY (`id`) + `id` int(9) NOT NULL auto_increment, + `item_id` int(9) default NULL, + `view_1` binary(1) default NULL, + `view_full_1` binary(1) default NULL, + `edit_1` binary(1) default NULL, + `add_1` binary(1) default NULL, + `view_2` binary(1) default NULL, + `view_full_2` binary(1) default NULL, + `edit_2` binary(1) default NULL, + `add_2` binary(1) default NULL, + PRIMARY KEY (`id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {access_intents} VALUES (1,1,'1','1','0','0','1','1','0','0'); DROP TABLE IF EXISTS {caches}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {caches} ( - `id` int(9) NOT NULL AUTO_INCREMENT, + `id` int(9) NOT NULL auto_increment, `key` varchar(255) NOT NULL, - `tags` varchar(255) DEFAULT NULL, + `tags` varchar(255) default NULL, `expiration` int(9) NOT NULL, `cache` longblob, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`), KEY `key` (`key`), KEY `tags` (`tags`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {comments}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {comments} ( - `author_id` int(9) DEFAULT NULL, + `author_id` int(9) default NULL, `created` int(9) NOT NULL, - `guest_email` varchar(128) DEFAULT NULL, - `guest_name` varchar(128) DEFAULT NULL, - `guest_url` varchar(255) DEFAULT NULL, - `id` int(9) NOT NULL AUTO_INCREMENT, + `guest_email` varchar(128) default NULL, + `guest_name` varchar(128) default NULL, + `guest_url` varchar(255) default NULL, + `id` int(9) NOT NULL auto_increment, `item_id` int(9) NOT NULL, - `server_http_accept_charset` varchar(64) DEFAULT NULL, - `server_http_accept_encoding` varchar(64) DEFAULT NULL, - `server_http_accept_language` varchar(64) DEFAULT NULL, - `server_http_accept` varchar(128) DEFAULT NULL, - `server_http_connection` varchar(64) DEFAULT NULL, - `server_http_host` varchar(64) DEFAULT NULL, - `server_http_referer` varchar(255) DEFAULT NULL, - `server_http_user_agent` varchar(128) DEFAULT NULL, - `server_query_string` varchar(64) DEFAULT NULL, - `server_remote_addr` varchar(32) DEFAULT NULL, - `server_remote_host` varchar(64) DEFAULT NULL, - `server_remote_port` varchar(16) DEFAULT NULL, - `state` varchar(15) DEFAULT 'unpublished', + `server_http_accept_charset` varchar(64) default NULL, + `server_http_accept_encoding` varchar(64) default NULL, + `server_http_accept_language` varchar(64) default NULL, + `server_http_accept` varchar(128) default NULL, + `server_http_connection` varchar(64) default NULL, + `server_http_host` varchar(64) default NULL, + `server_http_referer` varchar(255) default NULL, + `server_http_user_agent` varchar(128) default NULL, + `server_query_string` varchar(64) default NULL, + `server_remote_addr` varchar(32) default NULL, + `server_remote_host` varchar(64) default NULL, + `server_remote_port` varchar(16) default NULL, + `state` varchar(15) default 'unpublished', `text` text, `updated` int(9) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {failed_auths}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {failed_auths} ( - `id` int(9) NOT NULL AUTO_INCREMENT, + `id` int(9) NOT NULL auto_increment, `count` int(9) NOT NULL, `name` varchar(255) NOT NULL, `time` int(9) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {graphics_rules}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {graphics_rules} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `active` tinyint(1) DEFAULT '0', - `args` varchar(255) DEFAULT NULL, + `id` int(9) NOT NULL auto_increment, + `active` tinyint(1) default '0', + `args` varchar(255) default NULL, `module_name` varchar(64) NOT NULL, `operation` varchar(64) NOT NULL, `priority` int(9) NOT NULL, `target` varchar(32) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'thumb'); INSERT INTO {graphics_rules} VALUES (2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:640;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'resize'); DROP TABLE IF EXISTS {groups}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {groups} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `name` char(64) DEFAULT NULL, - `special` tinyint(1) DEFAULT '0', - PRIMARY KEY (`id`), + `id` int(9) NOT NULL auto_increment, + `name` char(64) default NULL, + `special` tinyint(1) default '0', + PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {groups} VALUES (1,'Everybody',1); INSERT INTO {groups} VALUES (2,'Registered Users',1); DROP TABLE IF EXISTS {groups_users}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {groups_users} ( `group_id` int(9) NOT NULL, `user_id` int(9) NOT NULL, - PRIMARY KEY (`group_id`,`user_id`), + PRIMARY KEY (`group_id`,`user_id`), UNIQUE KEY `user_id` (`user_id`,`group_id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {groups_users} VALUES (1,1); INSERT INTO {groups_users} VALUES (1,2); INSERT INTO {groups_users} VALUES (2,2); DROP TABLE IF EXISTS {incoming_translations}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {incoming_translations} ( - `id` int(9) NOT NULL AUTO_INCREMENT, + `id` int(9) NOT NULL auto_increment, `key` char(32) NOT NULL, `locale` char(10) NOT NULL, `message` text NOT NULL, - `revision` int(9) DEFAULT NULL, + `revision` int(9) default NULL, `translation` text, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`), UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {items}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {items} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `album_cover_item_id` int(9) DEFAULT NULL, - `captured` int(9) DEFAULT NULL, - `created` int(9) DEFAULT NULL, - `description` varchar(2048) DEFAULT NULL, - `height` int(9) DEFAULT NULL, + `id` int(9) NOT NULL auto_increment, + `album_cover_item_id` int(9) default NULL, + `captured` int(9) default NULL, + `created` int(9) default NULL, + `description` varchar(2048) default NULL, + `height` int(9) default NULL, `left_ptr` int(9) NOT NULL, `level` int(9) NOT NULL, - `mime_type` varchar(64) DEFAULT NULL, - `name` varchar(255) DEFAULT NULL, - `owner_id` int(9) DEFAULT NULL, + `mime_type` varchar(64) default NULL, + `name` varchar(255) default NULL, + `owner_id` int(9) default NULL, `parent_id` int(9) NOT NULL, - `rand_key` float DEFAULT NULL, - `relative_path_cache` varchar(255) DEFAULT NULL, - `relative_url_cache` varchar(255) DEFAULT NULL, - `resize_dirty` tinyint(1) DEFAULT '1', - `resize_height` int(9) DEFAULT NULL, - `resize_width` int(9) DEFAULT NULL, + `rand_key` float default NULL, + `relative_path_cache` varchar(255) default NULL, + `relative_url_cache` varchar(255) default NULL, + `resize_dirty` tinyint(1) default '1', + `resize_height` int(9) default NULL, + `resize_width` int(9) default NULL, `right_ptr` int(9) NOT NULL, - `slug` varchar(255) DEFAULT NULL, - `sort_column` varchar(64) DEFAULT NULL, - `sort_order` char(4) DEFAULT 'ASC', - `thumb_dirty` tinyint(1) DEFAULT '1', - `thumb_height` int(9) DEFAULT NULL, - `thumb_width` int(9) DEFAULT NULL, - `title` varchar(255) DEFAULT NULL, + `slug` varchar(255) default NULL, + `sort_column` varchar(64) default NULL, + `sort_order` char(4) default 'ASC', + `thumb_dirty` tinyint(1) default '1', + `thumb_height` int(9) default NULL, + `thumb_width` int(9) default NULL, + `title` varchar(255) default NULL, `type` varchar(32) NOT NULL, - `updated` int(9) DEFAULT NULL, - `view_count` int(9) DEFAULT '0', - `weight` int(9) NOT NULL DEFAULT '0', - `width` int(9) DEFAULT NULL, - `view_1` binary(1) DEFAULT '0', - `view_2` binary(1) DEFAULT '0', - PRIMARY KEY (`id`), + `updated` int(9) default NULL, + `view_count` int(9) default '0', + `weight` int(9) NOT NULL default '0', + `width` int(9) default NULL, + `view_1` binary(1) default '0', + `view_2` binary(1) default '0', + PRIMARY KEY (`id`), KEY `parent_id` (`parent_id`), KEY `type` (`type`), KEY `random` (`rand_key`), KEY `weight` (`weight`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {items} VALUES (1,NULL,NULL,UNIX_TIMESTAMP(),'',NULL,1,1,NULL,NULL,2,0,NULL,'','',1,NULL,NULL,2,NULL,'weight','ASC',1,NULL,NULL,'Gallery','album',UNIX_TIMESTAMP(),0,1,NULL,'1','1'); DROP TABLE IF EXISTS {items_tags}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {items_tags} ( - `id` int(9) NOT NULL AUTO_INCREMENT, + `id` int(9) NOT NULL auto_increment, `item_id` int(9) NOT NULL, `tag_id` int(9) NOT NULL, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`), KEY `tag_id` (`tag_id`,`id`), KEY `item_id` (`item_id`,`id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {logs}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {logs} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `category` varchar(64) DEFAULT NULL, - `html` varchar(255) DEFAULT NULL, + `id` int(9) NOT NULL auto_increment, + `category` varchar(64) default NULL, + `html` varchar(255) default NULL, `message` text, - `referer` varchar(255) DEFAULT NULL, - `severity` int(9) DEFAULT '0', - `timestamp` int(9) DEFAULT '0', - `url` varchar(255) DEFAULT NULL, - `user_id` int(9) DEFAULT '0', - PRIMARY KEY (`id`) + `referer` varchar(255) default NULL, + `severity` int(9) default '0', + `timestamp` int(9) default '0', + `url` varchar(255) default NULL, + `user_id` int(9) default '0', + PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {messages}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {messages} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `key` varchar(255) DEFAULT NULL, - `severity` varchar(32) DEFAULT NULL, - `value` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`), + `id` int(9) NOT NULL auto_increment, + `key` varchar(255) default NULL, + `severity` varchar(32) default NULL, + `value` varchar(255) default NULL, + PRIMARY KEY (`id`), UNIQUE KEY `key` (`key`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {modules}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {modules} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `active` tinyint(1) DEFAULT '0', - `name` varchar(64) DEFAULT NULL, - `version` int(9) DEFAULT NULL, - PRIMARY KEY (`id`), + `id` int(9) NOT NULL auto_increment, + `active` tinyint(1) default '0', + `name` varchar(64) default NULL, + `version` int(9) default NULL, + PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {modules} VALUES (1,1,'gallery',30); INSERT INTO {modules} VALUES (2,1,'user',3); INSERT INTO {modules} VALUES (3,1,'comment',3); @@ -249,150 +249,150 @@ INSERT INTO {modules} VALUES (6,1,'rest',3); INSERT INTO {modules} VALUES (7,1,'rss',1); INSERT INTO {modules} VALUES (8,1,'search',1); INSERT INTO {modules} VALUES (9,1,'slideshow',2); -INSERT INTO {modules} VALUES (10,1,'tag',1); +INSERT INTO {modules} VALUES (10,1,'tag',2); DROP TABLE IF EXISTS {outgoing_translations}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {outgoing_translations} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `base_revision` int(9) DEFAULT NULL, + `id` int(9) NOT NULL auto_increment, + `base_revision` int(9) default NULL, `key` char(32) NOT NULL, `locale` char(10) NOT NULL, `message` text NOT NULL, `translation` text, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`), UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {permissions}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {permissions} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `display_name` varchar(64) DEFAULT NULL, - `name` varchar(64) DEFAULT NULL, - PRIMARY KEY (`id`), + `id` int(9) NOT NULL auto_increment, + `display_name` varchar(64) default NULL, + `name` varchar(64) default NULL, + PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {permissions} VALUES (1,'View','view'); INSERT INTO {permissions} VALUES (2,'View full size','view_full'); INSERT INTO {permissions} VALUES (3,'Edit','edit'); INSERT INTO {permissions} VALUES (4,'Add','add'); DROP TABLE IF EXISTS {search_records}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {search_records} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `item_id` int(9) DEFAULT NULL, - `dirty` tinyint(1) DEFAULT '1', + `id` int(9) NOT NULL auto_increment, + `item_id` int(9) default NULL, + `dirty` tinyint(1) default '1', `data` longtext, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`), KEY `item_id` (`item_id`), FULLTEXT KEY `data` (`data`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {search_records} VALUES (1,1,0,' Gallery'); DROP TABLE IF EXISTS {sessions}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {sessions} ( `session_id` varchar(127) NOT NULL, `data` text NOT NULL, `last_activity` int(10) unsigned NOT NULL, - PRIMARY KEY (`session_id`) + PRIMARY KEY (`session_id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {tags}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {tags} ( - `id` int(9) NOT NULL AUTO_INCREMENT, + `id` int(9) NOT NULL auto_increment, `name` varchar(128) NOT NULL, - `count` int(10) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id`), + `count` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {tasks}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {tasks} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `callback` varchar(128) DEFAULT NULL, + `id` int(9) NOT NULL auto_increment, + `callback` varchar(128) default NULL, `context` text NOT NULL, - `done` tinyint(1) DEFAULT '0', - `name` varchar(128) DEFAULT NULL, - `owner_id` int(9) DEFAULT NULL, - `percent_complete` int(9) DEFAULT '0', - `state` varchar(32) DEFAULT NULL, - `status` varchar(255) DEFAULT NULL, - `updated` int(9) DEFAULT NULL, - PRIMARY KEY (`id`), + `done` tinyint(1) default '0', + `name` varchar(128) default NULL, + `owner_id` int(9) default NULL, + `percent_complete` int(9) default '0', + `state` varchar(32) default NULL, + `status` varchar(255) default NULL, + `updated` int(9) default NULL, + PRIMARY KEY (`id`), KEY `owner_id` (`owner_id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {themes}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {themes} ( - `id` int(9) NOT NULL AUTO_INCREMENT, - `name` varchar(64) DEFAULT NULL, - `version` int(9) DEFAULT NULL, - PRIMARY KEY (`id`), + `id` int(9) NOT NULL auto_increment, + `name` varchar(64) default NULL, + `version` int(9) default NULL, + PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {themes} VALUES (1,'wind',1); INSERT INTO {themes} VALUES (2,'admin_wind',1); DROP TABLE IF EXISTS {user_access_keys}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {user_access_keys} ( - `id` int(9) NOT NULL AUTO_INCREMENT, + `id` int(9) NOT NULL auto_increment, `user_id` int(9) NOT NULL, `access_key` char(32) NOT NULL, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`), UNIQUE KEY `access_key` (`access_key`), UNIQUE KEY `user_id` (`user_id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {users}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {users} ( - `id` int(9) NOT NULL AUTO_INCREMENT, + `id` int(9) NOT NULL auto_increment, `name` varchar(32) NOT NULL, `full_name` varchar(255) NOT NULL, `password` varchar(64) NOT NULL, - `login_count` int(10) unsigned NOT NULL DEFAULT '0', - `last_login` int(10) unsigned NOT NULL DEFAULT '0', - `email` varchar(64) DEFAULT NULL, - `admin` tinyint(1) DEFAULT '0', - `guest` tinyint(1) DEFAULT '0', - `hash` char(32) DEFAULT NULL, - `url` varchar(255) DEFAULT NULL, - `locale` char(10) DEFAULT NULL, - PRIMARY KEY (`id`), + `login_count` int(10) unsigned NOT NULL default '0', + `last_login` int(10) unsigned NOT NULL default '0', + `email` varchar(64) default NULL, + `admin` tinyint(1) default '0', + `guest` tinyint(1) default '0', + `hash` char(32) default NULL, + `url` varchar(255) default NULL, + `locale` char(10) default NULL, + PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), UNIQUE KEY `hash` (`hash`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {users} VALUES (1,'guest','Guest User','',0,0,NULL,0,1,NULL,NULL,NULL); INSERT INTO {users} VALUES (2,'admin','Gallery Administrator','',0,0,'unknown@unknown.com',1,0,NULL,NULL,NULL); DROP TABLE IF EXISTS {vars}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {vars} ( - `id` int(9) NOT NULL AUTO_INCREMENT, + `id` int(9) NOT NULL auto_increment, `module_name` varchar(64) NOT NULL, `name` varchar(64) NOT NULL, `value` text, - PRIMARY KEY (`id`), + PRIMARY KEY (`id`), UNIQUE KEY `module_name` (`module_name`,`name`) ) AUTO_INCREMENT=42 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind'); INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind'); INSERT INTO {vars} VALUES (NULL,'gallery','page_size','9'); -- cgit v1.2.3 From 545a91270d22506362e67032a3c54fdb21f8823e Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> 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(-) 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: "<?= $domain ?>", accessKey: "<?= $access_key ?>", protocol: "<?= request::protocol() ?>", @@ -121,7 +119,7 @@ attributes.id = "Gallery3WebClient"; attributes.name = "Gallery3WebClient"; attributes.align = "middle"; - swfobject.embedSWF("<?= $swf_url ?>", + swfobject.embedSWF("<?= $swf_uri ?>", "flashContent", size.width() - 100, size.height() - 135, swfVersionStr, xiSwfUrlStr, flashvars, params, attributes); </script> -- cgit v1.2.3 From 295a42e0f1d5bf5ba1a6a11fe7e222da59dae40b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Fri, 18 Jun 2010 20:20:05 -0700 Subject: change single to double quotes. --- modules/rest/controllers/rest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php index 3e364bff..acc4a7df 100644 --- a/modules/rest/controllers/rest.php +++ b/modules/rest/controllers/rest.php @@ -91,7 +91,7 @@ class Rest_Controller extends Controller { private function _format_exception_response($e) { // Add this exception to the log - Kohana_Log::add('error', Kohana_Exception::text($e)); + Kohana_Log::add("error", Kohana_Exception::text($e)); $rest_exception = array(); if ($e instanceof ORM_Validation_Exception) { -- cgit v1.2.3 From 9b788674275c843947d44934a50dd395b515737a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> 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(-) 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 From e40b2371ee4cc2756d80b36042124c71f21bc353 Mon Sep 17 00:00:00 2001 From: Tim Almdal <tnalmdal@shaw.ca> Date: Fri, 18 Jun 2010 21:49:11 -0700 Subject: Fix an issue that the root album was not being selected if there was no children, or if organize was being invoked on the root album. --- modules/organize/lib/Gallery3WebClient.swf | Bin 147793 -> 147825 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index 9f753076..4515182f 100644 Binary files a/modules/organize/lib/Gallery3WebClient.swf and b/modules/organize/lib/Gallery3WebClient.swf differ -- cgit v1.2.3 From fa404589d662bc4f304f05596b8cb563c715c3f2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 19 Jun 2010 10:24:26 -0700 Subject: Oops. Fix up a bad instance of $user in rest::access_key() introduced in my last change. --- modules/rest/helpers/rest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php index 0bad58f6..bcb12d58 100644 --- a/modules/rest/helpers/rest.php +++ b/modules/rest/helpers/rest.php @@ -72,7 +72,7 @@ class rest_Core { ->find(); if (!$key->loaded()) { - $key->user_id = $user_id; + $key->user_id = identity::active_user()->id; $key->access_key = md5(md5(uniqid(mt_rand(), true) . access::private_key())); $key->save(); } -- cgit v1.2.3 From 5736698b4ba17e382468ed9fdfed4b46e37f763e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 19 Jun 2010 10:51:05 -0700 Subject: single -> double quotes. --- modules/gallery/libraries/MY_Kohana_Exception.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/libraries/MY_Kohana_Exception.php b/modules/gallery/libraries/MY_Kohana_Exception.php index df7557ae..11556f7a 100644 --- a/modules/gallery/libraries/MY_Kohana_Exception.php +++ b/modules/gallery/libraries/MY_Kohana_Exception.php @@ -61,7 +61,7 @@ class Kohana_Exception extends Kohana_Exception_Core { $error = Kohana_Exception::text($e); // Add this exception to the log - Kohana_Log::add('error', $error); + Kohana_Log::add("error", $error); // Manually save logs after exceptions Kohana_Log::save(); -- cgit v1.2.3 From 41ca2b0195bf6a29429dfc5405f3c2073b1c3aba Mon Sep 17 00:00:00 2001 From: Bharat Mediratta <bharat@menalto.com> Date: Sat, 19 Jun 2010 13:52:48 -0700 Subject: Rework our exception framework to fit into Kohana's model better. Instead of overwriting Kohana_Exception::handle() (which we were doing in MY_Kohana_Exception) we instead use their existing template system. gallery/views/kohana/error.php overrides system/views/kohana/error.php and is the standard error template for all exceptions. Our version of error.php figures out the appropriate view based on context (cli, authenticated admin, guest viewing a 404, guest viewing a system error) and delegates appropriately. Each delegated view has a narrow responsibility. This paves the way for us to add new error views per module. For example, the rest module will define its own template in Rest_Exception and then its exceptions can be rendered the way that it wants (json encoded, in that case). --- modules/gallery/helpers/item_rest.php | 24 +- modules/gallery/libraries/MY_Kohana_Exception.php | 62 ----- modules/gallery/views/error_admin.html.php | 272 ++++++++++++++++++ modules/gallery/views/error_cli.txt.php | 3 + modules/gallery/views/error_user.html.php | 42 +++ modules/gallery/views/kohana/error.php | 321 +++------------------- 6 files changed, 372 insertions(+), 352 deletions(-) create mode 100644 modules/gallery/views/error_admin.html.php create mode 100644 modules/gallery/views/error_cli.txt.php create mode 100644 modules/gallery/views/error_user.html.php diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 0839b144..6869181d 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -161,20 +161,22 @@ class item_rest_Core { case "photo": case "movie": if (empty($request->file)) { - throw new Rest_Exception("file: Upload failed", 400); + throw new Rest_Exception( + "Bad Request", 400, array("errors" => array("file" => t("Upload failed")))); } - $item->type = $entity->type; - $item->parent_id = $parent->id; - $item->set_data_file($request->file); - $item->name = $entity->name; - $item->title = isset($entity->title) ? $entity->title : $entity->name; - $item->description = isset($entity->description) ? $entity->description : null; - $item->slug = isset($entity->slug) ? $entity->slug : null; - $item->save(); - break; + $item->type = $entity->type; + $item->parent_id = $parent->id; + $item->set_data_file($request->file); + $item->name = $entity->name; + $item->title = isset($entity->title) ? $entity->title : $entity->name; + $item->description = isset($entity->description) ? $entity->description : null; + $item->slug = isset($entity->slug) ? $entity->slug : null; + $item->save(); + break; default: - throw new Rest_Exception("Invalid type: $entity->type", 400); + throw new Rest_Exception( + "Bad Request", 400, array("errors" => array("type" => "invalid"))); } return array("url" => rest::url("item", $item)); diff --git a/modules/gallery/libraries/MY_Kohana_Exception.php b/modules/gallery/libraries/MY_Kohana_Exception.php index 11556f7a..72cb2ac0 100644 --- a/modules/gallery/libraries/MY_Kohana_Exception.php +++ b/modules/gallery/libraries/MY_Kohana_Exception.php @@ -29,68 +29,6 @@ class Kohana_Exception extends Kohana_Exception_Core { $e->getTraceAsString()); } - public static function handle(Exception $e) { - if ($e instanceof ORM_Validation_Exception) { - Kohana_Log::add("error", "Validation errors: " . print_r($e->validation->errors(), 1)); - } - try { - $user = identity::active_user(); - $try_themed_view = $user && !$user->admin; - } catch (Exception $e2) { - $try_themed_view = false; - } - - if ($try_themed_view) { - try { - return self::_show_themed_error_page($e); - } catch (Exception $e3) { - Kohana_Log::add("error", "Exception in exception handling code: " . self::text($e3)); - return parent::handle($e); - } - } else { - return parent::handle($e); - } - } - - /** - * Shows a themed error page. - * @see Kohana_Exception::handle - */ - private static function _show_themed_error_page(Exception $e) { - // Create a text version of the exception - $error = Kohana_Exception::text($e); - - // Add this exception to the log - Kohana_Log::add("error", $error); - - // Manually save logs after exceptions - Kohana_Log::save(); - - if (!headers_sent()) { - if ($e instanceof Kohana_Exception) { - $e->sendHeaders(); - } else { - header("HTTP/1.1 500 Internal Server Error"); - } - } - - $view = new Theme_View("page.html", "other", "error"); - if ($e instanceof Kohana_404_Exception) { - $view->page_title = t("Dang... Page not found!"); - $view->content = new View("error_404.html"); - $user = identity::active_user(); - $view->content->is_guest = $user && $user->guest; - if ($view->content->is_guest) { - $view->content->login_form = new View("login_ajax.html"); - $view->content->login_form->form = auth::get_login_form("login/auth_html"); - } - } else { - $view->page_title = t("Dang... Something went wrong!"); - $view->content = new View("error.html"); - } - print $view; - } - /** * @see Kohana_Exception::dump() */ diff --git a/modules/gallery/views/error_admin.html.php b/modules/gallery/views/error_admin.html.php new file mode 100644 index 00000000..40eb7374 --- /dev/null +++ b/modules/gallery/views/error_admin.html.php @@ -0,0 +1,272 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<? $error_id = uniqid("error") ?> +<? if (!function_exists("t")) { function t($msg) { return $msg; } } ?> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <style type="text/css"> + body { + background: #fff; + font-size: 14px; + line-height: 130%; + } + + div.big_box { + padding: 10px; + background: #eee; + border: solid 1px #ccc; + font-family: sans-serif; + color: #111; + width: 60em; + margin: 20px auto; + } + + div#framework_error { + text-align: center; + } + + div#error_details { + text-align: left; + } + + code { + font-family: monospace; + font-size: 12px; + margin: 20px 20px 20px 0px; + color: #333; + white-space: pre-wrap; + white-space: -moz-pre-wrap; + word-wrap: break-word; + } + + code .line { + padding-left: 10px; + } + + h3 { + font-family: sans-serif; + margin: 2px 0px 0px 0px; + padding: 8px 0px 0px 0px; + border-top: 1px solid #ddd; + } + + p { + padding: 0px; + margin: 0px 0px 10px 0px; + } + + li, pre { + padding: 0px; + margin: 0px; + } + + .collapsed { + display: none; + } + + .highlight { + font-weight: bold; + color: darkred; + } + + #kohana_error .message { + display: block; + padding-bottom: 10px; + } + + .source { + border: solid 1px #ccc; + background: #efe; + margin-bottom: 5px; + } + + table { + width: 100%; + display: block; + margin: 0 0 0.4em; + padding: 0; + border-collapse: collapse; + background: #efe; + } + + table td { + border: solid 1px #ddd; + text-align: left; + vertical-align: top; + padding: 0.4em; + } + + .args table td.key { + width: 200px; + } + + .number { + padding-right: 1em; + } + </style> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <title><?= t("Something went wrong!") ?> + + + + + +
    +

    + +

    +

    + +

    +
    +
    +

    + +

    +
    +

    + + [ ]: + + + + +

    +
    +
      +
    1. +

      + + [ ] + +

      + +
      + $row): ?>"> + +
      +
    2. + + + $step): ?> +
    3. +

      + + + + [ ] + + [ ] + + + {} + + + » + ( + + ) +

      + + + + + + +
    4. + + +
    + + +
    +

    + " onclick="return koggle('')"> +

    + +
    +
    + + diff --git a/modules/gallery/views/error_cli.txt.php b/modules/gallery/views/error_cli.txt.php new file mode 100644 index 00000000..b4f87fa6 --- /dev/null +++ b/modules/gallery/views/error_cli.txt.php @@ -0,0 +1,3 @@ + + + diff --git a/modules/gallery/views/error_user.html.php b/modules/gallery/views/error_user.html.php new file mode 100644 index 00000000..74c6a8fb --- /dev/null +++ b/modules/gallery/views/error_user.html.php @@ -0,0 +1,42 @@ + + + + + + + <?= t("Something went wrong!") ?> + + +
    +

    + +

    +

    + +

    +

    + +

    +
    + + diff --git a/modules/gallery/views/kohana/error.php b/modules/gallery/views/kohana/error.php index d55105a0..b0f0e907 100644 --- a/modules/gallery/views/kohana/error.php +++ b/modules/gallery/views/kohana/error.php @@ -1,280 +1,43 @@ - - - - - - - <?= t("Something went wrong!") ?> - - - - - - admin) ?> -
    -

    - -

    -

    - -

    - -

    - -

    - -
    - -
    -

    - -

    -
    -

    - - [ ]: - - - - -

    -
    -
      -
    1. -

      - - [ ] - -

      - -
      - $row): ?>"> - -
      -
    2. - - - $step): ?> -
    3. -

      - - - - [ ] - - [ ] - - - {} - - - » - ( - - ) -

      - - - - - - -
    4. - - -
    - - -
    -

    - " onclick="return koggle('')"> -

    - -
    -
    - - - +validation->errors(), 1)); +} + +if (php_sapi_name() == "cli") { + include Kohana::find_file("views", "error_cli.txt"); + return; +} + +try { + // Admins get a special error page + $user = identity::active_user(); + if ($user && $user->admin) { + include Kohana::find_file("views", "error_admin.html"); + return; + } +} catch (Exception $ignored) { +} + +// Try to show a themed error page for 404 errors +if ($e instanceof Kohana_404_Exception) { + $view = new Theme_View("page.html", "other", "error"); + $view->page_title = t("Dang... Page not found!"); + $view->content = new View("error_404.html"); + $user = identity::active_user(); + $view->content->is_guest = $user && $user->guest; + if ($view->content->is_guest) { + $view->content->login_form = new View("login_ajax.html"); + $view->content->login_form->form = auth::get_login_form("login/auth_html"); + } + print $view; + return; +} + +header("HTTP/1.1 500 Internal Server Error"); +include Kohana::find_file("views", "error_user.html"); +?> -- cgit v1.2.3 From 456d54ea2dccbe55a2efd89ecb4bde29fb91b619 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 19 Jun 2010 13:53:22 -0700 Subject: Throw exceptions as appropriate, but allow the Kohana exception handling framework to handle the exception and delegate to our template, which will JSON encode the response. --- modules/rest/controllers/rest.php | 41 +++++-------------------------- modules/rest/libraries/Rest_Exception.php | 11 +++++++-- modules/rest/views/error_rest.php | 2 ++ 3 files changed, 17 insertions(+), 37 deletions(-) create mode 100644 modules/rest/views/error_rest.php diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php index ccccc762..f8a46515 100644 --- a/modules/rest/controllers/rest.php +++ b/modules/rest/controllers/rest.php @@ -81,41 +81,12 @@ class Rest_Controller extends Controller { } $response = call_user_func(array($handler_class, $handler_method), $request); - } catch (Exception $e) { - $response = $this->_format_exception_response($e); + rest::reply($response); + } catch (ORM_Validation_Exception $e) { + // Note: this is totally insufficient because it doesn't take into account localization. We + // either need to map the result values to localized strings in the application code, or every + // client needs its own l10n string set. + throw new Rest_Exception("Bad Request", 400, $e->validation->errors()); } - - rest::reply($response); - } - - private function _format_exception_response($e) { - // Add this exception to the log - Kohana_Log::add("error", Kohana_Exception::text($e)); - - $rest_exception = array(); - if ($e instanceof ORM_Validation_Exception) { - $detail_response = true; - $rest_exception["code"] = 400; - $rest_exception["message"] = "Validation errors"; - $rest_exception["fields"] = $e->validation->errors(); - } else if ($e instanceof Rest_Exception) { - $rest_exception["code"] = $e->getCode(); - if ($e->getMessage() != "Bad Request") { - $rest_exception["message"] = "Bad Request"; - $rest_exception["fields"] = array("type", $e->getMessage()); - } else { - $rest_exception["message"] = $e->getMessage(); - } - } else { - $rest_exception["code"] = 500; - $rest_exception["message"] = t("Remote server call failed. Please contact the Adminstrator."); - } - - if (!headers_sent()) { - header($rest_exception["code"] == 500 ? "HTTP/1.1 500 Internal Server Error" : - "HTTP/1.1 400 Bad Request"); - } - - return $rest_exception; } } \ No newline at end of file diff --git a/modules/rest/libraries/Rest_Exception.php b/modules/rest/libraries/Rest_Exception.php index aa5b3281..c5baec63 100644 --- a/modules/rest/libraries/Rest_Exception.php +++ b/modules/rest/libraries/Rest_Exception.php @@ -18,13 +18,20 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Rest_Exception_Core extends Kohana_Exception { - public function __construct($message, $code) { + var $response = array(); + + public function __construct($message, $code, $response) { parent::__construct($message, null, $code); + $this->response = $response; } public function sendHeaders() { if (!headers_sent()) { - header("HTTP/1.1 " . $this->getCode() . "Bad Request"); + header("HTTP/1.1 " . $this->getCode() . " " . $this->getMessage()); } } + + public function getTemplate() { + return "error_rest"; + } } \ No newline at end of file diff --git a/modules/rest/views/error_rest.php b/modules/rest/views/error_rest.php new file mode 100644 index 00000000..c018378e --- /dev/null +++ b/modules/rest/views/error_rest.php @@ -0,0 +1,2 @@ + +response) ?> \ No newline at end of file -- cgit v1.2.3 From cd96ed887323c4006fa1a2008f153937cfa2f0ea Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 19 Jun 2010 14:13:34 -0700 Subject: $response is optional in the Rest_Exception constructor. --- modules/rest/libraries/Rest_Exception.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rest/libraries/Rest_Exception.php b/modules/rest/libraries/Rest_Exception.php index c5baec63..1257e3cf 100644 --- a/modules/rest/libraries/Rest_Exception.php +++ b/modules/rest/libraries/Rest_Exception.php @@ -20,7 +20,7 @@ class Rest_Exception_Core extends Kohana_Exception { var $response = array(); - public function __construct($message, $code, $response) { + public function __construct($message, $code, $response=array()) { parent::__construct($message, null, $code); $this->response = $response; } -- cgit v1.2.3 From 1ba9d079bfaa1be48186aaa51bcb0059886d4891 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 19 Jun 2010 15:00:33 -0700 Subject: post_test() should be using admin, not guest. --- modules/tag/tests/Tags_Rest_Helper_Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tag/tests/Tags_Rest_Helper_Test.php b/modules/tag/tests/Tags_Rest_Helper_Test.php index 99332c7c..1b909e50 100644 --- a/modules/tag/tests/Tags_Rest_Helper_Test.php +++ b/modules/tag/tests/Tags_Rest_Helper_Test.php @@ -45,7 +45,7 @@ class Tags_Rest_Helper_Test extends Gallery_Unit_Test_Case { } public function post_test() { - identity::set_active_user(identity::guest()); + identity::set_active_user(identity::admin_user()); $request = new stdClass(); $request->params = new stdClass(); -- cgit v1.2.3 From f451804c6d82bfbf214f08717c66684da66ca328 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 19 Jun 2010 15:00:44 -0700 Subject: $request->params might not exist. --- modules/tag/helpers/tags_rest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/tag/helpers/tags_rest.php b/modules/tag/helpers/tags_rest.php index 975cf140..4f40e7f4 100644 --- a/modules/tag/helpers/tags_rest.php +++ b/modules/tag/helpers/tags_rest.php @@ -29,9 +29,13 @@ class tags_rest_Core { static function get($request) { $tags = array(); - $p = $request->params; - $num = isset($p->num) ? min((int)$p->num, 100) : 10; - $start = isset($p->start) ? (int)$p->start : 0; + $num = 10; + $start = 0; + if (isset($request->params)) { + $p = $request->params; + $num = isset($p->num) ? min((int)$p->num, 100) : 10; + $start = isset($p->start) ? (int)$p->start : 0; + } foreach (ORM::factory("tag")->find_all($num, $start) as $tag) { $tags[] = rest::url("tag", $tag); -- cgit v1.2.3 From d86d1a32e8fc0feeaea3fa29a07035e0edfc7b90 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 19 Jun 2010 15:12:58 -0700 Subject: Updated for comment REST relationships. --- modules/gallery/tests/Item_Rest_Helper_Test.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/gallery/tests/Item_Rest_Helper_Test.php b/modules/gallery/tests/Item_Rest_Helper_Test.php index 0b5e0471..a2ab534b 100644 --- a/modules/gallery/tests/Item_Rest_Helper_Test.php +++ b/modules/gallery/tests/Item_Rest_Helper_Test.php @@ -43,6 +43,8 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { array("url" => rest::url("item", $album1), "entity" => $album1->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $album1)), "tags" => array( "url" => rest::url("item_tags", $album1), "members" => array())), @@ -58,6 +60,8 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { array("url" => rest::url("item", $album1), "entity" => $album1->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $album1)), "tags" => array( "url" => rest::url("item_tags", $album1), "members" => array())), @@ -73,6 +77,8 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { array("url" => rest::url("item", $album1), "entity" => $album1->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $album1)), "tags" => array( "url" => rest::url("item_tags", $album1), "members" => array())), @@ -100,6 +106,8 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { array("url" => rest::url("item", $album1), "entity" => $album1->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $album1)), "tags" => array( "url" => rest::url("item_tags", $album1), "members" => array())), @@ -123,6 +131,8 @@ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { array("url" => rest::url("item", $album1), "entity" => $album1->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $album1)), "tags" => array( "url" => rest::url("item_tags", $album1), "members" => array())), -- cgit v1.2.3 From a57ac38839e32b8f6551f67883c9596ee9c7b9e7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 19 Jun 2010 17:32:15 -0700 Subject: Change the organize dialog to make use of the new error handling --- modules/organize/lib/Gallery3WebClient.swf | Bin 147825 -> 147776 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/modules/organize/lib/Gallery3WebClient.swf b/modules/organize/lib/Gallery3WebClient.swf index 4515182f..40249a73 100644 Binary files a/modules/organize/lib/Gallery3WebClient.swf and b/modules/organize/lib/Gallery3WebClient.swf differ -- cgit v1.2.3 From f6025026eb4798774044fcd12f0f09313073141a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 08:50:19 -0700 Subject: Rename error_rest.php to error_rest.json.php so that we specify the result type in the filename as is our convention for views. --- modules/rest/libraries/Rest_Exception.php | 2 +- modules/rest/views/error_rest.json.php | 2 ++ modules/rest/views/error_rest.php | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 modules/rest/views/error_rest.json.php delete mode 100644 modules/rest/views/error_rest.php diff --git a/modules/rest/libraries/Rest_Exception.php b/modules/rest/libraries/Rest_Exception.php index 1257e3cf..087da939 100644 --- a/modules/rest/libraries/Rest_Exception.php +++ b/modules/rest/libraries/Rest_Exception.php @@ -32,6 +32,6 @@ class Rest_Exception_Core extends Kohana_Exception { } public function getTemplate() { - return "error_rest"; + return "error_rest.json"; } } \ No newline at end of file diff --git a/modules/rest/views/error_rest.json.php b/modules/rest/views/error_rest.json.php new file mode 100644 index 00000000..c018378e --- /dev/null +++ b/modules/rest/views/error_rest.json.php @@ -0,0 +1,2 @@ + +response) ?> \ No newline at end of file diff --git a/modules/rest/views/error_rest.php b/modules/rest/views/error_rest.php deleted file mode 100644 index c018378e..00000000 --- a/modules/rest/views/error_rest.php +++ /dev/null @@ -1,2 +0,0 @@ - -response) ?> \ No newline at end of file -- cgit v1.2.3 From 719328a5a7c0086fb97f0dd6b54d5db839696d33 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 09:02:59 -0700 Subject: If we use on the last line, it looks like we've got a trailing ?> and that causes File_Structure_Test to be sad. So instead use echo and tack on our own newline. But this also requires a semicolon. Weird, I know but still easier than fixing up the test. --- modules/gallery/views/error_cli.txt.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/views/error_cli.txt.php b/modules/gallery/views/error_cli.txt.php index b4f87fa6..9f476f54 100644 --- a/modules/gallery/views/error_cli.txt.php +++ b/modules/gallery/views/error_cli.txt.php @@ -1,3 +1,3 @@ - + Date: Sun, 20 Jun 2010 09:03:23 -0700 Subject: Add "json" as a valid view suffix. --- modules/gallery/tests/File_Structure_Test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php index 39df9f06..1c3356d9 100644 --- a/modules/gallery/tests/File_Structure_Test.php +++ b/modules/gallery/tests/File_Structure_Test.php @@ -42,8 +42,8 @@ class File_Structure_Test extends Gallery_Unit_Test_Case { if (strpos($file, "views")) { $this->assert_true( - preg_match("#/views/.*?(\.html|mrss|txt)\.php$#", $file->getPathname()), - "{$file->getPathname()} should end in .{html,mrss,txt}.php"); + preg_match("#/views/.*?\.(html|mrss|txt|json)\.php$#", $file->getPathname()), + "{$file->getPathname()} should end in .{html,mrss,txt,json}.php"); } } } -- cgit v1.2.3 From ab9049d5313d589cee696d0e082ac4f20c830cf1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 09:05:25 -0700 Subject: Remove trailing ?> --- modules/gallery/views/kohana/error.php | 1 - modules/rest/views/error_rest.json.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/gallery/views/kohana/error.php b/modules/gallery/views/kohana/error.php index b0f0e907..cc9d2e84 100644 --- a/modules/gallery/views/kohana/error.php +++ b/modules/gallery/views/kohana/error.php @@ -40,4 +40,3 @@ if ($e instanceof Kohana_404_Exception) { header("HTTP/1.1 500 Internal Server Error"); include Kohana::find_file("views", "error_user.html"); -?> diff --git a/modules/rest/views/error_rest.json.php b/modules/rest/views/error_rest.json.php index c018378e..179ce7f9 100644 --- a/modules/rest/views/error_rest.json.php +++ b/modules/rest/views/error_rest.json.php @@ -1,2 +1,2 @@ -response) ?> \ No newline at end of file +response); \ No newline at end of file -- cgit v1.2.3 From 9f9d3866e86d4b50fc1315c7db2687a5f0b8ce8d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 09:28:36 -0700 Subject: Exclude the .git directory. --- modules/gallery/tests/Gallery_Filters.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/gallery/tests/Gallery_Filters.php b/modules/gallery/tests/Gallery_Filters.php index debbe846..052990d5 100644 --- a/modules/gallery/tests/Gallery_Filters.php +++ b/modules/gallery/tests/Gallery_Filters.php @@ -32,6 +32,7 @@ class GalleryCodeFilterIterator extends FilterIterator { return !( $file_name == "." || $file_name == ".." || + strpos($path_name, DOCROOT . ".git") !== false || strpos($path_name, DOCROOT . "test") !== false || strpos($path_name, DOCROOT . "var") !== false || strpos($path_name, MODPATH . "forge") !== false || -- cgit v1.2.3 From ec052d71301acbf519947897f8adda7fdcf7fefb Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 09:36:56 -0700 Subject: Assert how many files we analyze so that we can tell if we're suddenly analzying too many or too few. --- modules/gallery/tests/File_Structure_Test.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php index 1c3356d9..96e0b758 100644 --- a/modules/gallery/tests/File_Structure_Test.php +++ b/modules/gallery/tests/File_Structure_Test.php @@ -23,13 +23,18 @@ class File_Structure_Test extends Gallery_Unit_Test_Case { public function no_trailing_closing_php_tag_test() { $dir = new GalleryCodeFilterIterator( new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT))); + $count = 0; foreach ($dir as $file) { + $count++; if (!preg_match("|\.html\.php$|", $file->getPathname())) { $this->assert_false( preg_match('/\?\>\s*$/', file_get_contents($file)), "{$file->getPathname()} ends in ?>"); } } + + $this->assert_true($count > 500, "We should have analyzed at least this 500 files"); + $this->assert_true($count < 1000, "We shouldn't be shipping 1000 files!"); } public function view_files_correct_suffix_test() { -- cgit v1.2.3 From 2e016855532962ea3e03700879be70f1ad3a8911 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 09:40:35 -0700 Subject: Add "comments" relationship support. --- modules/gallery/tests/Items_Rest_Helper_Test.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/gallery/tests/Items_Rest_Helper_Test.php b/modules/gallery/tests/Items_Rest_Helper_Test.php index 17e979a5..8e53110a 100644 --- a/modules/gallery/tests/Items_Rest_Helper_Test.php +++ b/modules/gallery/tests/Items_Rest_Helper_Test.php @@ -36,12 +36,16 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { array("url" => rest::url("item", $photo1), "entity" => $photo1->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $photo1)), "tags" => array( "url" => rest::url("item_tags", $photo1), "members" => array()))), array("url" => rest::url("item", $album2), "entity" => $album2->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $album2)), "tags" => array( "url" => rest::url("item_tags", $album2), "members" => array())), @@ -69,6 +73,8 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { array("url" => rest::url("item", $album2), "entity" => $album2->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $album2)), "tags" => array( "url" => rest::url("item_tags", $album2), "members" => array())), @@ -96,6 +102,8 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { array("url" => rest::url("item", $photo1), "entity" => $photo1->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $photo1)), "tags" => array( "url" => rest::url("item_tags", $photo1), "members" => array())))), @@ -121,12 +129,16 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { array("url" => rest::url("item", $photo1), "entity" => $photo1->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $photo1)), "tags" => array( "url" => rest::url("item_tags", $photo1), "members" => array()))), array("url" => rest::url("item", $album2), "entity" => $album2->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $album2)), "tags" => array( "url" => rest::url("item_tags", $album2), "members" => array())), @@ -162,6 +174,8 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { array("url" => rest::url("item", $album1), "entity" => $album1->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $album1)), "tags" => array( "url" => rest::url("item_tags", $album1), "members" => array())), @@ -172,6 +186,8 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { array("url" => rest::url("item", $album2), "entity" => $album2->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $album2)), "tags" => array( "url" => rest::url("item_tags", $album2), "members" => array())), @@ -180,6 +196,8 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case { array("url" => rest::url("item", $photo2), "entity" => $photo2->as_restful_array(), "relationships" => array( + "comments" => array( + "url" => rest::url("item_comments", $photo2)), "tags" => array( "url" => rest::url("item_tags", $photo2), "members" => array())))), -- cgit v1.2.3 From 6ebbb4fbf5cc5559f433300871078be41d615cf6 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 09:51:39 -0700 Subject: Updated golden files. --- modules/gallery/tests/controller_auth_data.txt | 2 + modules/gallery/tests/xss_data.txt | 82 ++++++++++++++++++++------ 2 files changed, 65 insertions(+), 19 deletions(-) diff --git a/modules/gallery/tests/controller_auth_data.txt b/modules/gallery/tests/controller_auth_data.txt index 94e7a07f..8263f79d 100644 --- a/modules/gallery/tests/controller_auth_data.txt +++ b/modules/gallery/tests/controller_auth_data.txt @@ -23,6 +23,8 @@ modules/gallery/controllers/user_profile.php show modules/gallery/controllers/user_profile.php contact DIRTY_AUTH modules/gallery/controllers/user_profile.php send DIRTY_AUTH modules/gallery/controllers/welcome_message.php index DIRTY_AUTH +modules/organize/controllers/organize.php dialog DIRTY_CSRF +modules/organize/controllers/organize.php add_album_fields DIRTY_AUTH modules/rest/controllers/rest.php index DIRTY_CSRF|DIRTY_AUTH modules/rest/controllers/rest.php __call DIRTY_CSRF|DIRTY_AUTH modules/rss/controllers/rss.php feed DIRTY_CSRF|DIRTY_AUTH diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 7fce42a1..4ead8a3f 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -33,8 +33,8 @@ modules/comment/views/comment.mrss.php 29 DIRTY $child modules/comment/views/comment.mrss.php 34 DIRTY_ATTR $child->thumb_url modules/comment/views/comment.mrss.php 35 DIRTY_ATTR $child->thumb_height modules/comment/views/comment.mrss.php 35 DIRTY_ATTR $child->thumb_width -modules/comment/views/comments.html.php 21 DIRTY_ATTR $comment->id -modules/comment/views/comments.html.php 24 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) +modules/comment/views/comments.html.php 28 DIRTY_ATTR $comment->id +modules/comment/views/comments.html.php 31 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) modules/comment/views/user_profile_comments.html.php 5 DIRTY_ATTR $comment->id modules/comment/views/user_profile_comments.html.php 10 DIRTY_JS $comment->item()->url() modules/comment/views/user_profile_comments.html.php 11 DIRTY $comment->item()->thumb_img(array(),50) @@ -122,6 +122,50 @@ modules/gallery/views/admin_themes.html.php 76 DIRTY $info- modules/gallery/views/admin_themes.html.php 78 DIRTY $info->description modules/gallery/views/admin_themes_preview.html.php 7 DIRTY_ATTR $url modules/gallery/views/error_404.html.php 14 DIRTY $login_form +modules/gallery/views/error_admin.html.php 150 DIRTY $type +modules/gallery/views/error_admin.html.php 150 DIRTY $code +modules/gallery/views/error_admin.html.php 153 DIRTY $message +modules/gallery/views/error_admin.html.php 156 DIRTY_ATTR $error_id +modules/gallery/views/error_admin.html.php 161 DIRTY Kohana_Exception::debug_path($file) +modules/gallery/views/error_admin.html.php 161 DIRTY $line +modules/gallery/views/error_admin.html.php 166 DIRTY_ATTR ($num==$line)?"highlight":"" +modules/gallery/views/error_admin.html.php 166 DIRTY $num +modules/gallery/views/error_admin.html.php 166 DIRTY htmlspecialchars($row,ENT_NOQUOTES,Kohana::CHARSET) +modules/gallery/views/error_admin.html.php 178 DIRTY_ATTR $source_id +modules/gallery/views/error_admin.html.php 178 DIRTY_JS $source_id +modules/gallery/views/error_admin.html.php 178 DIRTY Kohana_Exception::debug_path($step["file"]) +modules/gallery/views/error_admin.html.php 178 DIRTY $step["line"] +modules/gallery/views/error_admin.html.php 180 DIRTY Kohana_Exception::debug_path($step["file"]) +modules/gallery/views/error_admin.html.php 180 DIRTY $step["line"] +modules/gallery/views/error_admin.html.php 187 DIRTY $step["function"] +modules/gallery/views/error_admin.html.php 188 DIRTY_ATTR $args_id +modules/gallery/views/error_admin.html.php 188 DIRTY_JS $args_id +modules/gallery/views/error_admin.html.php 192 DIRTY_ATTR $args_id +modules/gallery/views/error_admin.html.php 197 DIRTY $name +modules/gallery/views/error_admin.html.php 200 DIRTY Kohana_Exception::safe_dump($arg,$name) +modules/gallery/views/error_admin.html.php 208 DIRTY_ATTR $source_id +modules/gallery/views/error_admin.html.php 208 DIRTY_ATTR ($num==$step["line"])?"highlight":"" +modules/gallery/views/error_admin.html.php 208 DIRTY $num +modules/gallery/views/error_admin.html.php 208 DIRTY htmlspecialchars($row,ENT_NOQUOTES,Kohana::CHARSET) +modules/gallery/views/error_admin.html.php 218 DIRTY_ATTR $env_id=$error_id."environment" +modules/gallery/views/error_admin.html.php 218 DIRTY_JS $env_id +modules/gallery/views/error_admin.html.php 220 DIRTY_ATTR $env_id +modules/gallery/views/error_admin.html.php 222 DIRTY_ATTR $env_id=$error_id."environment_included" +modules/gallery/views/error_admin.html.php 222 DIRTY_JS $env_id +modules/gallery/views/error_admin.html.php 222 DIRTY count($included) +modules/gallery/views/error_admin.html.php 223 DIRTY_ATTR $env_id +modules/gallery/views/error_admin.html.php 228 DIRTY Kohana_Exception::debug_path($file) +modules/gallery/views/error_admin.html.php 235 DIRTY_ATTR $env_id=$error_id."environment_loaded" +modules/gallery/views/error_admin.html.php 235 DIRTY_JS $env_id +modules/gallery/views/error_admin.html.php 235 DIRTY count($included) +modules/gallery/views/error_admin.html.php 236 DIRTY_ATTR $env_id +modules/gallery/views/error_admin.html.php 241 DIRTY Kohana_Exception::debug_path($file) +modules/gallery/views/error_admin.html.php 249 DIRTY_ATTR $env_id="$error_id.environment".strtolower($var) +modules/gallery/views/error_admin.html.php 250 DIRTY_JS $env_id +modules/gallery/views/error_admin.html.php 250 DIRTY $var +modules/gallery/views/error_admin.html.php 251 DIRTY_ATTR $env_id +modules/gallery/views/error_admin.html.php 257 DIRTY $key +modules/gallery/views/error_admin.html.php 261 DIRTY Kohana_Exception::safe_dump($value,$key) modules/gallery/views/form_uploadify.html.php 9 DIRTY_JS url::file("lib/uploadify/uploadify.swf") modules/gallery/views/form_uploadify.html.php 10 DIRTY_JS url::site("simple_uploader/add_photo/{$album->id}") modules/gallery/views/form_uploadify.html.php 14 DIRTY_JS url::file("lib/uploadify/cancel.png") @@ -235,16 +279,16 @@ modules/notification/views/item_updated.html.php 20 DIRTY_JS $item- modules/notification/views/item_updated.html.php 20 DIRTY $item->abs_url() modules/notification/views/user_profile_notification.html.php 5 DIRTY_ATTR $subscription->id modules/notification/views/user_profile_notification.html.php 6 DIRTY_JS $subscription->url -modules/organize/views/organize_dialog.html.php 92 DIRTY_JS $domain -modules/organize/views/organize_dialog.html.php 93 DIRTY_JS $access_key -modules/organize/views/organize_dialog.html.php 94 DIRTY_JS $protocol -modules/organize/views/organize_dialog.html.php 95 DIRTY_JS $file_filter -modules/organize/views/organize_dialog.html.php 96 DIRTY_JS $sort_order -modules/organize/views/organize_dialog.html.php 97 DIRTY_JS $sort_fields -modules/organize/views/organize_dialog.html.php 98 DIRTY_JS $album->id -modules/organize/views/organize_dialog.html.php 99 DIRTY_JS $rest_uri -modules/organize/views/organize_dialog.html.php 100 DIRTY_JS $controller_uri -modules/organize/views/organize_dialog.html.php 124 DIRTY_JS $swf_url +modules/organize/views/organize_dialog.html.php 90 DIRTY_JS $domain +modules/organize/views/organize_dialog.html.php 91 DIRTY_JS $access_key +modules/organize/views/organize_dialog.html.php 92 DIRTY_JS request::protocol() +modules/organize/views/organize_dialog.html.php 93 DIRTY_JS $file_filter +modules/organize/views/organize_dialog.html.php 94 DIRTY_JS $sort_order +modules/organize/views/organize_dialog.html.php 95 DIRTY_JS $sort_fields +modules/organize/views/organize_dialog.html.php 96 DIRTY_JS $album->id +modules/organize/views/organize_dialog.html.php 97 DIRTY_JS $rest_uri +modules/organize/views/organize_dialog.html.php 98 DIRTY_JS $controller_uri +modules/organize/views/organize_dialog.html.php 122 DIRTY_JS $swf_uri modules/recaptcha/views/admin_recaptcha.html.php 11 DIRTY $form modules/recaptcha/views/admin_recaptcha.html.php 23 DIRTY_JS $public_key modules/recaptcha/views/form_recaptcha.html.php 7 DIRTY_JS $public_key @@ -316,13 +360,13 @@ themes/admin_wind/views/admin.html.php 43 DIRTY $theme themes/admin_wind/views/admin.html.php 51 DIRTY $theme->admin_header_top() themes/admin_wind/views/admin.html.php 52 DIRTY_JS item::root()->url() themes/admin_wind/views/admin.html.php 55 DIRTY $theme->user_menu() -themes/admin_wind/views/admin.html.php 57 DIRTY $theme->admin_menu() -themes/admin_wind/views/admin.html.php 59 DIRTY $theme->admin_header_bottom() -themes/admin_wind/views/admin.html.php 66 DIRTY $content -themes/admin_wind/views/admin.html.php 72 DIRTY $sidebar -themes/admin_wind/views/admin.html.php 77 DIRTY $theme->admin_footer() -themes/admin_wind/views/admin.html.php 79 DIRTY $theme->admin_credits() -themes/admin_wind/views/admin.html.php 83 DIRTY $theme->admin_page_bottom() +themes/admin_wind/views/admin.html.php 58 DIRTY $theme->admin_menu() +themes/admin_wind/views/admin.html.php 61 DIRTY $theme->admin_header_bottom() +themes/admin_wind/views/admin.html.php 68 DIRTY $content +themes/admin_wind/views/admin.html.php 74 DIRTY $sidebar +themes/admin_wind/views/admin.html.php 79 DIRTY $theme->admin_footer() +themes/admin_wind/views/admin.html.php 81 DIRTY $theme->admin_credits() +themes/admin_wind/views/admin.html.php 85 DIRTY $theme->admin_page_bottom() themes/admin_wind/views/block.html.php 3 DIRTY_ATTR $anchor themes/admin_wind/views/block.html.php 5 DIRTY $id themes/admin_wind/views/block.html.php 5 DIRTY_ATTR $css_id -- cgit v1.2.3 From c7ce0228de3d4d33a2997269a59626fd09f46f65 Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Fri, 18 Jun 2010 19:06:41 +0800 Subject: (1) Correct the margin direction for checkboxes in RTL (2) Update the id of adding comment button for RTL (3) Flip the corner radiuses for any buttons set, which solves the issue of flipped corners in the comments admin page. Also, add the CSS3 selector of the round corners so they work in Opera (4) Fix ticket #1052 --- lib/gallery.common.css | 81 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/lib/gallery.common.css b/lib/gallery.common.css index 31988b67..10a1f35d 100644 --- a/lib/gallery.common.css +++ b/lib/gallery.common.css @@ -690,14 +690,91 @@ div#g-action-status { } .rtl input.checkbox { - margin-right: .4em; + margin-left: .4em; } -.rtl #g-admin-comment-button { +.rtl #g-add-comment { right: inherit; left: 0; } +.rtl .ui-icon-left .ui-icon { + margin-left: .2em; +} + +.rtl .ui-icon-right .ui-icon { + margin-right: .2em; +} + +/* RTL Corner radius ~~~~~~~~~~~~~~~~~~~~~~ */ +.rtl .g-buttonset .ui-corner-tl { + -moz-border-radius-topleft: 0; + -moz-border-radius-topright: 5px; + -webkit-border-top-left-radius: 0; + -webkit-border-top-right-radius: 5px; + border-top-left-radius: 0; + border-top-right-radius: 5px; +} + +.rtl .g-buttonset .ui-corner-tr { + -moz-border-radius-topright: 0; + -moz-border-radius-topleft: 5px; + -webkit-border-top-right-radius: 0; + -webkit-border-top-left-radius: 5px; + border-top-right-radius: 0; + border-top-left-radius: 5px; +} + +.rtl .g-buttonset .ui-corner-bl { + -moz-border-radius-bottomleft: 0; + -moz-border-radius-bottomright: 5px; + -webkit-border-bottom-left-radius: 0; + -webkit-border-bottom-right-radius: 5px; + border-bottom-left-radius: 0; + border-bottom-right-radius: 5px; +} + +.rtl .g-buttonset .ui-corner-br { + -moz-border-radius-bottomright: 0; + -moz-border-radius-bottomleft: 5px; + -webkit-border-bottom-right-radius: 0; + -webkit-border-bottom-left-radius: 5px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 5px; +} + +.rtl .g-buttonset .ui-corner-right, +.rtl .ui-progressbar .ui-corner-right { + -moz-border-radius-topright: 0; + -webkit-border-top-right-radius: 0; + border-top-right-radius: 0; + -moz-border-radius-topleft: 5px; + -webkit-border-top-left-radius: 5px; + border-top-left-radius: 5px; + -moz-border-radius-bottomright: 0; + -webkit-border-bottom-right-radius: 0; + border-bottom-right-radius: 0; + -moz-border-radius-bottomleft: 5px; + -webkit-border-bottom-left-radius: 5px; + border-bottom-left-radius: 5px; +} + +.rtl .g-buttonset .ui-corner-left, +.rtl .ui-progressbar .ui-corner-left { + -moz-border-radius-topleft: 0; + -webkit-border-top-left-radius: 0; + border-top-left-radius: 0; + -moz-border-radius-topright: 5px; + -webkit-border-top-right-radius: 5px; + border-top-right-radius: 5px; + -moz-border-radius-bottomleft: 0; + -webkit-border-bottom-left-radius: 0; + border-bottom-left-radius: 0; + -moz-border-radius-bottomright: 5px; + -webkit-border-bottom-right-radius: 5px; + border-bottom-right-radius: 5px; +} + /* RTL Superfish ~~~~~~~~~~~~~~~~~~~~~~~~~ */ .rtl .sf-menu a { -- cgit v1.2.3 From fcd39be28bbfc79186bbc4d6ee34bfc8cdfdc6e7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 10:39:24 -0700 Subject: Specify a default margin for all buttons in the common css. Fixes ticket #1165. --- lib/gallery.common.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/gallery.common.css b/lib/gallery.common.css index 63f1ee65..6c465ddb 100644 --- a/lib/gallery.common.css +++ b/lib/gallery.common.css @@ -454,6 +454,10 @@ ul.sf-menu li li li.sfHover ul { -moz-outline-style: none; } +button { + padding: 2px 4px 2px 4px; +} + /* jQuery UI ThemeRoller buttons ~~~~~~~~~ */ .g-buttonset { -- cgit v1.2.3 From 75002732284c85dfd82934b04ef477fc5a274bfe Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 10:55:10 -0700 Subject: Simplify the descendent logic. viewable() already joins with the items table so there's no need for a subquery. The subquery could generate way too many ids since it didn't pay attention to permissions. This isn't a security problem since we were restricting the item ids according to permissions in the outer query, but it's wasteful. --- modules/comment/helpers/comment_rss.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index 479023bd..2e8e564e 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -35,17 +35,14 @@ class comment_rss_Core { $comments = ORM::factory("comment") ->viewable() - ->where("state", "=", "published") - ->order_by("created", "DESC"); + ->where("comments.state", "=", "published") + ->order_by("comments.created", "DESC"); if ($feed_id == "item") { $item = ORM::factory("item", $id); - $subquery = db::select("id") - ->from("items") - ->where("left_ptr", ">=", $item->left_ptr) - ->where("right_ptr", "<=", $item->right_ptr); $comments - ->where("item_id", "in", $subquery); + ->where("items.left_ptr", ">=", $item->left_ptr) + ->where("items.right_ptr", "<=", $item->right_ptr); } $feed = new stdClass(); @@ -65,6 +62,8 @@ class comment_rss_Core { ArrayObject::ARRAY_AS_PROPS); } + Kohana_Log::add("error",print_r(Database::instance()->last_query(),1)); + $feed->max_pages = ceil($comments->count_all() / $limit); $feed->title = htmlspecialchars(t("Recent Comments")); $feed->uri = url::abs_site("albums/" . (empty($id) ? "1" : $id)); -- cgit v1.2.3 From 7938a57dbe1935731dccc945235b10bf5c002dd2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 10:57:48 -0700 Subject: Oops. Remove debug line. --- modules/comment/helpers/comment_rss.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index 2e8e564e..545192e5 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -62,8 +62,6 @@ class comment_rss_Core { ArrayObject::ARRAY_AS_PROPS); } - Kohana_Log::add("error",print_r(Database::instance()->last_query(),1)); - $feed->max_pages = ceil($comments->count_all() / $limit); $feed->title = htmlspecialchars(t("Recent Comments")); $feed->uri = url::abs_site("albums/" . (empty($id) ? "1" : $id)); -- cgit v1.2.3 From 1783c046924b1c54116dc626e5b50078780ca9c5 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 11:15:53 -0700 Subject: Remove the title attribute for menus using JS since we're showing that text anyway. This may be turn into an accessibility issue, but it's pretty annoying to have a tooltip show up with the text in it. --- themes/admin_wind/js/ui.init.js | 6 ++++-- themes/wind/js/ui.init.js | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/themes/admin_wind/js/ui.init.js b/themes/admin_wind/js/ui.init.js index e0210ce5..4ed912f8 100644 --- a/themes/admin_wind/js/ui.init.js +++ b/themes/admin_wind/js/ui.init.js @@ -4,7 +4,7 @@ */ $(document).ready(function(){ - + // Initialize Superfish menus $("#g-site-admin-menu .g-menu").hide().addClass("sf-menu"); $("#g-site-admin-menu .g-menu").superfish({ @@ -54,7 +54,9 @@ $(document).ready(function(){ $(".g-available .g-block").addClass("ui-corner-all"); $(".g-unavailable").addClass("ui-corner-all"); + // Remove titles for menu options since we're displaying that text anyway + $(".sf-menu a, .sf-menu li").removeAttr("title"); + // Initialize button hover effect $.fn.gallery_hover_init(); - }); diff --git a/themes/wind/js/ui.init.js b/themes/wind/js/ui.init.js index 53b58516..a4fc0e2f 100644 --- a/themes/wind/js/ui.init.js +++ b/themes/wind/js/ui.init.js @@ -43,6 +43,9 @@ $(document).ready(function() { }); } + // Remove titles for menu options since we're displaying that text anyway + $(".sf-menu a, .sf-menu li").removeAttr("title"); + // Album and search results views if ($("#g-album-grid").length) { // Set equal height for album items and vertically align thumbnails/metadata -- cgit v1.2.3 From 66bea24482be05ccfbea76bda2c9b70c93c34408 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 11:59:46 -0700 Subject: Use text::limit_chars() to keep individual elements in breadcrumbs from going over 15 chars. Fixes ticket #1108. --- themes/wind/views/page.html.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index 6ce2a559..16e43c63 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -107,12 +107,14 @@ level you're on the right page. --> item()->id}" : null) ?>"> - title) ?> + title), 15) ?> -
  • ">item()->title) ?>
  • +
  • "> + item()->title), 15) ?> +
  • -- cgit v1.2.3 From fb81de7a5b871cc7bccc0e44b973ba5c63e8c879 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 12:45:36 -0700 Subject: Disallow /digibug/print_photo to avoid search engines printing stuff. Resolves ticket #637. --- robots.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/robots.txt b/robots.txt index bc7b5ac9..000aac95 100644 --- a/robots.txt +++ b/robots.txt @@ -11,3 +11,4 @@ Disallow: /var/resizes/ Disallow: /var/thumbs/ Disallow: /var/tmp/ Disallow: /var/uploads/ +Disallow: /digibug/print_photo/ -- cgit v1.2.3 From 9b4d9d1d4604c9d65b1629b0e95eaa0c75e0a257 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 16:51:06 -0700 Subject: Fix two issues with the "loading" overlay: 1) gallery.common.js was using the wrong class name 2) we need to mark the CSS as !important because it conflicts with other background images. Note that this will replace the existing background which may not be desireable. --- lib/gallery.common.css | 6 ++---- lib/gallery.common.js | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/gallery.common.css b/lib/gallery.common.css index 6c465ddb..5dd0d031 100644 --- a/lib/gallery.common.css +++ b/lib/gallery.common.css @@ -363,13 +363,11 @@ form .g-error { .g-loading-large, .g-dialog-loading-large { - background: #e8e8e8 url('images/loading-large.gif') no-repeat center center; - font-size: 0; + background: #e8e8e8 url('images/loading-large.gif') no-repeat center center !important; } .g-loading-small { - background: #e8e8e8 url('images/loading-small.gif') no-repeat center center; - font-size: 0; + background: #e8e8e8 url('images/loading-small.gif') no-repeat center center !important; } /** ******************************************************************* diff --git a/lib/gallery.common.js b/lib/gallery.common.js index eb57c86c..a9aa6b2c 100644 --- a/lib/gallery.common.js +++ b/lib/gallery.common.js @@ -61,7 +61,7 @@ size = "small"; break; } - $(this).toggleClass("g-loading" + size); + $(this).toggleClass("g-loading-" + size); }); }; -- cgit v1.2.3 From 892727830d873a9f0a1a49f10ee14b0890088b23 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 16:52:10 -0700 Subject: Add a loading indicator to the delete form by tagging some JS on at the end which triggers .gallery_show_loading(). Not a complete fix for #817 but it's a start and it takes care of one place where we have a long running process. --- modules/gallery/helpers/item.php | 2 ++ modules/gallery/js/item_form_delete.js | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 modules/gallery/js/item_form_delete.js diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 15bbe977..aef68c6e 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -162,6 +162,8 @@ class item_Core { "quick/delete/$item->id?page_type=$page_type", "", "post", array("id" => "g-confirm-delete")); $group = $form->group("confirm_delete")->label(t("Confirm Deletion")); $group->submit("")->value(t("Delete")); + $form->script("") + ->url(url::abs_file("modules/gallery/js/item_form_delete.js")); return $form; } diff --git a/modules/gallery/js/item_form_delete.js b/modules/gallery/js/item_form_delete.js new file mode 100644 index 00000000..fa3f24a2 --- /dev/null +++ b/modules/gallery/js/item_form_delete.js @@ -0,0 +1,5 @@ +$("#g-confirm-delete").submit( + function() { + $("#g-confirm-delete input[type=submit]").gallery_show_loading(); + } +); -- cgit v1.2.3 From 2992daa00e09d5452e3baf0c279a93220d7a362b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 16:55:42 -0700 Subject: Add "Tag: %s" in the title on tag pages. Fixes ticket #1097. --- modules/tag/controllers/tags.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php index f9a56ccf..f3d456d3 100644 --- a/modules/tag/controllers/tags.php +++ b/modules/tag/controllers/tags.php @@ -41,7 +41,7 @@ class Tags_Controller extends Controller { $template->set_global("children", $tag->items($page_size, $offset)); $template->set_global("children_count", $children_count); $template->content = new View("dynamic.html"); - $template->content->title = $tag->name; + $template->content->title = t("Tag: %tag_name", array("tag_name" => $tag->name)); print $template; } -- cgit v1.2.3 From 7bdb9a49e5b038b21445d77c21f63b18619f8fb8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 16:58:38 -0700 Subject: Focus on the username field by default. --- modules/gallery/views/error_404.html.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/gallery/views/error_404.html.php b/modules/gallery/views/error_404.html.php index 4b037a79..42f62b6c 100644 --- a/modules/gallery/views/error_404.html.php +++ b/modules/gallery/views/error_404.html.php @@ -12,10 +12,15 @@

    +

    - \ No newline at end of file + -- cgit v1.2.3 From 261da7b1c362fe329fe97ca8478a0c6b3721dedf Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 17:18:11 -0700 Subject: Set the focus on the username field (and the name field when we reset the password) properly on IE7 using a setTimeout() hack. Fixes ticket #807. --- modules/gallery/views/login_ajax.html.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/gallery/views/login_ajax.html.php b/modules/gallery/views/login_ajax.html.php index 36647f9d..88fe2389 100644 --- a/modules/gallery/views/login_ajax.html.php +++ b/modules/gallery/views/login_ajax.html.php @@ -10,9 +10,16 @@ $(".submit").addClass("g-button ui-state-default ui-corner-all"); $(".submit").gallery_hover_init(); ajaxify_login_reset_form(); + + // See comment about IE7 below + setTimeout('$("#g-name").focus()', 100); } }); }); + + // Setting the focus here doesn't work on IE7, perhaps because the field is + // not ready yet? So set a timeout and do it the next time we're idle + setTimeout('$("#g-username").focus()', 100); }); function ajaxify_login_reset_form() { -- cgit v1.2.3 From 74e821b03ef149a43eb8704fd2350985699d3ded Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 17:21:25 -0700 Subject: Rename the feed variable from "children" to "comments" since that makes more semantic sense. --- modules/comment/helpers/comment_rss.php | 4 ++-- modules/comment/views/comment.mrss.php | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php index 545192e5..26d98d21 100644 --- a/modules/comment/helpers/comment_rss.php +++ b/modules/comment/helpers/comment_rss.php @@ -47,10 +47,10 @@ class comment_rss_Core { $feed = new stdClass(); $feed->view = "comment.mrss"; - $feed->children = array(); + $feed->comments = array(); foreach ($comments->find_all($limit, $offset) as $comment) { $item = $comment->item(); - $feed->children[] = new ArrayObject( + $feed->comments[] = new ArrayObject( array("pub_date" => date("D, d M Y H:i:s T", $comment->created), "text" => nl2br(html::purify($comment->text)), "thumb_url" => $item->thumb_url(), diff --git a/modules/comment/views/comment.mrss.php b/modules/comment/views/comment.mrss.php index c2a4b538..809e7890 100644 --- a/modules/comment/views/comment.mrss.php +++ b/modules/comment/views/comment.mrss.php @@ -20,19 +20,19 @@ - children as $child): ?> + comments as $comment): ?> - <?= html::purify($child->title) ?> - item_uri) ?> - author) ?> - item_uri ?> - pub_date ?> + <?= html::purify($comment->title) ?> + item_uri) ?> + author) ?> + item_uri ?> + pub_date ?> text)) ?>

    +

    text)) ?>

    - +

    ]]> -- cgit v1.2.3 From 48af5e6b5039839f93345bef92e1acf7952c50a1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 17:25:23 -0700 Subject: Rename "children" to "items" in our feed view because it makes more semantic sense. --- modules/gallery/helpers/gallery_rss.php | 8 ++-- modules/rss/views/feed.mrss.php | 66 ++++++++++++++++----------------- modules/tag/helpers/tag_rss.php | 2 +- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/modules/gallery/helpers/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php index 9c528c0e..bec34912 100644 --- a/modules/gallery/helpers/gallery_rss.php +++ b/modules/gallery/helpers/gallery_rss.php @@ -28,18 +28,18 @@ class gallery_rss_Core { $feed = new stdClass(); switch ($feed_id) { case "latest": - $feed->children = ORM::factory("item") + $feed->items = ORM::factory("item") ->viewable() ->where("type", "<>", "album") ->order_by("created", "DESC") ->find_all($limit, $offset); - $all_children = ORM::factory("item") + $all_items = ORM::factory("item") ->viewable() ->where("type", "<>", "album") ->order_by("created", "DESC"); - $feed->max_pages = ceil($all_children->find_all()->count() / $limit); + $feed->max_pages = ceil($all_items->find_all()->count() / $limit); $feed->title = t("Recent updates"); $feed->description = t("Recent updates"); return $feed; @@ -48,7 +48,7 @@ class gallery_rss_Core { $item = ORM::factory("item", $id); access::required("view", $item); - $feed->children = $item + $feed->items = $item ->viewable() ->descendants($limit, $offset, array(array("type", "=", "photo"))); $feed->max_pages = ceil( diff --git a/modules/rss/views/feed.mrss.php b/modules/rss/views/feed.mrss.php index 0fd8095d..3f0010bb 100644 --- a/modules/rss/views/feed.mrss.php +++ b/modules/rss/views/feed.mrss.php @@ -20,57 +20,57 @@ - children as $child): ?> + items as $item): ?> - <?= html::purify($child->title) ?> - type}s/{$child->id}") ?> - type}s/{$child->id}") ?> - created); ?> - description) ?> + <?= html::purify($item->title) ?> + type}s/{$item->id}") ?> + type}s/{$item->id}") ?> + created); ?> + description) ?> description) ?> + description) ?>

    - type == "photo"): ?> -
    + type == "photo"): ?> +
    - type}s/{$child->id}") ?>"> -
    + type}s/{$item->id}") ?>"> +
    - description) ?> + description) ?>

    ]]>
    - - - type == "photo" && $view_full): ?> + + type == "photo" && $view_full): ?> - type == "photo"): ?> - type == "photo"): ?> + - - type == "photo" && $view_full): ?> + type == "photo" && $view_full): ?>
    diff --git a/modules/tag/helpers/tag_rss.php b/modules/tag/helpers/tag_rss.php index 7d52814b..ea3865be 100644 --- a/modules/tag/helpers/tag_rss.php +++ b/modules/tag/helpers/tag_rss.php @@ -36,7 +36,7 @@ class tag_rss_Core { } $feed = new stdClass(); - $feed->children = $tag->items($limit, $offset, "photo"); + $feed->items = $tag->items($limit, $offset, "photo"); $feed->max_pages = ceil($tag->count / $limit); $feed->title = $tag->name; $feed->description = t("Photos related to %tag_name", array("tag_name" => $tag->name)); -- cgit v1.2.3 From e468ed7bd3f1e29b267e3902ef9c91273787d58f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 17:43:22 -0700 Subject: Add a margin above the "Select photos..." button. --- themes/wind/css/screen.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/themes/wind/css/screen.css b/themes/wind/css/screen.css index 1e55a967..bc9f3e59 100644 --- a/themes/wind/css/screen.css +++ b/themes/wind/css/screen.css @@ -319,6 +319,12 @@ td { background-color: #fff; } +/* Add dialog ~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#g-add-photos-button { + margin-top: 6px !important; +} + /** ******************************************************************* * 5) Navigation and menus *********************************************************************/ -- cgit v1.2.3 From 1b017c8c91501787344855c442a479cec5c666f0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 17:52:53 -0700 Subject: Updated README for RC2 release. --- README | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/README b/README index b3426212..afde82b8 100644 --- a/README +++ b/README @@ -14,14 +14,7 @@ release is out, we make no guarantees that it won't do bad things. Note: - We've contracted a professional security audit, received their results - and resolved all the really dire issues they found. There are still some - issues, but they are more along the lines of "you should ask for the old - password as a confirmation when you let users change their password". - Ie, they're issues but they're not really bad. We'll take care of them - before the final release. - - Most of the key features are in, but some of them (notably the "add from - server" and "organize album" features) are probably going to be completely - rewritten. + and resolved all the issues they found. - You can upgrade from beta 1, but not from alpha releases. The intended audience of this release is folks who are willing to live @@ -61,7 +54,7 @@ INSTALLATION FROM THE COMMAND LINE: BUGS? Go to http://apps.sourceforge.net/trac/gallery/ click the "login" link and log in with your SourceForge username and password, then click the -"new ticket" button. Mark any issues you find with the "Beta 2" +"new ticket" button. Mark any issues you find with the "3.0" milestone and we'll try to get 'em done for the next release. @@ -70,5 +63,3 @@ QUESTIONS, PROBLEMS: - Post to the Gallery 3 forums: http://gallery.menalto.com/forum/96 - Email gallery-devel@lists.sourceforge.net - - -- cgit v1.2.3 From 3d321927b8ebb738b1cae90de32e0c3099193798 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 17:53:41 -0700 Subject: Put the product title and version at the top of the README. --- README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README b/README index afde82b8..15519e31 100644 --- a/README +++ b/README @@ -1,3 +1,5 @@ +Gallery 3.0 (code name "Santa Fe") + ABOUT: Gallery 3 is a web based software product that lets you manage your photos on your own website. You must have your own website with PHP -- cgit v1.2.3 From e648ba58b387e2b167cda2b3c3272c833addd52d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 18:18:04 -0700 Subject: Add a section to hide files that browsers shouldn't see. --- .htaccess | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.htaccess b/.htaccess index 1d8bcb34..404b43f5 100644 --- a/.htaccess +++ b/.htaccess @@ -17,6 +17,17 @@ SecFilterScanPOST Off +# Increase security by uncommenting this block. It keeps browsers +# from seeing support files that they shouldn't have access to. We +# comment this out because Apache2 requires some minor configuration +# in order for you to use it. You must specify "AllowOverride Limit" +# in your Apache2 config file before you uncomment this block or +# you'll get an "Internal Server Error". +# +# +# Order allow,deny +# + # Improve performance by uncommenting this block. It tells the # browser that your images don't change very often so it won't keep # asking for them. If you get an error after uncommenting this, make -- cgit v1.2.3 From d82863421df3e7c8d500ab32c11c556a50691dbd Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jun 2010 21:10:22 -0700 Subject: Rename "simple_uploader" to "flash_uploader" to make room for an HTML uploader. --- modules/gallery/controllers/flash_uploader.php | 124 ++++++++++++++++++++++++ modules/gallery/controllers/simple_uploader.php | 124 ------------------------ modules/gallery/helpers/gallery_event.php | 4 +- modules/gallery/views/form_uploadify.html.php | 2 +- themes/wind/views/album.html.php | 2 +- 5 files changed, 128 insertions(+), 128 deletions(-) create mode 100644 modules/gallery/controllers/flash_uploader.php delete mode 100644 modules/gallery/controllers/simple_uploader.php diff --git a/modules/gallery/controllers/flash_uploader.php b/modules/gallery/controllers/flash_uploader.php new file mode 100644 index 00000000..f7da5124 --- /dev/null +++ b/modules/gallery/controllers/flash_uploader.php @@ -0,0 +1,124 @@ +is_album()) { + $item = $item->parent(); + } + + print $this->_get_add_form($item); + } + + public function start() { + access::verify_csrf(); + batch::start(); + } + + public function add_photo($id) { + $album = ORM::factory("item", $id); + access::required("view", $album); + access::required("add", $album); + access::verify_csrf(); + + // The Flash uploader not call /start directly, so simulate it here for now. + if (!batch::in_progress()) { + batch::start(); + } + + $form = $this->_get_add_form($album); + + // Uploadify adds its own field to the form, so validate that separately. + $file_validation = new Validation($_FILES); + $file_validation->add_rules( + "Filedata", "upload::valid", "upload::required", "upload::type[gif,jpg,jpeg,png,flv,mp4]"); + + if ($form->validate() && $file_validation->validate()) { + $temp_filename = upload::save("Filedata"); + try { + $item = ORM::factory("item"); + $item->name = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds + $item->title = item::convert_filename_to_title($item->name); + $item->parent_id = $album->id; + $item->set_data_file($temp_filename); + + $path_info = @pathinfo($temp_filename); + if (array_key_exists("extension", $path_info) && + in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) { + $item->type = "movie"; + $item->save(); + log::success("content", t("Added a movie"), + html::anchor("movies/$item->id", t("view movie"))); + } else { + $item->type = "photo"; + $item->save(); + log::success("content", t("Added a photo"), + html::anchor("photos/$item->id", t("view photo"))); + } + + module::event("add_photos_form_completed", $item, $form); + } catch (Exception $e) { + // The Flash uploader has no good way of reporting complex errors, so just keep it simple. + Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); + + // Ugh. I hate to use instanceof, But this beats catching the exception separately since + // we mostly want to treat it the same way as all other exceptions + if ($e instanceof ORM_Validation_Exception) { + Kohana_Log::add("error", "Validation errors: " . print_r($e->validation->errors(), 1)); + } + + if (file_exists($temp_filename)) { + unlink($temp_filename); + } + header("HTTP/1.1 500 Internal Server Error"); + print "ERROR: " . $e->getMessage(); + return; + } + unlink($temp_filename); + print "FILEID: $item->id"; + } else { + header("HTTP/1.1 400 Bad Request"); + print "ERROR: " . t("Invalid upload"); + } + } + + public function finish() { + access::verify_csrf(); + + batch::stop(); + print json_encode(array("result" => "success")); + } + + private function _get_add_form($album) { + $form = new Forge("flash_uploader/finish", "", "post", array("id" => "g-add-photos-form")); + $group = $form->group("add_photos") + ->label(t("Add photos to %album_title", array("album_title" => html::purify($album->title)))); + $group->uploadify("uploadify")->album($album); + + $group = $form->group("actions"); + $group->uploadify_buttons(""); + + module::event("add_photos_form", $album, $form); + + return $form; + } +} diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php deleted file mode 100644 index c7e5031b..00000000 --- a/modules/gallery/controllers/simple_uploader.php +++ /dev/null @@ -1,124 +0,0 @@ -is_album()) { - $item = $item->parent(); - } - - print $this->_get_add_form($item); - } - - public function start() { - access::verify_csrf(); - batch::start(); - } - - public function add_photo($id) { - $album = ORM::factory("item", $id); - access::required("view", $album); - access::required("add", $album); - access::verify_csrf(); - - // The Flash uploader not call /start directly, so simulate it here for now. - if (!batch::in_progress()) { - batch::start(); - } - - $form = $this->_get_add_form($album); - - // Uploadify adds its own field to the form, so validate that separately. - $file_validation = new Validation($_FILES); - $file_validation->add_rules( - "Filedata", "upload::valid", "upload::required", "upload::type[gif,jpg,jpeg,png,flv,mp4]"); - - if ($form->validate() && $file_validation->validate()) { - $temp_filename = upload::save("Filedata"); - try { - $item = ORM::factory("item"); - $item->name = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds - $item->title = item::convert_filename_to_title($item->name); - $item->parent_id = $album->id; - $item->set_data_file($temp_filename); - - $path_info = @pathinfo($temp_filename); - if (array_key_exists("extension", $path_info) && - in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) { - $item->type = "movie"; - $item->save(); - log::success("content", t("Added a movie"), - html::anchor("movies/$item->id", t("view movie"))); - } else { - $item->type = "photo"; - $item->save(); - log::success("content", t("Added a photo"), - html::anchor("photos/$item->id", t("view photo"))); - } - - module::event("add_photos_form_completed", $item, $form); - } catch (Exception $e) { - // The Flash uploader has no good way of reporting complex errors, so just keep it simple. - Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); - - // Ugh. I hate to use instanceof, But this beats catching the exception separately since - // we mostly want to treat it the same way as all other exceptions - if ($e instanceof ORM_Validation_Exception) { - Kohana_Log::add("error", "Validation errors: " . print_r($e->validation->errors(), 1)); - } - - if (file_exists($temp_filename)) { - unlink($temp_filename); - } - header("HTTP/1.1 500 Internal Server Error"); - print "ERROR: " . $e->getMessage(); - return; - } - unlink($temp_filename); - print "FILEID: $item->id"; - } else { - header("HTTP/1.1 400 Bad Request"); - print "ERROR: " . t("Invalid upload"); - } - } - - public function finish() { - access::verify_csrf(); - - batch::stop(); - print json_encode(array("result" => "success")); - } - - private function _get_add_form($album) { - $form = new Forge("simple_uploader/finish", "", "post", array("id" => "g-add-photos-form")); - $group = $form->group("add_photos") - ->label(t("Add photos to %album_title", array("album_title" => html::purify($album->title)))); - $group->uploadify("uploadify")->album($album); - - $group = $form->group("actions"); - $group->uploadify_buttons(""); - - module::event("add_photos_form", $album, $form); - - return $form; - } -} diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 55db47ce..82f42d98 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -202,7 +202,7 @@ class gallery_event_Core { $add_menu->append(Menu::factory("dialog") ->id("add_photos_item") ->label(t("Add photos")) - ->url(url::site("simple_uploader/app/$item->id"))); + ->url(url::site("flash_uploader/app/$item->id"))); if ($item->is_album()) { $add_menu->append(Menu::factory("dialog") ->id("add_album_item") @@ -471,7 +471,7 @@ class gallery_event_Core { ->id("add_item") ->label(t("Add a photo")) ->css_class("ui-icon-plus") - ->url(url::site("simple_uploader/app/$item->id"))) + ->url(url::site("flash_uploader/app/$item->id"))) ->append(Menu::factory("dialog") ->id("add_album") ->label(t("Add an album")) diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php index d811f913..588fa16d 100644 --- a/modules/gallery/views/form_uploadify.html.php +++ b/modules/gallery/views/form_uploadify.html.php @@ -7,7 +7,7 @@ width: 150, height: 33, uploader: "", - script: "id}") ?>", + script: "id}") ?>", scriptData: , fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4", fileDesc: for_js() ?>, diff --git a/themes/wind/views/album.html.php b/themes/wind/views/album.html.php index eabe07c3..b9072e2b 100644 --- a/themes/wind/views/album.html.php +++ b/themes/wind/views/album.html.php @@ -29,7 +29,7 @@ admin || access::can("add", $item)): ?> - id") ?> + id") ?>
  • Add some.", array("attrs" => html::mark_clean("href=\"$addurl\" class=\"g-dialog-link\""))) ?>
  • -- cgit v1.2.3 From a804c115138172634123ebebc9b055d6a26e6189 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 21 Jun 2010 10:11:38 -0700 Subject: 1) revert e468ed7bd3f1e29b267e3902ef9c91273787d58f 2) Add the padding to both the button and flash object so they always line up 3) Add some top padding to the uploadifyQueue panel to seprate it from the button. --- modules/gallery/css/gallery.css | 9 ++++++--- themes/wind/css/screen.css | 6 ------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index e2ad7458..282ebec2 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -30,7 +30,7 @@ #g-add-photos-canvas object, #g-add-photos-button { left: 137px; - margin: 0 0 .5em 0; + margin: .5em 0; padding: .4em 1em; position: absolute; top: 0; @@ -38,10 +38,13 @@ } #g-add-photos-canvas object { - margin: 0; z-index: 100; } +#g-add-photos-canvas .uploadifyQueue { + margin-top: .5em; +} + #g-add-photos-canvas .uploadifyQueueItem { margin: 0; } @@ -204,4 +207,4 @@ .rtl #g-translations ol { margin: 0 2em 1em 0; -} \ No newline at end of file +} diff --git a/themes/wind/css/screen.css b/themes/wind/css/screen.css index bc9f3e59..1e55a967 100644 --- a/themes/wind/css/screen.css +++ b/themes/wind/css/screen.css @@ -319,12 +319,6 @@ td { background-color: #fff; } -/* Add dialog ~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#g-add-photos-button { - margin-top: 6px !important; -} - /** ******************************************************************* * 5) Navigation and menus *********************************************************************/ -- cgit v1.2.3 From 0b7a8e1a692702b0497d0dde89ad5afa7bc4ea78 Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Wed, 23 Jun 2010 19:27:11 +0800 Subject: fix ticket #1051 --- lib/gallery.common.css | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/gallery.common.css b/lib/gallery.common.css index 5dd0d031..2b86700f 100644 --- a/lib/gallery.common.css +++ b/lib/gallery.common.css @@ -822,6 +822,7 @@ div#g-action-status { .rtl .sf-menu li:hover ul, .rtl .sf-menu li.sfHover ul { right: 0; + left: auto; } .rtl ul.sf-menu li li:hover ul, -- cgit v1.2.3 From d195e49d9f30c4d30682bbe5d633ee9dc85bde04 Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Wed, 23 Jun 2010 19:30:56 +0800 Subject: correct format --- lib/gallery.common.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/gallery.common.css b/lib/gallery.common.css index 2b86700f..054bc29a 100644 --- a/lib/gallery.common.css +++ b/lib/gallery.common.css @@ -780,7 +780,7 @@ div#g-action-status { /* RTL Superfish ~~~~~~~~~~~~~~~~~~~~~~~~~ */ .rtl .sf-menu a { - border-left: none; + border-left: none; border-right:1px solid #fff; } @@ -791,7 +791,7 @@ div#g-action-status { .rtl .sf-sub-indicator { left: .75em !important; - right: auto; + right: auto; background: url('superfish/images/arrows-ffffff-rtl.png') no-repeat -10px -100px; /* 8-bit indexed alpha png. IE6 gets solid image only */ } .rtl a > .sf-sub-indicator { /* give all except IE6 the correct values */ @@ -822,7 +822,7 @@ div#g-action-status { .rtl .sf-menu li:hover ul, .rtl .sf-menu li.sfHover ul { right: 0; - left: auto; + left: auto; } .rtl ul.sf-menu li li:hover ul, -- cgit v1.2.3 From bc8b64db0b65b8ba2d28be8022f7f8ac3ef1a85c Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Wed, 23 Jun 2010 19:36:59 +0800 Subject: more fixes for RTL Superfish --- lib/gallery.common.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/gallery.common.css b/lib/gallery.common.css index 054bc29a..682cef70 100644 --- a/lib/gallery.common.css +++ b/lib/gallery.common.css @@ -828,10 +828,12 @@ div#g-action-status { .rtl ul.sf-menu li li:hover ul, .rtl ul.sf-menu li li.sfHover ul { right: 12em; /* match ul width */ + left: auto; } .rtl ul.sf-menu li li li:hover ul, .rtl ul.sf-menu li li li.sfHover ul { right: 12em; /* match ul width */ + left: auto; } /*** shadows for all but IE6 ***/ -- cgit v1.2.3 From bae9546b88649592658fc37c66cd66b42ba83ace Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Wed, 23 Jun 2010 19:56:53 +0800 Subject: flip the window title and cancel button for RTL in dialogue windows --- lib/gallery.common.css | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/gallery.common.css b/lib/gallery.common.css index 682cef70..a83acdbb 100644 --- a/lib/gallery.common.css +++ b/lib/gallery.common.css @@ -846,6 +846,22 @@ div#g-action-status { -webkit-border-bottom-right-radius: 17px; } +/* RTL ThemeRoller ~~~~~~~~~~~~~~~~~~~~~~~~ */ + +.rtl .ui-dialog .ui-dialog-titlebar { + padding: 0.5em 1em 0.3em 0.3em; +} + +.rtl .ui-dialog .ui-dialog-title { + float: right; +} + +.rtl .ui-dialog .ui-dialog-titlebar-close { + left: 0.3em; + right: auto; +} + + /* RTL paginator ~~~~~~~~~~~~~~~~~~~~~~~~~~ */ .rtl .g-paginator .g-info { -- cgit v1.2.3 From b8800c69e1ddf5afd8d4c9ee3af74f37000515de Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Wed, 23 Jun 2010 20:10:59 +0800 Subject: flip the padding direction for sidebar blocks contents in RTL --- themes/admin_wind/css/screen.css | 4 ++++ themes/wind/css/screen.css | 3 +++ 2 files changed, 7 insertions(+) diff --git a/themes/admin_wind/css/screen.css b/themes/admin_wind/css/screen.css index dbfb59e8..e2817b78 100644 --- a/themes/admin_wind/css/screen.css +++ b/themes/admin_wind/css/screen.css @@ -487,4 +487,8 @@ th { .rtl .g-selected img, .rtl .g-available .g-block img { margin: 0 0 1em 1em; +} + +.rtl #g-sidebar .g-block-content { + padding-right: 1em; } \ No newline at end of file diff --git a/themes/wind/css/screen.css b/themes/wind/css/screen.css index 1e55a967..f5cb6601 100644 --- a/themes/wind/css/screen.css +++ b/themes/wind/css/screen.css @@ -457,3 +457,6 @@ td { background-image: url('../images/ico-view-slideshow-rtl.png'); } +.rtl #g-sidebar .g-block-content { + padding-right: 1em; +} \ No newline at end of file -- cgit v1.2.3 From 5494751a33c93df1afe3db151a332c81cdbc00b4 Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Wed, 23 Jun 2010 20:20:14 +0800 Subject: oops.. remove the padding in RTL for admin-wind, since it seems that it's zero (why the rule is duplicated with different values in the file in lines: 159, 301?) --- themes/admin_wind/css/screen.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/themes/admin_wind/css/screen.css b/themes/admin_wind/css/screen.css index e2817b78..dbfb59e8 100644 --- a/themes/admin_wind/css/screen.css +++ b/themes/admin_wind/css/screen.css @@ -487,8 +487,4 @@ th { .rtl .g-selected img, .rtl .g-available .g-block img { margin: 0 0 1em 1em; -} - -.rtl #g-sidebar .g-block-content { - padding-right: 1em; } \ No newline at end of file -- cgit v1.2.3 From acc9ec8180f7a354527b44e9f8e254e2b5d03813 Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Wed, 23 Jun 2010 20:20:50 +0800 Subject: remove the original padding --- themes/wind/css/screen.css | 1 + 1 file changed, 1 insertion(+) diff --git a/themes/wind/css/screen.css b/themes/wind/css/screen.css index f5cb6601..66645cef 100644 --- a/themes/wind/css/screen.css +++ b/themes/wind/css/screen.css @@ -459,4 +459,5 @@ td { .rtl #g-sidebar .g-block-content { padding-right: 1em; + padding-left: 0; } \ No newline at end of file -- cgit v1.2.3 From 69fffda87bcd9b72c3b0b7a43e610bae3395afe5 Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Wed, 23 Jun 2010 20:33:35 +0800 Subject: improve Superfish menus shadow for RTL, and add round corners support for Opera --- lib/gallery.common.css | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/gallery.common.css b/lib/gallery.common.css index a83acdbb..2bb5b6e2 100644 --- a/lib/gallery.common.css +++ b/lib/gallery.common.css @@ -840,10 +840,18 @@ div#g-action-status { .rtl .sf-shadow ul { background: url('superfish/images/shadow.png') no-repeat bottom left; padding: 0 0 9px 8px; - -moz-border-radius-bottomright: 17px; + border-top-right-radius: 0; + border-bottom-left-radius: 0; + -moz-border-radius-topright: 0; + -moz-border-radius-bottomleft: 0; + -webkit-border-top-right-radius: 0; + -webkit-border-bottom-left-radius: 0; -moz-border-radius-topleft: 17px; + -moz-border-radius-bottomright: 17px; -webkit-border-top-left-radius: 17px; -webkit-border-bottom-right-radius: 17px; + border-top-left-radius: 17px; + border-bottom-right-radius: 17px; } /* RTL ThemeRoller ~~~~~~~~~~~~~~~~~~~~~~~~ */ -- cgit v1.2.3 From cedfd9d364a293fdb99988743bcb09c92e9b5e18 Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Wed, 23 Jun 2010 20:39:19 +0800 Subject: flip the padding of footer for RTL --- themes/wind/css/screen.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/themes/wind/css/screen.css b/themes/wind/css/screen.css index 66645cef..063c5015 100644 --- a/themes/wind/css/screen.css +++ b/themes/wind/css/screen.css @@ -460,4 +460,8 @@ td { .rtl #g-sidebar .g-block-content { padding-right: 1em; padding-left: 0; +} + +.rtl #g-footer #g-credits li { + padding-left: 1.2em; } \ No newline at end of file -- cgit v1.2.3 From c41bd46a744479813b3442f3e20ce17765353e70 Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Wed, 23 Jun 2010 20:42:42 +0800 Subject: fix the footer padding for RTL, complete the last commit --- themes/wind/css/screen.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/wind/css/screen.css b/themes/wind/css/screen.css index 063c5015..44582a92 100644 --- a/themes/wind/css/screen.css +++ b/themes/wind/css/screen.css @@ -463,5 +463,6 @@ td { } .rtl #g-footer #g-credits li { - padding-left: 1.2em; + padding-left: 1.2em !important; + padding-right: 0; } \ No newline at end of file -- cgit v1.2.3 From ca09e9889004438090b4d9c8410cb746c135f163 Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Wed, 23 Jun 2010 22:12:25 +0800 Subject: centerize the group labels in Edit Permission window.. i think it's much cleaner this way --- modules/gallery/css/gallery.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index 282ebec2..08bd4749 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -84,6 +84,10 @@ clear: both; } +#g-edit-permissions-form th { + text-align: center; +} + #g-edit-permissions-form td { background-image: none; } -- cgit v1.2.3 From 3b05db2685d92ca538d7993c960b06ea32f3a8df Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 23 Jun 2010 11:16:56 -0700 Subject: Move the themeroller files to the themes from gallery/lib. These are visual related and make more sense to be in the theme. Both three_nids and browny_wind* have created copies for their visual standard. So this just makes it consistent across the board. --- .../images/ui-bg_flat_0_aaaaaa_40x100.png | Bin 180 -> 0 bytes .../images/ui-bg_flat_55_fbec88_40x100.png | Bin 182 -> 0 bytes .../images/ui-bg_glass_75_d0e5f5_1x400.png | Bin 124 -> 0 bytes .../images/ui-bg_glass_85_dfeffc_1x400.png | Bin 123 -> 0 bytes .../images/ui-bg_glass_95_fef1ec_1x400.png | Bin 119 -> 0 bytes .../images/ui-bg_gloss-wave_55_5c9ccc_500x100.png | Bin 4033 -> 0 bytes .../images/ui-bg_inset-hard_100_f5f8f9_1x100.png | Bin 104 -> 0 bytes .../images/ui-bg_inset-hard_100_fcfdfd_1x100.png | Bin 88 -> 0 bytes lib/themeroller/images/ui-icons_217bc0_256x240.png | Bin 7638 -> 0 bytes lib/themeroller/images/ui-icons_2e83ff_256x240.png | Bin 7626 -> 0 bytes lib/themeroller/images/ui-icons_469bdd_256x240.png | Bin 5399 -> 0 bytes lib/themeroller/images/ui-icons_6da8d5_256x240.png | Bin 8447 -> 0 bytes lib/themeroller/images/ui-icons_cd0a0a_256x240.png | Bin 4379 -> 0 bytes lib/themeroller/images/ui-icons_d8e7f3_256x240.png | Bin 4379 -> 0 bytes lib/themeroller/images/ui-icons_f9bd01_256x240.png | Bin 4379 -> 0 bytes lib/themeroller/ui.base.css | 7 - lib/themeroller/ui.core.css | 37 ---- lib/themeroller/ui.datepicker.css | 62 ------ lib/themeroller/ui.dialog.css | 13 -- lib/themeroller/ui.progressbar.css | 4 - lib/themeroller/ui.resizable.css | 13 -- lib/themeroller/ui.tabs.css | 9 - lib/themeroller/ui.theme.css | 243 --------------------- .../images/ui-bg_flat_0_aaaaaa_40x100.png | Bin 0 -> 180 bytes .../images/ui-bg_flat_55_fbec88_40x100.png | Bin 0 -> 182 bytes .../images/ui-bg_glass_75_d0e5f5_1x400.png | Bin 0 -> 124 bytes .../images/ui-bg_glass_85_dfeffc_1x400.png | Bin 0 -> 123 bytes .../images/ui-bg_glass_95_fef1ec_1x400.png | Bin 0 -> 119 bytes .../images/ui-bg_gloss-wave_55_5c9ccc_500x100.png | Bin 0 -> 4033 bytes .../images/ui-bg_inset-hard_100_f5f8f9_1x100.png | Bin 0 -> 104 bytes .../images/ui-bg_inset-hard_100_fcfdfd_1x100.png | Bin 0 -> 88 bytes .../themeroller/images/ui-icons_217bc0_256x240.png | Bin 0 -> 7638 bytes .../themeroller/images/ui-icons_2e83ff_256x240.png | Bin 0 -> 7626 bytes .../themeroller/images/ui-icons_469bdd_256x240.png | Bin 0 -> 5399 bytes .../themeroller/images/ui-icons_6da8d5_256x240.png | Bin 0 -> 8447 bytes .../themeroller/images/ui-icons_cd0a0a_256x240.png | Bin 0 -> 4379 bytes .../themeroller/images/ui-icons_d8e7f3_256x240.png | Bin 0 -> 4379 bytes .../themeroller/images/ui-icons_f9bd01_256x240.png | Bin 0 -> 4379 bytes themes/admin_wind/css/themeroller/ui.base.css | 7 + themes/admin_wind/css/themeroller/ui.core.css | 37 ++++ .../admin_wind/css/themeroller/ui.datepicker.css | 62 ++++++ themes/admin_wind/css/themeroller/ui.dialog.css | 13 ++ .../admin_wind/css/themeroller/ui.progressbar.css | 4 + themes/admin_wind/css/themeroller/ui.resizable.css | 13 ++ themes/admin_wind/css/themeroller/ui.tabs.css | 9 + themes/admin_wind/css/themeroller/ui.theme.css | 243 +++++++++++++++++++++ .../images/ui-bg_flat_0_aaaaaa_40x100.png | Bin 0 -> 180 bytes .../images/ui-bg_flat_55_fbec88_40x100.png | Bin 0 -> 182 bytes .../images/ui-bg_glass_75_d0e5f5_1x400.png | Bin 0 -> 124 bytes .../images/ui-bg_glass_85_dfeffc_1x400.png | Bin 0 -> 123 bytes .../images/ui-bg_glass_95_fef1ec_1x400.png | Bin 0 -> 119 bytes .../images/ui-bg_gloss-wave_55_5c9ccc_500x100.png | Bin 0 -> 4033 bytes .../images/ui-bg_inset-hard_100_f5f8f9_1x100.png | Bin 0 -> 104 bytes .../images/ui-bg_inset-hard_100_fcfdfd_1x100.png | Bin 0 -> 88 bytes .../themeroller/images/ui-icons_217bc0_256x240.png | Bin 0 -> 7638 bytes .../themeroller/images/ui-icons_2e83ff_256x240.png | Bin 0 -> 7626 bytes .../themeroller/images/ui-icons_469bdd_256x240.png | Bin 0 -> 5399 bytes .../themeroller/images/ui-icons_6da8d5_256x240.png | Bin 0 -> 8447 bytes .../themeroller/images/ui-icons_cd0a0a_256x240.png | Bin 0 -> 4379 bytes .../themeroller/images/ui-icons_d8e7f3_256x240.png | Bin 0 -> 4379 bytes .../themeroller/images/ui-icons_f9bd01_256x240.png | Bin 0 -> 4379 bytes themes/wind/css/themeroller/ui.base.css | 7 + themes/wind/css/themeroller/ui.core.css | 37 ++++ themes/wind/css/themeroller/ui.datepicker.css | 62 ++++++ themes/wind/css/themeroller/ui.dialog.css | 13 ++ themes/wind/css/themeroller/ui.progressbar.css | 4 + themes/wind/css/themeroller/ui.resizable.css | 13 ++ themes/wind/css/themeroller/ui.tabs.css | 9 + themes/wind/css/themeroller/ui.theme.css | 243 +++++++++++++++++++++ 69 files changed, 776 insertions(+), 388 deletions(-) delete mode 100644 lib/themeroller/images/ui-bg_flat_0_aaaaaa_40x100.png delete mode 100644 lib/themeroller/images/ui-bg_flat_55_fbec88_40x100.png delete mode 100644 lib/themeroller/images/ui-bg_glass_75_d0e5f5_1x400.png delete mode 100644 lib/themeroller/images/ui-bg_glass_85_dfeffc_1x400.png delete mode 100644 lib/themeroller/images/ui-bg_glass_95_fef1ec_1x400.png delete mode 100644 lib/themeroller/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png delete mode 100644 lib/themeroller/images/ui-bg_inset-hard_100_f5f8f9_1x100.png delete mode 100644 lib/themeroller/images/ui-bg_inset-hard_100_fcfdfd_1x100.png delete mode 100644 lib/themeroller/images/ui-icons_217bc0_256x240.png delete mode 100644 lib/themeroller/images/ui-icons_2e83ff_256x240.png delete mode 100644 lib/themeroller/images/ui-icons_469bdd_256x240.png delete mode 100644 lib/themeroller/images/ui-icons_6da8d5_256x240.png delete mode 100644 lib/themeroller/images/ui-icons_cd0a0a_256x240.png delete mode 100644 lib/themeroller/images/ui-icons_d8e7f3_256x240.png delete mode 100644 lib/themeroller/images/ui-icons_f9bd01_256x240.png delete mode 100644 lib/themeroller/ui.base.css delete mode 100644 lib/themeroller/ui.core.css delete mode 100644 lib/themeroller/ui.datepicker.css delete mode 100644 lib/themeroller/ui.dialog.css delete mode 100644 lib/themeroller/ui.progressbar.css delete mode 100644 lib/themeroller/ui.resizable.css delete mode 100644 lib/themeroller/ui.tabs.css delete mode 100644 lib/themeroller/ui.theme.css create mode 100644 themes/admin_wind/css/themeroller/images/ui-bg_flat_0_aaaaaa_40x100.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-bg_flat_55_fbec88_40x100.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-bg_glass_75_d0e5f5_1x400.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-bg_glass_85_dfeffc_1x400.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-bg_glass_95_fef1ec_1x400.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-bg_inset-hard_100_f5f8f9_1x100.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-bg_inset-hard_100_fcfdfd_1x100.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-icons_217bc0_256x240.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-icons_2e83ff_256x240.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-icons_469bdd_256x240.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-icons_6da8d5_256x240.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-icons_cd0a0a_256x240.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-icons_d8e7f3_256x240.png create mode 100644 themes/admin_wind/css/themeroller/images/ui-icons_f9bd01_256x240.png create mode 100644 themes/admin_wind/css/themeroller/ui.base.css create mode 100644 themes/admin_wind/css/themeroller/ui.core.css create mode 100644 themes/admin_wind/css/themeroller/ui.datepicker.css create mode 100644 themes/admin_wind/css/themeroller/ui.dialog.css create mode 100644 themes/admin_wind/css/themeroller/ui.progressbar.css create mode 100644 themes/admin_wind/css/themeroller/ui.resizable.css create mode 100644 themes/admin_wind/css/themeroller/ui.tabs.css create mode 100644 themes/admin_wind/css/themeroller/ui.theme.css create mode 100644 themes/wind/css/themeroller/images/ui-bg_flat_0_aaaaaa_40x100.png create mode 100644 themes/wind/css/themeroller/images/ui-bg_flat_55_fbec88_40x100.png create mode 100644 themes/wind/css/themeroller/images/ui-bg_glass_75_d0e5f5_1x400.png create mode 100644 themes/wind/css/themeroller/images/ui-bg_glass_85_dfeffc_1x400.png create mode 100644 themes/wind/css/themeroller/images/ui-bg_glass_95_fef1ec_1x400.png create mode 100644 themes/wind/css/themeroller/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png create mode 100644 themes/wind/css/themeroller/images/ui-bg_inset-hard_100_f5f8f9_1x100.png create mode 100644 themes/wind/css/themeroller/images/ui-bg_inset-hard_100_fcfdfd_1x100.png create mode 100644 themes/wind/css/themeroller/images/ui-icons_217bc0_256x240.png create mode 100644 themes/wind/css/themeroller/images/ui-icons_2e83ff_256x240.png create mode 100644 themes/wind/css/themeroller/images/ui-icons_469bdd_256x240.png create mode 100644 themes/wind/css/themeroller/images/ui-icons_6da8d5_256x240.png create mode 100644 themes/wind/css/themeroller/images/ui-icons_cd0a0a_256x240.png create mode 100644 themes/wind/css/themeroller/images/ui-icons_d8e7f3_256x240.png create mode 100644 themes/wind/css/themeroller/images/ui-icons_f9bd01_256x240.png create mode 100644 themes/wind/css/themeroller/ui.base.css create mode 100644 themes/wind/css/themeroller/ui.core.css create mode 100644 themes/wind/css/themeroller/ui.datepicker.css create mode 100644 themes/wind/css/themeroller/ui.dialog.css create mode 100644 themes/wind/css/themeroller/ui.progressbar.css create mode 100644 themes/wind/css/themeroller/ui.resizable.css create mode 100644 themes/wind/css/themeroller/ui.tabs.css create mode 100644 themes/wind/css/themeroller/ui.theme.css diff --git a/lib/themeroller/images/ui-bg_flat_0_aaaaaa_40x100.png b/lib/themeroller/images/ui-bg_flat_0_aaaaaa_40x100.png deleted file mode 100644 index 5b5dab2a..00000000 Binary files a/lib/themeroller/images/ui-bg_flat_0_aaaaaa_40x100.png and /dev/null differ diff --git a/lib/themeroller/images/ui-bg_flat_55_fbec88_40x100.png b/lib/themeroller/images/ui-bg_flat_55_fbec88_40x100.png deleted file mode 100644 index 47acaadd..00000000 Binary files a/lib/themeroller/images/ui-bg_flat_55_fbec88_40x100.png and /dev/null differ diff --git a/lib/themeroller/images/ui-bg_glass_75_d0e5f5_1x400.png b/lib/themeroller/images/ui-bg_glass_75_d0e5f5_1x400.png deleted file mode 100644 index 9fb564f8..00000000 Binary files a/lib/themeroller/images/ui-bg_glass_75_d0e5f5_1x400.png and /dev/null differ diff --git a/lib/themeroller/images/ui-bg_glass_85_dfeffc_1x400.png b/lib/themeroller/images/ui-bg_glass_85_dfeffc_1x400.png deleted file mode 100644 index 01495152..00000000 Binary files a/lib/themeroller/images/ui-bg_glass_85_dfeffc_1x400.png and /dev/null differ diff --git a/lib/themeroller/images/ui-bg_glass_95_fef1ec_1x400.png b/lib/themeroller/images/ui-bg_glass_95_fef1ec_1x400.png deleted file mode 100644 index 4443fdc1..00000000 Binary files a/lib/themeroller/images/ui-bg_glass_95_fef1ec_1x400.png and /dev/null differ diff --git a/lib/themeroller/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png b/lib/themeroller/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png deleted file mode 100644 index 0cdbda36..00000000 Binary files a/lib/themeroller/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png and /dev/null differ diff --git a/lib/themeroller/images/ui-bg_inset-hard_100_f5f8f9_1x100.png b/lib/themeroller/images/ui-bg_inset-hard_100_f5f8f9_1x100.png deleted file mode 100644 index 4f3faf8a..00000000 Binary files a/lib/themeroller/images/ui-bg_inset-hard_100_f5f8f9_1x100.png and /dev/null differ diff --git a/lib/themeroller/images/ui-bg_inset-hard_100_fcfdfd_1x100.png b/lib/themeroller/images/ui-bg_inset-hard_100_fcfdfd_1x100.png deleted file mode 100644 index 38c38335..00000000 Binary files a/lib/themeroller/images/ui-bg_inset-hard_100_fcfdfd_1x100.png and /dev/null differ diff --git a/lib/themeroller/images/ui-icons_217bc0_256x240.png b/lib/themeroller/images/ui-icons_217bc0_256x240.png deleted file mode 100644 index 7719d487..00000000 Binary files a/lib/themeroller/images/ui-icons_217bc0_256x240.png and /dev/null differ diff --git a/lib/themeroller/images/ui-icons_2e83ff_256x240.png b/lib/themeroller/images/ui-icons_2e83ff_256x240.png deleted file mode 100644 index d9897d25..00000000 Binary files a/lib/themeroller/images/ui-icons_2e83ff_256x240.png and /dev/null differ diff --git a/lib/themeroller/images/ui-icons_469bdd_256x240.png b/lib/themeroller/images/ui-icons_469bdd_256x240.png deleted file mode 100644 index d8161854..00000000 Binary files a/lib/themeroller/images/ui-icons_469bdd_256x240.png and /dev/null differ diff --git a/lib/themeroller/images/ui-icons_6da8d5_256x240.png b/lib/themeroller/images/ui-icons_6da8d5_256x240.png deleted file mode 100644 index b3c7d662..00000000 Binary files a/lib/themeroller/images/ui-icons_6da8d5_256x240.png and /dev/null differ diff --git a/lib/themeroller/images/ui-icons_cd0a0a_256x240.png b/lib/themeroller/images/ui-icons_cd0a0a_256x240.png deleted file mode 100644 index 2db88b79..00000000 Binary files a/lib/themeroller/images/ui-icons_cd0a0a_256x240.png and /dev/null differ diff --git a/lib/themeroller/images/ui-icons_d8e7f3_256x240.png b/lib/themeroller/images/ui-icons_d8e7f3_256x240.png deleted file mode 100644 index 2c8aac46..00000000 Binary files a/lib/themeroller/images/ui-icons_d8e7f3_256x240.png and /dev/null differ diff --git a/lib/themeroller/images/ui-icons_f9bd01_256x240.png b/lib/themeroller/images/ui-icons_f9bd01_256x240.png deleted file mode 100644 index e81603f5..00000000 Binary files a/lib/themeroller/images/ui-icons_f9bd01_256x240.png and /dev/null differ diff --git a/lib/themeroller/ui.base.css b/lib/themeroller/ui.base.css deleted file mode 100644 index 1a1810c8..00000000 --- a/lib/themeroller/ui.base.css +++ /dev/null @@ -1,7 +0,0 @@ -@import "ui.core.css"; -@import "ui.theme.css"; -@import "ui.datepicker.css"; -@import "ui.dialog.css"; -@import "ui.progressbar.css"; -@import "ui.resizable.css"; -@import "ui.tabs.css"; diff --git a/lib/themeroller/ui.core.css b/lib/themeroller/ui.core.css deleted file mode 100644 index d832ad7d..00000000 --- a/lib/themeroller/ui.core.css +++ /dev/null @@ -1,37 +0,0 @@ -/* -* jQuery UI CSS Framework -* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) -* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. -*/ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { display: none; } -.ui-helper-hidden-accessible { position: absolute; left: -99999999px; } -.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } -.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } -.ui-helper-clearfix { display: inline-block; } -/* required comment for clearfix to work in Opera \*/ -* html .ui-helper-clearfix { height:1%; } -.ui-helper-clearfix { display:block; } -/* end clearfix */ -.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { cursor: default !important; } - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } \ No newline at end of file diff --git a/lib/themeroller/ui.datepicker.css b/lib/themeroller/ui.datepicker.css deleted file mode 100644 index 92986c9e..00000000 --- a/lib/themeroller/ui.datepicker.css +++ /dev/null @@ -1,62 +0,0 @@ -/* Datepicker -----------------------------------*/ -.ui-datepicker { width: 17em; padding: .2em .2em 0; } -.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; } -.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; } -.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; } -.ui-datepicker .ui-datepicker-prev { left:2px; } -.ui-datepicker .ui-datepicker-next { right:2px; } -.ui-datepicker .ui-datepicker-prev-hover { left:1px; } -.ui-datepicker .ui-datepicker-next-hover { right:1px; } -.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } -.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; } -.ui-datepicker .ui-datepicker-title select { float:left; font-size:1em; margin:1px 0; } -.ui-datepicker select.ui-datepicker-month-year {width: 100%;} -.ui-datepicker select.ui-datepicker-month, -.ui-datepicker select.ui-datepicker-year { width: 49%;} -.ui-datepicker .ui-datepicker-title select.ui-datepicker-year { float: right; } -.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } -.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } -.ui-datepicker td { border: 0; padding: 1px; } -.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } -.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } -.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } -.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } - -/* with multiple calendars */ -.ui-datepicker.ui-datepicker-multi { width:auto; } -.ui-datepicker-multi .ui-datepicker-group { float:left; } -.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; } -.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; } -.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; } -.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; } -.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; } -.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; } -.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; } -.ui-datepicker-row-break { clear:left; width:100%; } - -/* RTL support */ -.ui-datepicker-rtl { direction: rtl; } -.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; } -.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; } -.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; } -.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; } -.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; } -.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; } -.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; } -.ui-datepicker-rtl .ui-datepicker-group { float:right; } -.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; } -.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; } - -/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */ -.ui-datepicker-cover { - display: none; /*sorry for IE5*/ - display/**/: block; /*sorry for IE5*/ - position: absolute; /*must have*/ - z-index: -1; /*must have*/ - filter: mask(); /*must have*/ - top: -4px; /*must have*/ - left: -4px; /*must have*/ - width: 200px; /*must have*/ - height: 200px; /*must have*/ -} \ No newline at end of file diff --git a/lib/themeroller/ui.dialog.css b/lib/themeroller/ui.dialog.css deleted file mode 100644 index f10f4090..00000000 --- a/lib/themeroller/ui.dialog.css +++ /dev/null @@ -1,13 +0,0 @@ -/* Dialog -----------------------------------*/ -.ui-dialog { position: relative; padding: .2em; width: 300px; } -.ui-dialog .ui-dialog-titlebar { padding: .5em .3em .3em 1em; position: relative; } -.ui-dialog .ui-dialog-title { float: left; margin: .1em 0 .2em; } -.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; } -.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; } -.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; } -.ui-dialog .ui-dialog-content { border: 0; padding: .5em 1em; background: none; overflow: auto; } -.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; } -.ui-dialog .ui-dialog-buttonpane button { float: right; margin: .5em .4em .5em 0; cursor: pointer; padding: .2em .6em .3em .6em; line-height: 1.4em; width:auto; overflow:visible; } -.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; } -.ui-draggable .ui-dialog-titlebar { cursor: move; } \ No newline at end of file diff --git a/lib/themeroller/ui.progressbar.css b/lib/themeroller/ui.progressbar.css deleted file mode 100644 index bc0939ec..00000000 --- a/lib/themeroller/ui.progressbar.css +++ /dev/null @@ -1,4 +0,0 @@ -/* Progressbar -----------------------------------*/ -.ui-progressbar { height:2em; text-align: left; } -.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; } \ No newline at end of file diff --git a/lib/themeroller/ui.resizable.css b/lib/themeroller/ui.resizable.css deleted file mode 100644 index 44efeb2e..00000000 --- a/lib/themeroller/ui.resizable.css +++ /dev/null @@ -1,13 +0,0 @@ -/* Resizable -----------------------------------*/ -.ui-resizable { position: relative;} -.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;} -.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } -.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0px; } -.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0px; } -.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0px; height: 100%; } -.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0px; height: 100%; } -.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } -.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; } -.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } -.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;} \ No newline at end of file diff --git a/lib/themeroller/ui.tabs.css b/lib/themeroller/ui.tabs.css deleted file mode 100644 index 70ed3ef4..00000000 --- a/lib/themeroller/ui.tabs.css +++ /dev/null @@ -1,9 +0,0 @@ -/* Tabs -----------------------------------*/ -.ui-tabs {padding: .2em;} -.ui-tabs .ui-tabs-nav { padding: .2em .2em 0 .2em; position: relative; } -.ui-tabs .ui-tabs-nav li { float: left; border-bottom: 0 !important; margin: 0 .2em -1px 0; padding: 0; list-style: none; } -.ui-tabs .ui-tabs-nav li a { display:block; text-decoration: none; padding: .5em 1em; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected { padding-bottom: .1em; border-bottom: 0; } -.ui-tabs .ui-tabs-panel { padding: 1em 1.4em; display: block; border: 0; background: none; } -.ui-tabs .ui-tabs-hide { display: none !important; } \ No newline at end of file diff --git a/lib/themeroller/ui.theme.css b/lib/themeroller/ui.theme.css deleted file mode 100644 index 477252e5..00000000 --- a/lib/themeroller/ui.theme.css +++ /dev/null @@ -1,243 +0,0 @@ - - -/* -* jQuery UI CSS Framework -* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) -* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. -* To view and modify this theme, visit http://ui.jquery.com/themeroller/?tr=&ffDefault=Lucida%20Grande,%20Lucida%20Sans,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=5px&bgColorHeader=5c9ccc&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=55&borderColorHeader=4297d7&fcHeader=ffffff&iconColorHeader=d8e7f3&bgColorContent=fcfdfd&bgTextureContent=06_inset_hard.png&bgImgOpacityContent=100&borderColorContent=a6c9e2&fcContent=222222&iconColorContent=469bdd&bgColorDefault=dfeffc&bgTextureDefault=02_glass.png&bgImgOpacityDefault=85&borderColorDefault=c5dbec&fcDefault=2e6e9e&iconColorDefault=6da8d5&bgColorHover=d0e5f5&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=79b7e7&fcHover=1d5987&iconColorHover=217bc0&bgColorActive=f5f8f9&bgTextureActive=06_inset_hard.png&bgImgOpacityActive=100&borderColorActive=79b7e7&fcActive=e17009&iconColorActive=f9bd01&bgColorHighlight=fbec88&bgTextureHighlight=01_flat.png&bgImgOpacityHighlight=55&borderColorHighlight=fad42e&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=02_glass.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px -*/ - - -/* Component containers -----------------------------------*/ -.ui-widget { font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1.1em; } -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em; } -.ui-widget-header { border: 1px solid #4297d7; background: #5c9ccc url(images/ui-bg_gloss-wave_55_5c9ccc_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; } -.ui-widget-header a { color: #ffffff; } -.ui-widget-content { border: 1px solid #a6c9e2; background: #fcfdfd url(images/ui-bg_inset-hard_100_fcfdfd_1x100.png) 50% bottom repeat-x; color: #222222; } -.ui-widget-content a { color: #222222; } - -/* Interaction states -----------------------------------*/ -.ui-state-default, .ui-widget-content .ui-state-default { border: 1px solid #c5dbec; background: #dfeffc url(images/ui-bg_glass_85_dfeffc_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #2e6e9e; outline: none; } -.ui-state-default a { color: #2e6e9e; text-decoration: none; outline: none; } -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus { border: 1px solid #79b7e7; background: #d0e5f5 url(images/ui-bg_glass_75_d0e5f5_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1d5987; outline: none; } -.ui-state-hover a { color: #1d5987; text-decoration: none; outline: none; } -.ui-state-active, .ui-widget-content .ui-state-active { border: 1px solid #79b7e7; background: #f5f8f9 url(images/ui-bg_inset-hard_100_f5f8f9_1x100.png) 50% 50% repeat-x; font-weight: bold; color: #e17009; outline: none; } -.ui-state-active a { color: #e17009; outline: none; text-decoration: none; } - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, .ui-widget-content .ui-state-highlight {border: 1px solid #fad42e; background: #fbec88 url(images/ui-bg_flat_55_fbec88_40x100.png) 50% 50% repeat-x; color: #363636; } -.ui-state-error, .ui-widget-content .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x; color: #cd0a0a; } -.ui-state-error-text, .ui-widget-content .ui-state-error-text { color: #cd0a0a; } -.ui-state-disabled, .ui-widget-content .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } -.ui-priority-primary, .ui-widget-content .ui-priority-primary { font-weight: bold; } -.ui-priority-secondary, .ui-widget-content .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_469bdd_256x240.png); } -.ui-widget-content .ui-icon {background-image: url(images/ui-icons_469bdd_256x240.png); } -.ui-widget-header .ui-icon {background-image: url(images/ui-icons_d8e7f3_256x240.png); } -.ui-state-default .ui-icon { background-image: url(images/ui-icons_6da8d5_256x240.png); } -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_217bc0_256x240.png); } -.ui-state-active .ui-icon {background-image: url(images/ui-icons_f9bd01_256x240.png); } -.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); } -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); } - -/* positioning */ -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-off { background-position: -96px -144px; } -.ui-icon-radio-on { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-tl { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; } -.ui-corner-tr { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } -.ui-corner-bl { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } -.ui-corner-br { -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } -.ui-corner-top { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } -.ui-corner-bottom { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } -.ui-corner-right { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } -.ui-corner-left { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } -.ui-corner-all { -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } - -/* Overlays */ -.ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); } -.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -webkit-border-radius: 8px; } \ No newline at end of file diff --git a/themes/admin_wind/css/themeroller/images/ui-bg_flat_0_aaaaaa_40x100.png b/themes/admin_wind/css/themeroller/images/ui-bg_flat_0_aaaaaa_40x100.png new file mode 100644 index 00000000..5b5dab2a Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-bg_flat_0_aaaaaa_40x100.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-bg_flat_55_fbec88_40x100.png b/themes/admin_wind/css/themeroller/images/ui-bg_flat_55_fbec88_40x100.png new file mode 100644 index 00000000..47acaadd Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-bg_flat_55_fbec88_40x100.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-bg_glass_75_d0e5f5_1x400.png b/themes/admin_wind/css/themeroller/images/ui-bg_glass_75_d0e5f5_1x400.png new file mode 100644 index 00000000..9fb564f8 Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-bg_glass_75_d0e5f5_1x400.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-bg_glass_85_dfeffc_1x400.png b/themes/admin_wind/css/themeroller/images/ui-bg_glass_85_dfeffc_1x400.png new file mode 100644 index 00000000..01495152 Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-bg_glass_85_dfeffc_1x400.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-bg_glass_95_fef1ec_1x400.png b/themes/admin_wind/css/themeroller/images/ui-bg_glass_95_fef1ec_1x400.png new file mode 100644 index 00000000..4443fdc1 Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-bg_glass_95_fef1ec_1x400.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png b/themes/admin_wind/css/themeroller/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png new file mode 100644 index 00000000..0cdbda36 Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-bg_inset-hard_100_f5f8f9_1x100.png b/themes/admin_wind/css/themeroller/images/ui-bg_inset-hard_100_f5f8f9_1x100.png new file mode 100644 index 00000000..4f3faf8a Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-bg_inset-hard_100_f5f8f9_1x100.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-bg_inset-hard_100_fcfdfd_1x100.png b/themes/admin_wind/css/themeroller/images/ui-bg_inset-hard_100_fcfdfd_1x100.png new file mode 100644 index 00000000..38c38335 Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-bg_inset-hard_100_fcfdfd_1x100.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-icons_217bc0_256x240.png b/themes/admin_wind/css/themeroller/images/ui-icons_217bc0_256x240.png new file mode 100644 index 00000000..7719d487 Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-icons_217bc0_256x240.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-icons_2e83ff_256x240.png b/themes/admin_wind/css/themeroller/images/ui-icons_2e83ff_256x240.png new file mode 100644 index 00000000..d9897d25 Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-icons_2e83ff_256x240.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-icons_469bdd_256x240.png b/themes/admin_wind/css/themeroller/images/ui-icons_469bdd_256x240.png new file mode 100644 index 00000000..d8161854 Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-icons_469bdd_256x240.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-icons_6da8d5_256x240.png b/themes/admin_wind/css/themeroller/images/ui-icons_6da8d5_256x240.png new file mode 100644 index 00000000..b3c7d662 Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-icons_6da8d5_256x240.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-icons_cd0a0a_256x240.png b/themes/admin_wind/css/themeroller/images/ui-icons_cd0a0a_256x240.png new file mode 100644 index 00000000..2db88b79 Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-icons_cd0a0a_256x240.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-icons_d8e7f3_256x240.png b/themes/admin_wind/css/themeroller/images/ui-icons_d8e7f3_256x240.png new file mode 100644 index 00000000..2c8aac46 Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-icons_d8e7f3_256x240.png differ diff --git a/themes/admin_wind/css/themeroller/images/ui-icons_f9bd01_256x240.png b/themes/admin_wind/css/themeroller/images/ui-icons_f9bd01_256x240.png new file mode 100644 index 00000000..e81603f5 Binary files /dev/null and b/themes/admin_wind/css/themeroller/images/ui-icons_f9bd01_256x240.png differ diff --git a/themes/admin_wind/css/themeroller/ui.base.css b/themes/admin_wind/css/themeroller/ui.base.css new file mode 100644 index 00000000..1a1810c8 --- /dev/null +++ b/themes/admin_wind/css/themeroller/ui.base.css @@ -0,0 +1,7 @@ +@import "ui.core.css"; +@import "ui.theme.css"; +@import "ui.datepicker.css"; +@import "ui.dialog.css"; +@import "ui.progressbar.css"; +@import "ui.resizable.css"; +@import "ui.tabs.css"; diff --git a/themes/admin_wind/css/themeroller/ui.core.css b/themes/admin_wind/css/themeroller/ui.core.css new file mode 100644 index 00000000..d832ad7d --- /dev/null +++ b/themes/admin_wind/css/themeroller/ui.core.css @@ -0,0 +1,37 @@ +/* +* jQuery UI CSS Framework +* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) +* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. +*/ + +/* Layout helpers +----------------------------------*/ +.ui-helper-hidden { display: none; } +.ui-helper-hidden-accessible { position: absolute; left: -99999999px; } +.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } +.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } +.ui-helper-clearfix { display: inline-block; } +/* required comment for clearfix to work in Opera \*/ +* html .ui-helper-clearfix { height:1%; } +.ui-helper-clearfix { display:block; } +/* end clearfix */ +.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } + + +/* Interaction Cues +----------------------------------*/ +.ui-state-disabled { cursor: default !important; } + + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } + + +/* Misc visuals +----------------------------------*/ + +/* Overlays */ +.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } \ No newline at end of file diff --git a/themes/admin_wind/css/themeroller/ui.datepicker.css b/themes/admin_wind/css/themeroller/ui.datepicker.css new file mode 100644 index 00000000..92986c9e --- /dev/null +++ b/themes/admin_wind/css/themeroller/ui.datepicker.css @@ -0,0 +1,62 @@ +/* Datepicker +----------------------------------*/ +.ui-datepicker { width: 17em; padding: .2em .2em 0; } +.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; } +.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; } +.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; } +.ui-datepicker .ui-datepicker-prev { left:2px; } +.ui-datepicker .ui-datepicker-next { right:2px; } +.ui-datepicker .ui-datepicker-prev-hover { left:1px; } +.ui-datepicker .ui-datepicker-next-hover { right:1px; } +.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } +.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; } +.ui-datepicker .ui-datepicker-title select { float:left; font-size:1em; margin:1px 0; } +.ui-datepicker select.ui-datepicker-month-year {width: 100%;} +.ui-datepicker select.ui-datepicker-month, +.ui-datepicker select.ui-datepicker-year { width: 49%;} +.ui-datepicker .ui-datepicker-title select.ui-datepicker-year { float: right; } +.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } +.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } +.ui-datepicker td { border: 0; padding: 1px; } +.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } +.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } +.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } +.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } + +/* with multiple calendars */ +.ui-datepicker.ui-datepicker-multi { width:auto; } +.ui-datepicker-multi .ui-datepicker-group { float:left; } +.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; } +.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; } +.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; } +.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; } +.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; } +.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; } +.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; } +.ui-datepicker-row-break { clear:left; width:100%; } + +/* RTL support */ +.ui-datepicker-rtl { direction: rtl; } +.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; } +.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; } +.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; } +.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; } +.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; } +.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; } +.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; } +.ui-datepicker-rtl .ui-datepicker-group { float:right; } +.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; } +.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; } + +/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */ +.ui-datepicker-cover { + display: none; /*sorry for IE5*/ + display/**/: block; /*sorry for IE5*/ + position: absolute; /*must have*/ + z-index: -1; /*must have*/ + filter: mask(); /*must have*/ + top: -4px; /*must have*/ + left: -4px; /*must have*/ + width: 200px; /*must have*/ + height: 200px; /*must have*/ +} \ No newline at end of file diff --git a/themes/admin_wind/css/themeroller/ui.dialog.css b/themes/admin_wind/css/themeroller/ui.dialog.css new file mode 100644 index 00000000..f10f4090 --- /dev/null +++ b/themes/admin_wind/css/themeroller/ui.dialog.css @@ -0,0 +1,13 @@ +/* Dialog +----------------------------------*/ +.ui-dialog { position: relative; padding: .2em; width: 300px; } +.ui-dialog .ui-dialog-titlebar { padding: .5em .3em .3em 1em; position: relative; } +.ui-dialog .ui-dialog-title { float: left; margin: .1em 0 .2em; } +.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; } +.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; } +.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; } +.ui-dialog .ui-dialog-content { border: 0; padding: .5em 1em; background: none; overflow: auto; } +.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; } +.ui-dialog .ui-dialog-buttonpane button { float: right; margin: .5em .4em .5em 0; cursor: pointer; padding: .2em .6em .3em .6em; line-height: 1.4em; width:auto; overflow:visible; } +.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; } +.ui-draggable .ui-dialog-titlebar { cursor: move; } \ No newline at end of file diff --git a/themes/admin_wind/css/themeroller/ui.progressbar.css b/themes/admin_wind/css/themeroller/ui.progressbar.css new file mode 100644 index 00000000..bc0939ec --- /dev/null +++ b/themes/admin_wind/css/themeroller/ui.progressbar.css @@ -0,0 +1,4 @@ +/* Progressbar +----------------------------------*/ +.ui-progressbar { height:2em; text-align: left; } +.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; } \ No newline at end of file diff --git a/themes/admin_wind/css/themeroller/ui.resizable.css b/themes/admin_wind/css/themeroller/ui.resizable.css new file mode 100644 index 00000000..44efeb2e --- /dev/null +++ b/themes/admin_wind/css/themeroller/ui.resizable.css @@ -0,0 +1,13 @@ +/* Resizable +----------------------------------*/ +.ui-resizable { position: relative;} +.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;} +.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } +.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0px; } +.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0px; } +.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0px; height: 100%; } +.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0px; height: 100%; } +.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } +.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; } +.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } +.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;} \ No newline at end of file diff --git a/themes/admin_wind/css/themeroller/ui.tabs.css b/themes/admin_wind/css/themeroller/ui.tabs.css new file mode 100644 index 00000000..70ed3ef4 --- /dev/null +++ b/themes/admin_wind/css/themeroller/ui.tabs.css @@ -0,0 +1,9 @@ +/* Tabs +----------------------------------*/ +.ui-tabs {padding: .2em;} +.ui-tabs .ui-tabs-nav { padding: .2em .2em 0 .2em; position: relative; } +.ui-tabs .ui-tabs-nav li { float: left; border-bottom: 0 !important; margin: 0 .2em -1px 0; padding: 0; list-style: none; } +.ui-tabs .ui-tabs-nav li a { display:block; text-decoration: none; padding: .5em 1em; } +.ui-tabs .ui-tabs-nav li.ui-tabs-selected { padding-bottom: .1em; border-bottom: 0; } +.ui-tabs .ui-tabs-panel { padding: 1em 1.4em; display: block; border: 0; background: none; } +.ui-tabs .ui-tabs-hide { display: none !important; } \ No newline at end of file diff --git a/themes/admin_wind/css/themeroller/ui.theme.css b/themes/admin_wind/css/themeroller/ui.theme.css new file mode 100644 index 00000000..477252e5 --- /dev/null +++ b/themes/admin_wind/css/themeroller/ui.theme.css @@ -0,0 +1,243 @@ + + +/* +* jQuery UI CSS Framework +* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) +* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. +* To view and modify this theme, visit http://ui.jquery.com/themeroller/?tr=&ffDefault=Lucida%20Grande,%20Lucida%20Sans,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=5px&bgColorHeader=5c9ccc&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=55&borderColorHeader=4297d7&fcHeader=ffffff&iconColorHeader=d8e7f3&bgColorContent=fcfdfd&bgTextureContent=06_inset_hard.png&bgImgOpacityContent=100&borderColorContent=a6c9e2&fcContent=222222&iconColorContent=469bdd&bgColorDefault=dfeffc&bgTextureDefault=02_glass.png&bgImgOpacityDefault=85&borderColorDefault=c5dbec&fcDefault=2e6e9e&iconColorDefault=6da8d5&bgColorHover=d0e5f5&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=79b7e7&fcHover=1d5987&iconColorHover=217bc0&bgColorActive=f5f8f9&bgTextureActive=06_inset_hard.png&bgImgOpacityActive=100&borderColorActive=79b7e7&fcActive=e17009&iconColorActive=f9bd01&bgColorHighlight=fbec88&bgTextureHighlight=01_flat.png&bgImgOpacityHighlight=55&borderColorHighlight=fad42e&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=02_glass.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px +*/ + + +/* Component containers +----------------------------------*/ +.ui-widget { font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1.1em; } +.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em; } +.ui-widget-header { border: 1px solid #4297d7; background: #5c9ccc url(images/ui-bg_gloss-wave_55_5c9ccc_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; } +.ui-widget-header a { color: #ffffff; } +.ui-widget-content { border: 1px solid #a6c9e2; background: #fcfdfd url(images/ui-bg_inset-hard_100_fcfdfd_1x100.png) 50% bottom repeat-x; color: #222222; } +.ui-widget-content a { color: #222222; } + +/* Interaction states +----------------------------------*/ +.ui-state-default, .ui-widget-content .ui-state-default { border: 1px solid #c5dbec; background: #dfeffc url(images/ui-bg_glass_85_dfeffc_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #2e6e9e; outline: none; } +.ui-state-default a { color: #2e6e9e; text-decoration: none; outline: none; } +.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus { border: 1px solid #79b7e7; background: #d0e5f5 url(images/ui-bg_glass_75_d0e5f5_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1d5987; outline: none; } +.ui-state-hover a { color: #1d5987; text-decoration: none; outline: none; } +.ui-state-active, .ui-widget-content .ui-state-active { border: 1px solid #79b7e7; background: #f5f8f9 url(images/ui-bg_inset-hard_100_f5f8f9_1x100.png) 50% 50% repeat-x; font-weight: bold; color: #e17009; outline: none; } +.ui-state-active a { color: #e17009; outline: none; text-decoration: none; } + +/* Interaction Cues +----------------------------------*/ +.ui-state-highlight, .ui-widget-content .ui-state-highlight {border: 1px solid #fad42e; background: #fbec88 url(images/ui-bg_flat_55_fbec88_40x100.png) 50% 50% repeat-x; color: #363636; } +.ui-state-error, .ui-widget-content .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x; color: #cd0a0a; } +.ui-state-error-text, .ui-widget-content .ui-state-error-text { color: #cd0a0a; } +.ui-state-disabled, .ui-widget-content .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } +.ui-priority-primary, .ui-widget-content .ui-priority-primary { font-weight: bold; } +.ui-priority-secondary, .ui-widget-content .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_469bdd_256x240.png); } +.ui-widget-content .ui-icon {background-image: url(images/ui-icons_469bdd_256x240.png); } +.ui-widget-header .ui-icon {background-image: url(images/ui-icons_d8e7f3_256x240.png); } +.ui-state-default .ui-icon { background-image: url(images/ui-icons_6da8d5_256x240.png); } +.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_217bc0_256x240.png); } +.ui-state-active .ui-icon {background-image: url(images/ui-icons_f9bd01_256x240.png); } +.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); } +.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); } + +/* positioning */ +.ui-icon-carat-1-n { background-position: 0 0; } +.ui-icon-carat-1-ne { background-position: -16px 0; } +.ui-icon-carat-1-e { background-position: -32px 0; } +.ui-icon-carat-1-se { background-position: -48px 0; } +.ui-icon-carat-1-s { background-position: -64px 0; } +.ui-icon-carat-1-sw { background-position: -80px 0; } +.ui-icon-carat-1-w { background-position: -96px 0; } +.ui-icon-carat-1-nw { background-position: -112px 0; } +.ui-icon-carat-2-n-s { background-position: -128px 0; } +.ui-icon-carat-2-e-w { background-position: -144px 0; } +.ui-icon-triangle-1-n { background-position: 0 -16px; } +.ui-icon-triangle-1-ne { background-position: -16px -16px; } +.ui-icon-triangle-1-e { background-position: -32px -16px; } +.ui-icon-triangle-1-se { background-position: -48px -16px; } +.ui-icon-triangle-1-s { background-position: -64px -16px; } +.ui-icon-triangle-1-sw { background-position: -80px -16px; } +.ui-icon-triangle-1-w { background-position: -96px -16px; } +.ui-icon-triangle-1-nw { background-position: -112px -16px; } +.ui-icon-triangle-2-n-s { background-position: -128px -16px; } +.ui-icon-triangle-2-e-w { background-position: -144px -16px; } +.ui-icon-arrow-1-n { background-position: 0 -32px; } +.ui-icon-arrow-1-ne { background-position: -16px -32px; } +.ui-icon-arrow-1-e { background-position: -32px -32px; } +.ui-icon-arrow-1-se { background-position: -48px -32px; } +.ui-icon-arrow-1-s { background-position: -64px -32px; } +.ui-icon-arrow-1-sw { background-position: -80px -32px; } +.ui-icon-arrow-1-w { background-position: -96px -32px; } +.ui-icon-arrow-1-nw { background-position: -112px -32px; } +.ui-icon-arrow-2-n-s { background-position: -128px -32px; } +.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } +.ui-icon-arrow-2-e-w { background-position: -160px -32px; } +.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } +.ui-icon-arrowstop-1-n { background-position: -192px -32px; } +.ui-icon-arrowstop-1-e { background-position: -208px -32px; } +.ui-icon-arrowstop-1-s { background-position: -224px -32px; } +.ui-icon-arrowstop-1-w { background-position: -240px -32px; } +.ui-icon-arrowthick-1-n { background-position: 0 -48px; } +.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } +.ui-icon-arrowthick-1-e { background-position: -32px -48px; } +.ui-icon-arrowthick-1-se { background-position: -48px -48px; } +.ui-icon-arrowthick-1-s { background-position: -64px -48px; } +.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } +.ui-icon-arrowthick-1-w { background-position: -96px -48px; } +.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } +.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } +.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } +.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } +.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } +.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } +.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } +.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } +.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } +.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } +.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } +.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } +.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } +.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } +.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } +.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } +.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } +.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } +.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } +.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } +.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } +.ui-icon-arrow-4 { background-position: 0 -80px; } +.ui-icon-arrow-4-diag { background-position: -16px -80px; } +.ui-icon-extlink { background-position: -32px -80px; } +.ui-icon-newwin { background-position: -48px -80px; } +.ui-icon-refresh { background-position: -64px -80px; } +.ui-icon-shuffle { background-position: -80px -80px; } +.ui-icon-transfer-e-w { background-position: -96px -80px; } +.ui-icon-transferthick-e-w { background-position: -112px -80px; } +.ui-icon-folder-collapsed { background-position: 0 -96px; } +.ui-icon-folder-open { background-position: -16px -96px; } +.ui-icon-document { background-position: -32px -96px; } +.ui-icon-document-b { background-position: -48px -96px; } +.ui-icon-note { background-position: -64px -96px; } +.ui-icon-mail-closed { background-position: -80px -96px; } +.ui-icon-mail-open { background-position: -96px -96px; } +.ui-icon-suitcase { background-position: -112px -96px; } +.ui-icon-comment { background-position: -128px -96px; } +.ui-icon-person { background-position: -144px -96px; } +.ui-icon-print { background-position: -160px -96px; } +.ui-icon-trash { background-position: -176px -96px; } +.ui-icon-locked { background-position: -192px -96px; } +.ui-icon-unlocked { background-position: -208px -96px; } +.ui-icon-bookmark { background-position: -224px -96px; } +.ui-icon-tag { background-position: -240px -96px; } +.ui-icon-home { background-position: 0 -112px; } +.ui-icon-flag { background-position: -16px -112px; } +.ui-icon-calendar { background-position: -32px -112px; } +.ui-icon-cart { background-position: -48px -112px; } +.ui-icon-pencil { background-position: -64px -112px; } +.ui-icon-clock { background-position: -80px -112px; } +.ui-icon-disk { background-position: -96px -112px; } +.ui-icon-calculator { background-position: -112px -112px; } +.ui-icon-zoomin { background-position: -128px -112px; } +.ui-icon-zoomout { background-position: -144px -112px; } +.ui-icon-search { background-position: -160px -112px; } +.ui-icon-wrench { background-position: -176px -112px; } +.ui-icon-gear { background-position: -192px -112px; } +.ui-icon-heart { background-position: -208px -112px; } +.ui-icon-star { background-position: -224px -112px; } +.ui-icon-link { background-position: -240px -112px; } +.ui-icon-cancel { background-position: 0 -128px; } +.ui-icon-plus { background-position: -16px -128px; } +.ui-icon-plusthick { background-position: -32px -128px; } +.ui-icon-minus { background-position: -48px -128px; } +.ui-icon-minusthick { background-position: -64px -128px; } +.ui-icon-close { background-position: -80px -128px; } +.ui-icon-closethick { background-position: -96px -128px; } +.ui-icon-key { background-position: -112px -128px; } +.ui-icon-lightbulb { background-position: -128px -128px; } +.ui-icon-scissors { background-position: -144px -128px; } +.ui-icon-clipboard { background-position: -160px -128px; } +.ui-icon-copy { background-position: -176px -128px; } +.ui-icon-contact { background-position: -192px -128px; } +.ui-icon-image { background-position: -208px -128px; } +.ui-icon-video { background-position: -224px -128px; } +.ui-icon-script { background-position: -240px -128px; } +.ui-icon-alert { background-position: 0 -144px; } +.ui-icon-info { background-position: -16px -144px; } +.ui-icon-notice { background-position: -32px -144px; } +.ui-icon-help { background-position: -48px -144px; } +.ui-icon-check { background-position: -64px -144px; } +.ui-icon-bullet { background-position: -80px -144px; } +.ui-icon-radio-off { background-position: -96px -144px; } +.ui-icon-radio-on { background-position: -112px -144px; } +.ui-icon-pin-w { background-position: -128px -144px; } +.ui-icon-pin-s { background-position: -144px -144px; } +.ui-icon-play { background-position: 0 -160px; } +.ui-icon-pause { background-position: -16px -160px; } +.ui-icon-seek-next { background-position: -32px -160px; } +.ui-icon-seek-prev { background-position: -48px -160px; } +.ui-icon-seek-end { background-position: -64px -160px; } +.ui-icon-seek-first { background-position: -80px -160px; } +.ui-icon-stop { background-position: -96px -160px; } +.ui-icon-eject { background-position: -112px -160px; } +.ui-icon-volume-off { background-position: -128px -160px; } +.ui-icon-volume-on { background-position: -144px -160px; } +.ui-icon-power { background-position: 0 -176px; } +.ui-icon-signal-diag { background-position: -16px -176px; } +.ui-icon-signal { background-position: -32px -176px; } +.ui-icon-battery-0 { background-position: -48px -176px; } +.ui-icon-battery-1 { background-position: -64px -176px; } +.ui-icon-battery-2 { background-position: -80px -176px; } +.ui-icon-battery-3 { background-position: -96px -176px; } +.ui-icon-circle-plus { background-position: 0 -192px; } +.ui-icon-circle-minus { background-position: -16px -192px; } +.ui-icon-circle-close { background-position: -32px -192px; } +.ui-icon-circle-triangle-e { background-position: -48px -192px; } +.ui-icon-circle-triangle-s { background-position: -64px -192px; } +.ui-icon-circle-triangle-w { background-position: -80px -192px; } +.ui-icon-circle-triangle-n { background-position: -96px -192px; } +.ui-icon-circle-arrow-e { background-position: -112px -192px; } +.ui-icon-circle-arrow-s { background-position: -128px -192px; } +.ui-icon-circle-arrow-w { background-position: -144px -192px; } +.ui-icon-circle-arrow-n { background-position: -160px -192px; } +.ui-icon-circle-zoomin { background-position: -176px -192px; } +.ui-icon-circle-zoomout { background-position: -192px -192px; } +.ui-icon-circle-check { background-position: -208px -192px; } +.ui-icon-circlesmall-plus { background-position: 0 -208px; } +.ui-icon-circlesmall-minus { background-position: -16px -208px; } +.ui-icon-circlesmall-close { background-position: -32px -208px; } +.ui-icon-squaresmall-plus { background-position: -48px -208px; } +.ui-icon-squaresmall-minus { background-position: -64px -208px; } +.ui-icon-squaresmall-close { background-position: -80px -208px; } +.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } +.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } +.ui-icon-grip-solid-vertical { background-position: -32px -224px; } +.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } +.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } +.ui-icon-grip-diagonal-se { background-position: -80px -224px; } + + +/* Misc visuals +----------------------------------*/ + +/* Corner radius */ +.ui-corner-tl { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; } +.ui-corner-tr { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } +.ui-corner-bl { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } +.ui-corner-br { -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-top { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } +.ui-corner-bottom { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-right { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-left { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } +.ui-corner-all { -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } + +/* Overlays */ +.ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); } +.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -webkit-border-radius: 8px; } \ No newline at end of file diff --git a/themes/wind/css/themeroller/images/ui-bg_flat_0_aaaaaa_40x100.png b/themes/wind/css/themeroller/images/ui-bg_flat_0_aaaaaa_40x100.png new file mode 100644 index 00000000..5b5dab2a Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-bg_flat_0_aaaaaa_40x100.png differ diff --git a/themes/wind/css/themeroller/images/ui-bg_flat_55_fbec88_40x100.png b/themes/wind/css/themeroller/images/ui-bg_flat_55_fbec88_40x100.png new file mode 100644 index 00000000..47acaadd Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-bg_flat_55_fbec88_40x100.png differ diff --git a/themes/wind/css/themeroller/images/ui-bg_glass_75_d0e5f5_1x400.png b/themes/wind/css/themeroller/images/ui-bg_glass_75_d0e5f5_1x400.png new file mode 100644 index 00000000..9fb564f8 Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-bg_glass_75_d0e5f5_1x400.png differ diff --git a/themes/wind/css/themeroller/images/ui-bg_glass_85_dfeffc_1x400.png b/themes/wind/css/themeroller/images/ui-bg_glass_85_dfeffc_1x400.png new file mode 100644 index 00000000..01495152 Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-bg_glass_85_dfeffc_1x400.png differ diff --git a/themes/wind/css/themeroller/images/ui-bg_glass_95_fef1ec_1x400.png b/themes/wind/css/themeroller/images/ui-bg_glass_95_fef1ec_1x400.png new file mode 100644 index 00000000..4443fdc1 Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-bg_glass_95_fef1ec_1x400.png differ diff --git a/themes/wind/css/themeroller/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png b/themes/wind/css/themeroller/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png new file mode 100644 index 00000000..0cdbda36 Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png differ diff --git a/themes/wind/css/themeroller/images/ui-bg_inset-hard_100_f5f8f9_1x100.png b/themes/wind/css/themeroller/images/ui-bg_inset-hard_100_f5f8f9_1x100.png new file mode 100644 index 00000000..4f3faf8a Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-bg_inset-hard_100_f5f8f9_1x100.png differ diff --git a/themes/wind/css/themeroller/images/ui-bg_inset-hard_100_fcfdfd_1x100.png b/themes/wind/css/themeroller/images/ui-bg_inset-hard_100_fcfdfd_1x100.png new file mode 100644 index 00000000..38c38335 Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-bg_inset-hard_100_fcfdfd_1x100.png differ diff --git a/themes/wind/css/themeroller/images/ui-icons_217bc0_256x240.png b/themes/wind/css/themeroller/images/ui-icons_217bc0_256x240.png new file mode 100644 index 00000000..7719d487 Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-icons_217bc0_256x240.png differ diff --git a/themes/wind/css/themeroller/images/ui-icons_2e83ff_256x240.png b/themes/wind/css/themeroller/images/ui-icons_2e83ff_256x240.png new file mode 100644 index 00000000..d9897d25 Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-icons_2e83ff_256x240.png differ diff --git a/themes/wind/css/themeroller/images/ui-icons_469bdd_256x240.png b/themes/wind/css/themeroller/images/ui-icons_469bdd_256x240.png new file mode 100644 index 00000000..d8161854 Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-icons_469bdd_256x240.png differ diff --git a/themes/wind/css/themeroller/images/ui-icons_6da8d5_256x240.png b/themes/wind/css/themeroller/images/ui-icons_6da8d5_256x240.png new file mode 100644 index 00000000..b3c7d662 Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-icons_6da8d5_256x240.png differ diff --git a/themes/wind/css/themeroller/images/ui-icons_cd0a0a_256x240.png b/themes/wind/css/themeroller/images/ui-icons_cd0a0a_256x240.png new file mode 100644 index 00000000..2db88b79 Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-icons_cd0a0a_256x240.png differ diff --git a/themes/wind/css/themeroller/images/ui-icons_d8e7f3_256x240.png b/themes/wind/css/themeroller/images/ui-icons_d8e7f3_256x240.png new file mode 100644 index 00000000..2c8aac46 Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-icons_d8e7f3_256x240.png differ diff --git a/themes/wind/css/themeroller/images/ui-icons_f9bd01_256x240.png b/themes/wind/css/themeroller/images/ui-icons_f9bd01_256x240.png new file mode 100644 index 00000000..e81603f5 Binary files /dev/null and b/themes/wind/css/themeroller/images/ui-icons_f9bd01_256x240.png differ diff --git a/themes/wind/css/themeroller/ui.base.css b/themes/wind/css/themeroller/ui.base.css new file mode 100644 index 00000000..1a1810c8 --- /dev/null +++ b/themes/wind/css/themeroller/ui.base.css @@ -0,0 +1,7 @@ +@import "ui.core.css"; +@import "ui.theme.css"; +@import "ui.datepicker.css"; +@import "ui.dialog.css"; +@import "ui.progressbar.css"; +@import "ui.resizable.css"; +@import "ui.tabs.css"; diff --git a/themes/wind/css/themeroller/ui.core.css b/themes/wind/css/themeroller/ui.core.css new file mode 100644 index 00000000..d832ad7d --- /dev/null +++ b/themes/wind/css/themeroller/ui.core.css @@ -0,0 +1,37 @@ +/* +* jQuery UI CSS Framework +* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) +* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. +*/ + +/* Layout helpers +----------------------------------*/ +.ui-helper-hidden { display: none; } +.ui-helper-hidden-accessible { position: absolute; left: -99999999px; } +.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } +.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } +.ui-helper-clearfix { display: inline-block; } +/* required comment for clearfix to work in Opera \*/ +* html .ui-helper-clearfix { height:1%; } +.ui-helper-clearfix { display:block; } +/* end clearfix */ +.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } + + +/* Interaction Cues +----------------------------------*/ +.ui-state-disabled { cursor: default !important; } + + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } + + +/* Misc visuals +----------------------------------*/ + +/* Overlays */ +.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } \ No newline at end of file diff --git a/themes/wind/css/themeroller/ui.datepicker.css b/themes/wind/css/themeroller/ui.datepicker.css new file mode 100644 index 00000000..92986c9e --- /dev/null +++ b/themes/wind/css/themeroller/ui.datepicker.css @@ -0,0 +1,62 @@ +/* Datepicker +----------------------------------*/ +.ui-datepicker { width: 17em; padding: .2em .2em 0; } +.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; } +.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; } +.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; } +.ui-datepicker .ui-datepicker-prev { left:2px; } +.ui-datepicker .ui-datepicker-next { right:2px; } +.ui-datepicker .ui-datepicker-prev-hover { left:1px; } +.ui-datepicker .ui-datepicker-next-hover { right:1px; } +.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } +.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; } +.ui-datepicker .ui-datepicker-title select { float:left; font-size:1em; margin:1px 0; } +.ui-datepicker select.ui-datepicker-month-year {width: 100%;} +.ui-datepicker select.ui-datepicker-month, +.ui-datepicker select.ui-datepicker-year { width: 49%;} +.ui-datepicker .ui-datepicker-title select.ui-datepicker-year { float: right; } +.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } +.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } +.ui-datepicker td { border: 0; padding: 1px; } +.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } +.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } +.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } +.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } + +/* with multiple calendars */ +.ui-datepicker.ui-datepicker-multi { width:auto; } +.ui-datepicker-multi .ui-datepicker-group { float:left; } +.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; } +.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; } +.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; } +.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; } +.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; } +.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; } +.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; } +.ui-datepicker-row-break { clear:left; width:100%; } + +/* RTL support */ +.ui-datepicker-rtl { direction: rtl; } +.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; } +.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; } +.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; } +.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; } +.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; } +.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; } +.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; } +.ui-datepicker-rtl .ui-datepicker-group { float:right; } +.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; } +.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; } + +/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */ +.ui-datepicker-cover { + display: none; /*sorry for IE5*/ + display/**/: block; /*sorry for IE5*/ + position: absolute; /*must have*/ + z-index: -1; /*must have*/ + filter: mask(); /*must have*/ + top: -4px; /*must have*/ + left: -4px; /*must have*/ + width: 200px; /*must have*/ + height: 200px; /*must have*/ +} \ No newline at end of file diff --git a/themes/wind/css/themeroller/ui.dialog.css b/themes/wind/css/themeroller/ui.dialog.css new file mode 100644 index 00000000..f10f4090 --- /dev/null +++ b/themes/wind/css/themeroller/ui.dialog.css @@ -0,0 +1,13 @@ +/* Dialog +----------------------------------*/ +.ui-dialog { position: relative; padding: .2em; width: 300px; } +.ui-dialog .ui-dialog-titlebar { padding: .5em .3em .3em 1em; position: relative; } +.ui-dialog .ui-dialog-title { float: left; margin: .1em 0 .2em; } +.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; } +.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; } +.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; } +.ui-dialog .ui-dialog-content { border: 0; padding: .5em 1em; background: none; overflow: auto; } +.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; } +.ui-dialog .ui-dialog-buttonpane button { float: right; margin: .5em .4em .5em 0; cursor: pointer; padding: .2em .6em .3em .6em; line-height: 1.4em; width:auto; overflow:visible; } +.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; } +.ui-draggable .ui-dialog-titlebar { cursor: move; } \ No newline at end of file diff --git a/themes/wind/css/themeroller/ui.progressbar.css b/themes/wind/css/themeroller/ui.progressbar.css new file mode 100644 index 00000000..bc0939ec --- /dev/null +++ b/themes/wind/css/themeroller/ui.progressbar.css @@ -0,0 +1,4 @@ +/* Progressbar +----------------------------------*/ +.ui-progressbar { height:2em; text-align: left; } +.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; } \ No newline at end of file diff --git a/themes/wind/css/themeroller/ui.resizable.css b/themes/wind/css/themeroller/ui.resizable.css new file mode 100644 index 00000000..44efeb2e --- /dev/null +++ b/themes/wind/css/themeroller/ui.resizable.css @@ -0,0 +1,13 @@ +/* Resizable +----------------------------------*/ +.ui-resizable { position: relative;} +.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;} +.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } +.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0px; } +.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0px; } +.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0px; height: 100%; } +.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0px; height: 100%; } +.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } +.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; } +.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } +.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;} \ No newline at end of file diff --git a/themes/wind/css/themeroller/ui.tabs.css b/themes/wind/css/themeroller/ui.tabs.css new file mode 100644 index 00000000..70ed3ef4 --- /dev/null +++ b/themes/wind/css/themeroller/ui.tabs.css @@ -0,0 +1,9 @@ +/* Tabs +----------------------------------*/ +.ui-tabs {padding: .2em;} +.ui-tabs .ui-tabs-nav { padding: .2em .2em 0 .2em; position: relative; } +.ui-tabs .ui-tabs-nav li { float: left; border-bottom: 0 !important; margin: 0 .2em -1px 0; padding: 0; list-style: none; } +.ui-tabs .ui-tabs-nav li a { display:block; text-decoration: none; padding: .5em 1em; } +.ui-tabs .ui-tabs-nav li.ui-tabs-selected { padding-bottom: .1em; border-bottom: 0; } +.ui-tabs .ui-tabs-panel { padding: 1em 1.4em; display: block; border: 0; background: none; } +.ui-tabs .ui-tabs-hide { display: none !important; } \ No newline at end of file diff --git a/themes/wind/css/themeroller/ui.theme.css b/themes/wind/css/themeroller/ui.theme.css new file mode 100644 index 00000000..477252e5 --- /dev/null +++ b/themes/wind/css/themeroller/ui.theme.css @@ -0,0 +1,243 @@ + + +/* +* jQuery UI CSS Framework +* Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) +* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. +* To view and modify this theme, visit http://ui.jquery.com/themeroller/?tr=&ffDefault=Lucida%20Grande,%20Lucida%20Sans,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=5px&bgColorHeader=5c9ccc&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=55&borderColorHeader=4297d7&fcHeader=ffffff&iconColorHeader=d8e7f3&bgColorContent=fcfdfd&bgTextureContent=06_inset_hard.png&bgImgOpacityContent=100&borderColorContent=a6c9e2&fcContent=222222&iconColorContent=469bdd&bgColorDefault=dfeffc&bgTextureDefault=02_glass.png&bgImgOpacityDefault=85&borderColorDefault=c5dbec&fcDefault=2e6e9e&iconColorDefault=6da8d5&bgColorHover=d0e5f5&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=79b7e7&fcHover=1d5987&iconColorHover=217bc0&bgColorActive=f5f8f9&bgTextureActive=06_inset_hard.png&bgImgOpacityActive=100&borderColorActive=79b7e7&fcActive=e17009&iconColorActive=f9bd01&bgColorHighlight=fbec88&bgTextureHighlight=01_flat.png&bgImgOpacityHighlight=55&borderColorHighlight=fad42e&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=02_glass.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px +*/ + + +/* Component containers +----------------------------------*/ +.ui-widget { font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1.1em; } +.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em; } +.ui-widget-header { border: 1px solid #4297d7; background: #5c9ccc url(images/ui-bg_gloss-wave_55_5c9ccc_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; } +.ui-widget-header a { color: #ffffff; } +.ui-widget-content { border: 1px solid #a6c9e2; background: #fcfdfd url(images/ui-bg_inset-hard_100_fcfdfd_1x100.png) 50% bottom repeat-x; color: #222222; } +.ui-widget-content a { color: #222222; } + +/* Interaction states +----------------------------------*/ +.ui-state-default, .ui-widget-content .ui-state-default { border: 1px solid #c5dbec; background: #dfeffc url(images/ui-bg_glass_85_dfeffc_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #2e6e9e; outline: none; } +.ui-state-default a { color: #2e6e9e; text-decoration: none; outline: none; } +.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus { border: 1px solid #79b7e7; background: #d0e5f5 url(images/ui-bg_glass_75_d0e5f5_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1d5987; outline: none; } +.ui-state-hover a { color: #1d5987; text-decoration: none; outline: none; } +.ui-state-active, .ui-widget-content .ui-state-active { border: 1px solid #79b7e7; background: #f5f8f9 url(images/ui-bg_inset-hard_100_f5f8f9_1x100.png) 50% 50% repeat-x; font-weight: bold; color: #e17009; outline: none; } +.ui-state-active a { color: #e17009; outline: none; text-decoration: none; } + +/* Interaction Cues +----------------------------------*/ +.ui-state-highlight, .ui-widget-content .ui-state-highlight {border: 1px solid #fad42e; background: #fbec88 url(images/ui-bg_flat_55_fbec88_40x100.png) 50% 50% repeat-x; color: #363636; } +.ui-state-error, .ui-widget-content .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x; color: #cd0a0a; } +.ui-state-error-text, .ui-widget-content .ui-state-error-text { color: #cd0a0a; } +.ui-state-disabled, .ui-widget-content .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } +.ui-priority-primary, .ui-widget-content .ui-priority-primary { font-weight: bold; } +.ui-priority-secondary, .ui-widget-content .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_469bdd_256x240.png); } +.ui-widget-content .ui-icon {background-image: url(images/ui-icons_469bdd_256x240.png); } +.ui-widget-header .ui-icon {background-image: url(images/ui-icons_d8e7f3_256x240.png); } +.ui-state-default .ui-icon { background-image: url(images/ui-icons_6da8d5_256x240.png); } +.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_217bc0_256x240.png); } +.ui-state-active .ui-icon {background-image: url(images/ui-icons_f9bd01_256x240.png); } +.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); } +.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); } + +/* positioning */ +.ui-icon-carat-1-n { background-position: 0 0; } +.ui-icon-carat-1-ne { background-position: -16px 0; } +.ui-icon-carat-1-e { background-position: -32px 0; } +.ui-icon-carat-1-se { background-position: -48px 0; } +.ui-icon-carat-1-s { background-position: -64px 0; } +.ui-icon-carat-1-sw { background-position: -80px 0; } +.ui-icon-carat-1-w { background-position: -96px 0; } +.ui-icon-carat-1-nw { background-position: -112px 0; } +.ui-icon-carat-2-n-s { background-position: -128px 0; } +.ui-icon-carat-2-e-w { background-position: -144px 0; } +.ui-icon-triangle-1-n { background-position: 0 -16px; } +.ui-icon-triangle-1-ne { background-position: -16px -16px; } +.ui-icon-triangle-1-e { background-position: -32px -16px; } +.ui-icon-triangle-1-se { background-position: -48px -16px; } +.ui-icon-triangle-1-s { background-position: -64px -16px; } +.ui-icon-triangle-1-sw { background-position: -80px -16px; } +.ui-icon-triangle-1-w { background-position: -96px -16px; } +.ui-icon-triangle-1-nw { background-position: -112px -16px; } +.ui-icon-triangle-2-n-s { background-position: -128px -16px; } +.ui-icon-triangle-2-e-w { background-position: -144px -16px; } +.ui-icon-arrow-1-n { background-position: 0 -32px; } +.ui-icon-arrow-1-ne { background-position: -16px -32px; } +.ui-icon-arrow-1-e { background-position: -32px -32px; } +.ui-icon-arrow-1-se { background-position: -48px -32px; } +.ui-icon-arrow-1-s { background-position: -64px -32px; } +.ui-icon-arrow-1-sw { background-position: -80px -32px; } +.ui-icon-arrow-1-w { background-position: -96px -32px; } +.ui-icon-arrow-1-nw { background-position: -112px -32px; } +.ui-icon-arrow-2-n-s { background-position: -128px -32px; } +.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } +.ui-icon-arrow-2-e-w { background-position: -160px -32px; } +.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } +.ui-icon-arrowstop-1-n { background-position: -192px -32px; } +.ui-icon-arrowstop-1-e { background-position: -208px -32px; } +.ui-icon-arrowstop-1-s { background-position: -224px -32px; } +.ui-icon-arrowstop-1-w { background-position: -240px -32px; } +.ui-icon-arrowthick-1-n { background-position: 0 -48px; } +.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } +.ui-icon-arrowthick-1-e { background-position: -32px -48px; } +.ui-icon-arrowthick-1-se { background-position: -48px -48px; } +.ui-icon-arrowthick-1-s { background-position: -64px -48px; } +.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } +.ui-icon-arrowthick-1-w { background-position: -96px -48px; } +.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } +.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } +.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } +.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } +.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } +.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } +.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } +.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } +.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } +.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } +.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } +.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } +.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } +.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } +.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } +.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } +.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } +.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } +.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } +.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } +.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } +.ui-icon-arrow-4 { background-position: 0 -80px; } +.ui-icon-arrow-4-diag { background-position: -16px -80px; } +.ui-icon-extlink { background-position: -32px -80px; } +.ui-icon-newwin { background-position: -48px -80px; } +.ui-icon-refresh { background-position: -64px -80px; } +.ui-icon-shuffle { background-position: -80px -80px; } +.ui-icon-transfer-e-w { background-position: -96px -80px; } +.ui-icon-transferthick-e-w { background-position: -112px -80px; } +.ui-icon-folder-collapsed { background-position: 0 -96px; } +.ui-icon-folder-open { background-position: -16px -96px; } +.ui-icon-document { background-position: -32px -96px; } +.ui-icon-document-b { background-position: -48px -96px; } +.ui-icon-note { background-position: -64px -96px; } +.ui-icon-mail-closed { background-position: -80px -96px; } +.ui-icon-mail-open { background-position: -96px -96px; } +.ui-icon-suitcase { background-position: -112px -96px; } +.ui-icon-comment { background-position: -128px -96px; } +.ui-icon-person { background-position: -144px -96px; } +.ui-icon-print { background-position: -160px -96px; } +.ui-icon-trash { background-position: -176px -96px; } +.ui-icon-locked { background-position: -192px -96px; } +.ui-icon-unlocked { background-position: -208px -96px; } +.ui-icon-bookmark { background-position: -224px -96px; } +.ui-icon-tag { background-position: -240px -96px; } +.ui-icon-home { background-position: 0 -112px; } +.ui-icon-flag { background-position: -16px -112px; } +.ui-icon-calendar { background-position: -32px -112px; } +.ui-icon-cart { background-position: -48px -112px; } +.ui-icon-pencil { background-position: -64px -112px; } +.ui-icon-clock { background-position: -80px -112px; } +.ui-icon-disk { background-position: -96px -112px; } +.ui-icon-calculator { background-position: -112px -112px; } +.ui-icon-zoomin { background-position: -128px -112px; } +.ui-icon-zoomout { background-position: -144px -112px; } +.ui-icon-search { background-position: -160px -112px; } +.ui-icon-wrench { background-position: -176px -112px; } +.ui-icon-gear { background-position: -192px -112px; } +.ui-icon-heart { background-position: -208px -112px; } +.ui-icon-star { background-position: -224px -112px; } +.ui-icon-link { background-position: -240px -112px; } +.ui-icon-cancel { background-position: 0 -128px; } +.ui-icon-plus { background-position: -16px -128px; } +.ui-icon-plusthick { background-position: -32px -128px; } +.ui-icon-minus { background-position: -48px -128px; } +.ui-icon-minusthick { background-position: -64px -128px; } +.ui-icon-close { background-position: -80px -128px; } +.ui-icon-closethick { background-position: -96px -128px; } +.ui-icon-key { background-position: -112px -128px; } +.ui-icon-lightbulb { background-position: -128px -128px; } +.ui-icon-scissors { background-position: -144px -128px; } +.ui-icon-clipboard { background-position: -160px -128px; } +.ui-icon-copy { background-position: -176px -128px; } +.ui-icon-contact { background-position: -192px -128px; } +.ui-icon-image { background-position: -208px -128px; } +.ui-icon-video { background-position: -224px -128px; } +.ui-icon-script { background-position: -240px -128px; } +.ui-icon-alert { background-position: 0 -144px; } +.ui-icon-info { background-position: -16px -144px; } +.ui-icon-notice { background-position: -32px -144px; } +.ui-icon-help { background-position: -48px -144px; } +.ui-icon-check { background-position: -64px -144px; } +.ui-icon-bullet { background-position: -80px -144px; } +.ui-icon-radio-off { background-position: -96px -144px; } +.ui-icon-radio-on { background-position: -112px -144px; } +.ui-icon-pin-w { background-position: -128px -144px; } +.ui-icon-pin-s { background-position: -144px -144px; } +.ui-icon-play { background-position: 0 -160px; } +.ui-icon-pause { background-position: -16px -160px; } +.ui-icon-seek-next { background-position: -32px -160px; } +.ui-icon-seek-prev { background-position: -48px -160px; } +.ui-icon-seek-end { background-position: -64px -160px; } +.ui-icon-seek-first { background-position: -80px -160px; } +.ui-icon-stop { background-position: -96px -160px; } +.ui-icon-eject { background-position: -112px -160px; } +.ui-icon-volume-off { background-position: -128px -160px; } +.ui-icon-volume-on { background-position: -144px -160px; } +.ui-icon-power { background-position: 0 -176px; } +.ui-icon-signal-diag { background-position: -16px -176px; } +.ui-icon-signal { background-position: -32px -176px; } +.ui-icon-battery-0 { background-position: -48px -176px; } +.ui-icon-battery-1 { background-position: -64px -176px; } +.ui-icon-battery-2 { background-position: -80px -176px; } +.ui-icon-battery-3 { background-position: -96px -176px; } +.ui-icon-circle-plus { background-position: 0 -192px; } +.ui-icon-circle-minus { background-position: -16px -192px; } +.ui-icon-circle-close { background-position: -32px -192px; } +.ui-icon-circle-triangle-e { background-position: -48px -192px; } +.ui-icon-circle-triangle-s { background-position: -64px -192px; } +.ui-icon-circle-triangle-w { background-position: -80px -192px; } +.ui-icon-circle-triangle-n { background-position: -96px -192px; } +.ui-icon-circle-arrow-e { background-position: -112px -192px; } +.ui-icon-circle-arrow-s { background-position: -128px -192px; } +.ui-icon-circle-arrow-w { background-position: -144px -192px; } +.ui-icon-circle-arrow-n { background-position: -160px -192px; } +.ui-icon-circle-zoomin { background-position: -176px -192px; } +.ui-icon-circle-zoomout { background-position: -192px -192px; } +.ui-icon-circle-check { background-position: -208px -192px; } +.ui-icon-circlesmall-plus { background-position: 0 -208px; } +.ui-icon-circlesmall-minus { background-position: -16px -208px; } +.ui-icon-circlesmall-close { background-position: -32px -208px; } +.ui-icon-squaresmall-plus { background-position: -48px -208px; } +.ui-icon-squaresmall-minus { background-position: -64px -208px; } +.ui-icon-squaresmall-close { background-position: -80px -208px; } +.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } +.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } +.ui-icon-grip-solid-vertical { background-position: -32px -224px; } +.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } +.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } +.ui-icon-grip-diagonal-se { background-position: -80px -224px; } + + +/* Misc visuals +----------------------------------*/ + +/* Corner radius */ +.ui-corner-tl { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; } +.ui-corner-tr { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } +.ui-corner-bl { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } +.ui-corner-br { -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-top { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } +.ui-corner-bottom { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-right { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-left { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } +.ui-corner-all { -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } + +/* Overlays */ +.ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); } +.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -webkit-border-radius: 8px; } \ No newline at end of file -- cgit v1.2.3 From d66c496fb1007bbd0b1640496808000c573d95fd Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 25 Jun 2010 06:45:09 -0700 Subject: Change the theme option page to display using tabs if the site theme has an admin page. --- modules/gallery/helpers/theme.php | 5 ++-- modules/gallery/views/admin_theme_options.html.php | 31 ++++++++++++++++++++++ themes/admin_wind/css/screen.css | 22 ++++++++++++++- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 980ee11a..a390645f 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -70,7 +70,7 @@ class theme_Core { static function get_edit_form_admin() { $form = new Forge("admin/theme_options/save/", "", null, array("id" =>"g-theme-options-form")); - $group = $form->group("edit_theme"); + $group = $form->group("edit_theme")->label(t("Theme Layout")); $group->input("page_size")->label(t("Items per page"))->id("g-page-size") ->rules("required|valid_digit") ->error_messages("required", t("You must enter a number")) @@ -95,7 +95,8 @@ class theme_Core { module::event("theme_edit_form", $form); - $group = $form->group("buttons"); + $group = $form->group("buttons") + ->set_attr("style","border: none"); $group->submit("")->value(t("Save")); return $form; } diff --git a/modules/gallery/views/admin_theme_options.html.php b/modules/gallery/views/admin_theme_options.html.php index a4bf1c4e..2cf97713 100644 --- a/modules/gallery/views/admin_theme_options.html.php +++ b/modules/gallery/views/admin_theme_options.html.php @@ -1,4 +1,35 @@ + +

    diff --git a/themes/admin_wind/css/screen.css b/themes/admin_wind/css/screen.css index dbfb59e8..937c4d15 100644 --- a/themes/admin_wind/css/screen.css +++ b/themes/admin_wind/css/screen.css @@ -399,6 +399,26 @@ th { background-color: #FFF; } +/* Theme options ~~~~~~~~~~~~~~~~~~~~~~~~ */ +#g-theme-options-form { + border: 1px solid #a6c9e2; +} +#g-theme-options-form-tabs { + border: none !important; +} +#g-theme-options-form fieldset { + border: none; +} + +.ui-tabs .ui-tabs-nav li a { + padding: 0 1em; +} + +.ui-tabs .ui-tabs-nav li a.g-error { + background: none no-repeat scroll 0 0 transparent; + color: #FF0000 !important; +} + /** ******************************************************************* * 5) Navigation and menus *********************************************************************/ @@ -487,4 +507,4 @@ th { .rtl .g-selected img, .rtl .g-available .g-block img { margin: 0 0 1em 1em; -} \ No newline at end of file +} -- cgit v1.2.3 From c946ad1fcd87d4cb9c8f45b0b3c553b31fcebec8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 25 Jun 2010 09:56:29 -0700 Subject: If we promote the

    element to be the title, hide it so we're not showing it twice. --- lib/gallery.dialog.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index f280a525..6ec8c634 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -40,6 +40,7 @@ $(".ui-dialog-titlebar").remove(); } else if ($("#g-dialog h1").length) { $("#g-dialog").dialog('option', 'title', $("#g-dialog h1:eq(0)").html()); + $("#g-dialog h1:eq(0)").hide(); } else if ($("#g-dialog fieldset legend").length) { $("#g-dialog").dialog('option', 'title', $("#g-dialog fieldset legend:eq(0)").html()); } -- cgit v1.2.3 From 8bc7eec60f8be5219bed64d95cf7e6efb85941f1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 25 Jun 2010 09:56:44 -0700 Subject: Add a

    title saying that this is a preview. --- modules/gallery/views/admin_themes_preview.html.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/gallery/views/admin_themes_preview.html.php b/modules/gallery/views/admin_themes_preview.html.php index a7aea172..80a6158b 100644 --- a/modules/gallery/views/admin_themes_preview.html.php +++ b/modules/gallery/views/admin_themes_preview.html.php @@ -1,4 +1,5 @@ +

    $info->name)) ?>

    "> %theme_name", array("theme_name" => $info->name)) ?> -- cgit v1.2.3 From e380f19ee29ee1f524aee2d4ebbf4c49f120fb19 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 25 Jun 2010 10:17:06 -0700 Subject: Fix an issue where a preview of the admin view would not work. --- modules/gallery/helpers/theme.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index a390645f..4730d296 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -53,6 +53,15 @@ class theme_Core { if (file_exists(THEMEPATH . self::$site_theme_name . "/admin")) { array_unshift($modules, THEMEPATH . self::$site_theme_name . "/admin"); } + // Admins can override the site theme, temporarily. This lets us preview themes. + if (identity::active_user()->admin && $override = $input->get("theme")) { + if (file_exists(THEMEPATH . $override)) { + self::$admin_theme_name = $override; + } else { + Kohana_Log::add("error", "Missing override theme: '$override'"); + } + } + array_unshift($modules, THEMEPATH . self::$admin_theme_name); } else { // Admins can override the site theme, temporarily. This lets us preview themes. if (identity::active_user()->admin && $override = $input->get("theme")) { -- cgit v1.2.3 From 8ecf28d3efa258d790d6cb31947407deb7149797 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 25 Jun 2010 10:23:11 -0700 Subject: Better fix for the problem that a preview of an admin theme was not showing up. --- modules/gallery/helpers/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 4730d296..419d986f 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -57,11 +57,11 @@ class theme_Core { if (identity::active_user()->admin && $override = $input->get("theme")) { if (file_exists(THEMEPATH . $override)) { self::$admin_theme_name = $override; + array_unshift($modules, THEMEPATH . self::$admin_theme_name); } else { Kohana_Log::add("error", "Missing override theme: '$override'"); } } - array_unshift($modules, THEMEPATH . self::$admin_theme_name); } else { // Admins can override the site theme, temporarily. This lets us preview themes. if (identity::active_user()->admin && $override = $input->get("theme")) { -- cgit v1.2.3 From 6b619e1098d770670b50553564b96bacec4a3f0c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 26 Jun 2010 12:00:14 -0700 Subject: Differentiate in our logs between missing site and admin theme overrides. --- modules/gallery/helpers/theme.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 419d986f..c2980149 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -59,7 +59,7 @@ class theme_Core { self::$admin_theme_name = $override; array_unshift($modules, THEMEPATH . self::$admin_theme_name); } else { - Kohana_Log::add("error", "Missing override theme: '$override'"); + Kohana_Log::add("error", "Missing override admin theme: '$override'"); } } } else { @@ -68,7 +68,7 @@ class theme_Core { if (file_exists(THEMEPATH . $override)) { self::$site_theme_name = $override; } else { - Kohana_Log::add("error", "Missing override theme: '$override'"); + Kohana_Log::add("error", "Missing override site theme: '$override'"); } } array_unshift($modules, THEMEPATH . self::$site_theme_name); -- cgit v1.2.3 From 5767971f433ca22f152fb348901d2f4336913038 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 26 Jun 2010 12:00:55 -0700 Subject: Sentence casing. --- modules/gallery/helpers/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index c2980149..3589a5b7 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -79,7 +79,7 @@ class theme_Core { static function get_edit_form_admin() { $form = new Forge("admin/theme_options/save/", "", null, array("id" =>"g-theme-options-form")); - $group = $form->group("edit_theme")->label(t("Theme Layout")); + $group = $form->group("edit_theme")->label(t("Theme layout")); $group->input("page_size")->label(t("Items per page"))->id("g-page-size") ->rules("required|valid_digit") ->error_messages("required", t("You must enter a number")) -- cgit v1.2.3 From e5ae2c91bc58518c977afdc134d5a59cb7ed9b71 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 26 Jun 2010 12:14:02 -0700 Subject: Style cleanup. --- modules/gallery/views/admin_theme_options.html.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/gallery/views/admin_theme_options.html.php b/modules/gallery/views/admin_theme_options.html.php index 2cf97713..b4a90682 100644 --- a/modules/gallery/views/admin_theme_options.html.php +++ b/modules/gallery/views/admin_theme_options.html.php @@ -10,17 +10,17 @@ var text = $("legend", this).text(); var tabId = "tab_" + index; var tabContentId = "tab_content_" + index; - console.log(tabId+": text='"+text+"'"); if (text == "") { text = for_js() ?> + index; } - $(".tabnav").append("

  • "+text+"
  • "); - $("#g-theme-options-form-tabs").append("
    "); - + $(".tabnav").append( + "
  • " + text + "
  • "); + $("#g-theme-options-form-tabs").append( + "
    "); if ($("li.g-error", this).length > 0) { - $("#"+tabId).addClass("g-error"); + $("#" + tabId).addClass("g-error"); } - $("#"+tabContentId).append($("ul", this)); + $("#" + tabContentId).append($("ul", this)); $(this).remove(); }); $("#g-theme-options-form-tabs").tabs({}); @@ -31,8 +31,7 @@
    -

    - +

    -- cgit v1.2.3 From 5335e4c0b4bffeeeb8667ed706b5e8702de00ce9 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 27 Jun 2010 11:25:31 -0700 Subject: Fix the autocomplete callback in item_edit_form(). We were incorrectly matching the form input in the jQuery selector. Did this ever work? Fixes ticket #1168 --- modules/tag/helpers/tag_event.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index a790b930..1a593d3f 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -67,8 +67,8 @@ class tag_event_Core { static function item_edit_form($item, $form) { $url = url::site("tags/autocomplete"); $form->script("") - ->text("$('form input[id=tags]').ready(function() { - $('form input[id=tags]').autocomplete( + ->text("$('form input[name=tags]').ready(function() { + $('form input[name=tags]').autocomplete( '$url', {max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1}); });"); -- cgit v1.2.3 From f75ce45b6b6b848840d9a1688ca382a49de4f338 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 27 Jun 2010 12:14:56 -0700 Subject: When detecting encodings, give priority to ISO-8859-1 which seems to solve the umlaut problem in IPTC data. Fixes ticket #1144. --- modules/exif/helpers/exif.php | 6 ++++-- modules/tag/helpers/tag_event.php | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/exif/helpers/exif.php b/modules/exif/helpers/exif.php index 943feba7..aa77b42e 100644 --- a/modules/exif/helpers/exif.php +++ b/modules/exif/helpers/exif.php @@ -36,7 +36,8 @@ class exif_Core { foreach(self::_keys() as $field => $exifvar) { if (isset($exif_raw[$exifvar[0]][$exifvar[1]])) { $value = $exif_raw[$exifvar[0]][$exifvar[1]]; - if (function_exists("mb_detect_encoding") && mb_detect_encoding($value) != "UTF-8") { + if (function_exists("mb_detect_encoding") && + mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { $value = utf8_encode($value); } $keys[$field] = Input::clean($value); @@ -59,7 +60,8 @@ class exif_Core { foreach (array("Keywords" => "2#025", "Caption" => "2#120") as $keyword => $iptc_key) { if (!empty($iptc[$iptc_key])) { $value = implode(" ", $iptc[$iptc_key]); - if (function_exists("mb_detect_encoding") && mb_detect_encoding($value) != "UTF-8") { + if (function_exists("mb_detect_encoding") && + mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { $value = utf8_encode($value); } $keys[$keyword] = Input::clean($value); diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 1a593d3f..7fe9fba3 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -36,7 +36,8 @@ class tag_event_Core { $tag = str_replace("\0", "", $tag); foreach (explode(",", $tag) as $word) { $word = trim($word); - if (function_exists("mb_detect_encoding") && mb_detect_encoding($word) != "UTF-8") { + if (function_exists("mb_detect_encoding") && + mb_detect_encoding($word, "ISO-8859-1, UTF-8") != "UTF-8") { $word = utf8_encode($word); } $tags[$word] = 1; -- cgit v1.2.3 From ca444a95651ba79feb92694b472f4b3cfbe03103 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 30 Jun 2010 20:17:59 -0700 Subject: Updated for RC2 --- README | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README b/README index 15519e31..a00d18cb 100644 --- a/README +++ b/README @@ -9,19 +9,18 @@ interface. SECURITY (& INTENDED AUDIENCE): -This is the third and final beta release of Gallery 3.0 and while it's -not a finished product, it's heading into the home stretch. You can -install it on public websites, but remember that until the final -release is out, we make no guarantees that it won't do bad things. +This is the second release candidate of Gallery 3.0. We're putting it +out there so that we can find out if we overlooked any small things. +We expect the final version to be virtually identical. You can +install it on public websites and use it freely -- we recommend it! Note: - We've contracted a professional security audit, received their results and resolved all the issues they found. - You can upgrade from beta 1, but not from alpha releases. -The intended audience of this release is folks who are willing to live -a little bit on the edge. We'll do our best to take care of your data -and your security, but we might screw it up here or there. We welcome +This version is intended for broad distribution. We stand ready to +support the product and help you to make the most of it. We welcome theme and module developers to play with this release and start turning out slick new designs for our happy users. -- cgit v1.2.3 From 3feb561054a735e6959e894eb568aa386426bb65 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 3 Jul 2010 11:40:56 -0700 Subject: Internationalize the "Gallery 2 path saved." message and remove the trailing period. Fixes ticket #1171. --- modules/g2_import/controllers/admin_g2_import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index cc60f757..b9427f79 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -60,7 +60,7 @@ class Admin_g2_import_Controller extends Admin_Controller { } if (g2_import::is_valid_embed_path($embed_path)) { - message::success("Gallery 2 path saved."); + message::success(t("Gallery 2 path saved")); module::set_var("g2_import", "embed_path", $embed_path); url::redirect("admin/g2_import"); } else { -- cgit v1.2.3 From 0d424a635d12eee59d2080fa7ffa32a248b0fd5c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 3 Jul 2010 14:25:33 -0700 Subject: When we delete an item, make sure that we scrub it from any other items that may have it in the album_cover_item_id column. Fixes ticket #1172. --- modules/gallery/helpers/gallery_event.php | 9 +++++++++ modules/gallery/tests/Item_Helper_Test.php | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 82f42d98..40ea50fa 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -98,6 +98,15 @@ class gallery_event_Core { static function item_deleted($item) { access::delete_item($item); + // Find any other albums that had the deleted item as the album cover and null it out. + // In some cases this may leave us with a missing album cover up in this item's parent + // hierarchy, but in most cases it'll work out fine. + foreach (ORM::factory("item") + ->where("album_cover_item_id", "=", $item->id) + ->find_all() as $parent) { + item::remove_album_cover($parent); + } + $parent = $item->parent(); if (!$parent->album_cover_item_id) { // Assume we deleted the album cover and pick a new one. Choosing the first photo in the diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php index 00229973..eb2458cb 100644 --- a/modules/gallery/tests/Item_Helper_Test.php +++ b/modules/gallery/tests/Item_Helper_Test.php @@ -111,15 +111,18 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case { $this->assert_not_same($rand, $photo2->slug); } - public function delete_cover_photo_picks_new_album_cover() { - $album = test::random_album(); + public function delete_cover_photo_picks_new_album_cover_test() { + $parent = test::random_album(); + $album = test::random_album($parent); $photo1 = test::random_photo($album); // At this point, $photo1 is the album cover. We verify this in // Item_Model_Test::first_photo_becomes_album_cover $photo2 = test::random_photo($album); $photo1->delete(); $album->reload(); + $parent->reload(); $this->assert_same($photo2->id, $album->album_cover_item_id); + $this->assert_same($photo2->id, $parent->album_cover_item_id); } } -- cgit v1.2.3 From 60126adc7e73ec6e70ee5033abf5032ac6b88305 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 4 Jul 2010 20:40:50 -0700 Subject: In the site menu, say "Delete album", "Delete photo" or "Delete movie" as appropriate for the item type. Fixes ticket #1175. --- modules/gallery/helpers/gallery_event.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 40ea50fa..272fd205 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -228,14 +228,17 @@ class gallery_event_Core { case "album": $option_text = t("Album options"); $edit_text = t("Edit album"); + $delete_text = t("Delete album"); break; case "movie": $option_text = t("Movie options"); $edit_text = t("Edit movie"); + $delete_text = t("Delete movie"); break; default: $option_text = t("Photo options"); $edit_text = t("Edit photo"); + $delete_text = t("Delete photo"); } $menu->append($options_menu = Menu::factory("submenu") @@ -309,7 +312,7 @@ class gallery_event_Core { ->append( Menu::factory("dialog") ->id("delete") - ->label(t("Delete this photo")) + ->label($delete_text) ->css_class("ui-icon-trash") ->css_class("g-quick-delete") ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))); -- cgit v1.2.3 From e4d397d30118a3d673b146c44ed329efa08bbefe Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 5 Jul 2010 08:21:14 -0700 Subject: Make the trailing slash on the url optional. Sometimes it is not there, so the regex doesn't match --- modules/gallery/config/routes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gallery/config/routes.php b/modules/gallery/config/routes.php index 55d3cf6c..e1ea9612 100644 --- a/modules/gallery/config/routes.php +++ b/modules/gallery/config/routes.php @@ -23,10 +23,10 @@ $config["^admin_.*"] = null; // Redirect /form/add/admin/controller and /form/edit/admin/controller to // admin/controller/form_(add|edit)/parms. provides the same as below for admin pages -$config["^form/(edit|add)/admin/(\w+)/(.*)$"] = "admin/$2/form_$1/$3"; +$config["^form/(edit|add)/admin/(\w+)/?(.*)$"] = "admin/$2/form_$1/$3"; // Redirect /form/add and /form/edit to the module/form_(add|edit)/parms. -$config["^form/(edit|add)/(\w+)/(.*)$"] = "$2/form_$1/$3"; +$config["^form/(edit|add)/(\w+)/?(.*)$"] = "$2/form_$1/$3"; // Default page is the root album $config["_default"] = "albums"; -- cgit v1.2.3 From 8493a3d36f597e183490ae880b35a3d98f50a045 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 5 Jul 2010 08:23:17 -0700 Subject: If the admin request originates as a dialog link, don't display the entire page when reauthenticating the administrator. Just put the form in the dialog. --- lib/gallery.dialog.js | 3 ++- modules/gallery/controllers/admin.php | 11 ++++++-- modules/gallery/controllers/reauthenticate.php | 20 ++------------ modules/gallery/helpers/reauthenticate.php | 36 ++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 21 deletions(-) create mode 100644 modules/gallery/helpers/reauthenticate.php diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index 6ec8c634..dd1a5663 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -26,7 +26,8 @@ $("#g-dialog").gallery_show_loading(); - $.get(sHref, function(data) { + var url = sHref + (sHref.indexOf("?") == -1 ? "?" : "&") + "g-in-dialog"; + $.get(url, function(data) { $("#g-dialog").html(data).gallery_show_loading(); if ($("#g-dialog form").length) { diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php index c460f58c..d9bee284 100644 --- a/modules/gallery/controllers/admin.php +++ b/modules/gallery/controllers/admin.php @@ -38,7 +38,8 @@ class Admin_Controller extends Controller { return self::_reauth_check(); } if (auth::must_reauth_for_admin_area()) { - return self::_prompt_for_reauth($controller_name, $args); + print self::_prompt_for_reauth($controller_name, $args); + return; } if (request::method() == "post") { @@ -85,7 +86,13 @@ class Admin_Controller extends Controller { // Avoid anti-phishing protection by passing the url as session variable. Session::instance()->set("continue_url", url::abs_current(true)); } - url::redirect("reauthenticate"); + + // Check that we we not in a dialog. If we are, then use an ajax response. + if (strpos(Router::$query_string, "g-in-dialog") === false) { + url::redirect("reauthenticate"); + } else { + return reauthenticate::get_authenticate_form(); + } } } diff --git a/modules/gallery/controllers/reauthenticate.php b/modules/gallery/controllers/reauthenticate.php index acb27f6a..9ddaff2e 100644 --- a/modules/gallery/controllers/reauthenticate.php +++ b/modules/gallery/controllers/reauthenticate.php @@ -22,7 +22,7 @@ class Reauthenticate_Controller extends Controller { if (!identity::active_user()->admin) { access::forbidden(); } - return self::_show_form(self::_form()); + return self::_show_form(reauthenticate::get_authenticate_form()); } public function auth() { @@ -31,7 +31,7 @@ class Reauthenticate_Controller extends Controller { } access::verify_csrf(); - $form = self::_form(); + $form = reauthenticate::get_authenticate_form(); $valid = $form->validate(); $user = identity::active_user(); if ($valid) { @@ -54,20 +54,4 @@ class Reauthenticate_Controller extends Controller { $view->content->user_name = identity::active_user()->name; print $view; } - - private static function _form() { - $form = new Forge("reauthenticate/auth", "", "post", array("id" => "g-reauthenticate-form")); - $form->set_attr('class', "g-narrow"); - $form->hidden("continue_url")->value(Session::instance()->get("continue_url", "admin")); - $group = $form->group("reauthenticate")->label(t("Re-authenticate")); - $group->password("password")->label(t("Password"))->id("g-password")->class(null) - ->callback("auth::validate_too_many_failed_auth_attempts") - ->callback("user::valid_password") - ->error_messages("invalid_password", t("Incorrect password")) - ->error_messages( - "too_many_failed_auth_attempts", - t("Too many incorrect passwords. Try again later")); - $group->submit("")->value(t("Submit")); - return $form; - } } diff --git a/modules/gallery/helpers/reauthenticate.php b/modules/gallery/helpers/reauthenticate.php new file mode 100644 index 00000000..1ad90e15 --- /dev/null +++ b/modules/gallery/helpers/reauthenticate.php @@ -0,0 +1,36 @@ + "g-reauthenticate-form")); + $form->set_attr('class', "g-narrow"); + $form->hidden("continue_url")->value(Session::instance()->get("continue_url", "admin")); + $group = $form->group("reauthenticate")->label(t("Re-authenticate")); + $group->password("password")->label(t("Password"))->id("g-password")->class(null) + ->callback("auth::validate_too_many_failed_auth_attempts") + ->callback("user::valid_password") + ->error_messages("invalid_password", t("Incorrect password")) + ->error_messages( + "too_many_failed_auth_attempts", + t("Too many incorrect passwords. Try again later")); + $group->submit("")->value(t("Submit")); + return $form; + } +} -- cgit v1.2.3 From 45b210c2879d93067f3d903b83cd56d392c75156 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 5 Jul 2010 08:44:46 -0700 Subject: Add maessage when we automatically log you out of the admin area. --- modules/gallery/controllers/admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php index c460f58c..40dd260b 100644 --- a/modules/gallery/controllers/admin.php +++ b/modules/gallery/controllers/admin.php @@ -74,6 +74,7 @@ class Admin_Controller extends Controller { $result = new stdClass(); $result->result = "success"; if ($time_remaining < 30) { + message::success(t("Automatically logged out of the admin area for your security")); $result->location = url::abs_site(""); } -- cgit v1.2.3 From 226d1f714635995722fe7927f8ec049fe3890011 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 5 Jul 2010 08:58:36 -0700 Subject: Revert "If the admin request originates as a dialog link, don't display the entire page when reauthenticating the administrator. Just put the form in the dialog." This reverts commit 8493a3d36f597e183490ae880b35a3d98f50a045. --- lib/gallery.dialog.js | 3 +-- modules/gallery/controllers/admin.php | 11 ++------ modules/gallery/controllers/reauthenticate.php | 20 ++++++++++++-- modules/gallery/helpers/reauthenticate.php | 36 -------------------------- 4 files changed, 21 insertions(+), 49 deletions(-) delete mode 100644 modules/gallery/helpers/reauthenticate.php diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index dd1a5663..6ec8c634 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -26,8 +26,7 @@ $("#g-dialog").gallery_show_loading(); - var url = sHref + (sHref.indexOf("?") == -1 ? "?" : "&") + "g-in-dialog"; - $.get(url, function(data) { + $.get(sHref, function(data) { $("#g-dialog").html(data).gallery_show_loading(); if ($("#g-dialog form").length) { diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php index d9bee284..c460f58c 100644 --- a/modules/gallery/controllers/admin.php +++ b/modules/gallery/controllers/admin.php @@ -38,8 +38,7 @@ class Admin_Controller extends Controller { return self::_reauth_check(); } if (auth::must_reauth_for_admin_area()) { - print self::_prompt_for_reauth($controller_name, $args); - return; + return self::_prompt_for_reauth($controller_name, $args); } if (request::method() == "post") { @@ -86,13 +85,7 @@ class Admin_Controller extends Controller { // Avoid anti-phishing protection by passing the url as session variable. Session::instance()->set("continue_url", url::abs_current(true)); } - - // Check that we we not in a dialog. If we are, then use an ajax response. - if (strpos(Router::$query_string, "g-in-dialog") === false) { - url::redirect("reauthenticate"); - } else { - return reauthenticate::get_authenticate_form(); - } + url::redirect("reauthenticate"); } } diff --git a/modules/gallery/controllers/reauthenticate.php b/modules/gallery/controllers/reauthenticate.php index 9ddaff2e..acb27f6a 100644 --- a/modules/gallery/controllers/reauthenticate.php +++ b/modules/gallery/controllers/reauthenticate.php @@ -22,7 +22,7 @@ class Reauthenticate_Controller extends Controller { if (!identity::active_user()->admin) { access::forbidden(); } - return self::_show_form(reauthenticate::get_authenticate_form()); + return self::_show_form(self::_form()); } public function auth() { @@ -31,7 +31,7 @@ class Reauthenticate_Controller extends Controller { } access::verify_csrf(); - $form = reauthenticate::get_authenticate_form(); + $form = self::_form(); $valid = $form->validate(); $user = identity::active_user(); if ($valid) { @@ -54,4 +54,20 @@ class Reauthenticate_Controller extends Controller { $view->content->user_name = identity::active_user()->name; print $view; } + + private static function _form() { + $form = new Forge("reauthenticate/auth", "", "post", array("id" => "g-reauthenticate-form")); + $form->set_attr('class', "g-narrow"); + $form->hidden("continue_url")->value(Session::instance()->get("continue_url", "admin")); + $group = $form->group("reauthenticate")->label(t("Re-authenticate")); + $group->password("password")->label(t("Password"))->id("g-password")->class(null) + ->callback("auth::validate_too_many_failed_auth_attempts") + ->callback("user::valid_password") + ->error_messages("invalid_password", t("Incorrect password")) + ->error_messages( + "too_many_failed_auth_attempts", + t("Too many incorrect passwords. Try again later")); + $group->submit("")->value(t("Submit")); + return $form; + } } diff --git a/modules/gallery/helpers/reauthenticate.php b/modules/gallery/helpers/reauthenticate.php deleted file mode 100644 index 1ad90e15..00000000 --- a/modules/gallery/helpers/reauthenticate.php +++ /dev/null @@ -1,36 +0,0 @@ - "g-reauthenticate-form")); - $form->set_attr('class', "g-narrow"); - $form->hidden("continue_url")->value(Session::instance()->get("continue_url", "admin")); - $group = $form->group("reauthenticate")->label(t("Re-authenticate")); - $group->password("password")->label(t("Password"))->id("g-password")->class(null) - ->callback("auth::validate_too_many_failed_auth_attempts") - ->callback("user::valid_password") - ->error_messages("invalid_password", t("Incorrect password")) - ->error_messages( - "too_many_failed_auth_attempts", - t("Too many incorrect passwords. Try again later")); - $group->submit("")->value(t("Submit")); - return $form; - } -} -- cgit v1.2.3 From 67223fc43d1cfd5f33d4fc007935eaadb79a112e Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 5 Jul 2010 08:59:08 -0700 Subject: Revert "Make the trailing slash on the url optional. Sometimes it is not there, so the regex doesn't match" This reverts commit e4d397d30118a3d673b146c44ed329efa08bbefe. --- modules/gallery/config/routes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gallery/config/routes.php b/modules/gallery/config/routes.php index e1ea9612..55d3cf6c 100644 --- a/modules/gallery/config/routes.php +++ b/modules/gallery/config/routes.php @@ -23,10 +23,10 @@ $config["^admin_.*"] = null; // Redirect /form/add/admin/controller and /form/edit/admin/controller to // admin/controller/form_(add|edit)/parms. provides the same as below for admin pages -$config["^form/(edit|add)/admin/(\w+)/?(.*)$"] = "admin/$2/form_$1/$3"; +$config["^form/(edit|add)/admin/(\w+)/(.*)$"] = "admin/$2/form_$1/$3"; // Redirect /form/add and /form/edit to the module/form_(add|edit)/parms. -$config["^form/(edit|add)/(\w+)/?(.*)$"] = "$2/form_$1/$3"; +$config["^form/(edit|add)/(\w+)/(.*)$"] = "$2/form_$1/$3"; // Default page is the root album $config["_default"] = "albums"; -- cgit v1.2.3 From 1d40c62f53b37445b5f62a65ce76f4b3ecfb2d4f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 5 Jul 2010 19:46:19 -0700 Subject: Updated version for RC2 --- README | 9 +++++---- modules/gallery/helpers/gallery.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README b/README index a00d18cb..67efff4b 100644 --- a/README +++ b/README @@ -9,10 +9,11 @@ interface. SECURITY (& INTENDED AUDIENCE): -This is the second release candidate of Gallery 3.0. We're putting it -out there so that we can find out if we overlooked any small things. -We expect the final version to be virtually identical. You can -install it on public websites and use it freely -- we recommend it! +This is the second (and hopefully final) release candidate of Gallery +3.0. We're putting it out there so that we can find out if we +overlooked any small things. We expect the final version to be +virtually identical. You can install it on public websites and use it +freely -- we recommend it! Note: - We've contracted a professional security audit, received their results diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 7f7db10b..d4078209 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class gallery_Core { - const VERSION = "3.0 RC1 (Santa Fe)"; + const VERSION = "3.0 RC2 (Santa Fe)"; /** * If Gallery is in maintenance mode, then force all non-admins to get routed to a "This site is -- cgit v1.2.3 From eee8c27f2666d65c03c36698a612a055e9b55d5e Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 6 Jul 2010 08:43:02 -0700 Subject: Correct the controller auth golden file from when the simple_uploader was renamed to flash_uploader --- modules/gallery/tests/controller_auth_data.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gallery/tests/controller_auth_data.txt b/modules/gallery/tests/controller_auth_data.txt index 8263f79d..f7ceed90 100644 --- a/modules/gallery/tests/controller_auth_data.txt +++ b/modules/gallery/tests/controller_auth_data.txt @@ -9,6 +9,8 @@ modules/gallery/controllers/albums.php show modules/gallery/controllers/combined.php javascript DIRTY_AUTH modules/gallery/controllers/combined.php css DIRTY_AUTH modules/gallery/controllers/file_proxy.php __call DIRTY_CSRF|DIRTY_AUTH +modules/gallery/controllers/flash_uploader.php start DIRTY_AUTH +modules/gallery/controllers/flash_uploader.php finish DIRTY_AUTH modules/gallery/controllers/login.php ajax DIRTY_AUTH modules/gallery/controllers/login.php auth_ajax DIRTY_AUTH modules/gallery/controllers/login.php html DIRTY_AUTH @@ -16,8 +18,6 @@ modules/gallery/controllers/login.php auth_html modules/gallery/controllers/logout.php index DIRTY_AUTH modules/gallery/controllers/maintenance.php index DIRTY_AUTH modules/gallery/controllers/quick.php form_edit DIRTY_CSRF -modules/gallery/controllers/simple_uploader.php start DIRTY_AUTH -modules/gallery/controllers/simple_uploader.php finish DIRTY_AUTH modules/gallery/controllers/upgrader.php index DIRTY_AUTH modules/gallery/controllers/user_profile.php show DIRTY_AUTH modules/gallery/controllers/user_profile.php contact DIRTY_AUTH -- cgit v1.2.3 From 9d66783f47636153bf3661d1d89e694dd5188c36 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 6 Jul 2010 09:48:37 -0700 Subject: Update the xss golden file --- modules/gallery/tests/xss_data.txt | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 4ead8a3f..26edaebc 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -28,11 +28,11 @@ modules/comment/views/comment.mrss.php 16 DIRTY_JS $feed- modules/comment/views/comment.mrss.php 19 DIRTY_JS $feed->next_page_uri modules/comment/views/comment.mrss.php 21 DIRTY $pub_date modules/comment/views/comment.mrss.php 22 DIRTY $pub_date -modules/comment/views/comment.mrss.php 28 DIRTY $child->item_uri -modules/comment/views/comment.mrss.php 29 DIRTY $child->pub_date -modules/comment/views/comment.mrss.php 34 DIRTY_ATTR $child->thumb_url -modules/comment/views/comment.mrss.php 35 DIRTY_ATTR $child->thumb_height -modules/comment/views/comment.mrss.php 35 DIRTY_ATTR $child->thumb_width +modules/comment/views/comment.mrss.php 28 DIRTY $comment->item_uri +modules/comment/views/comment.mrss.php 29 DIRTY $comment->pub_date +modules/comment/views/comment.mrss.php 34 DIRTY_ATTR $comment->thumb_url +modules/comment/views/comment.mrss.php 35 DIRTY_ATTR $comment->thumb_height +modules/comment/views/comment.mrss.php 35 DIRTY_ATTR $comment->thumb_width modules/comment/views/comments.html.php 28 DIRTY_ATTR $comment->id modules/comment/views/comments.html.php 31 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) modules/comment/views/user_profile_comments.html.php 5 DIRTY_ATTR $comment->id @@ -109,7 +109,7 @@ modules/gallery/views/admin_sidebar.html.php 50 DIRTY $avail modules/gallery/views/admin_sidebar.html.php 58 DIRTY $active modules/gallery/views/admin_sidebar_blocks.html.php 4 DIRTY_ATTR $ref modules/gallery/views/admin_sidebar_blocks.html.php 4 DIRTY $text -modules/gallery/views/admin_theme_options.html.php 6 DIRTY $form +modules/gallery/views/admin_theme_options.html.php 36 DIRTY $form modules/gallery/views/admin_themes.html.php 3 DIRTY_JS url::site("admin/themes/choose") modules/gallery/views/admin_themes.html.php 5 DIRTY_JS $csrf modules/gallery/views/admin_themes.html.php 22 DIRTY $themes[$site]->name @@ -120,7 +120,7 @@ modules/gallery/views/admin_themes.html.php 60 DIRTY $theme modules/gallery/views/admin_themes.html.php 62 DIRTY $themes[$admin]->description modules/gallery/views/admin_themes.html.php 76 DIRTY $info->name modules/gallery/views/admin_themes.html.php 78 DIRTY $info->description -modules/gallery/views/admin_themes_preview.html.php 7 DIRTY_ATTR $url +modules/gallery/views/admin_themes_preview.html.php 8 DIRTY_ATTR $url modules/gallery/views/error_404.html.php 14 DIRTY $login_form modules/gallery/views/error_admin.html.php 150 DIRTY $type modules/gallery/views/error_admin.html.php 150 DIRTY $code @@ -167,7 +167,7 @@ modules/gallery/views/error_admin.html.php 251 DIRTY_ATTR $env modules/gallery/views/error_admin.html.php 257 DIRTY $key modules/gallery/views/error_admin.html.php 261 DIRTY Kohana_Exception::safe_dump($value,$key) modules/gallery/views/form_uploadify.html.php 9 DIRTY_JS url::file("lib/uploadify/uploadify.swf") -modules/gallery/views/form_uploadify.html.php 10 DIRTY_JS url::site("simple_uploader/add_photo/{$album->id}") +modules/gallery/views/form_uploadify.html.php 10 DIRTY_JS url::site("flash_uploader/add_photo/{$album->id}") modules/gallery/views/form_uploadify.html.php 14 DIRTY_JS url::file("lib/uploadify/cancel.png") modules/gallery/views/form_uploadify.html.php 15 DIRTY_JS $simultaneous_upload_limit modules/gallery/views/in_place_edit.html.php 2 DIRTY form::open($action,array("method"=>"post","id"=>"g-in-place-edit-form","class"=>"g-short-form")) @@ -190,7 +190,7 @@ modules/gallery/views/l10n_client.html.php 58 DIRTY form:: modules/gallery/views/l10n_client.html.php 62 DIRTY form::textarea("l10n-edit-plural-translation-many","",' rows="2"') modules/gallery/views/l10n_client.html.php 67 DIRTY form::textarea("l10n-edit-plural-translation-other","",' rows="2"') modules/gallery/views/login_ajax.html.php 6 DIRTY_JS url::site("password/reset") -modules/gallery/views/login_ajax.html.php 37 DIRTY $form +modules/gallery/views/login_ajax.html.php 44 DIRTY $form modules/gallery/views/maintenance.html.php 46 DIRTY auth::get_login_form("login/auth_html") modules/gallery/views/menu.html.php 4 DIRTY $menu->css_id?"id='$menu->css_id'":"" modules/gallery/views/menu.html.php 4 DIRTY_ATTR $menu->css_class @@ -298,26 +298,26 @@ modules/rss/views/feed.mrss.php 16 DIRTY_JS $feed- modules/rss/views/feed.mrss.php 19 DIRTY_JS $feed->next_page_uri modules/rss/views/feed.mrss.php 21 DIRTY $pub_date modules/rss/views/feed.mrss.php 22 DIRTY $pub_date -modules/rss/views/feed.mrss.php 28 DIRTY date("D, d M Y H:i:s T",$child->created); -modules/rss/views/feed.mrss.php 35 DIRTY_ATTR $child->resize_url(true) -modules/rss/views/feed.mrss.php 37 DIRTY_ATTR $child->resize_height -modules/rss/views/feed.mrss.php 37 DIRTY_ATTR $child->resize_width -modules/rss/views/feed.mrss.php 40 DIRTY_ATTR $child->thumb_url(true) -modules/rss/views/feed.mrss.php 42 DIRTY_ATTR $child->thumb_height -modules/rss/views/feed.mrss.php 42 DIRTY_ATTR $child->thumb_width -modules/rss/views/feed.mrss.php 48 DIRTY_ATTR $child->thumb_url(true) -modules/rss/views/feed.mrss.php 49 DIRTY_ATTR $child->thumb_height -modules/rss/views/feed.mrss.php 50 DIRTY_ATTR $child->thumb_width -modules/rss/views/feed.mrss.php 57 DIRTY_ATTR $child->resize_url(true) -modules/rss/views/feed.mrss.php 58 DIRTY_ATTR @filesize($child->resize_path()) -modules/rss/views/feed.mrss.php 59 DIRTY_ATTR $child->mime_type -modules/rss/views/feed.mrss.php 60 DIRTY_ATTR $child->resize_height -modules/rss/views/feed.mrss.php 61 DIRTY_ATTR $child->resize_width -modules/rss/views/feed.mrss.php 65 DIRTY_ATTR $child->file_url(true) -modules/rss/views/feed.mrss.php 66 DIRTY_ATTR @filesize($child->file_path()) -modules/rss/views/feed.mrss.php 67 DIRTY_ATTR $child->mime_type -modules/rss/views/feed.mrss.php 68 DIRTY_ATTR $child->height -modules/rss/views/feed.mrss.php 69 DIRTY_ATTR $child->width +modules/rss/views/feed.mrss.php 28 DIRTY date("D, d M Y H:i:s T",$item->created); +modules/rss/views/feed.mrss.php 35 DIRTY_ATTR $item->resize_url(true) +modules/rss/views/feed.mrss.php 37 DIRTY_ATTR $item->resize_height +modules/rss/views/feed.mrss.php 37 DIRTY_ATTR $item->resize_width +modules/rss/views/feed.mrss.php 40 DIRTY_ATTR $item->thumb_url(true) +modules/rss/views/feed.mrss.php 42 DIRTY_ATTR $item->thumb_height +modules/rss/views/feed.mrss.php 42 DIRTY_ATTR $item->thumb_width +modules/rss/views/feed.mrss.php 48 DIRTY_ATTR $item->thumb_url(true) +modules/rss/views/feed.mrss.php 49 DIRTY_ATTR $item->thumb_height +modules/rss/views/feed.mrss.php 50 DIRTY_ATTR $item->thumb_width +modules/rss/views/feed.mrss.php 57 DIRTY_ATTR $item->resize_url(true) +modules/rss/views/feed.mrss.php 58 DIRTY_ATTR @filesize($item->resize_path()) +modules/rss/views/feed.mrss.php 59 DIRTY_ATTR $item->mime_type +modules/rss/views/feed.mrss.php 60 DIRTY_ATTR $item->resize_height +modules/rss/views/feed.mrss.php 61 DIRTY_ATTR $item->resize_width +modules/rss/views/feed.mrss.php 65 DIRTY_ATTR $item->file_url(true) +modules/rss/views/feed.mrss.php 66 DIRTY_ATTR @filesize($item->file_path()) +modules/rss/views/feed.mrss.php 67 DIRTY_ATTR $item->mime_type +modules/rss/views/feed.mrss.php 68 DIRTY_ATTR $item->height +modules/rss/views/feed.mrss.php 69 DIRTY_ATTR $item->width modules/rss/views/rss_block.html.php 6 DIRTY_JS rss::url($url) modules/search/views/search.html.php 27 DIRTY_ATTR $item_class modules/search/views/search.html.php 28 DIRTY_JS $item->url() @@ -406,9 +406,9 @@ themes/wind/views/page.html.php 81 DIRTY $heade themes/wind/views/page.html.php 83 DIRTY_JS item::root()->url() themes/wind/views/page.html.php 87 DIRTY $theme->user_menu() themes/wind/views/page.html.php 108 DIRTY_JS $parent->url($parent==$theme->item()->parent()?"show={$theme->item()->id}":null) -themes/wind/views/page.html.php 124 DIRTY $content -themes/wind/views/page.html.php 130 DIRTY newView("sidebar.html") -themes/wind/views/page.html.php 137 DIRTY $footer_text +themes/wind/views/page.html.php 126 DIRTY $content +themes/wind/views/page.html.php 132 DIRTY newView("sidebar.html") +themes/wind/views/page.html.php 139 DIRTY $footer_text themes/wind/views/paginator.html.php 33 DIRTY_JS $first_page_url themes/wind/views/paginator.html.php 42 DIRTY_JS $previous_page_url themes/wind/views/paginator.html.php 70 DIRTY_JS $next_page_url -- cgit v1.2.3