// small changes on admincms
This commit is contained in:
1 parent
8be88324f9
commit
8b1f9d0560
2 files changed
+45
-44
No files matched your search
@@ -396,8 +396,10 @@ class DispatcherCore
|
|||||||
$this->default_routes[$route] = array_merge($this->default_routes[$route], $route_details);
|
$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
|
// Set default routes
|
||||||
foreach (Language::getLanguages() as $lang)
|
foreach ($languages as $lang)
|
||||||
foreach ($this->default_routes as $id => $route)
|
foreach ($this->default_routes as $id => $route)
|
||||||
$this->addRoute(
|
$this->addRoute(
|
||||||
$id,
|
$id,
|
||||||
@@ -441,7 +443,10 @@ class DispatcherCore
|
|||||||
// Load custom routes
|
// Load custom routes
|
||||||
foreach ($this->default_routes as $route_id => $route_data)
|
foreach ($this->default_routes as $route_id => $route_data)
|
||||||
if ($custom_route = Configuration::get('PS_ROUTE_'.$route_id, null, null, $id_shop))
|
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(
|
$this->addRoute(
|
||||||
$route_id,
|
$route_id,
|
||||||
$custom_route,
|
$custom_route,
|
||||||
@@ -451,6 +456,7 @@ class DispatcherCore
|
|||||||
isset($route_data['params']) ? $route_data['params'] : array(),
|
isset($route_data['params']) ? $route_data['params'] : array(),
|
||||||
$id_shop
|
$id_shop
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,7 +599,7 @@ class DispatcherCore
|
|||||||
$id_lang = (int)Context::getContext()->language->id;
|
$id_lang = (int)Context::getContext()->language->id;
|
||||||
if ($id_shop === null)
|
if ($id_shop === null)
|
||||||
$id_shop = (int)Context::getContext()->shop->id;
|
$id_shop = (int)Context::getContext()->shop->id;
|
||||||
|
|
||||||
if (!isset($this->routes[$id_shop]))
|
if (!isset($this->routes[$id_shop]))
|
||||||
$this->loadRoutes($id_shop);
|
$this->loadRoutes($id_shop);
|
||||||
|
|
||||||
|
|||||||
@@ -70,26 +70,33 @@ class AdminCmsControllerCore extends AdminController
|
|||||||
parent::__construct();
|
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()
|
public function renderForm()
|
||||||
{
|
{
|
||||||
if (!$this->loadObject(true))
|
if (!$this->loadObject(true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Validate::isLoadedObject($this->object))
|
if (Validate::isLoadedObject($this->object))
|
||||||
$this->display = 'edit';
|
$this->display = 'edit';
|
||||||
else
|
else
|
||||||
$this->display = 'add';
|
$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->initToolbar();
|
||||||
|
$this->initPageHeaderToolbar();
|
||||||
|
|
||||||
$categories = CMSCategory::getCategories($this->context->language->id, false);
|
$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);
|
$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()
|
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))
|
if (Tools::isSubmit('viewcms') && ($id_cms = (int)Tools::getValue('id_cms')) && ($cms = new CMS($id_cms, $this->context->language->id)) && Validate::isLoadedObject($cms))
|
||||||
{
|
$this->redirect_after = $this->getPreviewUrl($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);
|
|
||||||
}
|
|
||||||
elseif (Tools::isSubmit('deletecms'))
|
elseif (Tools::isSubmit('deletecms'))
|
||||||
{
|
{
|
||||||
if (Tools::getValue('id_cms') == Configuration::get('PS_CONDITIONS_CMS_ID'))
|
if (Tools::getValue('id_cms') == Configuration::get('PS_CONDITIONS_CMS_ID'))
|
||||||
@@ -301,27 +299,7 @@ class AdminCmsControllerCore extends AdminController
|
|||||||
$this->updateAssoShop($cms->id);
|
$this->updateAssoShop($cms->id);
|
||||||
}
|
}
|
||||||
if (Tools::isSubmit('submitAddcmsAndPreview'))
|
if (Tools::isSubmit('submitAddcmsAndPreview'))
|
||||||
{
|
$this->redirect_after = $this->previewUrl($cms);
|
||||||
$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);
|
|
||||||
}
|
|
||||||
elseif (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
|
elseif (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$cms->id.'&conf=4&update'.$this->table.'&token='.Tools::getAdminTokenLite('AdminCmsContent'));
|
Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$cms->id.'&conf=4&update'.$this->table.'&token='.Tools::getAdminTokenLite('AdminCmsContent'));
|
||||||
else
|
else
|
||||||
@@ -380,6 +358,23 @@ class AdminCmsControllerCore extends AdminController
|
|||||||
else
|
else
|
||||||
parent::postProcess(true);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in new issue
Block a user