Skip to content

Commit

Permalink
Merge branch 'master' into 3.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
bharat committed Jan 23, 2013
2 parents 4c5a74b + 1d700bf commit 677f20d
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 5 deletions.
8 changes: 8 additions & 0 deletions modules/gallery/helpers/gallery.php
Expand Up @@ -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");
}
}
4 changes: 2 additions & 2 deletions modules/gallery/helpers/gallery_theme.php
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions modules/gallery/libraries/MY_Database.php
Expand Up @@ -32,6 +32,9 @@ protected function __construct(array $config) {
$config["connection"]["params"] = null;
}
parent::__construct($config);
if (gallery::show_profiler()) {
$this->config['benchmark'] = true;
}
}

/**
Expand Down
7 changes: 7 additions & 0 deletions modules/gallery/libraries/Theme_View.php
Expand Up @@ -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.
Expand Down
22 changes: 22 additions & 0 deletions modules/organize/controllers/organize.php
Expand Up @@ -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()
Expand Down
68 changes: 66 additions & 2 deletions modules/organize/views/organize_frame.html.php
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
}
},
Expand Down Expand Up @@ -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: <?= 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() ?>,
Expand Down Expand Up @@ -375,10 +425,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",
Expand Down
2 changes: 1 addition & 1 deletion modules/rest/helpers/rest.php
Expand Up @@ -54,7 +54,7 @@ static function reply($data=array()) {
$html = t("Empty response");
}
print "<pre>$html</pre>";
if (Session::instance()->get("profiler", false)) {
if (gallery::show_profiler()) {
Profiler::enable();
$profiler = new Profiler();
$profiler->render();
Expand Down

0 comments on commit 677f20d

Please sign in to comment.