summaryrefslogtreecommitdiff
path: root/modules/rearrange/controllers
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2008-12-04 20:05:58 +0000
committerTim Almdal <tnalmdal@shaw.ca>2008-12-04 20:05:58 +0000
commit0f103b1c069063a2e6109a0ba7e566104f4ba8fa (patch)
tree8b7e26b0ef3650a6b90c0b9602da6b37bf3437f3 /modules/rearrange/controllers
parent80a7db61c9fba53477c1ec0850bdffaf7b11657a (diff)
Moving albums around with a drag and drop interface seems to work and preserve the left right pointers.
* changed _lock and _unlock to protected methods lock and lock respectively * added a moveTo method on the Item_Model * Corrected the hole closure on delete. * added moveTo on the ORM_MTPP class * Changed the rearrange javascript to do moves with ajax
Diffstat (limited to 'modules/rearrange/controllers')
-rw-r--r--modules/rearrange/controllers/rearrange.php26
1 files changed, 19 insertions, 7 deletions
diff --git a/modules/rearrange/controllers/rearrange.php b/modules/rearrange/controllers/rearrange.php
index 59c1b069..6118e07e 100644
--- a/modules/rearrange/controllers/rearrange.php
+++ b/modules/rearrange/controllers/rearrange.php
@@ -22,14 +22,26 @@ class Rearrange_Controller extends Controller {
public function show($id=null) {
$view = new View("rearrange_item_list.html");
- if (empty($id)) {
- $item = ORM::factory("item", 1);
- $view->children = array($item);
- } else {
- $item = ORM::factory("item", $id);
- $view->children = $item->children();
- }
+ $isRoot = empty($id);
+ $item = ORM::factory("item", $isRoot ? 1 : $id);
+
+ $view->children = $isRoot ? array($item) : $item->children();
print $view;
}
+
+ public function move($source_id, $target_id) {
+ $source = ORM_MPTT::factory("item", $source_id);
+ $target = ORM_MPTT::factory("item", $target_id);
+
+ try {
+ $source->moveTo($target);
+ print "success";
+ } catch (Exception $e) {
+ Kohana::log("error", $e->getMessage() . "\n" + $e->getTraceAsString());
+ header("HTTP/1.1 500");
+ print $e->getMessage();
+ }
+ }
+
} \ No newline at end of file