fix frontcontroller

This commit is contained in:
root 2017-06-19 17:28:07 +02:00
parent cae2d21ea2
commit 8c13f2ddba

View File

@ -46,7 +46,7 @@ class FrontController extends FrontControllerCore
if ($this->php_self == 'password') {
$this->php_self = 'index';
$this->template = _PS_THEME_DIR_.'password.tpl';
}
}
if (!in_array($this->php_self, ['index', 'password'])
|| Tools::getValue('submitAccount')
|| Tools::getValue('SubmitCreate')) {
@ -145,182 +145,40 @@ class FrontController extends FrontControllerCore
}
return true;
}
public function getLayout()
{
global $cookie;
// public function display()
// {
// global $cookie;
// if (empty($cookie->tmp)) {
// $cookie->tmp = serialize($this->errors);
// }
// if (defined('ANTADIS_CHECK_GROUPS') && ANTADIS_CHECK_GROUPS) {
// $id_customer_group = Configuration::get('PS_CUSTOMER_GROUP');
// if ($id_customer_group!==FALSE && (int)$id_customer_group>0) {
// $sql = 'SELECT COUNT(a.id_customer)
// FROM `'._DB_PREFIX_.'customer` a
// WHERE a.`id_customer` NOT IN (
// SELECT b.id_customer
// FROM `'._DB_PREFIX_.'customer_group` b
// WHERE b.id_group = '.(int)$id_customer_group.'
// )';
// $nb_customer_not_in_default_group = Db::getInstance()->getValue($sql);
// if ($nb_customer_not_in_default_group!==FALSE && $nb_customer_not_in_default_group>0) {
// error_log(
// 'check : '.$nb_customer_not_in_default_group.' customers are not associated with default group id : '.$id_customer_group,
// 0
// );
// error_log(
// 'check : '.$nb_customer_not_in_default_group.' customers are not associated with default group id : '.$id_customer_group,
// 1,
// 'figaro+levestcheck@antadis.fr'
// );
// }
// }
// }
$entity = $this->php_self;
if (!$cookie->isLogged()
&& (!Context::getContext()->controller instanceOf addCustomerFormModuleFrontController)) {
if (!in_array($this->php_self, ['index', 'password']) || Tools::getValue('submitAccount') || Tools::getValue('SubmitCreate')) {
Tools::redirect('index');
exit;
}
}
// /*
// // * Force assign template
// // */
// if (!$cookie->isLogged()
// && Context::getContext()->controller->module->name != 'addcustomer') {
// $this->template = _PS_THEME_DIR_.'authentication.tpl';
// if ($this->php_self == 'password') {
// $this->php_self = 'index';
// $this->template = _PS_THEME_DIR_.'password.tpl';
// }
// if (!in_array($this->php_self, ['index', 'password'])
// || Tools::getValue('submitAccount')
// || Tools::getValue('SubmitCreate')) {
// Tools::redirect('index');
// exit;
// }
// }
$id_item = (int)Tools::getValue('id_'.$entity);
// Tools::safePostVars();
$layout_dir = $this->getThemeDir();
$layout_override_dir = $this->getOverrideThemeDir();
// // assign css_files and js_files at the very last time
// if ((Configuration::get('PS_CSS_THEME_CACHE') || Configuration::get('PS_JS_THEME_CACHE')) && is_writable(_PS_THEME_DIR_.'cache'))
// {
// // CSS compressor management
// if (Configuration::get('PS_CSS_THEME_CACHE'))
// $this->css_files = Media::cccCss($this->css_files);
// //JS compressor management
// if (Configuration::get('PS_JS_THEME_CACHE') && !$this->useMobileTheme())
// $this->js_files = Media::cccJs($this->js_files);
// }
$layout = false;
if ($entity) {
if ($id_item > 0 && file_exists($layout_override_dir.'layout-'.$entity.'-'.$id_item.'.tpl')) {
$layout = $layout_override_dir.'layout-'.$entity.'-'.$id_item.'.tpl';
} elseif (file_exists($layout_override_dir.'layout-'.$entity.'.tpl')) {
$layout = $layout_override_dir.'layout-'.$entity.'.tpl';
}
}
// /* Override destroy all css */
// $this->css_files = array();
if (!$layout && file_exists($layout_dir.'layout.tpl')) {
$layout = $layout_dir.'layout.tpl';
}
// Override Add real css
// $this->css_files[_THEME_CSS_DIR_.'strapivarious.css?v='.filemtime($this->getThemeDir().'css/strapivarious.css')] = 'all';
// $this->css_files[_THEME_CSS_DIR_.'k2000.css?v='.filemtime($this->getThemeDir().'css/k2000.css')] = 'all';
// $this->css_files[_THEME_CSS_DIR_.'global.css?v='.filemtime($this->getThemeDir().'css/global.css')] = 'all';
// if (@filemtime($this->getThemeDir().'css/autoload/'))
// {
// foreach (scandir($this->getThemeDir().'css/autoload', 0) as $file)
// {
// if (preg_match('/^[^.].*\.css$/', $file))
// {
// $this->css_files[_THEME_CSS_DIR_.'autoload/'.$file.'?v='.filemtime($this->getThemeDir().'css/autoload/'.$file)] = 'all';
// }
// }
// }
// foreach($this->js_files as $key => $file)
// {
// if(strpos($file, _THEME_JS_DIR_) === false)
// {
// continue;
// }
// $this->js_files[$key] = $file.'?v='.filemtime($this->getThemeDir().'js/'.str_replace(_THEME_JS_DIR_, '', $file));
// }
// /****************************/
// $this->context->smarty->assign(array(
// 'css_files' => $this->css_files,
// 'js_files' => ($this->getLayout() && (bool)Configuration::get('PS_JS_DEFER')) ? array() : $this->js_files,
// 'js_defer' => (bool)Configuration::get('PS_JS_DEFER'),
// 'errors' => (!empty(unserialize($cookie->tmp))) ? unserialize($cookie->tmp) : $this->errors,
// 'display_header' => $this->display_header,
// 'display_footer' => $this->display_footer,
// ));
// unset($cookie->tmp);
// $this->context->smarty->assign('customer', Context::getContext()->customer);
// $layout = $this->getLayout();
// if ($layout)
// {
// if ($this->template)
// $template = $this->context->smarty->fetch($this->template);
// else // For retrocompatibility with 1.4 controller
// {
// ob_start();
// $this->displayContent();
// $template = ob_get_contents();
// ob_clean();
// }
// $template = $this->context->smarty->assign('template', $template);
// $this->smartyOutputContent($layout);
// }
// else
// {
// Tools::displayAsDeprecated('layout.tpl is missing in your theme directory');
// if ($this->display_header)
// $this->smartyOutputContent(_PS_THEME_DIR_.'header.tpl');
// if ($this->template)
// $this->smartyOutputContent($this->template);
// else // For retrocompatibility with 1.4 controller
// $this->displayContent();
// if ($this->display_footer)
// $this->smartyOutputContent(_PS_THEME_DIR_.'footer.tpl');
// }
// return true;
// }
// public function getLayout()
// {
// global $cookie;
// $entity = $this->php_self;
// if (!$cookie->isLogged()) {
// if (!in_array($this->php_self, ['index', 'password']) || Tools::getValue('submitAccount') || Tools::getValue('SubmitCreate')) {
// Tools::redirect('index');
// exit;
// }
// }
// $id_item = (int)Tools::getValue('id_'.$entity);
// $layout_dir = $this->getThemeDir();
// $layout_override_dir = $this->getOverrideThemeDir();
// $layout = false;
// if ($entity) {
// if ($id_item > 0 && file_exists($layout_override_dir.'layout-'.$entity.'-'.$id_item.'.tpl')) {
// $layout = $layout_override_dir.'layout-'.$entity.'-'.$id_item.'.tpl';
// } elseif (file_exists($layout_override_dir.'layout-'.$entity.'.tpl')) {
// $layout = $layout_override_dir.'layout-'.$entity.'.tpl';
// }
// }
// if (!$layout && file_exists($layout_dir.'layout.tpl')) {
// $layout = $layout_dir.'layout.tpl';
// }
// return $layout;
// }
return $layout;
}
public function addColorsToProductList(&$products)
{