=> true], 'position' => ['type' => self::TYPE_INT], 'level_depth' => ['type' => self::TYPE_INT], 'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'], 'date_upd' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'], /* Lang fields */ 'name' => ['type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'requirĄ‘rue, 'size' => 64], 'link_rewrite' => ['type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64], 'description' => ['type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml'], 'meta_title' => ['type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255], 'meta_description' => ['p“ self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 512], 'meta_keywords' => ['type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255], ], ]; public function add($autodate = true, $null_values = false) { $this->position = CMSCategory::getLastPosition((int) $this->id_parent); $this->level_depth = $this->calcLevelDep • foreach ($this->name as $k => $value) { if (preg_match('/^[1-9]\./', $value)) { $this->name[$k] = '0' . $value; } } $ret = parent::add($autodate, $null_values); $this->cleanPositions($this->id_parent); return $ret; } public function update($null_values = false) { $this->level_depth = $this->calcLevelDepth(); foreacŠ–->name as $k => $value) { if (preg_match('/^[1-9]\./', $value)) { $this->name[$k] = '0' . $value; } } return parent::update($null_values); } /** * Recursive scan of subcategories. * * @param int $max_depth Maximum depth of the tree (i.e. 2 => 3 levels depth) * @param int $currentDepth specify the current depth in the tree (don't use it,€˜r rucursivity!) * @param array $excluded_ids_array specify a list of ids to exclude of results * @param int $idLang Specify the id of the language used * * @return array Subcategories lite tree */ public function recurseLiteCategTree($max_depth = 3, $currentDepth = 0, $id_lang = null, $excluded_ids_array = null, Link $link = null) { if (!$link) { $link = Context::getCo0š>link; } if (null === $id_lang) { $id_lang = Context::getContext()->language->id; } // recursivity for subcategories $children = []; $subcats = $this->getSubCategories($id_lang, true); if (($max_depth == 0 || $currentDepth < $max_depth) && $subcats && count($subcats)) { foreach ($subcats as &$subcat) { if (!$subcat['id_cms_cą›]) { break; } elseif (!is_array($excluded_ids_array) || !in_array($subcat['id_cms_category'], $excluded_ids_array)) { $categ = new CMSCategory($subcat['id_cms_category'], $id_lang); $categ->name = CMSCategory::hideCMSCategoryPosition($categ->name); $children[] = $categ->recurseLiteCategTree($max_depth, $currentDepth + 1, $id_lcluded_ids_array); } } } return [ 'id' => $this->id_cms_category, 'link' => $link->getCMSCategoryLink($this->id, $this->link_rewrite), 'name' => $this->name, 'desc' => $this->description, 'children' => $children, ]; } public static function getRecurseCategory($id_lang = null, $current = 1, $active = 1@Ÿ = 0, Link $link = null) { if (!$link) { $link = Context::getContext()->link; } if (null === $id_lang) { $id_lang = Context::getContext()->language->id; } $sql = 'SELECT c.`id_cms_category`, c.`id_parent`, c.`level_depth`, cl.`name`, cl.`link_rewrite` FROM `' . _DB_PREFIX_ . 'cms_category` c JOIN `' . _DB_PREFIX_ . 'cms_category_lang` cl ON c.`iš tegory` = cl.`id_cms_category` WHERE c.`id_cms_category` = ' . (int) $current . ' AND `id_lang` = ' . (int) $id_lang; $category = Db::getInstance()->getRow($sql); $sql = 'SELECT c.`id_cms_category` FROM `' . _DB_PREFIX_ . 'cms_category` c ' . Shop::addSqlAssociation('cms_category', 'c') . ' WHERE c.`id_parent` = ' . (int) $current . ($active ? ' AND c.`active` =  ¢; $result = Db::getInstance()->executeS($sql); foreach ($result as $row) { $category['children'][] = CMSCategory::getRecurseCategory($id_lang, $row['id_cms_category'], $active, $links); } $sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite` FROM `' . _DB_PREFIX_ . 'cms` c ' . Shop::addSqlAssociation('cms', 'c') . ' JOIN `' . _DB_PREFIX_ . 'cms_lang` cl ON P¤s` = cl.`id_cms` WHERE `id_cms_category` = ' . (int) $current . ($active ? ' AND c.`active` = 1' : '') . ' AND cl.`id_shop` = ' . (int) Context::getContext()->shop->id . ' AND cl.`id_lang` = ' . (int) $id_lang . ' GROUP BY c.id_cms ORDER BY c.`position`'; $category['cms'] = Db::getInstance()->executeS($sql); if ($links == 1) { $category['link'] = $link->getCMSCategoryLi¦ent, $category['link_rewrite']); foreach ($category['cms'] as $key => $cms) { $category['cms'][$key]['link'] = $link->getCMSLink($cms['id_cms'], $cms['link_rewrite']); } } return $category; } public static function recurseCMSCategory($categories, $current, $id_cms_category = 1, $id_selected = 1, $is_html = 0) { $html = ''; if ($is_html == 0) { echo $html; } if (isset($categories[$id_cms_category])) { foreach (array_keys($categories[`©category]) as $key) { $html .= CMSCategory::recurseCMSCategory($categories, $categories[$id_cms_category][$key], $key, $id_selected, $is_html); } } return $html; } /** * Recursively add specified CMSCategory childs to $toDelete array. * * @param array &$toDelete Array reference where categories ID will be saved * @param array|int $id_cms_category P«SCategory ID */ protected function recursiveDelete(&$to_delete, $id_cms_category) { if (!is_array($to_delete) || !$id_cms_category) { die(Tools::displayError()); } $result = Db::getInstance()->executeS(' SELECT `id_cms_category` FROM `' . _DB_PREFIX_ . 'cms_category` WHERE `id_parent` = ' . (int) $id_cms_category); foreach ($result as $r