This commit is contained in:
Michael RICOIS 2017-11-08 16:47:54 +01:00
parent cda38086b5
commit eb4ee2af4a
3 changed files with 62 additions and 66 deletions

View File

@ -17,10 +17,10 @@ class AdminGuide extends AdminTab
);
$str_rewrite_rules =
'RewriteRule ^guide$ '.__PS_BASE_URI__.'modules/purchaseguide/rubrique.php [QSA,L]'.
'RewriteRule ^guide/([0-9]+)\-([a-zA-Z0-9-]*)$ '.__PS_BASE_URI__.'modules/purchaseguide/rubrique.php?cid=$1 [QSA,L]'.
'RewriteRule ^guide/([0-9]+)\-([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)$ '.__PS_BASE_URI__.'modules/purchaseguide/rubrique.php?cid=$1&sid=$3 [QSA,L]'.
'RewriteRule ^guide/([0-9]+)\-([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)$ '.__PS_BASE_URI__.'modules/purchaseguide/post.php?cid=$1&sid=$3&id=$5 [QSA,L]';
"RewriteRule ^guide$ ".__PS_BASE_URI__."modules/purchaseguide/rubrique.php [QSA,L]". "\n" .
"RewriteRule ^guide/([0-9]+)\-([a-zA-Z0-9-]*)$ ".__PS_BASE_URI__."modules/purchaseguide/rubrique.php?cid=$1 [QSA,L]". "\n" .
"RewriteRule ^guide/([0-9]+)\-([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)$ ".__PS_BASE_URI__."modules/purchaseguide/rubrique.php?cid=$1&sid=$3 [QSA,L]". "\n" .
"RewriteRule ^guide/([0-9]+)\-([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)$ ".__PS_BASE_URI__."modules/purchaseguide/post.php?cid=$1&sid=$3&id=$5 [QSA,L]";
if(count($langs) > 1) {
$rewrite_rules = '';

View File

@ -23,57 +23,49 @@ class AdminGuideCategories extends AdminTab
$this->delete = true;
$this->view = true;
$this->fieldsDisplay = array(
'id_guide_category' => array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 30
),
),
'name' => array(
'title' => $this->l('Title'),
'width' => 100
),
),
'description' => array(
'title' => $this->l('Description'),
'width' => 500,
'maxlength' => 90,
'orderby' => false
),
'position' => array(
'title' => $this->l('Position'),
'width' => 40,
'filter_key' => 'position',
'align' => 'center',
'position' => 'position'
),
),
'position' => array(
'title' => $this->l('Position'),
'width' => 40,
'filter_key' => 'position',
'align' => 'center',
'position' => 'position'
),
'active' => array(
'title' => $this->l('Displayed'),
'active' => 'status',
'align' => 'center',
'type' => 'bool',
'orderby' => false
)
);
)
);
if (isset($_GET['delete'.$this->table])) {
self::$current_category = new GuideCategory(
(int)(Tools::getValue('id_guide_category_parent', 0))
);
(int)(Tools::getValue('id_guide_category_parent', 0)));
}
else {
self::$current_category = new GuideCategory(
(int)(
Tools::getValue('id_guide_category',
Tools::getValue('id_guide_category_parent', 0))
)
);
self::$current_category = new GuideCategory((int)(Tools::getValue('id_guide_category',
Tools::getValue('id_guide_category_parent', 0))));
}
$this->_select = 'position ';
$this->_filter = 'AND a.`id_parent` = '.(int)(self::$current_category->id);
$this->_orderBy = 'position';
$this->_orderWay = 'DESC';
$this->_select = 'position ';
$this->identifiersDnd['id_guide_category'] = 'id_guide_category';
parent::__construct();
@ -191,31 +183,32 @@ class AdminGuideCategories extends AdminTab
public function displayList()
{
global $currentIndex;
$this->displayTop();
if ($this->edit AND (!isset($this->noAdd) OR !$this->noAdd))
if ($this->edit AND (!isset($this->noAdd) OR !$this->noAdd)) {
echo '<br /><a href="'.$currentIndex.'&id_guide_category_parent='.self::$current_category->id.'&add'.$this->table.'&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add new').'</a><br /><br />';
}
// Append when we get a syntax error in SQL query
if ($this->_list === false)
{
if ($this->_list === false) {
$this->displayWarning($this->l('Bad SQL query'));
return false;
}
// Display list header (filtering, pagination and column names)
$this->displayListHeader();
if (!sizeof($this->_list))
if (!sizeof($this->_list)) {
echo '<tr><td class="center" colspan="'.(sizeof($this->fieldsDisplay) + 2).'">'.$this->l('No items found').'</td></tr>';
}
$this->_orderBy = 'position';
// Show the content of the table
$this->displayListContent();
// Close list table and submit button
$this->displayListFooter();
}

