From a67e1ee1fc2fa8bb182c9db64f258b20d2bb107b Mon Sep 17 00:00:00 2001 From: avl Date: Wed, 25 Mar 2009 13:02:09 +0200 Subject: [PATCH] MORE, more reorder customizable --- ipf/admin/templates/admin/items.html | 12 ++++++++---- ipf/admin/views.php | 24 ++++++++++++++---------- ipf/orm/record.php | 3 +-- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/ipf/admin/templates/admin/items.html b/ipf/admin/templates/admin/items.html index c32ed12..c5b546e 100644 --- a/ipf/admin/templates/admin/items.html +++ b/ipf/admin/templates/admin/items.html @@ -11,15 +11,19 @@ diff --git a/ipf/admin/views.php b/ipf/admin/views.php index 80c5761..615eb6c 100644 --- a/ipf/admin/views.php +++ b/ipf/admin/views.php @@ -80,19 +80,20 @@ function IPF_Admin_Views_Reorder($request, $match){ if ($ca!==true) return $ca; if ($request->method != 'POST') - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound(); if (!isset($request->POST['ids'])) - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound(); + + if (!isset($request->POST['prev_ids'])) + return new IPF_HTTP_Response_NotFound(); if (!isset($request->POST['drop_id'])) - return new IPF_HTTP_Response_NotFound(); - $drop_id = $request->POST['drop_id']; + return new IPF_HTTP_Response_NotFound(); $lapp = $match[1]; $lmodel = $match[2]; - foreach (IPF_Project::getInstance()->appList() as $app){ foreach($app->modelList() as $m){ if (strtolower($m)==$lmodel){ @@ -101,14 +102,17 @@ function IPF_Admin_Views_Reorder($request, $match){ return new IPF_HTTP_Response_NotFound(); if (method_exists($ma, 'list_order')) - $ord_field = $ma->list_order(); + $ord_field = $ma->list_order(); else - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound(); + + $ids = split(',',(string)$request->POST['ids']); + $prev_ids = split(',',(string)$request->POST['prev_ids']); + $drop_id = $request->POST['drop_id']; $o = new $m(); - $ids = split(',',(string)$request->POST['ids']); - $o->_reorder($ids, $ord_field, $drop_id); - return new IPF_HTTP_Response_Json("Ok"); + $o->_reorder($ids, $ord_field, $drop_id, $prev_ids); + return new IPF_HTTP_Response_Json("Ok"); } } } diff --git a/ipf/orm/record.php b/ipf/orm/record.php index 6333a34..d389b23 100644 --- a/ipf/orm/record.php +++ b/ipf/orm/record.php @@ -1296,7 +1296,7 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab return null; } - public function _reorder($ids, $ord_field, $drop_id){ + public function _reorder($ids, $ord_field, $drop_id, $prev_ids){ $ord = 1; foreach($ids as $id){ $item = $this->getTable()->find($id); @@ -1305,5 +1305,4 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab $ord++; } } - } \ No newline at end of file -- 2.49.0