From 092a4bd451639264dbd8029e9cc838aa2c99d173 Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Thu, 19 Apr 2012 14:34:51 +0000 Subject: [PATCH] [-] MO : fix bug #PSTEST-1178 - block CMS position drag and drop was not implemented --- js/admin-dnd.js | 25 +++++++------------------ modules/blockcms/blockcms.php | 24 +++++++++++++++++++++--- modules/blockcms/translations/fr.php | 2 +- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/js/admin-dnd.js b/js/admin-dnd.js index 6d7b226e5..be810c293 100644 --- a/js/admin-dnd.js +++ b/js/admin-dnd.js @@ -50,24 +50,12 @@ function initTableDnD(table) var tableDrag = table; var params = ''; - if (table.id == 'cms_block_0') + if (table.id == 'cms_block_0' || table.id == 'cms_block_1') params = { - ajaxCMSBlockPositions: true, - id_cms_block: ids[1], - position: ids[2], - way: way, - token: token + updatePositions: true, + configure: 'blockcms' }; - if (table.id == 'cms_block_1') - params = { - ajaxCMSBlockPositions: true, - id_cms_block: ids[1], - position: ids[2], - way: way, - token: token - }; - - if (table.id == 'category') + else if (table.id == 'category') params = { action: 'updatePositions', id_category_parent: ids[1], @@ -118,8 +106,9 @@ function initTableDnD(table) way: way }; } - - if (!params) { + // default + else + { params = { action : 'updatePositions', id : ids[2], diff --git a/modules/blockcms/blockcms.php b/modules/blockcms/blockcms.php index 36c7051c8..eb6fb59d9 100755 --- a/modules/blockcms/blockcms.php +++ b/modules/blockcms/blockcms.php @@ -436,7 +436,7 @@ class BlockCms extends Module return $helper; } - private function changePosition() + protected function changePosition() { if (!Validate::isInt(Tools::getValue('position')) || (Tools::getValue('location') != BlockCMSModel::LEFT_COLUMN && @@ -638,8 +638,9 @@ class BlockCms extends Module else if (Tools::isSubmit('deleteBlockCMSConfirmation')) $this->_html .= $this->displayConfirmation($this->l('Deletion successful')); else if (Tools::isSubmit('id_cms_block') && Tools::isSubmit('way') && Tools::isSubmit('position') && Tools::isSubmit('location')) - $this->changePosition() - ; + $this->changePosition(); + else if (Tools::isSubmit('updatePositions')) + $this->updatePositionsDnd(); if (count($this->_errors)) { foreach ($this->_errors as $err) @@ -727,4 +728,21 @@ class BlockCms extends Module return $this->display(__FILE__, 'blockmobilecms.tpl'); } + protected function updatePositionsDnd() + { + if (Tools::getValue('cms_block_0')) + $positions = Tools::getValue('cms_block_0'); + elseif (Tools::getValue('cms_block_1')) + $positions = Tools::getValue('cms_block_1'); + else + $positions = array(); + + foreach ($positions as $position => $value) + { + $pos = explode('_', $value); + + if (isset($pos[2])) + BlockCMSModel::updateCMSBlockPosition($pos[2], $position); + } + } } diff --git a/modules/blockcms/translations/fr.php b/modules/blockcms/translations/fr.php index 75b0e56e4..23b634bfc 100755 --- a/modules/blockcms/translations/fr.php +++ b/modules/blockcms/translations/fr.php @@ -9,7 +9,7 @@ $_MODULE['<{blockcms}prestashop>blockcms_ea4788705e6873b424c65e91c2846b19'] = 'A $_MODULE['<{blockcms}prestashop>blockcms_ef61fb324d729c341ea8ab9901e23566'] = 'Ajouter un bloc'; $_MODULE['<{blockcms}prestashop>blockcms_c9cc8cce247e49bae79f15173ce97354'] = 'Enregistrer'; $_MODULE['<{blockcms}prestashop>blockcms_97390dd0b5ba7867120aee2ff22bfa38'] = 'Configuration du bloc CMS'; -$_MODULE['<{blockcms}prestashop>blockcms_790dde5207c6635d6d743102c85395c0'] = 'Blocs CNS'; +$_MODULE['<{blockcms}prestashop>blockcms_790dde5207c6635d6d743102c85395c0'] = 'Blocs CMS'; $_MODULE['<{blockcms}prestashop>blockcms_965be994da393e5aa15bd3a2444c6ccf'] = 'Configuration des liens CMS en pied de page'; $_MODULE['<{blockcms}prestashop>blockcms_2a2dc7b7f184468f25c0504a0998be51'] = 'Lien de pied de page'; $_MODULE['<{blockcms}prestashop>blockcms_0b31e765f1e9cb451319b32e84a75a9e'] = 'Sélectionnez les pages que vous souhaitez afficher dans le bloc CMS de pied de page';