Merge branch 'master' of git://github.com/gallery/gallery3

This commit is contained in:
Tim Almdal
2009-08-29 11:22:19 -07:00
8 changed files with 245 additions and 380 deletions
+14 -7
View File
@@ -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"));
}
}
@@ -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());
}
}
+96 -207
View File
@@ -18,235 +18,124 @@
* 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 move($target_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")));
function album($album_id, $offset) {
$album = ORM::factory("item", $album_id);
access::required("view", $album);
access::required("edit", $album);
print json_encode(
array("result" => "started",
"status" => $task->status,
"url" => url::site("organize/run/$task->id?csrf=" . access::csrf_token())));
array("grid" => self::_get_micro_thumb_grid($album, $offset)->__toString(),
"sort_column" => $album->sort_column,
"sort_order" => $album->sort_order));
}
function move_to($album_id) {
access::verify_csrf();
$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("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")));
$target = ORM::factory("item", $target_id);
$album = $target->parent();
access::required("view", $album);
access::required("edit", $album);
$source_ids = $this->input->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
Database::Instance()->update("items", array("weight" => ++$i), array("id" => $child->id));
}
$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);
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));
}
module::event("album_rearrange", $album);
print json_encode(
array("result" => "started",
"status" => $task->status,
"url" => url::site("organize/run/$task->id?csrf=" . access::csrf_token())));
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($item, $offset) {
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" => 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->item = $item;
$v->album = $album;
$v->offset = $offset;
return $v;
}
/**
* Run the task
*/
function run($task_id) {
access::verify_csrf();
$task = ORM::factory("task", $task_id);
if (!$task->loaded || $task->owner_id != user::active()->id) {
access::forbidden();
}
$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;
}
}
print json_encode($results);
}
private static function _tree($item, $parents) {
private static function _tree($album) {
$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);
}
}
if (count($v->children)) {
$v->album_icon = empty($parents[$item->id]) ? "ui-icon-plus" : "ui-icon-minus";
}
$v->parents = $album->parents();
$v->album = $album;
return $v;
}
static function move_task_handler($task) {
$start = microtime(true);
if ($task->percent_complete == 0) {
batch::start();
}
$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());
}
}
static function rearrange_task_handler($task) {
$start = microtime(true);
$mode = $task->get("mode", "init");
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;
}
}
$task->set("mode", $mode);
}
}
+13 -63
View File
@@ -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;
#gOrganizeControls select {
display: inline;
}
#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 {
#gOrganizeClose {
float: right;
height: 20px;
padding: 2px 10px;
}
#gOrganizeEditHandleButtonsRight a {
float: left;
margin: 0 2.5px;
}
#gOrganizeEditHandleRight {
background-color: #FFF;
background-position: -15px 0;
float: right;
height: 30px;
width: 15px;
margin-right: 12px;
}
+57 -71
View File
@@ -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);
+12 -16
View File
@@ -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>
@@ -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();
+43 -13
View File
@@ -1,17 +1,47 @@
<?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 ?>
<? if ($parent->id == $album->parent_id): ?>
<? foreach ($parent->children(null, 0, array("type" => "album")) 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 ?>
<? endif ?>
<? foreach ($parents as $parent): ?>
</ul>
</li>
<? endforeach ?>