105 lines
3.1 KiB
PHP
Raw Normal View History

2015-08-12 14:10:25 +02:00
<?php
2015-08-13 12:41:23 +02:00
require_once(dirname(__FILE__).'/../../blockadshooks.php');
2015-08-12 14:10:25 +02:00
class AdminAdsController extends ModuleAdminController {
public function __construct()
{
$this->identifier = 'id_block_ads';
$this->lang = true;
$this->table = 'ads';
$this->className = 'BlockAds';
$this->bootstrap = true;
$this->addRowAction('view');
$this->addRowAction('edit');
parent::__construct();
}
public function renderList()
{
$this->fields_list = array(
'id_block_ads' => array(
'title' => 'ID',
'width' => 25,
'class' => 'text-center',
),
'label' => array(
'title' => $this->l('Label'),
2015-08-13 12:41:23 +02:00
),
'hook_name' => array(
'title' => $this->l('Hook'),
2015-08-12 14:10:25 +02:00
)
);
return parent::renderList();
}
public function renderForm()
{
$this->fields_form = array(
'multilang' => true,
'tinymce' => true,
'legend' => array(
'title' => $this->l('Ads'),
),
'submit' => array(
'title' => $this->l('Save'),
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Label'),
'name' => 'label',
),
2015-08-13 12:41:23 +02:00
array(
'type' => 'text',
'label' => $this->l('Nom du hook'),
'name' => 'hook_name',
'disabled' => Validate::isLoadedObject($this->object)
),
2015-08-12 14:10:25 +02:00
array(
'type' => 'text',
'label' => $this->l('Width'),
'name' => 'width',
),
array(
'type' => 'text',
'label' => $this->l('Height'),
'name' => 'height',
),
array(
'type' => 'textarea',
'label' => $this->l('Contenu par défaut de l emplacement'),
2015-08-12 14:10:25 +02:00
'name' => 'content',
'lang' => true
),
)
);
2015-08-13 12:41:23 +02:00
2015-08-12 14:10:25 +02:00
return parent::renderForm();
}
2015-08-13 09:59:25 +02:00
public function renderView()
{
2015-08-13 12:41:23 +02:00
require(_PS_MODULE_DIR_.'blockadshooks/controllers/admin/AdminAdsPublication.php');
$controller = new AdminAdsPublicationController();
$controller->listByAds(array($this->object->id));
$controller->toolbar_title = $this->l('Liste des publicités');
2015-08-13 12:41:23 +02:00
$controller->toolbar_btn['new'] = array(
'href' => Context::getContext()->link->getAdminLink('AdminAdsPublication', true).'&id_default_ads='.$this->object->id.'&addads_publication',
'desc' => $this->l('Add new')
);
2015-08-13 09:59:25 +02:00
$this->context->smarty->assign(array(
2015-08-13 12:41:23 +02:00
'ads' => $this->object,
'publications_list' => $controller->renderList()
2015-08-13 09:59:25 +02:00
));
return parent::renderView();
}
2015-08-12 14:10:25 +02:00
}