From 2fd7807ae5b11abf52ad1fa6a697c7dc5cf4b76a Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Fri, 18 May 2012 15:25:33 +0000 Subject: [PATCH] // Fix bug with js inclusion git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15394 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/controller/Controller.php | 8 +- controllers/admin/AdminModulesController.php | 2 +- controllers/admin/AdminProductsController.php | 86 +++++++++---------- 3 files changed, 47 insertions(+), 49 deletions(-) diff --git a/classes/controller/Controller.php b/classes/controller/Controller.php index 9f59dca64..f8c65f73c 100644 --- a/classes/controller/Controller.php +++ b/classes/controller/Controller.php @@ -150,6 +150,10 @@ abstract class ControllerCore $this->init(); if ($this->checkAccess()) { + // setMedia MUST be called before postProcess + if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) + $this->setMedia(); + // postProcess handles ajaxProcess $this->postProcess(); @@ -157,10 +161,7 @@ abstract class ControllerCore $this->redirect(); if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) - { - $this->setMedia(); $this->initHeader(); - } if ($this->viewAccess()) $this->initContent(); @@ -266,6 +267,7 @@ abstract class ControllerCore */ public function addJS($js_uri) { +//elog($js_uri); if (is_array($js_uri)) foreach ($js_uri as $js_file) { diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index 349d2d8d3..7cd2062f0 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -618,7 +618,7 @@ class AdminModulesControllerCore extends AdminController public function postProcessCallback() { - $return = false; + $return = false; $installed_modules = array(); foreach ($this->map as $key => $method) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 3cd6ad955..e3981db96 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -1069,6 +1069,47 @@ class AdminProductsControllerCore extends AdminController { if (!$this->redirect_after) parent::postProcess(); + + if ($this->display == 'edit' || $this->display == 'add') + { + $this->addjQueryPlugin(array( + 'autocomplete', + 'tablednd', + 'thickbox', + 'ajaxfileupload', + 'date' + )); + + $this->addJqueryUI(array( + 'ui.core', + 'ui.widget', + 'ui.accordion', + 'ui.slider', + 'ui.datepicker' + )); + + $this->addJS(array( + _PS_JS_DIR_.'productTabsManager.js', + _PS_JS_DIR_.'admin-products.js', + _PS_JS_DIR_.'attributesBack.js', + _PS_JS_DIR_.'price.js', + _PS_JS_DIR_.'tiny_mce/tiny_mce.js', + _PS_JS_DIR_.'tinymce.inc.js', + _PS_JS_DIR_.'fileuploader.js', + _PS_JS_DIR_.'admin-dnd.js', + _PS_JS_DIR_.'jquery/plugins/treeview-categories/jquery.treeview-categories.js', + _PS_JS_DIR_.'jquery/plugins/treeview-categories/jquery.treeview-categories.async.js', + _PS_JS_DIR_.'jquery/plugins/treeview-categories/jquery.treeview-categories.edit.js', + _PS_JS_DIR_.'admin-categories-tree.js', + _PS_JS_DIR_.'jquery/ui/jquery.ui.progressbar.min.js', + _PS_JS_DIR_.'jquery/plugins/timepicker/jquery-ui-timepicker-addon.js' + )); + + $this->addCSS(array( + _PS_JS_DIR_.'jquery/plugins/treeview-categories/jquery.treeview-categories.css', + _PS_JS_DIR_.'jquery/plugins/timepicker/jquery-ui-timepicker-addon.css', + )); + } } /* @todo rename to processaddproductimage */ @@ -3890,51 +3931,6 @@ class AdminProductsControllerCore extends AdminController return $trad[$key]; } - public function setMedia() - { - parent::setMedia(); - if ($this->display == 'edit' || $this->display == 'add') - { - $this->addjQueryPlugin(array( - 'autocomplete', - 'tablednd', - 'thickbox', - 'ajaxfileupload', - 'date' - )); - - $this->addJqueryUI(array( - 'ui.core', - 'ui.widget', - 'ui.accordion', - 'ui.slider', - 'ui.datepicker' - )); - - $this->addJS(array( - _PS_JS_DIR_.'productTabsManager.js', - _PS_JS_DIR_.'admin-products.js', - _PS_JS_DIR_.'attributesBack.js', - _PS_JS_DIR_.'price.js', - _PS_JS_DIR_.'tiny_mce/tiny_mce.js', - _PS_JS_DIR_.'tinymce.inc.js', - _PS_JS_DIR_.'fileuploader.js', - _PS_JS_DIR_.'admin-dnd.js', - _PS_JS_DIR_.'jquery/plugins/treeview-categories/jquery.treeview-categories.js', - _PS_JS_DIR_.'jquery/plugins/treeview-categories/jquery.treeview-categories.async.js', - _PS_JS_DIR_.'jquery/plugins/treeview-categories/jquery.treeview-categories.edit.js', - _PS_JS_DIR_.'admin-categories-tree.js', - _PS_JS_DIR_.'jquery/ui/jquery.ui.progressbar.min.js', - _PS_JS_DIR_.'jquery/plugins/timepicker/jquery-ui-timepicker-addon.js' - )); - - $this->addCSS(array( - _PS_JS_DIR_.'jquery/plugins/treeview-categories/jquery.treeview-categories.css', - _PS_JS_DIR_.'jquery/plugins/timepicker/jquery-ui-timepicker-addon.css', - )); - } - } - protected function _displayUnavailableProductWarning() { $content = '