-
\ No newline at end of file
diff --git a/admin-dev/themes/default/template/layout.tpl b/admin-dev/themes/default/template/layout.tpl
index 3edb3edb1..485b35d07 100644
--- a/admin-dev/themes/default/template/layout.tpl
+++ b/admin-dev/themes/default/template/layout.tpl
@@ -22,7 +22,7 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
-
+{$header}
{if isset($conf)}
{$conf}
@@ -91,3 +91,4 @@
{if !$bootstrap}
{/if}
{$page}
{if !$bootstrap}
{/if}
+{$footer}
\ No newline at end of file
diff --git a/classes/Dispatcher.php b/classes/Dispatcher.php
index f9b114897..1dc7f39a8 100644
--- a/classes/Dispatcher.php
+++ b/classes/Dispatcher.php
@@ -396,8 +396,10 @@ class DispatcherCore
$this->default_routes[$route] = array_merge($this->default_routes[$route], $route_details);
}
+ if (!in_array($context->language->id, $languages = Language::getLanguages()))
+ $languages[] = (int)$context->language->id;
// Set default routes
- foreach (Language::getLanguages() as $lang)
+ foreach ($languages as $lang)
foreach ($this->default_routes as $id => $route)
$this->addRoute(
$id,
@@ -441,7 +443,10 @@ class DispatcherCore
// Load custom routes
foreach ($this->default_routes as $route_id => $route_data)
if ($custom_route = Configuration::get('PS_ROUTE_'.$route_id, null, null, $id_shop))
- foreach (Language::getLanguages() as $lang)
+ {
+ if (!in_array($context->language->id, $languages = Language::getLanguages()))
+ $languages[] = (int)$context->language->id;
+ foreach ($languages as $lang)
$this->addRoute(
$route_id,
$custom_route,
@@ -451,6 +456,7 @@ class DispatcherCore
isset($route_data['params']) ? $route_data['params'] : array(),
$id_shop
);
+ }
}
}
@@ -593,7 +599,7 @@ class DispatcherCore
$id_lang = (int)Context::getContext()->language->id;
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
-
+
if (!isset($this->routes[$id_shop]))
$this->loadRoutes($id_shop);
diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php
index 0ce276087..5b85c4e81 100644
--- a/classes/controller/AdminController.php
+++ b/classes/controller/AdminController.php
@@ -682,6 +682,7 @@ class AdminControllerCore extends Controller
'export_content' => $content
)
);
+
$this->layout = 'layout-export.tpl';
}
@@ -1372,12 +1373,14 @@ class AdminControllerCore extends Controller
foreach (array('errors', 'warnings', 'informations', 'confirmations') as $type)
$this->context->smarty->assign($type, $this->json ? Tools::jsonEncode(array_unique($this->$type)) : array_unique($this->$type));
- $this->context->smarty->assign('page', $this->json ? Tools::jsonEncode($page) : $page);
-
- if (!$this->ajax)
- $this->smartyOutputContent(array($header_tpl, $this->layout, $footer_tpl));
- else
- $this->smartyOutputContent($this->layout);
+ $this->context->smarty->assign(array(
+ 'page' => $this->json ? Tools::jsonEncode($page) : $page,
+ 'header' => $this->context->smarty->fetch($header_tpl),
+ 'footer' => $this->context->smarty->fetch($footer_tpl)
+ )
+ );
+
+ $this->smartyOutputContent($this->layout);
}
/**
diff --git a/classes/helper/HelperForm.php b/classes/helper/HelperForm.php
index 410ec0c48..14cd889be 100644
--- a/classes/helper/HelperForm.php
+++ b/classes/helper/HelperForm.php
@@ -118,13 +118,20 @@ class HelperFormCore extends Helper
$uploader->setUrl(isset($params['url'])?$params['url']:null);
$uploader->setMultiple(isset($params['multiple'])?$params['multiple']:false);
$uploader->setUseAjax(isset($params['ajax'])?$params['ajax']:false);
- $uploader->setDisplayImage(isset($params['display_image'])?$params['display_image']:false);
- $uploader->setImage(isset($params['image'])?$params['image']:null);
+
+ if (isset($params['images']))
+ $uploader->setImages($params['images']);
+ elseif (isset($params['image'])) // Use for retrocompatibility
+ $uploader->setImages(array(
+ 0 => array(
+ 'image' => isset($params['image'])?$params['image']:null,
+ 'size' => isset($params['size'])?$params['size']:null,
+ 'delete_url' => isset($params['delete_url'])?$params['delete_url']:null
+ )));
+
$uploader->setThumb(isset($params['thumb'])?$params['thumb']:null);
- $uploader->setSize(isset($params['size'])?$params['size']:null);
$uploader->setFile(isset($params['file'])?$params['file']:null);
$uploader->setTitle(isset($params['title'])?$params['title']:null);
- $uploader->setDeleteUrl(isset($params['delete_url'])?$params['delete_url']:null);
$params['file'] = $uploader->render();
break;
diff --git a/classes/helper/HelperOptions.php b/classes/helper/HelperOptions.php
index 138e18c7a..ee77f9b0a 100644
--- a/classes/helper/HelperOptions.php
+++ b/classes/helper/HelperOptions.php
@@ -104,16 +104,22 @@ class HelperOptionsCore extends Helper
$uploader->setUrl(isset($field['url'])?$field['url']:null);
$uploader->setMultiple(isset($field['multiple'])?$field['multiple']:false);
$uploader->setUseAjax(isset($field['ajax'])?$field['ajax']:false);
- $uploader->setDisplayImage(isset($field['display_image'])?$field['display_image']:false);
- $uploader->setImage(isset($field['image'])?$field['image']:null);
- $uploader->setThumb(isset($field['thumb'])?$field['thumb']:null);
- $uploader->setSize(isset($field['size'])?$field['size']:null);
- $uploader->setTitle(isset($field['title'])?$field['title']:null);
- $uploader->setDeleteUrl(isset($field['delete_url'])?$field['delete_url']:null);
+ if (isset($field['images']))
+ $uploader->setImages($field['images']);
+ elseif (isset($field['image'])) // Use for retrocompatibility
+ $uploader->setImages(array(
+ 0 => array(
+ 'image' => isset($field['image'])?$field['image']:null,
+ 'size' => isset($field['size'])?$field['size']:null,
+ 'delete_url' => isset($field['delete_url'])?$field['delete_url']:null
+ )));
+
+ $uploader->setThumb(isset($field['thumb'])?$field['thumb']:null);
+ $uploader->setTitle(isset($field['title'])?$field['title']:null);
$field['file'] = $uploader->render();
}
-
+
// Cast options values if specified
if ($field['type'] == 'select' && isset($field['cast']))
foreach ($field['list'] as $option_key => $option)
diff --git a/classes/helper/HelperUploader.php b/classes/helper/HelperUploader.php
index 08db62384..70689fa50 100644
--- a/classes/helper/HelperUploader.php
+++ b/classes/helper/HelperUploader.php
@@ -31,13 +31,10 @@ class HelperUploaderCore extends Uploader
const DEFAULT_AJAX_TEMPLATE = 'ajax.tpl';
private $_context;
- private $_delete_url;
- private $_display_image;
private $_id;
- private $_image;
+ private $_images;
private $_name;
private $_multiple;
- private $_size;
private $_file;
protected $_template;
private $_template_directory;
@@ -60,23 +57,6 @@ class HelperUploaderCore extends Uploader
return $this->_context;
}
- public function setDeleteUrl($value)
- {
- $this->_delete_url = $value;
- return $this;
- }
-
- public function getDeleteUrl()
- {
- return $this->_delete_url;
- }
-
- public function setDisplayImage($value)
- {
- $this->_display_image = $value;
- return $this;
- }
-
public function setId($value)
{
$this->_id = (string)$value;
@@ -91,15 +71,18 @@ class HelperUploaderCore extends Uploader
return $this->_id;
}
- public function setImage($value)
+ public function setImages($value)
{
- $this->_image = $value;
+ $this->_images = $value;
return $this;
}
- public function getImage()
+ public function getImages()
{
- return $this->_image;
+ if (!isset($this->_images))
+ $this->_images = array();
+
+ return $this->_images;
}
public function setName($value)
@@ -119,17 +102,6 @@ class HelperUploaderCore extends Uploader
return $this;
}
- public function setSize($value)
- {
- $this->_size = $value;
- return $this;
- }
-
- public function getSize()
- {
- return $this->_size;
- }
-
public function setTemplate($value)
{
$this->_template = $value;
@@ -246,11 +218,6 @@ class HelperUploaderCore extends Uploader
return $this;
}
- public function displayImage()
- {
- return (isset($this->_display_image) && $this->_display_image);
- }
-
public function isMultiple()
{
return (isset($this->_multiple) && $this->_multiple);
@@ -297,7 +264,6 @@ class HelperUploaderCore extends Uploader
$this->getContext()->controller->addJs(__PS_BASE_URI__.'/js/vendor/spin.js');
$this->getContext()->controller->addJs(__PS_BASE_URI__.'/js/vendor/ladda.js');
-
}
if ($this->useAjax())
@@ -312,12 +278,9 @@ class HelperUploaderCore extends Uploader
'name' => $this->getName(),
'url' => $this->getUrl(),
'multiple' => $this->isMultiple(),
- 'display_image' => $this->displayImage(),
- 'image' => $this->getImage(),
+ 'images' => $this->getImages(),
'thumb' => $this->getThumb(),
'file' => $this->getFile(),
- 'size' => $this->getSize(),
- 'delete_url' => $this->getDeleteUrl(),
'title' => $this->getTitle()
));
diff --git a/controllers/admin/AdminCmsController.php b/controllers/admin/AdminCmsController.php
index 5e7ad50ca..3c8ce8b65 100644
--- a/controllers/admin/AdminCmsController.php
+++ b/controllers/admin/AdminCmsController.php
@@ -70,26 +70,33 @@ class AdminCmsControllerCore extends AdminController
parent::__construct();
}
+ public function initPageHeaderToolbar()
+ {
+ $this->page_header_toolbar_btn['save-and-preview'] = array(
+ 'href' => '#',
+ 'desc' => $this->l('Save and preview')
+ );
+ $this->page_header_toolbar_btn['save-and-stay'] = array(
+ 'short' => 'SaveAndStay',
+ 'href' => '#',
+ 'desc' => $this->l('Save and stay'),
+ );
+
+ return parent::initPageHeaderToolbar();
+ }
+
public function renderForm()
{
if (!$this->loadObject(true))
return;
-
+
if (Validate::isLoadedObject($this->object))
$this->display = 'edit';
else
$this->display = 'add';
- $this->toolbar_btn['save-and-preview'] = array(
- 'href' => '#',
- 'desc' => $this->l('Save and preview')
- );
- $this->toolbar_btn['save-and-stay'] = array(
- 'short' => 'SaveAndStay',
- 'href' => '#',
- 'desc' => $this->l('Save and stay'),
- );
$this->initToolbar();
+ $this->initPageHeaderToolbar();
$categories = CMSCategory::getCategories($this->context->language->id, false);
$html_categories = CMSCategory::recurseCMSCategory($categories, $categories[0][1], 1, $this->getFieldValue($this->object, 'id_cms_category'), 1);
@@ -226,16 +233,7 @@ class AdminCmsControllerCore extends AdminController
public function postProcess()
{
if (Tools::isSubmit('viewcms') && ($id_cms = (int)Tools::getValue('id_cms')) && ($cms = new CMS($id_cms, $this->context->language->id)) && Validate::isLoadedObject($cms))
- {
- $redir = $this->context->link->getCMSLink($cms);
- if (!$cms->active)
- {
- $admin_dir = dirname($_SERVER['PHP_SELF']);
- $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
- $redir .= '?adtoken='.Tools::getAdminTokenLite('AdminCmsContent').'&ad='.$admin_dir.'&id_employee='.(int)$this->context->employee->id;
- }
- Tools::redirectAdmin($redir);
- }
+ $this->redirect_after = $this->getPreviewUrl($cms);
elseif (Tools::isSubmit('deletecms'))
{
if (Tools::getValue('id_cms') == Configuration::get('PS_CONDITIONS_CMS_ID'))
@@ -301,27 +299,7 @@ class AdminCmsControllerCore extends AdminController
$this->updateAssoShop($cms->id);
}
if (Tools::isSubmit('submitAddcmsAndPreview'))
- {
- $alias = $this->getFieldValue($cms, 'link_rewrite', $this->context->language->id);
- $preview_url = $this->context->link->getCMSLink($cms, $alias, $this->context->language->id);
-
- if (!$cms->active)
- {
- $admin_dir = dirname($_SERVER['PHP_SELF']);
- $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
- $params = http_build_query(array(
- 'adtoken' => Tools::getAdminTokenLite('AdminCmsContent'),
- 'ad' => $admin_dir,
- 'id_employee' => (int)$this->context->employee->id)
- );
- if (Configuration::get('PS_REWRITING_SETTINGS'))
- $params = '?'.$params;
- else
- $params = '&'.$params;
- $preview_url .= $cms->active ? '' : $params;
- }
- Tools::redirectAdmin($preview_url);
- }
+ $this->redirect_after = $this->previewUrl($cms);
elseif (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$cms->id.'&conf=4&update'.$this->table.'&token='.Tools::getAdminTokenLite('AdminCmsContent'));
else
@@ -380,6 +358,23 @@ class AdminCmsControllerCore extends AdminController
else
parent::postProcess(true);
}
+
+ public function getPreviewUrl(CMS $cms)
+ {
+ $preview_url = $this->context->link->getCMSLink($cms, null, null, $this->context->language->id);
+ if (!$cms->active)
+ {
+ $params = http_build_query(array(
+ 'adtoken' => Tools::getAdminTokenLite('AdminCmsContent'),
+ 'ad' => substr(dirname($_SERVER['PHP_SELF']), strrpos(dirname($_SERVER['PHP_SELF']), '/') + 1),
+ 'id_employee' => (int)$this->context->employee->id
+ )
+ );
+ $preview_url .= (strpos($preview_url, '?') === false ? '?' : '&').$params;
+ }
+
+ return $preview_url;
+ }
}
diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php
index f29da72a8..c43f5094d 100644
--- a/controllers/admin/AdminProductsController.php
+++ b/controllers/admin/AdminProductsController.php
@@ -2430,11 +2430,58 @@ class AdminProductsControllerCore extends AdminController
{
if (empty($this->display))
$this->page_header_toolbar_btn['new_product'] = array(
- 'href' => self::$currentIndex.'&addproduct&token='.$this->token,
- 'desc' => $this->l('Add new product'),
- 'icon' => 'process-icon-new'
- );
+ 'href' => self::$currentIndex.'&addproduct&token='.$this->token,
+ 'desc' => $this->l('Add new product'),
+ 'icon' => 'process-icon-new'
+ );
+ if ($this->display == 'edit' || $this->display == 'add')
+ {
+ if (($product = $this->loadObject(true)))
+ {
+ // adding button for duplicate this product
+ if ($this->tabAccess['add'] && $this->display != 'add')
+ $this->page_header_toolbar_btn['duplicate'] = array(
+ 'short' => 'Duplicate',
+ 'desc' => $this->l('Duplicate'),
+ 'confirm' => 1,
+ 'js' => 'if (confirm(\''.$this->l('Also copy images').' ?\')) document.location = \''.$this->context->link->getAdminLink('AdminProducts').'&id_product='.(int)$product->id.'&duplicateproduct\'; else document.location = \''.$this->context->link->getAdminLink('AdminProducts').'&id_product='.(int)$product->id.'&duplicateproduct&noimage=1\';'
+ );
+ // adding button for preview this product
+ if ($url_preview = $this->getPreviewUrl($product))
+ $this->page_header_toolbar_btn['preview'] = array(
+ 'short' => 'Preview',
+ 'href' => $url_preview,
+ 'desc' => $this->l('Preview'),
+ 'target' => true,
+ 'class' => 'previewUrl'
+ );
+
+ // adding button for preview this product statistics
+ if (file_exists(_PS_MODULE_DIR_.'statsproduct/statsproduct.php') && $this->display != 'add')
+ $this->page_header_toolbar_btn['stats'] = array(
+ 'short' => 'Statistics',
+ 'href' => $this->context->link->getAdminLink('AdminStats').'&module=statsproduct&id_product='.(int)$product->id,
+ 'desc' => $this->l('Product sales'),
+ );
+
+ // adding button for delete this product
+ if ($this->tabAccess['delete'] && $this->display != 'add')
+ $this->page_header_toolbar_btn['delete'] = array(
+ 'short' => 'Delete',
+ 'href' => $this->context->link->getAdminLink('AdminProducts').'&id_product='.(int)$product->id.'&deleteproduct',
+ 'desc' => $this->l('Delete this product'),
+ 'confirm' => 1,
+ 'js' => 'if (confirm(\''.$this->l('Delete product?').'\')){return true;}else{event.preventDefault();}'
+ );
+
+ $this->page_header_toolbar_btn['save-and-stay'] = array(
+ 'short' => 'SaveAndStay',
+ 'href' => '#',
+ 'desc' => $this->l('Save and stay'),
+ );
+ }
+ }
parent::initPageHeaderToolbar();
}
@@ -2443,76 +2490,25 @@ class AdminProductsControllerCore extends AdminController
parent::initToolbar();
if ($this->display == 'edit' || $this->display == 'add')
{
- if ($product = $this->loadObject(true))
- {
- if ($this->tabAccess['edit'])
- {
- $this->toolbar_btn['save'] = array(
- 'short' => 'Save',
- 'href' => '#',
- 'desc' => $this->l('Save'),
- );
+ $this->toolbar_btn['save'] = array(
+ 'short' => 'Save',
+ 'href' => '#',
+ 'desc' => $this->l('Save'),
+ );
- $this->toolbar_btn['save-and-stay'] = array(
- 'short' => 'SaveAndStay',
- 'href' => '#',
- 'desc' => $this->l('Save and stay'),
- );
- }
+ $this->toolbar_btn['save-and-stay'] = array(
+ 'short' => 'SaveAndStay',
+ 'href' => '#',
+ 'desc' => $this->l('Save and stay'),
+ );
- if ((bool)$product->id)
- {
- // adding button for duplicate this product
- if ($this->tabAccess['add'] && $this->display != 'add')
- $this->toolbar_btn['duplicate'] = array(
- 'short' => 'Duplicate',
- 'desc' => $this->l('Duplicate'),
- 'confirm' => 1,
- 'js' => 'if (confirm(\''.$this->l('Also copy images').' ?\')) document.location = \''.$this->context->link->getAdminLink('AdminProducts').'&id_product='.(int)$product->id.'&duplicateproduct\'; else document.location = \''.$this->context->link->getAdminLink('AdminProducts').'&id_product='.(int)$product->id.'&duplicateproduct&noimage=1\';'
- );
-
- // adding button for preview this product
- if ($url_preview = $this->getPreviewUrl($product))
- $this->toolbar_btn['preview'] = array(
- 'short' => 'Preview',
- 'href' => $url_preview,
- 'desc' => $this->l('Preview'),
- 'target' => true,
- 'class' => 'previewUrl'
- );
-
- // adding button for preview this product statistics
- if (file_exists(_PS_MODULE_DIR_.'statsproduct/statsproduct.php') && $this->display != 'add')
- $this->toolbar_btn['stats'] = array(
- 'short' => 'Statistics',
- 'href' => $this->context->link->getAdminLink('AdminStats').'&module=statsproduct&id_product='.(int)$product->id,
- 'desc' => $this->l('Product sales'),
- );
-
- // adding button for adding a new combination in Combination tab
- $this->toolbar_btn['newCombination'] = array(
- 'short' => 'New combination',
- 'desc' => $this->l('New combination'),
- 'class' => 'toolbar-new'
- );
-
- // adding button for delete this product
- if ($this->tabAccess['delete'] && $this->display != 'add')
- $this->toolbar_btn['delete'] = array(
- 'short' => 'Delete',
- 'href' => $this->context->link->getAdminLink('AdminProducts').'&id_product='.(int)$product->id.'&deleteproduct',
- 'desc' => $this->l('Delete this product'),
- 'confirm' => 1,
- 'js' => 'if (confirm(\''.$this->l('Delete product?').'\')){return true;}else{event.preventDefault();}'
- );
- }
- }
+ // adding button for adding a new combination in Combination tab
+ $this->toolbar_btn['newCombination'] = array(
+ 'short' => 'New combination',
+ 'desc' => $this->l('New combination'),
+ 'class' => 'toolbar-new'
+ );
}
- else
- $this->toolbar_btn['import'] = array(
- 'href' => $this->context->link->getAdminLink('AdminImport', true).'&import_type=products',
- 'desc' => $this->l('Import')
- );
$this->context->smarty->assign('toolbar_scroll', 1);
$this->context->smarty->assign('show_toolbar', 1);