171 lines
4.9 KiB
PHP
171 lines
4.9 KiB
PHP
<?php
|
|
require_once(__DIR__.'/classes/GuidePost.php');
|
|
require_once(__DIR__.'/classes/GuideCategory.php');
|
|
require_once(__DIR__.'/classes/FormBuilder.php');
|
|
|
|
class AdminGuidePosts extends AdminTab
|
|
{
|
|
public function __construct()
|
|
{
|
|
global $cookie;
|
|
|
|
$this->table = 'guide_post';
|
|
$this->identifier = 'id_guide_post';
|
|
$this->className = 'GuidePost';
|
|
$this->lang = true;
|
|
$this->edit = true;
|
|
$this->view = true;
|
|
$this->delete = true;
|
|
|
|
$this->identifiersDnd['id_guide_post'] = 'id_guide_post';
|
|
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function _displayViewLink($token = null, $id)
|
|
{
|
|
$_cacheLang['View'] = $this->l('View');
|
|
|
|
echo '
|
|
<a href="'._PS_BASE_URL_SSL_.'/modules/purchaseguide/post.php?pid='.$id.'" target="_blank">
|
|
<img src="../img/admin/details.gif" alt="'.$_cacheLang['View'].'" title="'.$_cacheLang['View'].'" /></a>';
|
|
}
|
|
|
|
public function postProcess()
|
|
{
|
|
global $cookie, $currentIndex;
|
|
|
|
$this->fieldsDisplay = array(
|
|
'id_guide_post' => array(
|
|
'title' => $this->l('ID'),
|
|
'align' => 'center',
|
|
'width' => 25
|
|
),
|
|
'name' => array(
|
|
'title' => $this->l('Category'),
|
|
'width' => 200,
|
|
),
|
|
'link_rewrite' => array(
|
|
'title' => $this->l('URL'),
|
|
'width' => 200
|
|
),
|
|
'meta_title' => array(
|
|
'title' => $this->l('Title'),
|
|
'width' => 300
|
|
),
|
|
'active' => array(
|
|
'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
|
|
ON gc.`id_guide_category` = a.`id_guide_category`
|
|
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).')';
|
|
|
|
if (Tools::getIsset('id_guide_category')) {
|
|
$this->fieldsDisplay['position'] = array(
|
|
'title' => $this->l('Position'),
|
|
'width' => 40,
|
|
'filter_key' => 'position',
|
|
'align' => 'center',
|
|
'position' => 'position'
|
|
);
|
|
$this->_where = ' AND a.`id_guide_category`='.(int)Tools::getValue('id_guide_category');
|
|
$currentIndex.= '&id_guide_category='.(int)Tools::getValue('id_guide_category');
|
|
}
|
|
|
|
parent::postProcess();
|
|
}
|
|
|
|
public function displayTop()
|
|
{
|
|
global $cookie;
|
|
|
|
$id_guide_category = Tools::getValue('id_guide_category', 0);
|
|
if ($id_guide_category == 0) {
|
|
|
|
} else {
|
|
$category = new GuideCategory($id_guide_category);
|
|
|
|
$currentIndex = '?tab=AdminGuideCategories';
|
|
$token = Tools::getAdminTokenLite('AdminGuideCategories');
|
|
|
|
echo '<a href="'.$currentIndex.'&token='.$token.'&id_guide_category='.$category->id_parent.
|
|
'"><img src="../img/admin/arrow2.gif" /> '.$this->l('back to').' '.
|
|
$category->name[$cookie->id_lang].'</a><br /><br />';
|
|
|
|
echo $this->l('Current category').' : '.$category->name[$cookie->id_lang].'<br /><br />';
|
|
}
|
|
}
|
|
|
|
public function displayList()
|
|
{
|
|
$this->_orderBy = 'position';
|
|
parent::displayList();
|
|
}
|
|
|
|
public function displayForm($token = NULL)
|
|
{
|
|
global $currentIndex, $cookie, $smarty;
|
|
parent::displayForm();
|
|
|
|
if (!($obj = $this->loadObject(true))) {
|
|
return;
|
|
}
|
|
|
|
$langs = Language::getLanguages(false);
|
|
|
|
$form = new FormBuilder('AdminGuidePosts', $this->table, 'id_guide_post', 'Add');
|
|
|
|
$this->fieldsForm = array(
|
|
'id_guide_category' => array(
|
|
'title' => $this->l('Catégorie du guide'),
|
|
'type' => 'select',
|
|
'options_raw' => GuideCategory::findCategoriesTree($cookie->id_lang, 2),
|
|
'options_map' => ['id_guide_category', 'name', 'level'],
|
|
'initial_value' => $obj->id_guide_category
|
|
),
|
|
'meta_title' => array(
|
|
'title' => $this->l('Title (META)'),
|
|
'type' => 'text',
|
|
'translatable' => true,
|
|
'attrs' => [
|
|
'onkeyup' => "copyField2friendlyURL('meta_title', 'link_rewrite');"
|
|
]
|
|
),
|
|
'meta_description' => array(
|
|
'title' => $this->l('Description (META)'),
|
|
'type' => 'textarea',
|
|
'translatable' => true,
|
|
),
|
|
'link_rewrite' => array(
|
|
'title' => $this->l('Simplified URL'),
|
|
'type' => 'text',
|
|
'required' => true,
|
|
),
|
|
'content' => array(
|
|
'title' => $this->l('Contenu de la page'),
|
|
'type' => 'textarea_tinymce',
|
|
'translatable' => true
|
|
),
|
|
'active' => array(
|
|
'title' => $this->l('Displayed'),
|
|
'type' => 'yesno',
|
|
'required' => true,
|
|
),
|
|
);
|
|
|
|
$form->setTitle($this->l('Purchase guide page'));
|
|
$form->setFields($this->fieldsForm);
|
|
$form->setSubmitButton($this->l('Save'));
|
|
$form->display($smarty, $langs, $obj);
|
|
}
|
|
}
|