public function getContent() { include_once dirname(__FILE__) . '/ProductCommentCriterion.php'; $this->_setBaseUrl(); $this->_productCommentsCriterionTypes = ProductCommentCriterion::getTypes(); $this->_html = '<h2>' . $this->displayName . '</h2>'; $this->_postProcess(); $this->_checkModerateComment(); $this->_checkReportedComment(); $this->_checkCriterion(); $this->_updateApplicationCriterion(); $this->_checkDeleteComment(); return $this->_html . $this->_displayForm(); }
function renderCriterionForm($id_criterion = 0) { $types = ProductCommentCriterion::getTypes(); $query = array(); foreach ($types as $key => $value) { $query[] = array('id' => $key, 'label' => $value); } $criterion = new ProductCommentCriterion((int) $id_criterion); $selected_categories = $criterion->getCategories(); $product_table_values = Product::getSimpleProducts($this->context->language->id); $selected_products = $criterion->getProducts(); foreach ($product_table_values as $key => $product) { if (false !== array_search($product['id_product'], $selected_products)) { $product_table_values[$key]['selected'] = 1; } } if (version_compare(_PS_VERSION_, '1.6', '<')) { $field_category_tree = array('type' => 'categories_select', 'name' => 'categoryBox', 'label' => $this->l('Criterion will be restricted to the following categories'), 'category_tree' => $this->initCategoriesAssociation(null, $id_criterion)); } else { $field_category_tree = array('type' => 'categories', 'label' => $this->l('Criterion will be restricted to the following categories'), 'name' => 'categoryBox', 'desc' => $this->l('Mark the boxes of categories to which this criterion applies.'), 'tree' => array('use_search' => false, 'id' => 'categoryBox', 'use_checkbox' => true, 'selected_categories' => $selected_categories), 'values' => array('trads' => array('Root' => Category::getTopCategory(), 'selected' => $this->l('Selected'), 'Collapse All' => $this->l('Collapse All'), 'Expand All' => $this->l('Expand All'), 'Check All' => $this->l('Check All'), 'Uncheck All' => $this->l('Uncheck All')), 'selected_cat' => $selected_categories, 'input_name' => 'categoryBox[]', 'use_radio' => false, 'use_search' => false, 'disabled_categories' => array(), 'top_category' => Category::getTopCategory(), 'use_context' => true)); } $fields_form_1 = array('form' => array('legend' => array('title' => $this->l('Add new criterion'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => 'hidden', 'name' => 'id_product_comment_criterion'), array('type' => 'text', 'lang' => true, 'label' => $this->l('Criterion name'), 'name' => 'name'), array('type' => 'select', 'name' => 'id_product_comment_criterion_type', 'label' => $this->l('Application scope of the criterion'), 'options' => array('query' => $query, 'id' => 'id', 'name' => 'label')), $field_category_tree, array('type' => 'products', 'label' => $this->l('The criterion will be restricted to the following products'), 'name' => 'ids_product', 'values' => $product_table_values), array('type' => 'switch', 'is_bool' => true, 'label' => $this->l('Active'), 'name' => 'active', 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))))), 'submit' => array('title' => $this->l('Save'), 'class' => 'btn btn-default pull-right', 'name' => 'submitEditCriterion'))); $helper = new HelperForm(); $helper->show_toolbar = false; $helper->table = $this->name; $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->module = $this; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $helper->identifier = $this->identifier; $helper->submit_action = 'submitEditCriterion'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array('fields_value' => $this->getCriterionFieldsValues($id_criterion), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id); return $helper->generateForm(array($fields_form_1)); }