Merge branch 'bootstrap' of https://github.com/PrestaShop/PrestaShop into bootstrap

Conflicts:
	classes/helper/HelperForm.php
	classes/helper/HelperUploader.php
This commit is contained in:
Damien Metzger
2013-10-25 18:58:07 +02:00
14 changed files with 238 additions and 238 deletions
+36 -41
View File
@@ -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;
}
}
+67 -71
View File
@@ -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);