View File

@ -20,53 +20,56 @@ class AdminGuidePosts extends AdminTab
$this->fieldsDisplay = array(
'id_guide_post' => array(
'title' => $this->l('ID'),
'align' => 'center',
'title' => $this->l('ID'),
'align' => 'center',
'width' => 25
),
),
'name' => array(
'title' => $this->l('Category'),
'width' => 200,
),
),
'link_rewrite' => array(
'title' => $this->l('URL'),
'title' => $this->l('URL'),
'width' => 200
),
),
'meta_title' => array(
'title' => $this->l('Title'),
'title' => $this->l('Title'),
'width' => 300
),
),
'position' => array(
'title' => $this->l('Position'),
'title' => $this->l('Position'),
'width' => 40,
'filter_key' => 'position',
'align' => 'center',
'filter_key' => 'position',
'align' => 'center',
'position' => 'position'
),
),
'active' => array(
'title' => $this->l('Enabled'),
'width' => 25,
'align' => 'center',
'active' => 'status',
'type' => 'bool',
'title' => $this->l('Enabled'),
'width' => 25,
'align' => 'center',
'active' => 'status',
'type' => 'bool',
'orderby' => false
)
);
)
);
$this->_select = 'a.position, gcl.name, a.id_guide_category ';
$this->_join = '
LEFT JOIN `'._DB_PREFIX_.'guide_category` gc
LEFT JOIN `'._DB_PREFIX_.'guide_category` gc
ON gc.`id_guide_category` = a.`id_guide_category`
LEFT JOIN `'._DB_PREFIX_.'guide_category_lang` gcl
LEFT JOIN `'._DB_PREFIX_.'guide_category_lang` gcl
ON (gcl.`id_guide_category` = gc.`id_guide_category` AND gcl.`id_lang` = '.(int)($cookie->id_lang).')';
$this->_orderBy = 'position';
$this->_orderWay = 'ASC';
$this->identifiersDnd['id_guide_post'] = 'id_guide_post';
parent::__construct();
}
public function displayList()
{
$this->_orderBy = 'position';
parent::displayList();
}
public function displayForm($token = NULL)
{
global $currentIndex, $cookie, $smarty;
@ -86,9 +89,9 @@ class AdminGuidePosts extends AdminTab
'options_raw' => GuideCategory::findCategoriesTree($cookie->id_lang),
'options_map' => ['id_guide_category', 'name', 'level'],
'initial_value' => $obj->id_guide_category
),
),
'meta_title' => array(
'title' => $this->l('Title (META)'),
'title' => $this->l('Title (META)'),
'type' => 'text',
'translatable' => true,
'attrs' => [
@ -96,12 +99,12 @@ class AdminGuidePosts extends AdminTab
]
),
'meta_description' => array(
'title' => $this->l('Description (META)'),
'title' => $this->l('Description (META)'),
'type' => 'textarea',
'translatable' => true,
),
'link_rewrite' => array(
'title' => $this->l('Simplified URL'),
'title' => $this->l('Simplified URL'),
'type' => 'text',
'required' => true,
),
@ -132,7 +135,7 @@ class AdminGuidePosts extends AdminTab
if (Tools::isSubmit('viewguide_post') AND ($id_guide_post = (int)(Tools::getValue('id_guide_post'))) AND $guide_post = new GuidePost($id_guide_post, (int)($cookie->id_lang)) AND Validate::isLoadedObject($guide_post))
{
$redir = $link->getGuideLink($guide_post, null, null,
$redir = $link->getGuideLink($guide_post, null, null,
$cookie->id_lang);
if (!$guide_post->active)
@ -146,7 +149,7 @@ class AdminGuidePosts extends AdminTab
}
else {
parent::postProcess();
}
}
}
}