[-] FO : fixed bug #PSCFV-5826 #PSCFV-4697 Live edit only works for home page && Live edit can't load module

This commit is contained in:
vAugagneur
2012-12-04 18:29:10 +01:00
parent da5c5fb4a0
commit 712f0c3d6d
2 changed files with 22 additions and 25 deletions
+1 -1
View File
@@ -418,7 +418,7 @@ class HookCore extends ObjectModel
else if ($hook_retro_callable) else if ($hook_retro_callable)
$display = $moduleInstance->{'hook'.$retro_hook_name}($hook_args); $display = $moduleInstance->{'hook'.$retro_hook_name}($hook_args);
// Live edit // Live edit
if ($array_return && $array['live_edit'] && Tools::isSubmit('live_edit') && Tools::getValue('ad') && Tools::getValue('liveToken') == Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee'))) if (!$array_return && $array['live_edit'] && Tools::isSubmit('live_edit') && Tools::getValue('ad') && Tools::getValue('liveToken') == Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee')))
{ {
$live_edit = true; $live_edit = true;
$output .= self::wrapLiveEdit($display, $moduleInstance, $array['id_hook']); $output .= self::wrapLiveEdit($display, $moduleInstance, $array['id_hook']);
+21 -24
View File
@@ -396,10 +396,8 @@ class FrontControllerCore extends Controller
if ($this->restrictedCountry) if ($this->restrictedCountry)
$this->displayRestrictedCountryPage(); $this->displayRestrictedCountryPage();
//live edit if (Tools::isSubmit('live_edit') && !$this->checkLiveEditAccess())
if (Tools::isSubmit('live_edit') && ($ad = Tools::getValue('ad')) && Tools::getValue('liveToken') == Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee'))) die(Tools::displayError());
if (!is_dir(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$ad))
die(Tools::displayError());
$this->iso = $iso; $this->iso = $iso;
$this->setMedia(); $this->setMedia();
@@ -407,7 +405,7 @@ class FrontControllerCore extends Controller
$this->context->cart = $cart; $this->context->cart = $cart;
$this->context->currency = $currency; $this->context->currency = $currency;
} }
public function postProcess() public function postProcess()
{ {
/*// For retrocompatibility with versions before 1.5, preProcess support will be removed on next release /*// For retrocompatibility with versions before 1.5, preProcess support will be removed on next release
@@ -543,23 +541,24 @@ class FrontControllerCore extends Controller
'display_header' => $this->display_header, 'display_header' => $this->display_header,
'display_footer' => $this->display_footer, 'display_footer' => $this->display_footer,
)); ));
$live_edit_content = '';
// Don't use live edit if on mobile device // Don't use live edit if on mobile device
if ($this->context->getMobileDevice() == false && Tools::isSubmit('live_edit')) if (!$this->context->getMobileDevice() && $this->checkLiveEditAccess())
$this->context->smarty->assign('live_edit', $this->getLiveEditFooter()); $live_edit_content = $this->getLiveEditFooter();
$layout = $this->getLayout(); $layout = $this->getLayout();
if ($layout) if ($layout)
{ {
if ($this->template) if ($this->template)
$this->context->smarty->assign('template', $this->context->smarty->fetch($this->template)); $this->context->smarty->assign('template', $this->context->smarty->fetch($this->template).$live_edit_content);
else // For retrocompatibility with 1.4 controller else // For retrocompatibility with 1.4 controller
{ {
ob_start(); ob_start();
$this->displayContent(); $this->displayContent();
$template = ob_get_contents(); $template = ob_get_contents();
ob_clean(); ob_clean();
$this->context->smarty->assign('template', $template); $this->context->smarty->assign('template', $template.$live_edit_content);
} }
$this->smartyOutputContent($layout); $this->smartyOutputContent($layout);
} }
@@ -577,16 +576,9 @@ class FrontControllerCore extends Controller
if ($this->display_footer) if ($this->display_footer)
$this->smartyOutputContent(_PS_THEME_DIR_.'footer.tpl'); $this->smartyOutputContent(_PS_THEME_DIR_.'footer.tpl');
// live edit
if (Tools::isSubmit('live_edit') && ($ad = Tools::getValue('ad')) && Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee')))
{
$this->context->smarty->assign(array('ad' => $ad, 'live_edit' => true));
$this->smartyOutputContent(_PS_ALL_THEMES_DIR_.'live_edit.tpl');
}
// END - 1.4 retrocompatibility - will be removed in 1.6 // END - 1.4 retrocompatibility - will be removed in 1.6
} }
return true; return true;
} }
@@ -793,16 +785,21 @@ class FrontControllerCore extends Controller
)); ));
} }
public function checkLiveEditAccess()
{
$live_token = Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee'));
$ad = Tools::getValue('ad');
return Tools::isSubmit('live_edit') && $ad && Tools::getValue('liveToken') == $live_token && is_dir(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$ad);
}
public function getLiveEditFooter() public function getLiveEditFooter()
{ {
if (Tools::isSubmit('live_edit') if ($this->checkLiveEditAccess())
&& ($ad = Tools::getValue('ad'))
&& Tools::getAdminToken('AdminModulesPositions'.(int)Tab::getIdFromClassName('AdminModulesPositions').(int)Tools::getValue('id_employee')))
{ {
$data = $this->context->smarty->createData(); $data = $this->context->smarty->createData();
$data->assign(array( $data->assign(array(
'ad' => $ad, 'ad' => Tools::getValue('ad'),
'live_edit' => true, 'live_edit' => true,
'hook_list' => Hook::$executed_hooks, 'hook_list' => Hook::$executed_hooks,
'id_shop' => $this->context->shop->id 'id_shop' => $this->context->shop->id