diff options
author | Nathan Kinkade <nath@nkinka.de> | 2013-02-14 14:28:46 +0000 |
---|---|---|
committer | Nathan Kinkade <nath@nkinka.de> | 2013-02-14 14:28:46 +0000 |
commit | 711651f727e093cc7357a6bbff6bd992fd6dfd80 (patch) | |
tree | 2dadc1c06acf1ab3d42d3ed5415568535db54416 /modules/organize | |
parent | 0047af90bf4db08b22838e6ded22a7fa70cee98a (diff) | |
parent | e5ed05004f005bdccdbf68e199ae2324ad97e895 (diff) |
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/organize')
-rw-r--r-- | modules/organize/controllers/organize.php | 34 | ||||
-rw-r--r-- | modules/organize/helpers/organize_event.php | 2 | ||||
-rw-r--r-- | modules/organize/helpers/organize_installer.php | 2 | ||||
-rw-r--r-- | modules/organize/module.info | 6 | ||||
-rw-r--r-- | modules/organize/views/organize_frame.html.php | 74 |
5 files changed, 101 insertions, 17 deletions
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index b0c13e7d..ba73ae75 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -1,7 +1,7 @@ <?php defined("SYSPATH") or die("No direct script access."); /** * Gallery - a web based photo album viewer and editor - * Copyright (C) 2000-2012 Bharat Mediratta + * Copyright (C) 2000-2013 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 @@ -129,12 +129,8 @@ class Organize_Controller extends Controller { if ($album->sort_column != "weight") { // Force all the weights into the current order before changing the order to manual - $weight = 0; - foreach ($album->children() as $child) { - $child->weight = ++$weight; - $child->save(); - } - + // @todo: consider making this a trigger in the Item_Model. + item::resequence_child_weights($album); $album->sort_column = "weight"; $album->sort_order = "ASC"; $album->save(); @@ -158,7 +154,7 @@ class Organize_Controller extends Controller { // Move all the source items to the right spots. for ($i = 0; $i < count($source_ids); $i++) { $source = ORM::factory("item", $source_ids[$i]); - if ($source->parent_id = $album->id) { + if ($source->parent_id == $album->id) { $source->weight = $base_weight + $i; $source->save(); } @@ -182,6 +178,28 @@ class Organize_Controller extends Controller { json::reply(null); } + function tag() { + access::verify_csrf(); + $input = Input::instance(); + + foreach (explode(",", $input->post("item_ids")) as $item_id) { + $item = ORM::factory("item", $item_id); + if (access::can("edit", $item)) { + // Assuming the user can view/edit the current item, loop + // through each tag that was submitted and apply it to + // the current item. + foreach (explode(",", $input->post("tag_names")) as $tag_name) { + $tag_name = trim($tag_name); + if ($tag_name) { + tag::add($item, $tag_name); + } + } + } + } + + json::reply(null); + } + private function _get_tree($item, $selected) { $tree = array(); $children = $item->viewable() diff --git a/modules/organize/helpers/organize_event.php b/modules/organize/helpers/organize_event.php index 674cc064..2ca9e9b4 100644 --- a/modules/organize/helpers/organize_event.php +++ b/modules/organize/helpers/organize_event.php @@ -1,7 +1,7 @@ <?php defined("SYSPATH") or die("No direct script access."); /** * Gallery - a web based photo album viewer and editor - * Copyright (C) 2000-2012 Bharat Mediratta + * Copyright (C) 2000-2013 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 diff --git a/modules/organize/helpers/organize_installer.php b/modules/organize/helpers/organize_installer.php index 8121bdbe..a2a07447 100644 --- a/modules/organize/helpers/organize_installer.php +++ b/modules/organize/helpers/organize_installer.php @@ -1,7 +1,7 @@ <?php defined("SYSPATH") or die("No direct script access."); /** * Gallery - a web based photo album viewer and editor - * Copyright (C) 2000-2012 Bharat Mediratta + * Copyright (C) 2000-2013 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 diff --git a/modules/organize/module.info b/modules/organize/module.info index 07b9dc38..4d4560b9 100644 --- a/modules/organize/module.info +++ b/modules/organize/module.info @@ -2,6 +2,6 @@ name = "Organize" description = "Visually rearrange and move photos in your gallery" version = 4 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:organize" -discuss_url = "http://gallery.menalto.com/forum_module_organize" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:organize" +discuss_url = "http://galleryproject.org/forum_module_organize" diff --git a/modules/organize/views/organize_frame.html.php b/modules/organize/views/organize_frame.html.php index 51d49104..3a70ccff 100644 --- a/modules/organize/views/organize_frame.html.php +++ b/modules/organize/views/organize_frame.html.php @@ -104,9 +104,33 @@ }); } + var tag_selected_items = function(tag) { + var nodes = thumb_data_view.getSelectedNodes(); + var item_ids = []; + for (var i = 0; i != nodes.length; i++) { + var node = Ext.fly(nodes[i]); + item_ids.push(get_id_from_node(node)); + } + start_busy(<?= t("Tagging...")->for_js() ?>); + Ext.Ajax.request({ + url: '<?= url::site("organize/tag") ?>', + method: "post", + success: function() { + stop_busy(); + reload_album_data(); + }, + failure: show_generic_error, + params: { + item_ids: item_ids.join(","), + tag_names: tag, + csrf: '<?= access::csrf_token() ?>' + } + }); + }; + var delete_selected_items = function() { var nodes = thumb_data_view.getSelectedNodes(); - item_ids = []; + var item_ids = []; for (var i = 0; i != nodes.length; i++) { var node = Ext.fly(nodes[i]); item_ids.push(get_id_from_node(node)); @@ -166,8 +190,10 @@ getDragData: function(e) { var target = e.getTarget(v.itemSelector, 10); if (target) { - if (!v.isSelected(target)) { - v.onClick(e); + if (e.ctrlKey == false) { + if (!v.isSelected(target)) { + v.onClick(e); + } } var selected_nodes = v.getSelectedNodes(); var drag_data = { @@ -254,6 +280,7 @@ }); }, "selectionchange": function(v, selections) { + tag_button.setDisabled(!selections.length || !current_album_editable || !tag_textfield.getValue()); delete_button.setDisabled(!selections.length || !current_album_editable); } }, @@ -330,6 +357,31 @@ displayField: "value" }); + var tag_textfield = new Ext.form.TextField({ + flex: 4, + enableKeyEvents: true, + listeners: { + "keyup": function(v, e) { + var nodes = thumb_data_view.getSelectedNodes(); + tag_button.setDisabled(!nodes.length || !current_album_editable || !tag_textfield.getValue()); + } + } + }); + + var tag_button = new Ext.Button({ + flex: 2, + text: <?= t("Tag")->for_js() ?>, + cls: "x-btn-text-icon", + id: "tag-button", + disabled: true, + listeners: { + "click": function() { + tag_selected_items(tag_textfield.getValue()); + return true; + } + } + }); + var delete_button = new Ext.Button({ flex: 2, text: <?= t("Delete")->for_js() ?>, @@ -375,10 +427,24 @@ sort_column_combobox, sort_order_combobox ] - }, { + }, +<? if (module::is_active("tag")): ?> + { + xtype: "spacer", + flex: 3 + }, + tag_textfield, + tag_button, + { + xtype: "spacer", + flex: 1 + }, +<? else: ?> + { xtype: "spacer", flex: 10 }, +<? endif ?> delete_button, { xtype: "button", |