diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 133cad2b3d..30899c3fc5 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -214,4 +214,12 @@ static function build_number() { } return null; } + + /** + * Return true if we should show the profiler at the bottom of the page. Note that this + * function is called at database setup time so it cannot rely on the database. + */ + static function show_profiler() { + return file_exists(VARPATH . "PROFILE"); + } } \ No newline at end of file diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index f94b9ecd3a..3c6d71e9ed 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -71,7 +71,7 @@ static function admin_head($theme) { static function page_bottom($theme) { $session = Session::instance(); - if ($session->get("profiler", false)) { + if (gallery::show_profiler()) { Profiler::enable(); $profiler = new Profiler(); $profiler->render(); @@ -96,7 +96,7 @@ static function page_bottom($theme) { static function admin_page_bottom($theme) { $session = Session::instance(); - if ($session->get("profiler", false)) { + if (gallery::show_profiler()) { Profiler::enable(); $profiler = new Profiler(); $profiler->render(); diff --git a/modules/gallery/libraries/MY_Database.php b/modules/gallery/libraries/MY_Database.php index 604b6484e0..aae0bb79d9 100644 --- a/modules/gallery/libraries/MY_Database.php +++ b/modules/gallery/libraries/MY_Database.php @@ -32,6 +32,9 @@ protected function __construct(array $config) { $config["connection"]["params"] = null; } parent::__construct($config); + if (gallery::show_profiler()) { + $this->config['benchmark'] = true; + } } /** diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 1dfa72a02e..8d69f23b15 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -63,6 +63,13 @@ public function __construct($name, $page_type, $page_subtype) { * @return int */ public function thumb_proportion($item=null) { + // If the item is an album with children, grab the first item in that album instead. We're + // interested in the size of the thumbnails in this album, not the thumbnail of the + // album itself. + if ($item && $item->is_album() && $item->children_count()) { + $item = $item->children(1)->current(); + } + // By default we have a globally fixed thumbnail size In core code, we just return a fixed // proportion based on the global thumbnail size, but since modules can override that, we // return the actual proportions when we have them. diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index f090b8a9e4..97280489ca 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -182,6 +182,28 @@ function delete() { 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/views/organize_frame.html.php b/modules/organize/views/organize_frame.html.php index 51d49104d9..c33b76074e 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(for_js() ?>); + Ext.Ajax.request({ + url: '', + method: "post", + success: function() { + stop_busy(); + reload_album_data(); + }, + failure: show_generic_error, + params: { + item_ids: item_ids.join(","), + tag_names: tag, + csrf: '' + } + }); + }; + 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)); @@ -254,6 +278,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 +355,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: 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: for_js() ?>, @@ -375,10 +425,24 @@ sort_column_combobox, sort_order_combobox ] - }, { + }, + + { + xtype: "spacer", + flex: 3 + }, + tag_textfield, + tag_button, + { + xtype: "spacer", + flex: 1 + }, + + { xtype: "spacer", flex: 10 }, + delete_button, { xtype: "button", diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php index eeedff2acd..9b367febe8 100644 --- a/modules/rest/helpers/rest.php +++ b/modules/rest/helpers/rest.php @@ -54,7 +54,7 @@ static function reply($data=array()) { $html = t("Empty response"); } print "
$html
"; - if (Session::instance()->get("profiler", false)) { + if (gallery::show_profiler()) { Profiler::enable(); $profiler = new Profiler(); $profiler->render();