table = 'cmsps_editos'; $this->className = 'CmsPsEdito'; $this->identifier = 'id_edito'; $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_edito' => array( 'title' => 'ID', 'width' => 25 ), 'title' => array( 'title' => $this->module->l('Titre'), 'width' => 200, 'filter_key' => 'b!title', ), 'slug' => array( 'title' => $this->module->l('Alias'), 'width' => 100, ), 'active' => array( 'title' => $this->l('Active'), 'active' => 'status', 'type' => 'bool', 'class' => 'fixed-width-xs', 'align' => 'center', 'ajax' => true, 'orderby' => false ) ); if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL){ $this->_join .= 'JOIN `'._DB_PREFIX_.'cmsps_editos_shop` acs ON a.`id_edito` = acs.`id_edito` AND acs.`id_shop` IN ('.implode(', ', Shop::getContextListShopID()).')'; $this->_group .= 'GROUP BY acs.`id_edito`'; } } public function initPageHeaderToolbar() { parent::initPageHeaderToolbar(); if ($this->display != 'edit' && $this->display != 'add') { $this->page_header_toolbar_btn['new_sales'] = array( 'href' => self::$currentIndex.'&addcmsps_editos&token='.$this->token, 'desc' => $this->l('Ajouter un édito', NULL, NULL, FALSE), 'icon' => 'process-icon-new' ); } } public function renderForm() { if (!($obj = $this->loadObject(TRUE))) return; $this->fields_form = array( 'multilang' => TRUE, 'tinymce' => TRUE, 'legend' => array( 'title' => $this->className, ), 'submit' => array( 'name' => 'submitCMSPSEdito', 'title' => $this->l('Save'), ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Titre'), 'name' => 'title', 'lang' => TRUE, 'required' => TRUE, 'size' => 114, 'form_group_class' => 'fieldhide input_content', ), array( 'type' => 'text', 'label' => $this->l('Alias'), 'name' => 'slug', 'lang' => TRUE, 'required' => TRUE, 'size' => 114, 'form_group_class' => 'fieldhide input_content' ), array( 'type' => 'textarea', 'label' => $this->l('Introduction'), 'name' => 'intro', 'autoload_rte' => TRUE, 'cols' => 100, 'rows' => 6, 'lang' => TRUE, 'form_group_class' => 'fieldhide input_content', ), array( 'type' => 'textarea', 'label' => $this->l('Contenu'), 'name' => 'content', 'autoload_rte' => TRUE, 'cols' => 100, 'rows' => 6, 'lang' => TRUE, 'form_group_class' => 'fieldhide input_content', ), array( 'type' => 'text', 'label' => $this->l('Meta title'), 'name' => 'meta_title', 'lang' => TRUE, 'size' => 114, 'form_group_class' => 'fieldhide input_seo', ), array( 'type' => 'text', 'label' => $this->l('Meta desc'), 'name' => 'meta_desc', 'lang' => TRUE, 'size' => 114, 'form_group_class' => 'fieldhide input_seo', ), array( 'type' => 'shop', 'label' => $this->l('Shop'), 'form_group_class' => 'fieldhide input_content', 'name' => 'checkBoxShopAsso_cmsps_posts' ), array( 'type' => 'switch', 'label' => $this->l('Actif'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'form_group_class' => 'fieldhide input_content', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ) ), ) ); return parent::renderForm(); } public function setMedia() { parent::setMedia(); $this->addJs(_PS_MODULE_DIR_.'cmsps/js/admin.js'); } public function ajaxProcessstatuscmspsEditos() { if (!$id_edito = (int)Tools::getValue('id_edito')) die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->l('Failed to update the status')))); else { $post = new CmsPsEdito((int)$id_edito); if (Validate::isLoadedObject($post)) { $post->active = $post->active == 1 ? 0 : 1; $post->save() ? die(Tools::jsonEncode(array('success' => true, 'text' => $this->l('The status has been updated successfully')))) : die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->l('Failed to update the status')))); } } } public function processSave() { parent::processSave(); Hook::exec('seoUrlCmsEdito', array( 'object' => $this->object )); } }