summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/comment/helpers/comment.php2
-rw-r--r--modules/comment/helpers/comment_rss.php51
-rw-r--r--modules/comment/models/comment.php10
-rw-r--r--modules/comment/tests/Comment_Model_Test.php40
-rw-r--r--modules/gallery/controllers/l10n_client.php13
-rw-r--r--modules/gallery/css/l10n_client.css12
-rw-r--r--modules/gallery/helpers/album.php21
-rw-r--r--modules/gallery/helpers/gallery.php65
-rw-r--r--modules/gallery/helpers/item.php37
-rw-r--r--modules/gallery/js/l10n_client.js7
-rw-r--r--modules/gallery/models/item.php34
-rw-r--r--modules/gallery/tests/Item_Helper_Test.php49
-rw-r--r--modules/gallery/tests/Item_Model_Test.php14
-rw-r--r--modules/gallery/views/admin_languages.html.php80
-rw-r--r--modules/gallery/views/l10n_client.html.php5
-rw-r--r--modules/notification/helpers/notification_event.php7
-rw-r--r--modules/organize/controllers/organize.php292
-rw-r--r--modules/organize/css/organize.css76
-rw-r--r--modules/organize/js/organize.js128
-rw-r--r--modules/organize/views/organize_dialog.html.php28
-rw-r--r--modules/organize/views/organize_thumb_grid.html.php6
-rw-r--r--modules/organize/views/organize_tree.html.php53
-rw-r--r--modules/server_add/helpers/server_add_event.php29
-rw-r--r--modules/user/helpers/user.php7
-rw-r--r--themes/admin_default/css/admin_screen.css12
25 files changed, 541 insertions, 537 deletions
diff --git a/modules/comment/helpers/comment.php b/modules/comment/helpers/comment.php
index 3d743325..f74a8644 100644
--- a/modules/comment/helpers/comment.php
+++ b/modules/comment/helpers/comment.php
@@ -35,7 +35,7 @@ class comment_Core {
* @return Comment_Model
*/
static function create($item, $author, $text, $guest_name=null,
- $guest_email=ull, $guest_url=null) {
+ $guest_email=null, $guest_url=null) {
$comment = ORM::factory("comment");
$comment->author_id = $author->id;
$comment->guest_email = $guest_email;
diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php
index ab3d2283..e233de59 100644
--- a/modules/comment/helpers/comment_rss.php
+++ b/modules/comment/helpers/comment_rss.php
@@ -34,41 +34,36 @@ class comment_rss_Core {
}
$comments = ORM::factory("comment")
- ->where("state", "published")
- ->orderby("created", "DESC");
- $all_comments = ORM::factory("comment")
+ ->viewable()
->where("state", "published")
->orderby("created", "DESC");
if ($feed_id == "item") {
$comments->where("item_id", $id);
- $all_comments->where("item_id", $id);
}
- if (!empty($comments)) {
- $feed->view = "comment.mrss";
- $comments = $comments->find_all($limit, $offset);
- $feed->children = array();
- foreach ($comments as $comment) {
- $item = $comment->item();
- $feed->children[] = new ArrayObject(
- array("pub_date" => date("D, d M Y H:i:s T", $comment->created),
- "text" => nl2br(p::purify($comment->text)),
- "thumb_url" => $item->thumb_url(),
- "thumb_height" => $item->thumb_height,
- "thumb_width" => $item->thumb_width,
- "item_uri" => url::abs_site("{$item->type}s/$item->id"),
- "title" => p::purify($item->title),
- "author" => p::clean($comment->author_name())),
- ArrayObject::ARRAY_AS_PROPS);
- }
+ $comments = $comments->find_all($limit, $offset);
+ $feed->view = "comment.mrss";
+ $feed->children = array();
+ foreach ($comments as $comment) {
+ $item = $comment->item();
+ $feed->children[] = new ArrayObject(
+ array("pub_date" => date("D, d M Y H:i:s T", $comment->created),
+ "text" => nl2br(p::purify($comment->text)),
+ "thumb_url" => $item->thumb_url(),
+ "thumb_height" => $item->thumb_height,
+ "thumb_width" => $item->thumb_width,
+ "item_uri" => url::abs_site("{$item->type}s/$item->id"),
+ "title" => p::purify($item->title),
+ "author" => p::clean($comment->author_name())),
+ ArrayObject::ARRAY_AS_PROPS);
+ }
- $feed->max_pages = ceil($all_comments->find_all()->count() / $limit);
- $feed->title = htmlspecialchars(t("Recent Comments"));
- $feed->uri = url::abs_site("albums/" . (empty($id) ? "1" : $id));
- $feed->description = t("Recent Comments");
+ $feed->max_pages = ceil($comments->count_all() / $limit);
+ $feed->title = htmlspecialchars(t("Recent Comments"));
+ $feed->uri = url::abs_site("albums/" . (empty($id) ? "1" : $id));
+ $feed->description = t("Recent Comments");
- return $feed;
- }
+ return $feed;
}
-} \ No newline at end of file
+}
diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php
index 83d0888a..de9b0cd6 100644
--- a/modules/comment/models/comment.php
+++ b/modules/comment/models/comment.php
@@ -80,4 +80,14 @@ class Comment_Model extends ORM {
return $this;
}
+
+ /**
+ * Add a set of restrictions to any following queries to restrict access only to items
+ * viewable by the active user.
+ * @chainable
+ */
+ public function viewable() {
+ $this->join("items", "items.id", "comments.item_id");
+ return item::viewable($this);
+ }
}
diff --git a/modules/comment/tests/Comment_Model_Test.php b/modules/comment/tests/Comment_Model_Test.php
new file mode 100644
index 00000000..f4c68b15
--- /dev/null
+++ b/modules/comment/tests/Comment_Model_Test.php
@@ -0,0 +1,40 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Comment_Model_Test extends Unit_Test_Case {
+
+ public function cant_view_comments_for_unviewable_items_test() {
+ $root = ORM::factory("item", 1);
+ $album = album::create($root, rand(), rand(), rand());
+ $comment = comment::create($album, user::guest(), "text", "name", "email", "url");
+ user::set_active(user::guest());
+
+ // We can see the comment when permissions are granted on the album
+ access::allow(group::everybody(), "view", $album);
+ $this->assert_equal(
+ 1,
+ ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
+
+ // We can't see the comment when permissions are denied on the album
+ access::deny(group::everybody(), "view", $album);
+ $this->assert_equal(
+ 0,
+ ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
+ }
+}
diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php
index 831c79c1..0775791e 100644
--- a/modules/gallery/controllers/l10n_client.php
+++ b/modules/gallery/controllers/l10n_client.php
@@ -90,10 +90,15 @@ class L10n_Client_Controller extends Controller {
}
$session = Session::instance();
- $session->set("l10n_mode",
- !$session->get("l10n_mode", false));
-
- url::redirect("albums/1");
+ $l10n_mode = $session->get("l10n_mode", false);
+ $session->set("l10n_mode", !$l10n_mode);
+
+ $redirect_url = "admin/languages";
+ if (!$l10n_mode) {
+ $redirect_url .= "#l10n-client";
+ }
+
+ url::redirect($redirect_url);
}
private static function _l10n_client_search_form() {
diff --git a/modules/gallery/css/l10n_client.css b/modules/gallery/css/l10n_client.css
index 51cbc753..9c1b12d0 100644
--- a/modules/gallery/css/l10n_client.css
+++ b/modules/gallery/css/l10n_client.css
@@ -42,9 +42,17 @@
cursor:pointer;
display:block;
position:absolute; right:0em;
- padding: 0em .75em; height:2em; line-height:2em;
+ height:2em; line-height:2em;
text-transform:uppercase;
- text-align:center; background:#000;}
+ text-align:center; background:#000;
+}
+#l10n-client-toggler a {
+ font-size: 1em;
+ padding: .5em;
+}
+#l10n-client-toggler #gMinimizeL10n {
+ border-right: 1px solid #ffffff;
+}
/* Panel labels */
#l10n-client h2 {
diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php
index 1b6b875d..d46f21ac 100644
--- a/modules/gallery/helpers/album.php
+++ b/modules/gallery/helpers/album.php
@@ -116,13 +116,7 @@ class album_Core {
$sort_order->dropdown("column", array("id" => "gAlbumSortColumn"))
->label(t("Sort by"))
- ->options(array("weight" => t("Manual"),
- "captured" => t("Date captured"),
- "created" => t("Date uploaded"),
- "title" => t("Title"),
- "updated" => t("Date modified"),
- "view_count" => t("Number of views"),
- "rand_key" => t("Random")))
+ ->options(album::get_sort_order_options())
->selected($parent->sort_column);
$sort_order->dropdown("direction", array("id" => "gAlbumSortDirection"))
->label(t("Order"))
@@ -137,4 +131,17 @@ class album_Core {
$form->add_rules_from(ORM::factory("item"));
return $form;
}
+
+ /**
+ * Return a structured set of all the possible sort orders.
+ */
+ static function get_sort_order_options() {
+ return array("weight" => t("Manual"),
+ "captured" => t("Date captured"),
+ "created" => t("Date uploaded"),
+ "title" => t("Title"),
+ "updated" => t("Date modified"),
+ "view_count" => t("Number of views"),
+ "rand_key" => t("Random"));
+ }
}
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index c81af842..122227fc 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -82,9 +82,9 @@ class gallery_Core {
static function site_menu($menu, $theme) {
if ($theme->page_type != "login") {
$menu->append(Menu::factory("link")
- ->id("home")
- ->label(t("Home"))
- ->url(url::site("albums/1")));
+ ->id("home")
+ ->label(t("Home"))
+ ->url(url::site("albums/1")));
$item = $theme->item();
@@ -92,48 +92,47 @@ class gallery_Core {
$can_add = $item && access::can("add", $item);
if ($can_add) {
- $menu->append(Menu::factory("dialog")
- ->id("add_photos_item")
- ->label(t("Add photos"))
- ->url(url::site("simple_uploader/app/$item->id")));
+ $menu->append($add_menu = Menu::factory("submenu")
+ ->id("add_menu")
+ ->label(t("Add")));
+ $add_menu->append(Menu::factory("dialog")
+ ->id("add_photos_item")
+ ->label(t("Add photos"))
+ ->url(url::site("simple_uploader/app/$item->id")));
+ if ($item->is_album()) {
+ $add_menu->append(Menu::factory("dialog")
+ ->id("add_album_item")
+ ->label(t("Add an album"))
+ ->url(url::site("form/add/albums/$item->id?type=album")));
+ }
}
$menu->append($options_menu = Menu::factory("submenu")
- ->id("options_menu")
- ->label(t("Options")));
+ ->id("options_menu")
+ ->label(t("Photo options")));
if ($item && ($can_edit || $can_add)) {
if ($can_edit) {
- $options_menu
- ->append(Menu::factory("dialog")
- ->id("edit_item")
- ->label($item->is_album() ? t("Edit album") : t("Edit photo"))
- ->url(url::site("form/edit/{$item->type}s/$item->id")));
+ $options_menu->append(Menu::factory("dialog")
+ ->id("edit_item")
+ ->label($item->is_album() ? t("Edit album") : t("Edit photo"))
+ ->url(url::site("form/edit/{$item->type}s/$item->id")));
}
- // @todo Move album options menu to the album quick edit pane
if ($item->is_album()) {
- if ($can_add) {
- $options_menu
- ->append(Menu::factory("dialog")
- ->id("add_album")
- ->label(t("Add an album"))
- ->url(url::site("form/add/albums/$item->id?type=album")));
- }
-
+ $options_menu->label(t("Album options"));
if ($can_edit) {
- $options_menu
- ->append(Menu::factory("dialog")
- ->id("edit_permissions")
- ->label(t("Edit permissions"))
- ->url(url::site("permissions/browse/$item->id")));
+ $options_menu->append(Menu::factory("dialog")
+ ->id("edit_permissions")
+ ->label(t("Edit permissions"))
+ ->url(url::site("permissions/browse/$item->id")));
}
}
}
if (user::active()->admin) {
$menu->append($admin_menu = Menu::factory("submenu")
- ->id("admin_menu")
- ->label(t("Admin")));
+ ->id("admin_menu")
+ ->label(t("Admin")));
gallery::admin_menu($admin_menu, $theme);
module::event("admin_menu", $admin_menu, $theme);
}
@@ -160,12 +159,6 @@ class gallery_Core {
->label(t("Languages"))
->url(url::site("admin/languages")))
->append(Menu::factory("link")
- ->id("l10n_mode")
- ->label(Session::instance()->get("l10n_mode", false)
- ? t("Stop translating") : t("Start translating"))
- ->url(url::site("l10n_client/toggle_l10n_mode?csrf=" .
- access::csrf_token())))
- ->append(Menu::factory("link")
->id("advanced")
->label(t("Advanced"))
->url(url::site("admin/advanced_settings"))))
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index a2d3859f..8839861f 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -151,4 +151,41 @@ class item_Core {
->get()->current();
return ($result ? $result->weight : 0) + 1;
}
+
+ /**
+ * Add a set of restrictions to any following queries to restrict access only to items
+ * viewable by the active user.
+ * @chainable
+ */
+ static function viewable($model) {
+ $view_restrictions = array();
+ if (!user::active()->admin) {
+ foreach (user::group_ids() as $id) {
+ // Separate the first restriction from the rest to make it easier for us to formulate
+ // our where clause below
+ if (empty($view_restrictions)) {
+ $view_restrictions[0] = "items.view_$id";
+ } else {
+ $view_restrictions[1]["items.view_$id"] = access::ALLOW;
+ }
+ }
+ }
+ switch (count($view_restrictions)) {
+ case 0:
+ break;
+
+ case 1:
+ $model->where($view_restrictions[0], access::ALLOW);
+ break;
+
+ default:
+ $model->open_paren();
+ $model->where($view_restrictions[0], access::ALLOW);
+ $model->orwhere($view_restrictions[1]);
+ $model->close_paren();
+ break;
+ }
+
+ return $model;
+ }
} \ No newline at end of file
diff --git a/modules/gallery/js/l10n_client.js b/modules/gallery/js/l10n_client.js
index f5be5058..80fe166b 100644
--- a/modules/gallery/js/l10n_client.js
+++ b/modules/gallery/js/l10n_client.js
@@ -58,7 +58,8 @@ jQuery.extend(Gallery, {
case 1:
$('#l10n-client-string-select, #l10n-client-string-editor, #l10n-client .labels .label').show();
$('#l10n-client').height('22em').removeClass('hidden');
- $('#l10n-client-toggler').text(MSG_CLOSE_X);
+ //$('#l10n-client').slideUp();
+ $('#gMinimizeL10n').text("_");
/*
* This CSS clashes with Gallery's CSS, probably due to
* YUI's grid / floats.
@@ -72,7 +73,7 @@ jQuery.extend(Gallery, {
$('#l10n-client-string-select, #l10n-client-string-editor, #l10n-client .labels .label').hide();
$('#l10n-client').height('2em').addClass('hidden');
// TODO: Localize this message
- $('#l10n-client-toggler').text(MSG_TRANSLATE_TEXT);
+ $('#gMinimizeL10n').text(MSG_TRANSLATE_TEXT);
/*
if(!$.browser.msie) {
$('body').css('border-bottom', '0px');
@@ -197,7 +198,7 @@ Gallery.behaviors.l10nClient = function(context) {
});
// When l10n_client window is clicked, toggle based on current state.
- $('#l10n-client-toggler').click(function() {
+ $('#gMinimizeL10n').click(function() {
if($('#l10n-client').is('.hidden')) {
Gallery.l10nClient.toggle(1);
} else {
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 7a3a2ba7..68e89db6 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -19,7 +19,6 @@
*/
class Item_Model extends ORM_MPTT {
protected $children = 'items';
- private $view_restrictions = null;
protected $sorting = array();
var $rules = array(
@@ -34,38 +33,7 @@ class Item_Model extends ORM_MPTT {
* @chainable
*/
public function viewable() {
- if (is_null($this->view_restrictions)) {
- if (user::active()->admin) {
- $this->view_restrictions = array();
- } else {
- foreach (user::group_ids() as $id) {
- // Separate the first restriction from the rest to make it easier for us to formulate
- // our where clause below
- if (empty($this->view_restrictions)) {
- $this->view_restrictions[0] = "view_$id";
- } else {
- $this->view_restrictions[1]["view_$id"] = access::ALLOW;
- }
- }
- }
- }
- switch (count($this->view_restrictions)) {
- case 0:
- break;
-
- case 1:
- $this->where($this->view_restrictions[0], access::ALLOW);
- break;
-
- default:
- $this->open_paren();
- $this->where($this->view_restrictions[0], access::ALLOW);
- $this->orwhere($this->view_restrictions[1]);
- $this->close_paren();
- break;
- }
-
- return $this;
+ return item::viewable($this);
}
/**
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
new file mode 100644
index 00000000..3f80733f
--- /dev/null
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -0,0 +1,49 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Item_Helper_Test extends Unit_Test_Case {
+
+ public function viewable_test() {
+ $root = ORM::factory("item", 1);
+ $album = album::create($root, rand(), rand(), rand());
+ $item = self::_create_random_item($album);
+ user::set_active(user::guest());
+
+ // We can see the item when permissions are granted
+ access::allow(group::everybody(), "view", $album);
+ $this->assert_equal(
+ 1,
+ ORM::factory("item")->viewable()->where("id", $item->id)->count_all());
+
+ // We can't see the item when permissions are denied
+ access::deny(group::everybody(), "view", $album);
+ $this->assert_equal(
+ 0,
+ ORM::factory("item")->viewable()->where("id", $item->id)->count_all());
+ }
+
+
+ private static function _create_random_item($album) {
+ // Set all required fields (values are irrelevant)
+ $item = ORM::factory("item");
+ $item->name = rand();
+ $item->type = "photo";
+ return $item->add_to_parent($album);
+ }
+}
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index 0940d076..585e247c 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -19,12 +19,12 @@
*/
class Item_Model_Test extends Unit_Test_Case {
public function saving_sets_created_and_updated_dates_test() {
- $item = self::create_random_item();
+ $item = self::_create_random_item();
$this->assert_true(!empty($item->created));
$this->assert_true(!empty($item->updated));
}
- private function create_random_item() {
+ private static function _create_random_item() {
$item = ORM::factory("item");
/* Set all required fields (values are irrelevant) */
$item->name = rand();
@@ -33,7 +33,7 @@ class Item_Model_Test extends Unit_Test_Case {
}
public function updating_doesnt_change_created_date_test() {
- $item = self::create_random_item();
+ $item = self::_create_random_item();
// Force the creation date to something well known
$db = Database::instance();
@@ -47,7 +47,7 @@ class Item_Model_Test extends Unit_Test_Case {
}
public function updating_view_count_only_doesnt_change_updated_date_test() {
- $item = self::create_random_item();
+ $item = self::_create_random_item();
$item->reload();
$this->assert_same(0, $item->view_count);
@@ -64,7 +64,7 @@ class Item_Model_Test extends Unit_Test_Case {
public function move_photo_test() {
// Create a test photo
- $item = self::create_random_item();
+ $item = self::_create_random_item();
file_put_contents($item->thumb_path(), "thumb");
file_put_contents($item->resize_path(), "resize");
@@ -128,7 +128,7 @@ class Item_Model_Test extends Unit_Test_Case {
public function item_rename_wont_accept_slash_test() {
// Create a test photo
- $item = self::create_random_item();
+ $item = self::_create_random_item();
$new_name = rand() . "/";
@@ -142,7 +142,7 @@ class Item_Model_Test extends Unit_Test_Case {
}
public function save_original_values_test() {
- $item = $this->create_random_item();
+ $item = self::_create_random_item();
$item->title = "ORIGINAL_VALUE";
$item->save();
$item->title = "NEW_VALUE";
diff --git a/modules/gallery/views/admin_languages.html.php b/modules/gallery/views/admin_languages.html.php
index fc3a87dc..4025437a 100644
--- a/modules/gallery/views/admin_languages.html.php
+++ b/modules/gallery/views/admin_languages.html.php
@@ -2,7 +2,7 @@
<div id="gLanguages">
<h1> <?= t("Languages") ?> </h1>
<p>
- <?= t("Here you can install new languages, update installed ones and set the default language for your Gallery.") ?>
+ <?= t("Install new languages, update installed ones and set the default language for your Gallery.") ?>
</p>
<form id="gLanguagesForm" method="post" action="<?= url::site("admin/languages/save") ?>">
@@ -40,31 +40,61 @@
</form>
<script type="text/javascript">
- var old_default_locale = "<?= $default_locale ?>";
-
- $("input[name='installed_locales[]']").change(function (event) {
- if (this.checked) {
- $("input[type='radio'][value='" + this.value + "']").enable();
- } else {
- if ($("input[type='radio'][value='" + this.value + "']").selected()) { // if you deselect your default language, switch to some other installed language
- $("input[type='radio'][value='" + old_default_locale + "']").attr("checked", "checked");
- }
- $("input[type='radio'][value='" + this.value + "']").attr("disabled", "disabled");
- }
- });
-
+ var old_default_locale = "<?= $default_locale ?>";
+
+ $("input[name='installed_locales[]']").change(function (event) {
+ if (this.checked) {
+ $("input[type='radio'][value='" + this.value + "']").enable();
+ } else {
+ if ($("input[type='radio'][value='" + this.value + "']").selected()) { // if you deselect your default language, switch to some other installed language
+ $("input[type='radio'][value='" + old_default_locale + "']").attr("checked", "checked");
+ }
+ $("input[type='radio'][value='" + this.value + "']").attr("disabled", "disabled");
+ }
+ });
+
$("#gLanguagesForm").ajaxForm({
- dataType: "json",
- success: function(data) {
- if (data.result == "success") {
- el = $('<a href="<?= url::site("admin/maintenance/start/gallery_task::update_l10n?csrf=$csrf") ?>"></a>'); // this is a little hack to trigger the update_l10n task in a dialog
- el.gallery_dialog();
- el.trigger('click');
- }
- }
- });
- </script>
+ dataType: "json",
+ success: function(data) {
+ if (data.result == "success") {
+ el = $('<a href="<?= url::site("admin/maintenance/start/gallery_task::update_l10n?csrf=$csrf") ?>"></a>'); // this is a little hack to trigger the update_l10n task in a dialog
+ el.gallery_dialog();
+ el.trigger('click');
+ }
+ }
+ });
+ </script>
+</div>
- <h2> <?= t("Your Own Translations") ?> </h2>
+<div id="gTranslations">
+ <h1> <?= t("Translations") ?> </h1>
+ <p>
+ <?= t("Create your own translations and share them with the rest of the Gallery community.") ?>
+ </p>
+
+ <h3><?= t("Translating Gallery") ?></h3>
+
+ <div class="gBlock">
+ <a href="http://codex.gallery2.org/Gallery3:Localization" target="_blank"
+ class="gDocLink ui-state-default ui-corner-all ui-icon ui-icon-help"
+ title="<?= t("Localization documentation") ?>">
+ <?= t("Localization documentation") ?>
+ </a>
+
+ <p><strong><?= t("Step 1") ?>:</strong> <?= t("Make sure the target language is installed and updated (check above).") ?></p>
+
+ <p><strong><?= t("Step 2") ?>:</strong> <?= t("Make sure the target language is the active one (currently '").locales::display_name()."')." ?></p>
+
+ <p><strong><?= t("Step 3") ?>:</strong> <?= t("Start the translation mode and the translation interface will appear at the bottom of each Gallery page.") ?></p>
+
+ <a href="<?= url::site("l10n_client/toggle_l10n_mode?csrf=".access::csrf_token()) ?>"
+ class="gButtonLink ui-state-default ui-corner-all ui-icon-left">
+ <span class="ui-icon ui-icon-power"></span>
+ <?= t((Session::instance()->get("l10n_mode", false)) ? "Stop translation mode" : "Start translation mode") ?>
+ </a>
+ </div>
+
+ <h3>Sharing your translations</h3>
+
<?= $share_translations_form ?>
</div>
diff --git a/modules/gallery/views/l10n_client.html.php b/modules/gallery/views/l10n_client.html.php
index c73719ca..5ee7eca3 100644
--- a/modules/gallery/views/l10n_client.html.php
+++ b/modules/gallery/views/l10n_client.html.php
@@ -1,7 +1,10 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="l10n-client" class="hidden">
<div class="labels">
- <span id="l10n-client-toggler">X</span>
+ <span id="l10n-client-toggler">
+ <a id="gMinimizeL10n">_</a>
+ <a id="gCloseL10n" href="<?= url::site("l10n_client/toggle_l10n_mode?csrf=".access::csrf_token()) ?>">X</a>
+ </span>
<div class="label strings"><h2><?= t("Page Text") ?>
<? if (!Input::instance()->get('show_all_l10n_messages')): ?>
<a style="background-color:#fff" href="<?= url::site("admin/languages?show_all_l10n_messages=1") ?>"><?= t("(Show All)") ?></a>
diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php
index 8fbeda92..c50b04c4 100644
--- a/modules/notification/helpers/notification_event.php
+++ b/modules/notification/helpers/notification_event.php
@@ -26,6 +26,7 @@ class notification_event_Core {
notification::send_item_updated($new);
} catch (Exception $e) {
Kohana::log("error", "@todo notification_event::item_updated() failed");
+ Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString());
}
}
@@ -34,6 +35,7 @@ class notification_event_Core {
notification::send_item_add($item);
} catch (Exception $e) {
Kohana::log("error", "@todo notification_event::item_created() failed");
+ Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString());
}
}
@@ -46,6 +48,7 @@ class notification_event_Core {
}
} catch (Exception $e) {
Kohana::log("error", "@todo notification_event::item_deleted() failed");
+ Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString());
}
}
@@ -56,6 +59,7 @@ class notification_event_Core {
}
} catch (Exception $e) {
Kohana::log("error", "@todo notification_event::comment_created() failed");
+ Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString());
}
}
@@ -66,6 +70,7 @@ class notification_event_Core {
}
} catch (Exception $e) {
Kohana::log("error", "@todo notification_event::comment_updated() failed");
+ Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString());
}
}
@@ -76,6 +81,7 @@ class notification_event_Core {
->delete_all();
} catch (Exception $e) {
Kohana::log("error", "@todo notification_event::user_before_delete() failed");
+ Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString());
}
}
@@ -84,6 +90,7 @@ class notification_event_Core {
notification::send_pending_notifications();
} catch (Exception $e) {
Kohana::log("error", "@todo notification_event::batch_complete() failed");
+ Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString());
}
}
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php
index f56ad006..2b966657 100644
--- a/modules/organize/controllers/organize.php
+++ b/modules/organize/controllers/organize.php
@@ -18,235 +18,131 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Organize_Controller extends Controller {
- function dialog($item_id) {
- $item = ORM::factory("item", $item_id);
- $root = $item->id == 1 ? $item : ORM::factory("item", 1);
- access::required("view", $item);
- access::required("edit", $item);
+ function dialog($album_id) {
+ $album = ORM::factory("item", $album_id);
+ access::required("view", $album);
+ access::required("edit", $album);
$v = new View("organize_dialog.html");
- $v->title = $item->title;
- $parents = array();
- foreach ($item->parents() as $parent) {
- $parents[$parent->id] = 1;
- }
- $parents[$item->id] = 1;
-
- $v->album_tree = self::_tree($root, $parents);
- $v->micro_thumb_grid = self::_get_micro_thumb_grid($item, 0);
+ $v->album = $album;
+ $v->album_tree = self::_tree($album);
+ $v->micro_thumb_grid = self::_get_micro_thumb_grid($album, 0);
print $v;
}
- function content($item_id, $offset) {
- $item = ORM::factory("item", $item_id);
- access::required("view", $item);
- access::required("edit", $item);
- print self::_get_micro_thumb_grid($item, $offset);
+ function album($album_id, $offset) {
+ $album = ORM::factory("item", $album_id);
+ access::required("view", $album);
+ access::required("edit", $album);
+
+ print json_encode(
+ array("grid" => self::_get_micro_thumb_grid($album, $offset)->__toString(),
+ "sort_column" => $album->sort_column,
+ "sort_order" => $album->sort_order));
}
- function move($target_id) {
+ function move_to($album_id) {
access::verify_csrf();
- $task_def = Task_Definition::factory()
- ->callback("Organize_Controller::move_task_handler")
- ->description(t("Move images"))
- ->name(t("Move Images"));
- $task = task::create($task_def, array("target_id" => $target_id,
- "source_ids" => $this->input->post("source_ids")));
+ $album = ORM::factory("item", $album_id);
+ foreach ($this->input->post("source_ids") as $source_id) {
+ item::move(ORM::factory("item", $source_id), $album);
+ }
print json_encode(
- array("result" => "started",
- "status" => $task->status,
- "url" => url::site("organize/run/$task->id?csrf=" . access::csrf_token())));
+ array("tree" => self::_tree($album)->__toString(),
+ "grid" => self::_get_micro_thumb_grid($album, 0)->__toString()));
}
function rearrange($target_id, $before_or_after) {
access::verify_csrf();
- $target = ORM::factory("item", $target_id);
- $parent = $target->parent();
- access::required("view", $parent);
- access::required("edit", $parent);
-
- $task_def = Task_Definition::factory()
- ->callback("Organize_Controller::rearrange_task_handler")
- ->description(t("Rearrange Image"))
- ->name(t("Rearrange Images"));
- $task = task::create(
- $task_def,
- array("target_id" => $target_id,
- "before_or_after" => $before_or_after,
- "parent_id" => $parent->id,
- "source_ids" => $this->input->post("source_ids")));
- print json_encode(
- array("result" => "started",
- "status" => $task->status,
- "url" => url::site("organize/run/$task->id?csrf=" . access::csrf_token())));
- }
-
- private static function _get_micro_thumb_grid($item, $offset) {
- $v = new View("organize_thumb_grid.html");
- $v->item = $item;
- $v->offset = $offset;
- return $v;
- }
-
- /**
- * Run the task
- */
- function run($task_id) {
- access::verify_csrf();
+ $target = ORM::factory("item", $target_id);
+ $album = $target->parent();
+ access::required("view", $album);
+ access::required("edit", $album);
- $task = ORM::factory("task", $task_id);
- if (!$task->loaded || $task->owner_id != user::active()->id) {
- access::forbidden();
- }
+ $source_ids = $this->input->post("source_ids", array());
- $task = task::run($task_id);
- $results = array("done" => $task->done, "status" => $task->status,
- "percent_complete" => $task->percent_complete);
- foreach (array("tree", "content") as $data) {
- $value = $task->get($data, false);
- if ($value !== false) {
- $results[$data] = $value;
+ if ($album->sort_column != "weight") {
+ $i = 0;
+ foreach ($album->children() as $child) {
+ // Do this directly in the database to avoid sending notifications
+ Database::Instance()->update("items", array("weight" => ++$i), array("id" => $child->id));
}
+ $album->sort_column = "weight";
+ $album->sort_order = "ASC";
+ $album->save();
+ $target->reload();
}
- print json_encode($results);
- }
- private static function _tree($item, $parents) {
- $v = new View("organize_tree.html");
- $v->album = $item;
- $keys = array_keys($parents);
- $v->selected = end($keys) == $item->id;
- $v->can_edit= access::can("edit", $item);
- $v->children = array();
- $v->album_icon = "gBranchEmpty";
-
- $albums = $item->children(null, 0, array("type" => "album"), array("title" => "ASC"));
- foreach ($albums as $album) {
- if (access::can("view", $album)) {
- $v->children[] = self::_tree($album, $parents);
- }
+ // Find the insertion point
+ $target_weight = $target->weight;
+ if ($before_or_after == "after") {
+ $target_weight++;
}
- if (count($v->children)) {
- $v->album_icon = empty($parents[$item->id]) ? "ui-icon-plus" : "ui-icon-minus";
+
+ // Make a hole
+ $count = count($source_ids);
+ Database::Instance()->query(
+ "UPDATE {items} " .
+ "SET `weight` = `weight` + $count " .
+ "WHERE `weight` >= $target_weight AND `parent_id` = {$album->id}");
+
+ // Insert source items into the hole
+ foreach ($source_ids as $source_id) {
+ Database::Instance()->update(
+ "items", array("weight" => $target_weight++), array("id" => $source_id));
}
- return $v;
+
+ module::event("album_rearrange", $album);
+
+ print json_encode(
+ array("grid" => self::_get_micro_thumb_grid($album, 0)->__toString(),
+ "sort_column" => $album->sort_column,
+ "sort_order" => $album->sort_order));
}
- static function move_task_handler($task) {
- $start = microtime(true);
- if ($task->percent_complete == 0) {
- batch::start();
- }
+ function sort_order($album_id, $col, $dir) {
+ access::verify_csrf();
- $target = ORM::factory("item", $task->get("target_id"));
- $source_ids = $task->get("source_ids", array());
- $idx = $task->get("current", 0);
- $count = 0;
- for (; $idx < count($source_ids) && microtime(true) - $start < 0.5; $idx++) {
- item::move(ORM::factory("item", $source_ids[$idx]), $target);
- $count++;
- }
- $task->set("current", $idx);
- $task->percent_complete = (int)($idx / count($source_ids) * 100);
- $task->status = t2("Moved one file", "Moved %count files", $count);
- if ($task->percent_complete == 100) {
- batch::stop();
- $task->done = true;
- $task->state = "success";
- $parents = array();
- foreach ($target->parents() as $parent) {
- $parents[$parent->id] = 1;
- }
- $parents[$target->id] = 1;
- // @TODO do we want to set a flag and then generate them in the run method so we don't
- // potentially store large data items in the task?
- $task->set("tree", self::_tree(ORM::factory("item", 1), $parents)->__toString());
- $task->set("content", self::_get_micro_thumb_grid($target, 0)->__toString());
+ $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" => self::_get_micro_thumb_grid($album, 0)->__toString(),
+ "sort_column" => $album->sort_column,
+ "sort_order" => $album->sort_order));
+ }
+
+ private static function _get_micro_thumb_grid($album, $offset) {
+ $v = new View("organize_thumb_grid.html");
+ $v->album = $album;
+ $v->offset = $offset;
+ return $v;
}
- static function rearrange_task_handler($task) {
- $start = microtime(true);
- $mode = $task->get("mode", "init");
+ private static function _tree($album) {
+ $v = new View("organize_tree.html");
+ $v->parents = $album->parents();
+ $v->album = $album;
- if ($task->percent_complete == 0) {
- batch::start();
- }
- while (microtime(true) - $start < 1.5) {
- switch ($mode) {
- case "init":
- $album = ORM::factory("item", $task->get("parent_id"));
- if ($album->sort_column != "weight") {
- $mode = "convert-to-weight-order";
- } else {
- $mode = "find-insertion-point";
- }
- break;
-
- case "convert-to-weight-order":
- $i = 0;
- $album = ORM::factory("item", $task->get("parent_id"));
- foreach ($album->children() as $child) {
- // Do this directly in the database to avoid sending notifications
- Database::Instance()->update("items", array("weight" => ++$i), array("id" => $child->id));
- }
- $album->sort_column = "weight";
- $album->sort_order = "ASC";
- $album->save();
- $mode = "find-insertion-point";
- $task->percent_complete = 25;
- break;
-
- case "find-insertion-point":
- $target = ORM::factory("item", $task->get("target_id"));
- $target_weight = $target->weight;
-
- if ($task->get("before_or_after") == "after") {
- $target_weight++;
- }
- $task->set("target_weight", $target_weight);
- $task->percent_complete = 40;
- $mode = "make-a-hole";
- break;
-
- case "make-a-hole":
- $target_weight = $task->get("target_weight");
- $source_ids = $task->get("source_ids");
- $count = count($source_ids);
- $parent_id = $task->get("parent_id");
- Database::Instance()->query(
- "UPDATE {items} " .
- "SET `weight` = `weight` + $count " .
- "WHERE `weight` >= $target_weight AND `parent_id` = {$parent_id}");
-
- $mode = "insert-source-items";
- $task->percent_complete = 80;
- break;
-
- case "insert-source-items":
- $target_weight = $task->get("target_weight");
- foreach ($source_ids as $source_id) {
- Database::Instance()->update(
- "items", array("weight" => $target_weight++), array("id" => $source_id));
- }
- $mode = "done";
- break;
-
- case "done":
- $album = ORM::factory("item", $task->get("parent_id"));
- module::event("album_rearrange", $album);
- batch::stop();
- $task->done = true;
- $task->state = "success";
- $task->percent_complete = 100;
- $task->set("content", self::_get_micro_thumb_grid($album, 0)->__toString());
- break;
- }
+ if ($album->id == 1) {
+ $v->peers = array($album);
+ } else {
+ $v->peers = $album->parent()->children(null, 0, array("type" => "album"));
}
- $task->set("mode", $mode);
+ return $v;
}
}
diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css
index d717bcae..85168810 100644
--- a/modules/organize/css/organize.css
+++ b/modules/organize/css/organize.css
@@ -51,30 +51,23 @@
padding-left: 1.2em;
}
-.gBranchText:hover {
+.gAlbumText:hover {
border: 1px dashed #999;
+ padding: 1px;
}
-.gBranchEmpty {
- visibility: hidden;
-}
-
-.gBranchSelected {
+#gOrganizeAlbumTree .selected {
background-color: #cfdeff !important;
border-bottom: 1px solid #999 !important;
display: block;
padding: .3em 0;
}
-.gBranchCollapsed {
- display: none;
-}
-
-.gOrganizeBranch span {
+.gOrganizeAlbum span {
cursor: pointer;
}
-.gBranchText {
+.gAlbumText {
cursor: pointer;
width: auto;
}
@@ -134,63 +127,20 @@
}
/****************************************************************
- * Organize Edit Drawer styling
+ * Organize Controls styling
*/
-#gOrganizeEditDrawer {
+#gOrganizeControls {
+ padding-left: 8px;
background-color: #13A;
+ color: #ccc;
width: 100% !important;
}
-#gOrganizeEditDrawerPanel {
- background-color: #fff;
- border: 1px solid #13A;
- display: none;
- height: 195px;
-}
-
-#gOrganizeEditDrawerHandle {
- height: 30px;
-}
-
-#gOrganizeEditHandleLeft {
- background-color: #FFF;
- float: left;
- height: 30px;
- width: 15px;
-}
-
-#gOrganizeEditHandleButtonsMiddle,
-#gOrganizeEditHandleButtonsLeft {
- float: left;
- height: 20px;
- padding: 2px 10px;
-}
-
-#gOrganizeEditHandleButtonsMiddle {
- margin-left: 20px;
-}
-
-#gOrganizeEditHandleButtonsMiddle a,
-#gOrganizeEditHandleButtonsLeft a {
- float: left;
- margin: 0 2.5px;
-}
-
-#gOrganizeEditHandleButtonsRight {
- float: right;
- height: 20px;
- padding: 2px 10px;
-}
-
-#gOrganizeEditHandleButtonsRight a {
- float: left;
- margin: 0 2.5px;
+#gOrganizeControls select {
+ display: inline;
}
-#gOrganizeEditHandleRight {
- background-color: #FFF;
- background-position: -15px 0;
+#gOrganizeClose {
float: right;
- height: 30px;
- width: 15px;
+ margin-right: 12px;
}
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js
index ec6bd924..04e14a2f 100644
--- a/modules/organize/js/organize.js
+++ b/modules/organize/js/organize.js
@@ -28,7 +28,8 @@
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);
+ .animate({ width: 10, height: 10, outlineWidth: 1, margin: 1,
+ left: (20 * j), top: (row * 20) }, 500);
});
return set;
}
@@ -55,10 +56,12 @@
tolerance: "pointer",
greedy: true,
drop: function(event, ui) {
+ var before_or_after = $(".currentDropTarget").css("borderLeftStyle") == "solid" ? "before" : "after";
$.organize.do_drop({
url: rearrange_url
.replace("__TARGET_ID__", $(".currentDropTarget").attr("ref"))
- .replace("__BEFORE__", $(".currentDropTarget").css("borderLeftStyle") == "solid" ? "before" : "after"),
+ .replace("__ALBUM_ID__", $(".currentDropTarget").attr("ref"))
+ .replace("__BEFORE__", before_or_after),
source: $(ui.helper).children("img")
});
}
@@ -74,14 +77,14 @@
$(".gMicroThumbGridCell").css("borderStyle", "none");
} else {
$.organize.do_drop({
- url: move_url.replace("__TARGET_ID__", $(event.target).attr("ref")),
+ url: move_url.replace("__ALBUM_ID__", $(event.target).attr("ref")),
source: $(ui.helper).children("img")
});
}
}
},
- do_drop:function(options) {
+ do_drop: function(options) {
$("#gMicroThumbPanel").selectable("destroy");
var source_ids = [];
$(options.source).each(function(i) {
@@ -89,57 +92,23 @@
});
if (source_ids.length) {
- $("#gOrganize .gProgressBar").progressbar().progressbar("value", 0);
- $("#gOrganizeProgress").animate(
- { height: "toggle", display: "toggle" },
- {
- duration: "fast",
- step: function() {
- },
- complete: function() {
- $("#gMicroThumbPanel").height($("#gMicroThumbPanel").height() - $(this).height());
- $.ajax({
- url: options.url,
- type: "POST",
- async: false,
- data: { "source_ids[]": source_ids },
- dataType: "json",
- success: function(data, textStatus) {
- $("#gStatus").html(data.status);
- $("#gOrganize .gProgressBar").progressbar("value", data.percent_complete);
- setTimeout(function() { $.organize._run_task(data.url); }, 0);
- }
- });
- }
- });
+ $.post(options.url,
+ { "source_ids[]": source_ids },
+ function(data) { $.organize._refresh(data); },
+ "json");
}
},
- _run_task: function(url) {
- $.ajax({
- url: url,
- async: false,
- dataType: "json",
- success: function(data, textStatus) {
- $("#gStatus").html(data.status);
- $("#gOrganize .gProgressBar").progressbar("value", data.percent_complete);
- if (data.done) {
- var height = $("#gOrganizeProgress").height();
- $("#gOrganizeProgress").toggle();
- $("#gMicroThumbPanel").height($("#gDialog").innerHeight() - 90);
- //$("#gMicroThumbPanel").height($("#gMicroThumbPanel").height() + height);
- if (data.tree) {
- $("#gOrganizeAlbumTree").html(data.tree);
- }
- if (data.content) {
- $("#gMicroThumbGrid").html(data.content);
- }
- $.organize.set_handlers();
- } else {
- setTimeout(function() { $.organize._run_task(url); }, 0);
- }
- }
- });
+ _refresh: function(data) {
+ if (data.tree) {
+ $("#gOrganizeAlbumTree").html(data.tree);
+ }
+ if (data.grid) {
+ $("#gMicroThumbGrid").html(data.grid);
+ $("#gOrganizeSortColumn").attr("value", data.sort_column);
+ $("#gOrganizeSortOrder").attr("value", data.sort_order);
+ }
+ $.organize.set_handlers();
},
mouse_move_handler: function(event) {
@@ -171,10 +140,14 @@
window.location.reload();
});
- $("#gDialog #gMicroThumbDone").click(function(event) {
+ $("#gDialog #gOrganizeClose").click(function(event) {
$("#gDialog").dialog("close");
});
+ $("#gOrganizeSortColumn,#gOrganizeSortOrder").change(function(event) {
+ $.organize.resort($("#gOrganizeSortColumn").attr("value"), $("#gOrganizeSortOrder").attr("value"));
+ });
+
$.organize.set_handlers();
},
@@ -184,26 +157,17 @@
$(".gMicroThumbGridCell").draggable($.organize.micro_thumb_draggable);
$(".gMicroThumbGridCell").mousemove($.organize.mouse_move_handler);
- $(".gOrganizeBranch").droppable($.organize.branch_droppable);
- $(".gBranchText").click($.organize.show_album);
- $(".gOrganizeBranch .ui-icon").click($.organize.collapse_or_expand_tree);
+ $(".gOrganizeAlbum").droppable($.organize.branch_droppable);
+ $(".gAlbumText").click($.organize.show_album);
},
- /**
- * Open or close a branch.
- */
- collapse_or_expand_tree: function(event) {
- event.stopPropagation();
- $(event.currentTarget).toggleClass("ui-icon-minus").toggleClass("ui-icon-plus");
- $("#gOrganizeChildren-" + $(event.currentTarget).attr("ref")).toggle();
- },
/**
* When the text of a selection is clicked, then show that albums contents
*/
show_album: function(event) {
event.preventDefault();
- if ($(event.currentTarget).hasClass("gBranchSelected")) {
+ if ($(event.currentTarget).hasClass("selected")) {
return;
}
var parent = $(event.currentTarget).parents(".gOrganizeBranch");
@@ -212,13 +176,35 @@
}
$("#gMicroThumbPanel").selectable("destroy");
var id = $(event.currentTarget).attr("ref");
- $(".gBranchSelected").removeClass("gBranchSelected");
- $("#gOrganizeBranch-" + id).addClass("gBranchSelected");
+ $("#gOrganizeAlbumTree .selected").removeClass("selected");
+ $(".gAlbumText[ref=" + id + "]").addClass("selected");
var url = $("#gMicroThumbPanel").attr("ref").replace("__ITEM_ID__", id).replace("__OFFSET__", 0);
- $.get(url, function(data) {
- $("#gMicroThumbGrid").html(data);
- $.organize.set_handlers();
- });
+ $.get(url, {},
+ function(data) {
+ $("#gMicroThumbGrid").html(data.grid);
+ $("#gOrganizeSortColumn").attr("value", data.sort_column);
+ $("#gOrganizeSortOrder").attr("value", data.sort_order);
+ $.organize.set_handlers();
+ },
+ "json");
+ },
+
+ /**
+ * Change the sort order.
+ */
+ resort: function(column, dir) {
+ var url = sort_order_url
+ .replace("__ALBUM_ID__", $("#gOrganizeAlbumTree .selected").attr("ref"))
+ .replace("__COL__", column)
+ .replace("__DIR__", dir);
+ $.get(url, {},
+ function(data) {
+ $("#gMicroThumbGrid").html(data.grid);
+ $("#gOrganizeSortColumn").attr("value", data.sort_column);
+ $("#gOrganizeSortOrder").attr("value", data.sort_order);
+ $.organize.set_handlers();
+ },
+ "json");
}
};
})(jQuery);
diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php
index 7c09266f..b03c066c 100644
--- a/modules/organize/views/organize_dialog.html.php
+++ b/modules/organize/views/organize_dialog.html.php
@@ -1,10 +1,11 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<script type="text/javascript">
- var move_url = "<?= url::site("organize/move/__TARGET_ID__?csrf=$csrf") ?>";
+ var move_url = "<?= url::site("organize/move_to/__ALBUM_ID__?csrf=$csrf") ?>";
var rearrange_url = "<?= url::site("organize/rearrange/__TARGET_ID__/__BEFORE__?csrf=$csrf") ?>";
+ var sort_order_url = "<?= url::site("organize/sort_order/__ALBUM_ID__/__COL__/__DIR__?csrf=$csrf") ?>";
</script>
<div id="gOrganize" class="gDialogPanel">
- <h1 style="display:none"><?= t("Organize %name", array("name" => p::purify($title))) ?></h1>
+ <h1 style="display:none"><?= t("Organize %name", array("name" => p::purify($album->title))) ?></h1>
<div id="bd">
<div class="yui-gf">
<div class="yui-u first">
@@ -22,24 +23,19 @@
</div>
<div id="gOrganizeDetail" class="yui-u">
<div id="gMicroThumbPanel"
- ref="<?= url::site("organize/content/__ITEM_ID__/__OFFSET__") ?>">
+ ref="<?= url::site("organize/album/__ITEM_ID__/__OFFSET__") ?>">
<ul id="gMicroThumbGrid">
<?= $micro_thumb_grid ?>
</ul>
</div>
- <div id="gOrganizeEditDrawer" class="yui-u">
- <div id="gOrganizeEditDrawerPanel" class="yui-gf">
- </div>
- <div id="gOrganizeEditDrawerHandle">
- <div id="gOrganizeEditHandleButtonsRight">
- <a id="gMicroThumbDone" href="#" ref="done"
- class="gButtonLink ui-corner-all ui-state-default"><?= t("Close") ?></a>
- </div>
- </div>
- </div>
- <div id="gOrganizeProgress" style="display: none">
- <div class="gProgressBar"></div>
- <div id="gStatus"></div>
+ <div id="gOrganizeControls">
+ <a id="gOrganizeClose" href="#" ref="done"
+ class="gButtonLink ui-corner-all ui-state-default"><?= t("Close") ?></a>
+ <form>
+ <?= t("Sort order") ?>
+ <?= form::dropdown(array("id" => "gOrganizeSortColumn"), album::get_sort_order_options(), $album->sort_column) ?>
+ <?= form::dropdown(array("id" => "gOrganizeSortOrder"), array("ASC" => "Ascending", "DESC" => "Descending"), $album->sort_order) ?>
+ </form>
</div>
</div>
</div>
diff --git a/modules/organize/views/organize_thumb_grid.html.php b/modules/organize/views/organize_thumb_grid.html.php
index 5adb487a..31dc9af5 100644
--- a/modules/organize/views/organize_thumb_grid.html.php
+++ b/modules/organize/views/organize_thumb_grid.html.php
@@ -1,5 +1,5 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
-<? foreach ($item->children(25, $offset) as $child): ?>
+<? foreach ($album->children(25, $offset) as $child): ?>
<li class="gMicroThumbGridCell" ref="<?= $child->id ?>">
<div id="gMicroThumb_<?= $child->id ?>"
class="gMicroThumb <?= $child->is_album() ? "gAlbum" : "gPhoto" ?>">
@@ -8,10 +8,10 @@
</li>
<? endforeach ?>
-<? if ($item->children_count() > $offset): ?>
+<? if ($album->children_count() > $offset): ?>
<script>
setTimeout(function() {
- $.get("<?= url::site("organize/content/$item->id/" . ($offset + 25)) ?>",
+ $.get("<?= url::site("organize/content/$album->id/" . ($offset + 25)) ?>",
function(data) {
$("#gMicroThumbGrid").append(data);
$.organize.set_handlers();
diff --git a/modules/organize/views/organize_tree.html.php b/modules/organize/views/organize_tree.html.php
index 823301fc..36f900ac 100644
--- a/modules/organize/views/organize_tree.html.php
+++ b/modules/organize/views/organize_tree.html.php
@@ -1,17 +1,44 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
-<li class="gOrganizeBranch ui-icon-left <?= $can_edit ? "" : "gViewOnly" ?>" ref="<?= $album->id ?>">
- <div id="gOrganizeBranch-<?= $album->id ?>" ref="<?= $album->id ?>"
- class="<?= $selected ? "gBranchSelected" : "" ?>">
- <span id="gOrganizeIcon-<?= $album->id ?>" ref="<?= $album->id ?>"
- class="ui-icon <?= $album_icon ?>">
- </span>
- <span class="gBranchText" ref="<?= $album->id ?>"><?= p::clean($album->title) ?></span>
- </div>
- <ul id="gOrganizeChildren-<?= $album->id ?>"
- class="<?= $album_icon == "ui-icon-plus" ? "gBranchCollapsed" : "" ?>">
- <li style="display:none">&nbsp;</li>
- <? foreach ($children as $child): ?>
- <?= $child ?>
+<? foreach ($parents as $parent): ?>
+<li class="gOrganizeAlbum ui-icon-left <?= access::can("edit", $parent) ? "" : "gViewOnly" ?>"
+ ref="<?= $parent->id ?>">
+ <span class="ui-icon ui-icon-minus">
+ </span>
+ <span class="gAlbumText" ref="<?= $parent->id ?>">
+ <?= p::clean($parent->title) ?>
+ </span>
+ <ul class="ui-icon-plus">
<? endforeach ?>
+
+ <? foreach ($peers as $peer): ?>
+ <li class="gOrganizeAlbum ui-icon-left <?= access::can("edit", $peer) ? "" : "gViewOnly" ?>"
+ ref="<?= $peer->id ?>">
+ <span class="ui-icon <?= $peer->id == $album->id ? "ui-icon-minus" : "ui-icon-plus" ?>">
+ </span>
+ <span class="gAlbumText <?= $peer->id == $album->id ? "selected" : "" ?>"
+ ref="<?= $peer->id ?>">
+ <?= p::clean($peer->title) ?>
+ </span>
+
+ <? if ($peer->id == $album->id): ?>
+ <ul class="ui-icon-plus">
+ <? foreach ($album->children(null, 0, array("type" => "album")) as $child): ?>
+ <li class="gOrganizeAlbum ui-icon-left <?= access::can("edit", $child) ? "" : "gViewOnly" ?>"
+ ref="<?= $child->id ?>">
+ <span class="ui-icon ui-icon-plus">
+ </span>
+ <span class="gAlbumText"
+ ref="<?= $child->id ?>">
+ <?= p::clean($child->title) ?>
+ </span>
+ </li>
+ <? endforeach ?>
+ </ul>
+ <? endif ?>
+ </li>
+ <? endforeach ?>
+
+ <? foreach ($parents as $parent): ?>
</ul>
</li>
+<? endforeach ?>
diff --git a/modules/server_add/helpers/server_add_event.php b/modules/server_add/helpers/server_add_event.php
index b53e72d1..6b21ec2e 100644
--- a/modules/server_add/helpers/server_add_event.php
+++ b/modules/server_add/helpers/server_add_event.php
@@ -35,30 +35,11 @@ class server_add_event_Core {
// turn that into a dropdown if there are two different ways to add things. Do that in a
// portable way for now. If we find ourselves duplicating this pattern, we should make an
// API method for this.
- $server_add = Menu::factory("dialog")
- ->id("server_add")
- ->label(t("Add from server"))
- ->url(url::site("server_add/browse/$item->id"));
- $add_photos_item = $menu->get("add_photos_item");
- $add_photos_menu = $menu->get("add_photos_menu");
-
- if ($add_photos_item && !$add_photos_menu) {
- // Assuming that $add_menu is unset, create add_menu and add our item
- $menu->add_after(
- "add_photos_item",
- Menu::factory("submenu")
- ->id("add_photos_menu")
- ->label($add_photos_item->label)
- ->append(Menu::factory("dialog")
- ->id("add_photos_submenu_item")
- ->label(t("Simple Uploader"))
- ->url($add_photos_item->url))
- ->append($server_add));
- $menu->remove("add_photos_item");
- } else if ($add_photos_menu) {
- // Append to the existing sub-menu
- $add_photos_menu->append($server_add);
- }
+ $add_menu = $menu->get("add_menu");
+ $add_menu->append(Menu::factory("dialog")
+ ->id("server_add")
+ ->label(t("Server add"))
+ ->url(url::site("server_add/browse/$item->id")));
}
}
}
diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php
index 69a6ecb3..40acc2ec 100644
--- a/modules/user/helpers/user.php
+++ b/modules/user/helpers/user.php
@@ -159,7 +159,12 @@ class user_Core {
*/
static function active() {
// @todo (maybe) cache this object so we're not always doing session lookups.
- $user = Session::instance()->get("user", self::guest());
+ $user = Session::instance()->get("user", null);
+ if (!isset($user)) {
+ // Don't do this as a fallback in the Session::get() call because it can trigger unnecessary
+ // work.
+ $user = user::guest();
+ }
return $user;
}
diff --git a/themes/admin_default/css/admin_screen.css b/themes/admin_default/css/admin_screen.css
index 7e468442..fd1ed02e 100644
--- a/themes/admin_default/css/admin_screen.css
+++ b/themes/admin_default/css/admin_screen.css
@@ -462,8 +462,18 @@ li.gDefaultGroup h4, li.gDefaultGroup .gUser {
background-color: #C5DBEC;
font-weight: bold;
}
-#gLanguagesForm input, #gShareTranslationsForm, #gLanguages h2 {
+#gLanguagesForm input {
clear: both;
}
+#gTranslations {
+ padding: 2em 0 0 0;
+ clear: both;
+}
+#gTranslations .gButtonLink {
+ padding: .5em;
+}
+.gDocLink {
+ float: right;
+}