Exemple #1
0
 public static function recurseCMSCategory($categories, $current, $id_cms_category = 1, $id_selected = 1, $is_html = 0)
 {
     $html = '<option value="' . $id_cms_category . '"' . ($id_selected == $id_cms_category ? ' selected="selected"' : '') . '>' . str_repeat('&nbsp;', $current['infos']['level_depth'] * 5) . BlogCategory::hideBlogCategoryPosition(stripslashes($current['infos']['name'])) . '</option>';
     if ($is_html == 0) {
         echo $html;
     }
     if (isset($categories[$id_cms_category])) {
         foreach (array_keys($categories[$id_cms_category]) as $key) {
             $html .= BlogCategory::recurseCMSCategory($categories, $categories[$id_cms_category][$key], $key, $id_selected, $is_html);
         }
     }
     return $html;
 }
 public function renderForm()
 {
     $this->display = 'edit';
     $this->initToolbar();
     //Added From Old
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $image = _MODULE_SMARTBLOG_DIR_ . 'category/' . $obj->id . '.jpg';
     $image_url = ImageManager::thumbnail($image, $this->table . '_' . pSQL(Tools::getvalue('id_smart_blog_category')) . '.jpg', 200, 'jpg', true, true);
     $image_size = file_exists($image) ? filesize($image) / 1000 : false;
     // $root = BlogCategory::getRootCategory()['id_smart_blog_category'];
     $categories = BlogCategory::getCategories($this->context->language->id, false);
     $html_categories = BlogCategory::recurseCMSCategory($categories, $categories[0][1], 1, $this->getFieldValue($this->object, 'id_parent'), 1);
     $html_categories = '<div class="col-lg-9">
                     <div class="row">
                       <select name="id_parent">
                         ' . $html_categories . '
                       </select>
                     </div>
                   </div>';
     $this->fields_form = array('legend' => array('title' => $this->l('Blog Category')), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'class' => 'copyMeta2friendlyURL', 'required' => true, 'lang' => true, 'hint' => $this->l('Invalid characters:') . ' &lt;&gt;;=#{}'), array('type' => 'html', 'label' => $this->l('Parent Blog Category'), 'name' => 'id_parent', 'html_content' => $html_categories), array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'description', 'lang' => true, 'rows' => 10, 'cols' => 62, 'class' => 'rte', 'autoload_rte' => true, 'required' => false, 'desc' => $this->l('Enter Your Category Description')), array('type' => 'file', 'label' => $this->l('Category Image:'), 'name' => 'category_image', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'delete_url' => self::$currentIndex . '&' . $this->identifier . '=' . pSQL(Tools::getvalue('id_smart_blog_category')) . '&token=' . $this->token . '&deleteImage=1', 'hint' => $this->l('Upload a feature image from your computer.')), array('type' => 'text', 'label' => $this->l('Meta title'), 'name' => 'meta_title', 'lang' => true, 'hint' => $this->l('Invalid characters:') . ' &lt;&gt;;=#{}'), array('type' => 'text', 'label' => $this->l('Meta Keyword'), 'name' => 'meta_keyword', 'lang' => true, 'size' => 60, 'required' => false, 'desc' => $this->l('Enter Your Category Meta Keyword. Separated by comma(,)')), array('type' => 'textarea', 'label' => $this->l('Meta Description'), 'name' => 'meta_description', 'rows' => 10, 'cols' => 62, 'lang' => true, 'required' => false, 'desc' => $this->l('Enter Your Category Meta Description')), array('type' => 'text', 'label' => $this->l('Link Rewrite'), 'name' => 'link_rewrite', 'size' => 60, 'lang' => true, 'required' => true, 'desc' => $this->l('Enetr Your Category Slug. Use In SEO Friendly URL')), array('type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active', 'value' => 0, 'label' => $this->l('Disabled'))))));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
     }
     if (!($BlogCategory = $this->loadObject(true))) {
         return;
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save'));
     $image = ImageManager::thumbnail(_MODULE_SMARTBLOG_DIR_ . 'category/' . $BlogCategory->id_smart_blog_category . '.jpg', $this->table . '_' . (int) $BlogCategory->id_smart_blog_category . '.' . $this->imageType, 350, $this->imageType, true);
     $this->fields_value = array('image' => $image ? $image : false, 'size' => $image ? filesize(_MODULE_SMARTBLOG_DIR_ . 'category/' . $BlogCategory->id_smart_blog_category . '.jpg') / 1000 : false);
     $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
     return parent::renderForm();
 }