202 lines
5.0 KiB
PHP
202 lines
5.0 KiB
PHP
<?php
|
|
require_once dirname(__FILE__).'/../../classes/seourl.php';
|
|
|
|
class AdminSeoUrlController extends ModuleAdminController {
|
|
|
|
public static $list_type = array(
|
|
ManageSeoUrl::TYPE_CATEGORY => 'Catégorie',
|
|
ManageSeoUrl::TYPE_PRODUCT => 'Produit',
|
|
ManageSeoUrl::TYPE_MANUFACTURER => 'Fabricants',
|
|
ManageSeoUrl::TYPE_CATEGORY_CMS => 'Catégorie CMS',
|
|
ManageSeoUrl::TYPE_POST_CMS => 'Article CMS',
|
|
ManageSeoUrl::TYPE_POST_EDITO => 'Edito',
|
|
ManageSeoUrl::TYPE_CMS => 'CMS',
|
|
ManageSeoUrl::TYPE_301 => 'Redirection 301',
|
|
ManageSeoUrl::TYPE_STORE_HOME => 'Page accueil boutique',
|
|
ManageSeoUrl::TYPE_HOME_EDITO => 'Page accueil edito',
|
|
ManageSeoUrl::TYPE_VIDEO => 'Page vidéo'
|
|
);
|
|
|
|
public function __construct() {
|
|
$this->table = 'seourl';
|
|
$this->className = 'ManageSeoUrl';
|
|
$this->identifier = 'id_seourl';
|
|
$this->deleted = FALSE;
|
|
$this->lang = TRUE;
|
|
$this->bootstrap = TRUE;
|
|
$this->context = Context::getContext();
|
|
|
|
parent::__construct();
|
|
$this->actions = array('edit','delete');
|
|
|
|
$this->fields_list = array(
|
|
'id_seourl' => array(
|
|
'title' => 'ID',
|
|
'width' => 25
|
|
),
|
|
'link_rewrite' => array(
|
|
'title' => 'Url rewrite',
|
|
),
|
|
'type' => array(
|
|
'title' => 'Type',
|
|
'align' => 'center',
|
|
'callback' => 'getType',
|
|
'type' => 'select',
|
|
'list' => self::$list_type,
|
|
'filter_key' => 'a!type'
|
|
),
|
|
'id_element' => array(
|
|
'title' => 'Element (id)',
|
|
'align' => 'center',
|
|
)
|
|
);
|
|
|
|
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL){
|
|
$this->_join .= 'JOIN `'._DB_PREFIX_.'seourl_shop` acs ON a.`id_seourl` = acs.`id_seourl` AND acs.`id_shop` IN ('.implode(', ', Shop::getContextListShopID()).')';
|
|
$this->_group .= 'GROUP BY acs.`id_seourl`';
|
|
}
|
|
|
|
}
|
|
|
|
public function initContent(){
|
|
$context = Context::getContext();
|
|
parent::initContent();
|
|
}
|
|
|
|
public function initPageHeaderToolbar()
|
|
{
|
|
parent::initPageHeaderToolbar();
|
|
$context = Context::getContext();
|
|
}
|
|
|
|
public function getType($data, $elem){
|
|
if(isset(self::$list_type[$data])){
|
|
return self::$list_type[$data];
|
|
}else{
|
|
return "Inconnu";
|
|
}
|
|
}
|
|
|
|
public function renderForm(){
|
|
$options = array(
|
|
0 => array(
|
|
'id_type' => ManageSeoUrl::TYPE_CATEGORY,
|
|
'type' => $this->l('Catégorie'),
|
|
),
|
|
1 => array(
|
|
'id_type' => ManageSeoUrl::TYPE_PRODUCT,
|
|
'type' => $this->l('Produit')
|
|
),
|
|
2 => array(
|
|
'id_type' => ManageSeoUrl::TYPE_MANUFACTURER,
|
|
'type' => $this->l('Fabricants')
|
|
),
|
|
3 => array(
|
|
'id_type' => ManageSeoUrl::TYPE_CATEGORY_CMS,
|
|
'type' => $this->l('Catégorie CMS')
|
|
),
|
|
4 => array(
|
|
'id_type' => ManageSeoUrl::TYPE_POST_CMS,
|
|
'type' => $this->l('Article CMS')
|
|
),
|
|
5 => array(
|
|
'id_type' => ManageSeoUrl::TYPE_POST_EDITO,
|
|
'type' => $this->l('Edito')
|
|
),
|
|
6 => array(
|
|
'id_type' => ManageSeoUrl::TYPE_CMS,
|
|
'type' => $this->l('CMS')
|
|
),
|
|
7 => array(
|
|
'id_type' => ManageSeoUrl::TYPE_301,
|
|
'type' => $this->l('Redirection 301')
|
|
),
|
|
8 => array(
|
|
'id_type' => ManageSeoUrl::TYPE_STORE_HOME,
|
|
'type' => $this->l('Accueil boutique')
|
|
),
|
|
9 => array(
|
|
'id_type' => ManageSeoUrl::TYPE_HOME_EDITO,
|
|
'type' => $this->l('Accueil edito')
|
|
),
|
|
10 => array(
|
|
'id_type' => ManageSeoUrl::TYPE_VIDEO,
|
|
'type' => $this->l('Vidéos')
|
|
)
|
|
);
|
|
|
|
$this->fields_form = array(
|
|
'multilang' => true,
|
|
'legend' => array(
|
|
'title' => $this->className,
|
|
),
|
|
'submit' => array(
|
|
'name' => 'submitUrl',
|
|
'title' => $this->l('Save'),
|
|
),
|
|
'input' => array(
|
|
array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Link rewrite'),
|
|
'name' => 'link_rewrite',
|
|
'required' => true,
|
|
'lang' => true,
|
|
'size' => 114
|
|
),
|
|
array(
|
|
'type' => 'select',
|
|
'label' => $this->l('Type'),
|
|
'name' => 'type',
|
|
'required' => true,
|
|
'options' => array(
|
|
'query' => $options,
|
|
'id' => 'id_type',
|
|
'name' => 'type'
|
|
)
|
|
),
|
|
array(
|
|
'type' => 'text',
|
|
'label' => $this->l('ID Element'),
|
|
'name' => 'id_element',
|
|
'required' => true,
|
|
'hint' => "Si redirecton 301, mettre 0",
|
|
),
|
|
array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Redirect'),
|
|
'name' => 'redirect',
|
|
'lang' => true,
|
|
),
|
|
array(
|
|
'type' => 'text',
|
|
'label' => $this->l('Canonical'),
|
|
'name' => 'canonical',
|
|
'lang' => true,
|
|
),
|
|
array(
|
|
'type' => 'shop',
|
|
'label' => $this->l('Shop'),
|
|
'form_group_class' => 'fieldhide input_content',
|
|
'name' => 'checkBoxShopAsso_seourl'
|
|
),
|
|
)
|
|
);
|
|
return parent::renderForm();
|
|
}
|
|
|
|
public function copyFromPost(&$object, $table)
|
|
{
|
|
parent::copyFromPost($object, $table);
|
|
|
|
// Auto increment id_element pour les redirections 301
|
|
if ($object->type == ManageSeoUrl::TYPE_301){
|
|
$max_id = Db::getInstance()->getValue('SELECT MAX(id_element) FROM ps_seourl WHERE type = ' . ManageSeoUrl::TYPE_301);
|
|
|
|
if (empty($max_id)) {
|
|
$max_id = 0;
|
|
}
|
|
$object->id_element = $max_id + 1;
|
|
}
|
|
}
|
|
|
|
} |