[*] BO : #PSFV-865 - it is now possible to use drag and drop positions in custom controllers using HelperList

This commit is contained in:
tDidierjean
2012-04-18 15:48:38 +00:00
parent 0a9aaee6b9
commit 45ea9fdaae
14 changed files with 340 additions and 432 deletions
@@ -138,6 +138,8 @@ class AdminCmsContentControllerCore extends AdminController
|| (Tools::isSubmit('statuscms_category') && Tools::isSubmit('id_cms_category'))
|| (Tools::isSubmit('position') && Tools::isSubmit('id_cms_category_to_move')))
$this->adminCMSCategories->postProcess();
parent::postProcess();
}
public function setMedia()
@@ -146,4 +148,60 @@ class AdminCmsContentControllerCore extends AdminController
$this->addJqueryUi('ui.widget');
$this->addJqueryPlugin('tagify');
}
public function ajaxProcessUpdateCmsPositions()
{
$id_cms = (int)(Tools::getValue('id_cms'));
$id_category = (int)(Tools::getValue('id_cms_category'));
$way = (int)(Tools::getValue('way'));
$positions = Tools::getValue('cms');
if (is_array($positions))
foreach ($positions as $key => $value)
{
$pos = explode('_', $value);
if ((isset($pos[1]) && isset($pos[2])) && ($pos[1] == $id_category && $pos[2] == $id_cms))
{
$position = $key;
break;
}
}
$cms = new CMS($id_cms);
if (Validate::isLoadedObject($cms))
{
if (isset($position) && $cms->updatePosition($way, $position))
die(true);
else
die('{"hasError" : true, "errors" : "Can not update cms position"}');
}
else
die('{"hasError" : true, "errors" : "This cms can not be loaded"}');
}
public function ajaxProcessUpdateCmsCategoriesPositions()
{
$id_cms_category_to_move = (int)(Tools::getValue('id_cms_category_to_move'));
$id_cms_category_parent = (int)(Tools::getValue('id_cms_category_parent'));
$way = (int)(Tools::getValue('way'));
$positions = Tools::getValue('cms_category');
if (is_array($positions))
foreach ($positions as $key => $value)
{
$pos = explode('_', $value);
if ((isset($pos[1]) && isset($pos[2])) && ($pos[1] == $id_cms_category_parent && $pos[2] == $id_cms_category_to_move))
{
$position = $key;
break;
}
}
$cms_category = new CMSCategory($id_cms_category_to_move);
if (Validate::isLoadedObject($cms_category))
{
if (isset($position) && $cms_category->updatePosition($way, $position))
die(true);
else
die('{"hasError" : true, "errors" : "Can not update cms categories position"}');
}
else
die('{"hasError" : true, "errors" : "This cms category can not be loaded"}');
}
}