示例#1
0
    public function display($token = NULL)
    {
        global $currentIndex, $cookie;
        $id_cms_category = (int) Tools::getValue('id_cms_category', 1);
        $this->getList((int) $cookie->id_lang, !$cookie->__get($this->table . 'Orderby') ? 'position' : NULL, !$cookie->__get($this->table . 'Orderway') ? 'ASC' : NULL);
        echo '<h3>' . (!$this->_listTotal ? $this->l('There are no subcategories') : $this->_listTotal . ' ' . ($this->_listTotal > 1 ? $this->l('subcategories') : $this->l('subCMS Category'))) . ' ' . $this->l('in CMS Category') . ' "' . stripslashes(CMSCategory::hideCMSCategoryPosition($this->_CMSCategory->getName())) . '"</h3>';
        echo '<a href="' . __PS_BASE_URI__ . substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__)) . '?tab=AdminCMSContent&add' . $this->table . '&id_parent=' . Tools::getValue('id_cms_category') . '&token=' . ($token != NULL ? $token : $this->token) . '"><img src="../img/admin/add.gif" border="0" /> ' . $this->l('Add a new sub CMS Category') . '</a>
		<div style="margin:10px;">';
        $this->displayList($token);
        echo '</div>';
    }
 private function menuCMSCategory($categories, $current, $id_cms_category = 1, $id_selected = 1, $is_html = 0, $pref_value = '')
 {
     $html = '<option  value="' . $pref_value . $id_cms_category . '"' . ($id_selected == $id_cms_category ? ' selected="selected"' : '') . '><div>' . str_repeat('&nbsp;', $current['infos']['level_depth'] * 5) . CMSCategory::hideCMSCategoryPosition(stripslashes($current['infos']['name'])) . '</div></option>';
     if ($is_html == 0) {
         echo $html;
     }
     if (isset($categories[$id_cms_category])) {
         foreach (array_keys($categories[$id_cms_category]) as $key) {
             $html .= $this->menuCMSCategory($categories, $categories[$id_cms_category][$key], $key, $id_selected, $is_html, $pref_value);
         }
     }
     return $html;
 }
示例#3
0
/**
 * Return path to a product category
 *
 * @param string $urlBase Start URL
 * @param integer $id_category Start category
 * @param string $path Current path
 * @param string $highlight String to highlight (in XHTML/CSS)
 * @param string $type Category type (products/cms)
 */
function getPath($urlBase, $id_category, $path = '', $highlight = '', $categoryType = 'catalog')
{
    global $cookie;
    if ($categoryType == 'catalog') {
        $category = Db::getInstance()->getRow('
		SELECT id_category, level_depth, nleft, nright
		FROM ' . _DB_PREFIX_ . 'category
		WHERE id_category = ' . (int) $id_category);
        if (isset($category['id_category'])) {
            $categories = Db::getInstance()->ExecuteS('
			SELECT c.id_category, cl.name, cl.link_rewrite
			FROM ' . _DB_PREFIX_ . 'category c
			LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = c.id_category)
			WHERE c.nleft <= ' . (int) $category['nleft'] . ' AND c.nright >= ' . (int) $category['nright'] . ' AND cl.id_lang = ' . (int) $cookie->id_lang . '
			ORDER BY c.level_depth ASC
			LIMIT ' . (int) ($category['level_depth'] + 1));
            $fullPath = '';
            $n = 1;
            $nCategories = (int) sizeof($categories);
            foreach ($categories as $category) {
                $edit = '<a href="' . $urlBase . '&id_category=' . (int) $category['id_category'] . '&' . ($category['id_category'] == 1 ? 'viewcategory' : 'addcategory') . '&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" title="' . ($category['id_category'] == 1 ? 'Home' : 'Modify') . '"><img src="../img/admin/' . ($category['id_category'] == 1 ? 'home' : 'edit') . '.gif" alt="" /></a> ';
                $fullPath .= $edit . ($n < $nCategories ? '<a href="' . $urlBase . '&id_category=' . (int) $category['id_category'] . '&viewcategory&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" title="' . htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8') . '">' : '') . (!empty($highlight) ? str_ireplace($highlight, '<span class="highlight">' . htmlentities($highlight, ENT_NOQUOTES, 'UTF-8') . '</span>', $category['name']) : $category['name']) . ($n < $nCategories ? '</a>' : '') . (($n++ != $nCategories or !empty($path)) ? ' > ' : '');
            }
            return $fullPath . $path;
        }
    } elseif ($categoryType == 'cms') {
        $category = new CMSCategory($id_category, (int) $cookie->id_lang);
        if (!$category->id) {
            return $path;
        }
        $name = $highlight != NULL ? str_ireplace($highlight, '<span class="highlight">' . $highlight . '</span>', CMSCategory::hideCMSCategoryPosition($category->name)) : CMSCategory::hideCMSCategoryPosition($category->name);
        $edit = '<a href="' . $urlBase . '&id_cms_category=' . $category->id . '&addcategory&token=' . Tools::getAdminToken('AdminCMSContent' . (int) Tab::getIdFromClassName('AdminCMSContent') . (int) $cookie->id_employee) . '">
				<img src="../img/admin/edit.gif" alt="Modify" /></a> ';
        if ($category->id == 1) {
            $edit = '<a href="' . $urlBase . '&id_cms_category=' . $category->id . '&viewcategory&token=' . Tools::getAdminToken('AdminCMSContent' . (int) Tab::getIdFromClassName('AdminCMSContent') . (int) $cookie->id_employee) . '">
					<img src="../img/admin/home.gif" alt="Home" /></a> ';
        }
        $path = $edit . '<a href="' . $urlBase . '&id_cms_category=' . $category->id . '&viewcategory&token=' . Tools::getAdminToken('AdminCMSContent' . (int) Tab::getIdFromClassName('AdminCMSContent') . (int) $cookie->id_employee) . '">
		' . $name . '</a> > ' . $path;
        if ($category->id == 1) {
            return substr($path, 0, strlen($path) - 3);
        }
        return getPath($urlBase, $category->id_parent, $path, '', 'cms');
    }
}
示例#4
0
/**
 * Return path to a product category
 *
 * @param string $urlBase Start URL
 * @param integer $id_category Start category
 * @param string $path Current path
 * @param string $highlight String to highlight (in XHTML/CSS)
 * @param string $type Category type (products/cms)
 */
function getPath($urlBase, $id_category, $path = '', $highlight = '', $categoryType = 'catalog', $home = false)
{
    $context = Context::getContext();
    if ($categoryType == 'catalog') {
        $category = Db::getInstance()->getRow('
		SELECT id_category, level_depth, nleft, nright
		FROM ' . _DB_PREFIX_ . 'category
		WHERE id_category = ' . (int) $id_category);
        if (isset($category['id_category'])) {
            $sql = 'SELECT c.id_category, cl.name, cl.link_rewrite
					FROM ' . _DB_PREFIX_ . 'category c
					LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = c.id_category' . Shop::addSqlRestrictionOnLang('cl') . ')
					WHERE c.nleft <= ' . (int) $category['nleft'] . '
						AND c.nright >= ' . (int) $category['nright'] . '
						AND cl.id_lang = ' . (int) $context->language->id . ($home ? ' AND c.id_category=' . $id_category : '') . '
						AND c.id_category != ' . (int) Category::getTopCategory()->id . '
					GROUP BY c.id_category
					ORDER BY c.level_depth ASC
					LIMIT ' . (!$home ? (int) ($category['level_depth'] + 1) : 1);
            $categories = Db::getInstance()->executeS($sql);
            $fullPath = '';
            $n = 1;
            $nCategories = (int) sizeof($categories);
            foreach ($categories as $category) {
                $link = Context::getContext()->link->getAdminLink('AdminCategories');
                $edit = '<a href="' . $link . '&id_category=' . (int) $category['id_category'] . '&' . ($category['id_category'] == 1 || $home ? 'viewcategory' : 'updatecategory') . '" title="' . ($category['id_category'] == Category::getRootCategory()->id_category ? 'Home' : 'Modify') . '"><i class="icon-' . ($category['id_category'] == Category::getRootCategory()->id_category || $home ? 'home' : 'pencil') . '"></i></a> ';
                $fullPath .= $edit . ($n < $nCategories ? '<a href="' . $urlBase . '&id_category=' . (int) $category['id_category'] . '&viewcategory&token=' . Tools::getAdminToken('AdminCategories' . (int) Tab::getIdFromClassName('AdminCategories') . (int) $context->employee->id) . '" title="' . htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8') . '">' : '') . (!empty($highlight) ? str_ireplace($highlight, '<span class="highlight">' . htmlentities($highlight, ENT_NOQUOTES, 'UTF-8') . '</span>', $category['name']) : $category['name']) . ($n < $nCategories ? '</a>' : '') . ($n++ != $nCategories || !empty($path) ? ' > ' : '');
            }
            return $fullPath . $path;
        }
    } elseif ($categoryType == 'cms') {
        $category = new CMSCategory($id_category, $context->language->id);
        if (!$category->id) {
            return $path;
        }
        $name = $highlight != null ? str_ireplace($highlight, '<span class="highlight">' . $highlight . '</span>', CMSCategory::hideCMSCategoryPosition($category->name)) : CMSCategory::hideCMSCategoryPosition($category->name);
        $edit = '<a href="' . $urlBase . '&id_cms_category=' . $category->id . '&addcategory&token=' . Tools::getAdminToken('AdminCmsContent' . (int) Tab::getIdFromClassName('AdminCmsContent') . (int) $context->employee->id) . '">
				<i class="icon-pencil"></i></a> ';
        if ($category->id == 1) {
            $edit = '<li><a href="' . $urlBase . '&id_cms_category=' . $category->id . '&viewcategory&token=' . Tools::getAdminToken('AdminCmsContent' . (int) Tab::getIdFromClassName('AdminCmsContent') . (int) $context->employee->id) . '">
					<i class="icon-home"></i></a></li> ';
        }
        $path = $edit . '<li><a href="' . $urlBase . '&id_cms_category=' . $category->id . '&viewcategory&token=' . Tools::getAdminToken('AdminCmsContent' . (int) Tab::getIdFromClassName('AdminCmsContent') . (int) $context->employee->id) . '">
		' . $name . '</a></li> > ' . $path;
        if ($category->id == 1) {
            return substr($path, 0, strlen($path) - 3);
        }
        return getPath($urlBase, $category->id_parent, $path, '', 'cms');
    }
}
    public static function getChildren($id_parent, $id_lang, $active = true)
    {
        if (!Validate::isBool($active)) {
            die(Tools::displayError());
        }
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
		SELECT c.`id_cms_category`, cl.`name`, cl.`link_rewrite`
		FROM `' . _DB_PREFIX_ . 'cms_category` c
		LEFT JOIN `' . _DB_PREFIX_ . 'cms_category_lang` cl ON c.`id_cms_category` = cl.`id_cms_category`
		WHERE `id_lang` = ' . (int) $id_lang . '
		AND c.`id_parent` = ' . (int) $id_parent . '
		' . ($active ? 'AND `active` = 1' : '') . '
		ORDER BY `name` ASC');
        // Modify SQL result
        $results_array = array();
        foreach ($result as $row) {
            $row['name'] = CMSCategory::hideCMSCategoryPosition($row['name']);
            $results_array[] = $row;
        }
        return $results_array;
    }
示例#6
0
    public function display($token = NULL)
    {
        global $currentIndex, $cookie;
        if ($id_cms_category = (int) Tools::getValue('id_cms_category')) {
            $currentIndex .= '&id_cms_category=' . $id_cms_category;
        }
        $this->getList((int) $cookie->id_lang, !$cookie->__get($this->table . 'Orderby') ? 'position' : NULL, !$cookie->__get($this->table . 'Orderway') ? 'ASC' : NULL);
        //$this->getList((int)($cookie->id_lang));
        if (!$id_cms_category) {
            $id_cms_category = 1;
        }
        echo '<h3>' . (!$this->_listTotal ? $this->l('No pages found') : $this->_listTotal . ' ' . ($this->_listTotal > 1 ? $this->l('pages') : $this->l('page'))) . ' ' . $this->l('in category') . ' "' . stripslashes(CMSCategory::hideCMSCategoryPosition($this->_category->getName())) . '"</h3>';
        echo '<a href="' . $currentIndex . '&id_cms_category=' . $id_cms_category . '&add' . $this->table . '&token=' . Tools::getAdminTokenLite('AdminCMSContent') . '"><img src="../img/admin/add.gif" border="0" /> ' . $this->l('Add a new page') . '</a>
		<div style="margin:10px;">';
        $this->displayList($token);
        echo '</div>';
    }
示例#7
0
    public static function getChildren($id_parent, $id_lang, $active = true)
    {
        $results = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
		SELECT c.`id_cms_category`, cl.`name`, cl.`link_rewrite`
		FROM `' . _DB_PREFIX_ . 'cms_category` c
		LEFT JOIN `' . _DB_PREFIX_ . 'cms_category_lang` cl ON c.`id_cms_category` = cl.`id_cms_category`
		WHERE `id_lang` = ' . (int) $id_lang . ' AND c.`id_parent` = ' . (int) $id_parent . '
		' . ($active ? 'AND `active` = 1' : '') . '
		ORDER BY `name` ASC');
        /* Remove numbers from the titles */
        foreach ($results as &$row) {
            $row['name'] = CMSCategory::hideCMSCategoryPosition($row['name']);
        }
        return $results;
    }