Ejemplo n.º 1
0
 private function makeMenu()
 {
     global $cookie, $page_name;
     foreach ($this->getMenuItems() as $item) {
         $id = (int) substr($item, 3, strlen($item));
         switch (substr($item, 0, 3)) {
             case 'CAT':
                 $this->getCategory($id, $cookie->id_lang);
                 break;
             case 'PRD':
                 $selected = $page_name == 'product' && Tools::getValue('id_product') == $id ? ' class="sfHover"' : '';
                 $product = new Product($id, true, $cookie->id_lang);
                 if (!is_null($product->id)) {
                     $this->_menu .= '<li' . $selected . '><a href="' . $product->getLink() . '">' . $product->name . '</a></li>' . PHP_EOL;
                 }
                 break;
             case 'CMS':
                 $selected = $page_name == 'cms' && Tools::getValue('id_cms') == $id ? ' class="sfHover"' : '';
                 $cms = CMS::getLinks($cookie->id_lang, array($id));
                 if (count($cms)) {
                     $this->_menu .= '<li' . $selected . '><a href="' . $cms[0]['link'] . '">' . $cms[0]['meta_title'] . '</a></li>' . PHP_EOL;
                 }
                 break;
             case 'MAN':
                 $selected = $page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id ? ' class="sfHover"' : '';
                 $manufacturer = new Manufacturer($id, $cookie->id_lang);
                 if (!is_null($manufacturer->id)) {
                     if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) {
                         $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name, false);
                     } else {
                         $manufacturer->link_rewrite = 0;
                     }
                     $link = new Link();
                     $this->_menu .= '<li' . $selected . '><a href="' . $link->getManufacturerLink($id, $manufacturer->link_rewrite) . '">' . $manufacturer->name . '</a></li>' . PHP_EOL;
                 }
                 break;
             case 'SUP':
                 $selected = $page_name == 'supplier' && Tools::getValue('id_supplier') == $id ? ' class="sfHover"' : '';
                 $supplier = new Supplier($id, $cookie->id_lang);
                 if (!is_null($supplier->id)) {
                     $link = new Link();
                     $this->_menu .= '<li' . $selected . '><a href="' . $link->getSupplierLink($id, $supplier->link_rewrite) . '">' . $supplier->name . '</a></li>' . PHP_EOL;
                 }
                 break;
             case 'LNK':
                 $link = MenuTopLinks::get($id, $cookie->id_lang);
                 if (count($link)) {
                     $this->_menu .= '<li><a href="' . $link[0]['link'] . '"' . ($link[0]['new_window'] ? ' target="_blank"' : '') . '>' . $link[0]['label'] . '</a></li>' . PHP_EOL;
                 }
                 break;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Returns module content
  *
  * @param array $params Parameters
  * @return string Content
  */
 function hookFooter($params)
 {
     global $smarty, $cookie;
     $cms = CMS::listCms($cookie->id_lang, $this->id);
     $id_cms = array();
     foreach ($cms as $row) {
         $id_cms[] = intval($row['id_cms']);
     }
     $smarty->assign('cmslinks', CMS::getLinks($cookie->id_lang, $id_cms));
     return $this->display(__FILE__, 'blockvariouslinks.tpl');
 }
Ejemplo n.º 3
0
 /**
  * Returns module content
  *
  * @param array $params Parameters
  * @return string Content
  */
 function hookFooter($params)
 {
     global $smarty, $cookie;
     $smarty->caching = 0;
     $cms = CMS::listCms($cookie->id_lang, $this->id);
     $id_cms = array();
     $rewlink = array();
     foreach ($cms as $row) {
         $id_cms[] = intval($row['id_cms']);
     }
     $links = CMS::getLinks($cookie->id_lang, $id_cms);
     for ($x = 0; $x < count($links); $x++) {
         $l = $links[$x]["link"];
         $s = strpos($l, "/prestashop/");
         $links[$x]["link"] = substr($l, $s);
     }
     //                echo("<pre>");   print_r($links);   echo("</pre>");
     $smarty->assign('cmslinks', $links);
     return $this->display(__FILE__, 'blockvariouslinks.tpl');
 }
Ejemplo n.º 4
0
 protected function makeMenu()
 {
     $root_node = $this->makeNode(['label' => null, 'type' => 'root', 'children' => []]);
     $menu_items = $this->getMenuItems();
     $id_lang = (int) $this->context->language->id;
     $id_shop = (int) Shop::getContextShopID();
     foreach ($menu_items as $item) {
         if (!$item) {
             continue;
         }
         preg_match($this->pattern, $item, $value);
         $id = (int) substr($item, strlen($value[1]), strlen($item));
         switch (substr($item, 0, strlen($value[1]))) {
             case 'CAT':
                 $categories = $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, false, $this->user_groups));
                 $root_node['children'] = array_merge($root_node['children'], $categories);
                 break;
             case 'PRD':
                 $product = new Product((int) $id, true, (int) $id_lang);
                 if ($product->id) {
                     $root_node['children'][] = $this->makeNode(['type' => 'product', 'page_identifier' => 'product-' . $product->id, 'label' => $product->name, 'url' => $product->getLink()]);
                 }
                 break;
             case 'CMS':
                 $cms = CMS::getLinks((int) $id_lang, array($id));
                 if (count($cms)) {
                     $root_node['children'][] = $this->makeNode(['type' => 'cms-page', 'page_identifier' => 'cms-page-' . $id, 'label' => $cms[0]['meta_title'], 'url' => $cms[0]['link']]);
                 }
                 break;
             case 'CMS_CAT':
                 $root_node['children'][] = $this->generateCMSCategoriesMenu((int) $id, (int) $id_lang);
                 break;
                 // Case to handle the option to show all Manufacturers
             // Case to handle the option to show all Manufacturers
             case 'ALLMAN':
                 $children = array_map(function ($manufacturer) use($id_lang) {
                     return $this->makeNode(['type' => 'manufacturer', 'page_identifier' => 'manufacturer-' . $manufacturer['id_manufacturer'], 'label' => $manufacturer['name'], 'url' => $this->context->link->getManufacturerLink(new Manufacturer($manufacturer['id_manufacturer'], $id_lang), null, $id_lang)]);
                 }, Manufacturer::getManufacturers());
                 $root_node['children'][] = $this->makeNode(['type' => 'manufacturers', 'page_identifier' => 'manufacturers', 'label' => $this->l('All manufacturers'), 'url' => $this->context->link->getPageLink('manufacturer'), 'children' => $children]);
                 break;
             case 'MAN':
                 $manufacturer = new Manufacturer($id, $id_lang);
                 if ($manufacturer->id) {
                     $root_node['children'][] = $this->makeNode(['type' => 'manufacturer', 'page_identifier' => 'manufacturer-' . $manufacturer->id, 'label' => $manufacturer->name, 'url' => $this->context->link->getManufacturerLink($manufacturer, null, $id_lang)]);
                 }
                 break;
                 // Case to handle the option to show all Suppliers
             // Case to handle the option to show all Suppliers
             case 'ALLSUP':
                 $children = array_map(function ($supplier) use($id_lang) {
                     return $this->makeNode(['type' => 'supplier', 'page_identifier' => 'supplier-' . $supplier['id_supplier'], 'label' => $supplier['name'], 'url' => $this->context->link->getSupplierLink(new Supplier($supplier['id_supplier'], $id_lang), null, $id_lang)]);
                 }, Supplier::getSuppliers());
                 $root_node['children'][] = $this->makeNode(['type' => 'suppliers', 'page_identifier' => 'suppliers', 'label' => $this->l('All suppliers'), 'url' => $this->context->link->getPageLink('supplier'), 'children' => $children]);
                 break;
             case 'SUP':
                 $supplier = new Supplier($id, $id_lang);
                 if ($supplier->id) {
                     $root_node['children'][] = $this->makeNode(['type' => 'supplier', 'page_identifier' => 'supplier-' . $supplier->id, 'label' => $supplier->name, 'url' => $this->context->link->getSupplierLink($supplier, null, $id_lang)]);
                 }
                 break;
             case 'SHOP':
                 $shop = new Shop((int) $id);
                 if (Validate::isLoadedObject($shop)) {
                     $root_node['children'][] = $this->makeNode(['type' => 'shop', 'page_identifier' => 'shop-' . $id, 'label' => $shop->name, 'url' => $shop->getBaseURL()]);
                 }
                 break;
             case 'LNK':
                 $link = Ps_MenuTopLinks::get($id, $id_lang, $id_shop);
                 if (!empty($link)) {
                     if (!isset($link[0]['label']) || $link[0]['label'] == '') {
                         $default_language = Configuration::get('PS_LANG_DEFAULT');
                         $link = Ps_MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int) Shop::getContextShopID());
                     }
                     $root_node['children'][] = $this->makeNode(['type' => 'link', 'page_identifier' => $link[0]['link'], 'label' => $link[0]['label'], 'url' => $link[0]['link'], 'open_in_new_window' => $link[0]['new_window']]);
                 }
                 break;
         }
     }
     return $this->mapTree(function ($node, $depth) {
         $node['depth'] = $depth;
         return $node;
     }, $root_node);
 }
Ejemplo n.º 5
0
    function hookAjaxCall()
    {
        $action = Tools::getValue('action');
        $errors = null;
        $id_shop = null;
        if (Tools::getValue('id_shop') != '' && Tools::getValue('id_shop') != 0) {
            Shop::setContext(Shop::CONTEXT_SHOP, Tools::getValue('id_shop'));
            $id_shop = (int) Shop::getContextShopID();
        } else {
            $id_shop = Configuration::get('PS_SHOP_DEFAULT');
        }
        if ($action == "delete") {
            $link = new MegaMenuClass((int) Tools::getValue('id'));
            Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'megamenu` SET `position` = (`position` - 0.01) WHERE `position` > ' . $link->position . ' AND `parent` = ' . $link->parent);
            $link->delete();
            echo Tools::jsonEncode('Link deleted successfully');
        } elseif ($action == "enable") {
            if (Tools::getValue('custom') == 'true') {
                $link = new MegaMenuClass((int) Tools::getValue('id'));
                $link->active = $link->active ? 0 : 1;
                $link->update();
                $response = array('msg' => 'Item status has changed.', 'active' => $link->active);
                // if categories element
            } else {
                $active = null;
                $CATS = Configuration::get('MEGAMENU_CATS');
                $UN_CATS = array();
                $UN_CATS = unserialize($CATS);
                // get serialzie date
                if (empty($UN_CATS)) {
                    is_array($UN_CATS) == false ? $UN_CATS = array() : '';
                    // add first time if empty
                    array_push($UN_CATS, (int) Tools::getValue('id'));
                    $SE_CATS = serialize($UN_CATS);
                    Configuration::updateValue('MEGAMENU_CATS', $SE_CATS);
                    $active = 0;
                } else {
                    if (in_array(Tools::getValue('id'), $UN_CATS)) {
                        foreach ($UN_CATS as $key => $value) {
                            if ($value == Tools::getValue('id')) {
                                unset($UN_CATS[$key]);
                                $active = 1;
                            }
                        }
                    } else {
                        $active = 0;
                        array_push($UN_CATS, (int) Tools::getValue('id'));
                    }
                    //corect keys
                    $UN_CATS = array_values($UN_CATS);
                    //serialize and save configuration
                    $SE_CATS = serialize($UN_CATS);
                    Configuration::updateValue('MEGAMENU_CATS', $SE_CATS);
                }
                $response = array('msg' => 'Item status has changed.', 'active' => $active);
            }
            echo Tools::jsonEncode($response);
        } elseif ($action == "edit") {
            $link = new MegaMenuClass((int) Tools::getValue('id'), Context::getContext()->cookie->id_lang);
            echo Tools::jsonEncode($link);
        } elseif ($action == "add") {
            $link = new MegaMenuClass();
            $link->active = 1;
            $link->parent = (int) Tools::getValue('parent');
            $link->parent_custom = Tools::getValue('custom') == 'true' ? 1 : 0;
            $link->copyFromPost();
            $link->add();
            $response = array('id' => $link->id, 'parent' => $link->parent, 'name' => $link->name[Context::getContext()->cookie->id_lang], 'msg' => 'Menu item added.');
            echo Tools::jsonEncode($response);
        } elseif ($action == "saveedit") {
            $link = new MegaMenuClass((int) Tools::getValue('id_megamenu'));
            $link->copyFromPost();
            $link->update();
            $item = new MegaMenuClass((int) Tools::getValue('id_megamenu'), Context::getContext()->cookie->id_lang);
            $response = array('msg' => 'Item modified.', 'item' => $item);
            echo Tools::jsonEncode($response);
        } elseif ($action == "copycms") {
            $id_cms = array((int) Tools::getValue('id_cms'));
            $cmslink[] = null;
            $languages = Language::getLanguages(false);
            foreach ($languages as $language) {
                $cms = CMS::getLinks($language['id_lang'], $id_cms);
                $cmslink += array('name_' . $language['id_lang'] => $cms[0]['meta_title'], 'title_' . $language['id_lang'] => $cms[0]['meta_title'], 'url_' . $language['id_lang'] => $cms[0]['link']);
            }
            if (!$errors) {
                $link = new MegaMenuClass();
                $link->active = 1;
                $link->parent = (int) Tools::getValue('parentid');
                $link->parent_custom = Tools::getValue('custom') == 'true' ? 1 : 0;
                $link->copyFromPost($cmslink);
                $link->add();
                $response = array('id' => $link->id, 'parent' => $link->parent, 'name' => $link->name[Context::getContext()->cookie->id_lang], 'msg' => 'Cms item added.');
                echo Tools::jsonEncode($response);
            } else {
                $error = array('error' => $errors);
                echo Tools::jsonEncode($error);
            }
        } elseif ($action == "position") {
            $csvAll = explode(",", Tools::getValue('csv'));
            $total = count($csvAll) - 1;
            for ($i = 0; $i < $total; $i++) {
                $csv = explode("/", $csvAll[$i]);
                Db::getInstance()->Execute('update `' . _DB_PREFIX_ . 'megamenu` set position = ' . (double) $csv[2] . ', parent = ' . $csv[1] . ', parent_custom = ' . ($csv[3] == 'true' ? 1 : 0) . ' where id_megamenu = ' . $csv[0]);
            }
            echo Tools::jsonEncode('Position update.');
        } elseif ($action == "removeimage") {
            $id = Tools::getValue('id');
            if (file_exists(dirname(__FILE__) . "/images/" . $id . '.jpg')) {
                unlink(dirname(__FILE__) . "/images/" . $id . '.jpg');
            }
        } elseif ($action == "gettree") {
            $response = null;
            $subs = null;
            if (Tools::getValue('custom') == 'false') {
                $cat = new Category((int) Tools::getValue('id'));
                if (version_compare(_PS_VERSION_, '1.5.0.0') == +1) {
                    $subs = $this->getSubCategories($cat->id, Context::getContext()->cookie->id_lang, true);
                } else {
                    $subs = $cat->getSubCategories($cookie->id_lang, true);
                }
                //get disable categories
                $CATS = Configuration::get('MEGAMENU_CATS');
                $UN_CATS = array();
                $UN_CATS = unserialize($CATS);
            }
            $customLinks = MegaMenuClass::getCustomLinks(Tools::getValue('id'), Tools::getValue('custom'), Configuration::get('PS_LANG_DEFAULT'), $id_shop);
            if (count($subs) > 0) {
                $allLinks = array_merge($subs, $customLinks);
                $this->aasort($allLinks, "position");
            } else {
                $allLinks = $customLinks;
            }
            //echo( print_r($allLinks) );
            if ($allLinks) {
                foreach ($allLinks as $link) {
                    if (isset($link['id_category'])) {
                        $children = MegaMenuClass::getNBchildren(false, $link['id_category']);
                        $response .= '<li class="' . ($children > 0 ? 'parent collapsed' : '') . '" data-id="' . $link['id_category'] . '" pos="' . $link['position'] . '">
	                            	<a class="caption ui-droppable ' . (is_array($UN_CATS) && in_array($link['id_category'], $UN_CATS) == true ? 'disable' : 'enable') . '" rel="' . $link['id_category'] . '">' . $link['name'] . '</a>
	                             </li>';
                    } else {
                        $children = MegaMenuClass::getNBchildren(true, $link['id_megamenu']);
                        $response .= '<li class="custom ' . ($children > 0 ? 'parent collapsed' : '') . '" data-id="' . $link['id_megamenu'] . '" pos="' . $link['position'] . '">
	                        		<span class="custom-img"></span>
	                        		<a class="caption ui-droppable  ' . ($link['active'] ? 'enable' : 'disable') . '" rel="' . $link['id_megamenu'] . '">' . $link['name'] . '</a>
	                      	  </li>';
                    }
                }
            }
            echo $response;
        }
    }
Ejemplo n.º 6
0
 private function makeMobileMenu($item)
 {
     $listofthisfrontmenu = '';
     $id_lang = (int) $this->context->language->id;
     $id_shop = (int) Shop::getContextShopID();
     preg_match($this->pattern, $item, $values);
     $id = (int) substr($item, strlen($values[1]), strlen($item));
     switch (substr($item, 0, strlen($values[1]))) {
         case 'CAT':
             $this->_mmenu .= $this->getCatMobileOption((int) $id);
             break;
         case 'PRD':
             $selected = $this->page_name == 'product' && Tools::getValue('id_product') == $id ? ' class="sfHover"' : '';
             $product = new Product((int) $id, true, (int) $id_lang);
             if (!is_null($product->id)) {
                 $this->_mmenu .= '<option value="' . $product->getLink() . '">' . $product->name . '</option>' . PHP_EOL;
             }
             break;
         case 'CMS':
             $selected = $this->page_name == 'cms' && Tools::getValue('id_cms') == $id ? '' : '';
             $cms = CMS::getLinks((int) $id_lang, array($id));
             if (count($cms)) {
                 $this->_mmenu .= '<option value="' . $cms[0]['link'] . '">' . $cms[0]['meta_title'] . '</option>' . PHP_EOL;
             }
             break;
         case 'CMS_CAT':
             $category = new CMSCategory((int) $id, (int) $id_lang);
             if (count($category)) {
                 $this->_mmenu .= '<option value="' . $category->getLink() . '"><span class="errow"></span><span>' . $category->name . '</option>';
                 $this->getCMSMenuItems($category->id);
             }
             break;
         case 'MAN':
             $selected = $this->page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id ? ' class="sfHover"' : '';
             $manufacturer = new Manufacturer((int) $id, (int) $id_lang);
             if (!is_null($manufacturer->id)) {
                 if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) {
                     $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name);
                 } else {
                     $manufacturer->link_rewrite = 0;
                 }
                 $link = new Link();
                 $this->_mmenu .= '<option value="' . htmlentities($link->getManufacturerLink((int) $id, $manufacturer->link_rewrite)) . '">' . $manufacturer->name . '</option>' . PHP_EOL;
             }
             break;
         case 'SUP':
             $selected = $this->page_name == 'supplier' && Tools::getValue('id_supplier') == $id ? ' class="sfHover"' : '';
             $supplier = new Supplier((int) $id, (int) $id_lang);
             if (!is_null($supplier->id)) {
                 $link = new Link();
                 $this->_mmenu .= '<option value="' . $link->getSupplierLink((int) $id, $supplier->link_rewrite) . '">' . $supplier->name . '</option>' . PHP_EOL;
             }
             break;
         case 'LNK':
             $link = TdMegaMenu::getCustomLinksByid((int) $id, (int) $id_lang, (int) $id_shop);
             if (count($link)) {
                 if (!isset($link[0]['label']) || $link[0]['label'] == '') {
                     $default_language = Configuration::get('PS_LANG_DEFAULT');
                     $link = TdMegaMenu::getCustomLinksByid($link[0]['id_tdmegamenu'], (int) $default_language, (int) Shop::getContextShopID());
                 }
                 $listofthisfrontmenu .= '<option value="' . $link[0]['menu_link'] . '">' . $link[0]['menu_title'] . '</option>' . PHP_EOL;
                 if ($link[0]['custome_type'] == 'cus_html') {
                     $this->_mmenu .= html_entity_decode($link[0]['description']);
                 }
             }
             break;
         case 'SHOP':
             $selected = $this->page_name == 'index' && $this->context->shop->id == $id ? ' class="sfHover"' : '';
             $shop = new Shop((int) $id);
             if (Validate::isLoadedObject($shop)) {
                 $link = new Link();
                 $this->_mmenu .= '<option value="' . $shop->getBaseURL() . '">' . $shop->name . '</option>' . PHP_EOL;
             }
             break;
     }
     return $listofthisfrontmenu;
 }
Ejemplo n.º 7
0
 public function hookFooter($params)
 {
     $user_groups = $this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP'));
     $block1_id = Configuration::get('FOOTER_1_CAT_BLOCK', 0);
     $id_lang = (int) $this->context->language->id;
     if ($block1_id != 0) {
         $category1 = Category::getNestedCategories($block1_id, $id_lang, true, $user_groups);
         $category1 = $category1[$block1_id];
     } else {
         $category1 = null;
     }
     $block2_ids = json_decode(Configuration::get('FOOTER_2_CAT_BLOCK', '[]'));
     if (!empty($block2_ids)) {
         $categories = array();
         foreach ($block2_ids as $key => $id) {
             if ($id != 0) {
                 if ($key == 3) {
                     $sql_limit = 'LIMIT 0, 4';
                 } else {
                     $sql_limit = '';
                 }
                 $temp = Category::getNestedCategories($id, $id_lang, true, $user_groups, true, '', '', $sql_limit);
                 $categories2[] = $temp[$id];
             }
         }
     } else {
         $categories2 = array();
     }
     $block3_id = Configuration::get('FOOTER_3_CAT_BLOCK', 0);
     if ($block3_id != 0) {
         $sql_limit = 'LIMIT 0, 6';
         $category3 = Category::getNestedCategories($block3_id, $id_lang, true, $user_groups, true, '', '', $sql_limit);
         $category3 = $category3[$block3_id];
     } else {
         $category3 = null;
     }
     $block4_id = Configuration::get('FOOTER_4_CMS_BLOCK', 0);
     if ($block4_id != 0) {
         $sql_limit = 'LIMIT 0, 10';
         $category4 = new CMSCategory((int) $block4_id, (int) $id_lang);
         if (count($category4)) {
             $category['link'] = Tools::HtmlEntitiesUTF8($category4->getLink());
             $category['name'] = $category4->name;
             $pages = $this->getCMSPages($category4->id);
             foreach ($pages as $page) {
                 $cms = new CMS($page['id_cms'], (int) $id_lang);
                 $links = $cms->getLinks((int) $id_lang, array((int) $cms->id));
                 $page['link'] = $links[0]['link'];
                 $category['pages'][] = $page;
             }
             $category4 = $category;
         } else {
             $category4 = null;
         }
     } else {
         $category4 = null;
     }
     $this->smarty->assign('category1', $category1);
     $this->smarty->assign('categories2', $categories2);
     $this->smarty->assign('category3', $category3);
     $this->smarty->assign('category4', $category4);
     $this->smarty->assign('footer_category', new Category());
     $display = $this->display(__FILE__, 'footer.tpl');
     return $display;
 }
Ejemplo n.º 8
0
 private function getCMSMenuItems($parent, $depth = 1, $id_lang = false)
 {
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     if ($depth > 3) {
         return;
     }
     $categories = $this->getCMSCategories(false, (int) $parent, (int) $id_lang);
     $pages = $this->getCMSPages((int) $parent);
     if (count($categories) || count($pages)) {
         $this->_menuLink .= '<div class ="popup" style ="display:none">';
         foreach ($pages as $page) {
             $cms = new CMS($page['id_cms'], (int) $id_lang);
             $links = $cms->getLinks((int) $id_lang, array((int) $cms->id));
             $selected = $this->page_name == 'cms' && (int) Tools::getValue('id_cms') == $page['id_cms'] ? ' class="sfHoverForce"' : '';
             $this->_menuLink .= '<div class ="block1"><div class="column col1"><div class="itemSubMenu level3"><a href="' . $links[0]['link'] . '">' . $cms->meta_title . '</a></div></div></div>' . PHP_EOL;
         }
         $this->_menuLink .= '</div></div>';
     }
 }
 private function getCMSMenuItems(&$menu, $parent, $depth = 1, $id_lang = false)
 {
     $category_id = (int) Tools::getValue('id_cms_category', false);
     $page_id = (int) Tools::getValue('id_cms', false);
     $is_category = $this->page_name == 'cms' && $category_id;
     $is_page = $this->page_name == 'cms' && $page_id;
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $activeCategories = array();
     if ($is_page) {
         $parent_category = $this->getCmsParentCategory($page_id);
         $activeCategories = $this->getActiveCMSMenuItemPath($parent_category, $id_lang);
     } else {
         if ($is_category) {
             $activeCategories = $this->getActiveCMSMenuItemPath($category_id, $id_lang);
         }
     }
     $categories = $this->getCMSCategories(false, (int) $parent, (int) $id_lang);
     $pages = $this->getCMSPages((int) $parent);
     if ((count($categories) || count($pages)) && ($this->_showAll !== 'one level' || $this->_showAllResponsive !== 'one level')) {
         $pageMenu = '';
         foreach ($pages as $page) {
             $cms = new CMS($page['id_cms'], (int) $id_lang);
             $links = $cms->getLinks((int) $id_lang, array((int) $cms->id));
             $selected = $this->page_name == 'cms' && (int) Tools::getValue('id_cms') == $page['id_cms'] ? ' class="active"' : '';
             $pageMenu .= $this->_subItemHead . '<li class="' . $this->_subItemClass . '">';
             $pageMenu .= '<a href="' . $links[0]['link'] . '"' . $selected . '><span>' . $cms->meta_title . '</span></a>';
             $pageMenu .= '</li>' . $this->_subItemTail;
         }
         $catMenu = '';
         foreach ($categories as $category) {
             $currentId = (int) $category['id_cms_category'];
             $catSelect = '';
             foreach ($activeCategories as $activeCategory) {
                 if ($currentId === (int) $activeCategory['id_cms_category']) {
                     $catSelect = ' class="active"';
                 }
             }
             $cat = new CMSCategory((int) $category['id_cms_category'], (int) $id_lang);
             $catMenu .= $this->_subItemHead . '<li class="' . $this->_subItemClass . '">';
             $catMenu .= '<a href="' . Tools::HtmlEntitiesUTF8($cat->getLink()) . '"' . $catSelect . '><span>' . $category['name'] . '</span></a>';
             $this->getCMSMenuItems($catMenu, $category['id_cms_category'], (int) $depth + 1, $id_lang);
             $catMenu .= '</li>' . $this->_subItemTail;
         }
         $menu .= $this->_subMenuHead . '<ul class="' . $this->_subMenuClass . (empty($catMenu) ? '' : ' active') . '">';
         $menu .= $catMenu;
         $menu .= $pageMenu;
         $menu .= '</ul>' . $this->_subMenuTail;
     }
 }
 private function makeMenu()
 {
     global $cookie, $page_name;
     $curr_level = 1;
     foreach ($this->getMenuItems() as $key => $item) {
         extract($item);
         if ($depth > $curr_level) {
             $this->_menu .= '<ul>';
         }
         if ($depth == $curr_level && $key != 0) {
             $this->_menu .= '</li>';
         }
         if ($depth < $curr_level) {
             $this->_menu .= str_repeat('</li></ul>', $curr_level - $depth) . '</li>';
         }
         $curr_level = $depth;
         switch ($type) {
             case 'CAT':
                 $this->getCategory($id_ref, $cookie->id_lang);
                 break;
             case 'PRD':
                 $selected = $page_name == 'product' && Tools::getValue('id_product') == $id_ref ? ' class="sfHover"' : '';
                 $product = new Product($id_ref, true, $cookie->id_lang);
                 if (!is_null($product->id)) {
                     $this->_menu .= '<li' . $selected . '><a href="' . $product->getLink() . '"><span>' . $product->name . '</span></a>' . PHP_EOL;
                 }
                 break;
             case 'CCS':
                 $selected = $page_name == 'cms' && Tools::getValue('id_cms_category') == $id_ref ? ' class="sfHover"' : '';
                 $_this_cat = new CMSCategory($id_ref, $cookie->id_lang);
                 $link = new Link();
                 $this->_menu .= '<li' . $selected . '><a href="' . $link->getCMSCategoryLink($_this_cat->id, $_this_cat->link_rewrite) . '"><span>' . htmlentities($_this_cat->name) . '
       </span></a>' . PHP_EOL;
                 break;
             case 'CMS':
                 $selected = $page_name == 'cms' && Tools::getValue('id_cms') == $id_ref ? ' class="sfHover"' : '';
                 $cms = CMS::getLinks($cookie->id_lang, array($id_ref));
                 if (count($cms)) {
                     $this->_menu .= '<li' . $selected . '><a href="' . $cms[0]['link'] . '"><span>' . htmlentities($cms[0]['meta_title']) . '</span></a>' . PHP_EOL;
                 }
                 break;
             case 'MAN':
                 $selected = $page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id_ref ? ' class="sfHover"' : '';
                 $manufacturer = new Manufacturer($id_ref, $cookie->id_lang);
                 if (!is_null($manufacturer->id)) {
                     if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) {
                         $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name, false);
                     } else {
                         $manufacturer->link_rewrite = 0;
                     }
                     $link = new Link();
                     $this->_menu .= '<li' . $selected . '><a href="' . $link->getManufacturerLink($id_ref, $manufacturer->link_rewrite) . '">' . $manufacturer->name . '</a>' . PHP_EOL;
                 }
                 break;
             case 'SUP':
                 $selected = $page_name == 'supplier' && Tools::getValue('id_supplier') == $id_ref ? ' class="sfHover"' : '';
                 $supplier = new Supplier($id_ref, $cookie->id_lang);
                 if (!is_null($supplier->id)) {
                     $link = new Link();
                     $this->_menu .= '<li' . $selected . '><a href="' . $link->getSupplierLink($id_ref, $supplier->link_rewrite) . '"><span>' . $supplier->name . '</span></a>' . PHP_EOL;
                 }
                 break;
             case 'LNK':
                 $link = WPMenuTopLinks::get($id_ref, $cookie->id_lang);
                 if (count($link)) {
                     $this->_menu .= '<li><a href="' . $link[0]['link'] . '"' . ($link[0]['new_window'] ? ' target="_blank"' : '') . '><span>' . $link[0]['label'] . '</span></a>' . PHP_EOL;
                 }
                 break;
         }
     }
     $this->_menu .= str_repeat('</li></ul>', $curr_level - 1) . '</li>';
 }
Ejemplo n.º 11
0
    $ret = '<li>' . "\n";
    $ret .= '<a href="' . $node['link'] . '" title="' . strip_tags($node['desc']) . '">' . $node['name'] . '</a>' . "\n";
    if (!empty($node['children'])) {
        $ret .= '<ul>' . "\n";
        foreach ($node['children'] as $child) {
            $ret .= constructTreeNode($child);
        }
        $ret .= '</ul>' . "\n";
    }
    $ret .= '</li>' . "\n";
    return $ret;
}
$ulTree = '<div class="tree-top">' . $categTree['name'] . '</div>' . "\n";
$ulTree .= '<ul class="tree">' . "\n";
foreach ($categTree['children'] as $child) {
    $ulTree .= constructTreeNode($child);
}
$ulTree .= '</ul>' . "\n";
$smarty->assign('categoryTree', $ulTree);
/* ELSE */
$smarty->assign('categoriesTree', $categTree);
/* /ONLY FOR THEME OLDER THAN v1.0 */
$cms = CMS::listCms(intval($cookie->id_lang));
$id_cms = array();
foreach ($cms as $row) {
    $id_cms[] = intval($row['id_cms']);
}
$smarty->assign('cmslinks', CMS::getLinks(intval($cookie->id_lang), $id_cms));
$smarty->assign('voucherAllowed', intval(Configuration::get('PS_VOUCHERS')));
$smarty->display(_PS_THEME_DIR_ . 'sitemap.tpl');
include dirname(__FILE__) . '/footer.php';
Ejemplo n.º 12
0
 public static function getItemsForView($id_lang, $id_parent = 0)
 {
     if (self::isCached($id_lang)) {
         return self::getCache($id_lang);
     }
     $results = Db::getInstance()->ExecuteS('
         SELECT a.`id_menu`, a.`id_parent`, a.`id_item`, a.`type`, a.`level`, a.`ignore`, a.`logged`, a.`new_window`, a.`css`,  b.`title`, b.`link`
         FROM `' . _DB_PREFIX_ . 'menu` a
         LEFT JOIN `' . _DB_PREFIX_ . 'menu_lang` b ON (a.`id_menu` = b.`id_menu` AND b.`id_lang` = "' . $id_lang . '")
         WHERE a.`id_parent` = "' . $id_parent . '" AND a.`active` = 1
         ORDER BY a.`position` ASC
     ');
     foreach ($results as $k => $result) {
         if (is_array($result) && count($result)) {
             $childrens = self::getItemsForView($id_lang, $result['id_menu']);
         } else {
             $childrens = array();
         }
         // BEGIN - TITLE
         $link = $result['link'];
         if ($result['type'] == 'cms') {
             $object = new CMS($result['id_item'], $id_lang);
             $title = $object->meta_title;
             $cms = CMS::getLinks($id_lang, array($result['id_item']));
             if (count($cms)) {
                 $link = $cms[0]['link'];
             } else {
                 $link = '#';
             }
         } else {
             if ($result['type'] != 'link' && $result['type'] != 'manufacturers' && $result['type'] != 'suppliers') {
                 if ($result['type'] == 'product') {
                     $objectName = ucfirst($result['type']);
                     $object = new $objectName($result['id_item'], true, $id_lang);
                 } else {
                     $objectName = ucfirst($result['type']);
                     $object = new $objectName($result['id_item'], $id_lang);
                 }
                 $title = $object->name;
                 switch ($result['type']) {
                     case 'category':
                         $link = $object->getLink();
                         if (Configuration::get('MENU_CATEGORIES_NUM') == '2' && $result['id_item'] != '1') {
                             $results[$k]['numProducts'] = self::getNumProductsByCategory($result['id_item']);
                         }
                         $categories = self::getCategories($result['id_item'], $id_lang, explode(',', $result['ignore']), intval($result['level']));
                         if (isset($categories[0]) && isset($categories[0]['childrens'])) {
                             $childrens = array_merge($childrens, $categories[0]['childrens']);
                         }
                         break;
                     case 'product':
                         $link = $object->getLink();
                         break;
                     case 'manufacturer':
                         if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) {
                             $manufacturer->link_rewrite = Tools::link_rewrite($title, false);
                         } else {
                             $manufacturer->link_rewrite = 0;
                         }
                         $_link = new Link();
                         $link = $_link->getManufacturerLink($result['id_item'], $object->link_rewrite);
                         break;
                     case 'supplier':
                         $_link = new Link();
                         $link = $_link->getSupplierLink($result['id_item'], $object->link_rewrite);
                         break;
                 }
             }
         }
         // Manufacturers
         if ($result['type'] == 'manufacturers') {
             $link = 'manufacturer.php';
             $childrens = self::getManufacturers();
         }
         // Suppliers
         if ($result['type'] == 'suppliers') {
             $link = 'supplier.php';
             $childrens = self::getSuppliers();
         }
         $results[$k]['link'] = $link;
         if (trim($result['title']) == '') {
             $results[$k]['title'] = $title;
         }
         if (count(explode('.', $results[$k]['title'])) > 1) {
             $results[$k]['title'] = str_replace('.', '', strstr($results[$k]['title'], '.'));
         }
         $results[$k]['id'] = $result['id_item'];
         unset($results[$k]['id_parent'], $results[$k]['id_item'], $results[$k]['level'], $results[$k]['ignore']);
         // END - TITLE
         $results[$k]['childrens'] = $childrens;
     }
     if ($id_parent == 0) {
         self::setCache($results, $id_lang);
     }
     return $results;
 }
Ejemplo n.º 13
0
 public function getMenuCustomerLink($lang_id = NULL)
 {
     $menu_items = $this->getMenuItems();
     $id_lang = (int) $this->context->language->id;
     $id_shop = (int) Shop::getContextShopID();
     foreach ($menu_items as $item) {
         if (!$item) {
             continue;
         }
         preg_match($this->pattern, $item, $value);
         $id = (int) substr($item, strlen($value[1]), strlen($item));
         switch (substr($item, 0, strlen($value[1]))) {
             case 'CAT':
                 $this->_menuLink .= $this->drawCustomMenuItem($id, 0, false, 0, $lang_id);
                 break;
             case 'PRD':
                 $selected = $this->page_name == 'product' && Tools::getValue('id_product') == $id ? ' class="sfHover"' : '';
                 $product = new Product((int) $id, true, (int) $id_lang);
                 if (!is_null($product->id)) {
                     $this->_menuLink .= '<div id ="pt_menu_product" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($product->getLink()) . '"><span>' . $product->name . '</span></a></div></div>' . PHP_EOL;
                 }
                 break;
             case 'CMS':
                 $selected = $this->page_name == 'cms' && Tools::getValue('id_cms') == $id ? ' class="sfHover"' : '';
                 $cms = CMS::getLinks((int) $id_lang, array($id));
                 if (count($cms)) {
                     $this->_menuLink .= '<div id ="pt_menu_cms" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($cms[0]['link']) . '"><span>' . $cms[0]['meta_title'] . '</span></a></div></div>' . PHP_EOL;
                 }
                 break;
             case 'CMS_CAT':
                 $category = new CMSCategory((int) $id, (int) $id_lang);
                 if (Validate::isLoadedObject($category)) {
                     $this->_menuLink .= '<div id ="pt_menu_cms" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($category->getLink()) . '"><span>' . $category->name . '</span></a>';
                 }
                 $this->_menuLink .= '</div>' . PHP_EOL;
                 $this->_menuLink .= $this->getCMSMenuItems($category->id);
                 // Case to handle the option to show all Manufacturers
             // Case to handle the option to show all Manufacturers
             case 'ALLMAN':
                 $link = new Link();
                 $this->_menuLink .= '<div id ="pt_menu_allsub" class ="pt_menu"><div class="parentMenu" ><a href="' . $link->getPageLink('manufacturer') . '" ><span>' . $this->l('All manufacturers') . '</span></a></div>' . PHP_EOL;
                 $manufacturers = Manufacturer::getManufacturers();
                 $this->_menuLink .= '<div class ="popup" style ="display:none">';
                 foreach ($manufacturers as $key => $manufacturer) {
                     $this->_menuLink .= '<div class ="block1"><div class="column col1"><div class="itemSubMenu level3"><a href="' . $link->getManufacturerLink((int) $manufacturer['id_manufacturer'], $manufacturer['link_rewrite']) . '">' . $manufacturer['name'] . '</a></div></div></div>' . PHP_EOL;
                 }
                 $this->_menuLink .= '</div></div>';
                 break;
             case 'MAN':
                 $selected = $this->page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id ? ' class="sfHover"' : '';
                 $manufacturer = new Manufacturer((int) $id, (int) $id_lang);
                 if (!is_null($manufacturer->id)) {
                     if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) {
                         $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name);
                     } else {
                         $manufacturer->link_rewrite = 0;
                     }
                     $link = new Link();
                     $this->_menuLink .= '<div id ="pt_menu_man" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($link->getManufacturerLink((int) $id, $manufacturer->link_rewrite)) . '"><span>' . $manufacturer->name . '</span></a></div></div>' . PHP_EOL;
                 }
                 break;
                 // Case to handle the option to show all Suppliers
             // Case to handle the option to show all Suppliers
             case 'ALLSUP':
                 $link = new Link();
                 $this->_menuLink .= '<div id ="pt_menu_allsub" class ="pt_menu"><div class="parentMenu" ><a href="' . $link->getPageLink('supplier') . '" ><span>' . $this->l('All suppliers') . '</span></a></div>' . PHP_EOL;
                 $suppliers = Supplier::getSuppliers();
                 $this->_menuLink .= '<div class ="popup" style ="display:none">';
                 foreach ($suppliers as $key => $supplier) {
                     $this->_menuLink .= '<div class ="block1"><div class="column col1"><div class="itemSubMenu level3"><a href="' . $link->getSupplierLink((int) $supplier['id_supplier'], $supplier['link_rewrite']) . '">' . $supplier['name'] . '</a></div></div></div>' . PHP_EOL;
                 }
                 $this->_menuLink .= '</div></div>';
                 break;
             case 'SUP':
                 $selected = $this->page_name == 'supplier' && Tools::getValue('id_supplier') == $id ? ' class="sfHover"' : '';
                 $supplier = new Supplier((int) $id, (int) $id_lang);
                 if (!is_null($supplier->id)) {
                     $link = new Link();
                     $this->_menuLink .= '<div id ="pt_menu_sub" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($link->getSupplierLink((int) $id, $supplier->link_rewrite)) . '"><span>' . $supplier->name . '</span></a></div></div>' . PHP_EOL;
                 }
                 break;
             case 'SHOP':
                 $selected = $this->page_name == 'index' && $this->context->shop->id == $id ? ' class="sfHover"' : '';
                 $shop = new Shop((int) $id);
                 if (Validate::isLoadedObject($shop)) {
                     $link = new Link();
                     $this->_menuLink .= '<div id ="pt_menu_sub" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($shop->getBaseURL()) . '"><span>' . $supplier->name . '</span></a></div></div>' . PHP_EOL;
                 }
                 break;
             case 'LNK':
                 $link = VegaTopLinks::get((int) $id, (int) $id_lang, (int) $id_shop);
                 if (count($link)) {
                     if (!isset($link[0]['label']) || $link[0]['label'] == '') {
                         $default_language = Configuration::get('PS_LANG_DEFAULT');
                         $link = VegaTopLinks::get($link[0]['id_linksvegatop'], $default_language, (int) Shop::getContextShopID());
                     }
                     $this->_menuLink .= '<div id ="pt_ver_menu_link" class ="pt_menu"><div class="parentMenu" ><a href="' . Tools::HtmlEntitiesUTF8($link[0]['link']) . '"' . ($link[0]['new_window'] ? ' target="_blank"' : '') . '><span>' . $link[0]['label'] . '</a></span></div></div>' . PHP_EOL;
                 }
                 break;
         }
     }
 }
 private function getCMSMenuItems(&$menu, $parent, $depth = 1, $id_lang = false)
 {
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     if ($depth > 3) {
         return;
     }
     $categories = $this->getCMSCategories(false, (int) $parent, (int) $id_lang);
     $pages = $this->getCMSPages((int) $parent);
     if ((count($categories) || count($pages)) && ($this->_showAll !== 'one level' || $this->_showAllResponsive !== 'one level')) {
         $menu .= $this->_subMenuHead . '<ul class="' . $this->_subMenuClass . '">';
         foreach ($categories as $category) {
             $menu .= $this->_subItemHead . '<li class="' . $this->_subItemClass . '">';
             $menu .= '<a href="#"><span>' . $category['name'] . '</span></a>';
             $this->getCMSMenuItems($menu, $category['id_cms_category'], (int) $depth + 1);
             $menu .= '</li>' . $this->_subItemTail;
         }
         foreach ($pages as $page) {
             $cms = new CMS($page['id_cms'], (int) $id_lang);
             $links = $cms->getLinks((int) $id_lang, array((int) $cms->id));
             $selected = $this->page_name == 'cms' && (int) Tools::getValue('id_cms') == $page['id_cms'] ? ' active' : '';
             $menu .= $this->_subItemHead . '<li class="' . $this->_subItemClass . $selected . '">';
             $menu .= '<a href="' . $links[0]['link'] . '"><span>' . $cms->meta_title . '</span></a>';
             $menu .= '</li>' . $this->_subItemTail;
         }
         $menu .= '</ul>' . $this->_subMenuTail;
     }
 }
Ejemplo n.º 15
0
	protected function makeMenu()
	{
	    $menu_items = $this->getMenuItems();
	    $id_lang = (int)$this->context->language->id;
	    $id_shop = (int)Shop::getContextShopID();
	    $iteration = 1;
	    foreach ($menu_items as $item) {
	        if (!$item) {
	            continue;
	        }

	        preg_match($this->pattern, $item, $value);
	        $id = (int)substr($item, strlen($value[1]), strlen($item));

	        switch (substr($item, 0, strlen($value[1]))) {
	            case 'CAT':
	                $this->_menu .= $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, false, $this->user_groups), 0, $iteration);
	                    $iteration++;
	                break;

	            case 'PRD':
	                $selected = ($this->page_name == 'product' && (Tools::getValue('id_product') == $id)) ? ' class="sfHover"' : '';
	                $product = new Product((int)$id, true, (int)$id_lang);
	                if (!is_null($product->id)) {
	                    $this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($product->getLink()).'" title="'.$product->name.'">'.$product->name.'</a></li>'.PHP_EOL;
	                }
	                break;

	            case 'CMS':
	                $selected = ($this->page_name == 'cms' && (Tools::getValue('id_cms') == $id)) ? ' class="sfHover"' : '';
	                $cms = CMS::getLinks((int)$id_lang, array($id));
	                if (count($cms)) {
	                    $this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($cms[0]['link']).'" title="'.Tools::safeOutput($cms[0]['meta_title']).'">'.Tools::safeOutput($cms[0]['meta_title']).'</a></li>'.PHP_EOL;
	                }
	                break;

	            case 'CMS_CAT':
	                $category = new CMSCategory((int)$id, (int)$id_lang);
	                if (count($category)) {
	                    $this->_menu .= '<li><a href="'.Tools::HtmlEntitiesUTF8($category->getLink()).'" title="'.$category->name.'">'.$category->name.'</a>';
	                    $this->getCMSMenuItems($category->id);
	                    $this->_menu .= '</li>'.PHP_EOL;
	                }
	                break;

	            // Case to handle the option to show all Manufacturers
	            case 'ALLMAN':
	                $link = new Link;
	                $this->_menu .= '<li><a href="'.$link->getPageLink('manufacturer').'" title="'.$this->l('All manufacturers').'">'.$this->l('All manufacturers').'</a><ul>'.PHP_EOL;
	                $manufacturers = Manufacturer::getManufacturers();
	                foreach ($manufacturers as $key => $manufacturer) {
	                    $this->_menu .= '<li><a href="'.$link->getManufacturerLink((int)$manufacturer['id_manufacturer'], $manufacturer['link_rewrite']).'" title="'.Tools::safeOutput($manufacturer['name']).'">'.Tools::safeOutput($manufacturer['name']).'</a></li>'.PHP_EOL;
	                }
	                $this->_menu .= '</ul>';
	                break;

	            case 'MAN':
	                $selected = ($this->page_name == 'manufacturer' && (Tools::getValue('id_manufacturer') == $id)) ? ' class="sfHover"' : '';
	                $manufacturer = new Manufacturer((int)$id, (int)$id_lang);
	                if (!is_null($manufacturer->id)) {
	                    if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) {
	                        $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name);
	                    } else {
	                        $manufacturer->link_rewrite = 0;
	                    }
	                    $link = new Link;
	                    $this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($link->getManufacturerLink((int)$id, $manufacturer->link_rewrite)).'" title="'.Tools::safeOutput($manufacturer->name).'">'.Tools::safeOutput($manufacturer->name).'</a></li>'.PHP_EOL;
	                }
	                break;

	            // Case to handle the option to show all Suppliers
	            case 'ALLSUP':
	                $link = new Link;
	                $this->_menu .= '<li><a href="'.$link->getPageLink('supplier').'" title="'.$this->l('All suppliers').'">'.$this->l('All suppliers').'</a><ul>'.PHP_EOL;
	                $suppliers = Supplier::getSuppliers();
	                foreach ($suppliers as $key => $supplier) {
	                    $this->_menu .= '<li><a href="'.$link->getSupplierLink((int)$supplier['id_supplier'], $supplier['link_rewrite']).'" title="'.Tools::safeOutput($supplier['name']).'">'.Tools::safeOutput($supplier['name']).'</a></li>'.PHP_EOL;
	                }
	                $this->_menu .= '</ul>';
	                break;

	            case 'SUP':
	                $selected = ($this->page_name == 'supplier' && (Tools::getValue('id_supplier') == $id)) ? ' class="sfHover"' : '';
	                $supplier = new Supplier((int)$id, (int)$id_lang);
	                if (!is_null($supplier->id)) {
	                    $link = new Link;
	                    $this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($link->getSupplierLink((int)$id, $supplier->link_rewrite)).'" title="'.$supplier->name.'">'.$supplier->name.'</a></li>'.PHP_EOL;
	                }
	                break;

	            case 'SHOP':
	                $selected = ($this->page_name == 'index' && ($this->context->shop->id == $id)) ? ' class="sfHover"' : '';
	                $shop = new Shop((int)$id);
	                if (Validate::isLoadedObject($shop)) {
	                    $link = new Link;
	                    $this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($shop->getBaseURL()).'" title="'.$shop->name.'">'.$shop->name.'</a></li>'.PHP_EOL;
	                }
	                break;
	            case 'LNK':
	                $link = MenuTopLinks::get((int)$id, (int)$id_lang, (int)$id_shop);
	                if (count($link)) {
	                    if (!isset($link[0]['label']) || ($link[0]['label'] == '')) {
	                        $default_language = Configuration::get('PS_LANG_DEFAULT');
	                        $link = MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int)Shop::getContextShopID());
	                    }
	                    $this->_menu .= '<li><a href="'.Tools::HtmlEntitiesUTF8($link[0]['link']).'"'.(($link[0]['new_window']) ? ' onclick="return !window.open(this.href);"': '').' title="'.Tools::safeOutput($link[0]['label']).'">'.Tools::safeOutput($link[0]['label']).'</a></li>'.PHP_EOL;
	                }
	                break;
	        }
	    }
	}
Ejemplo n.º 16
0
 protected function getCMSMenuItems($parent, $depth = 1, $id_lang = false)
 {
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     if ($depth > 3) {
         return;
     }
     $categories = $this->getCMSCategories(false, (int) $parent, (int) $id_lang);
     $pages = $this->getCMSPages((int) $parent);
     if (count($categories) || count($pages)) {
         $this->_menu .= '<ul>';
         foreach ($categories as $category) {
             $cat = new CMSCategory((int) $category['id_cms_category'], (int) $id_lang);
             $this->_menu .= '<li>';
             $this->_menu .= '<a href="' . Tools::HtmlEntitiesUTF8($cat->getLink()) . '">' . $category['name'] . '</a>';
             $this->getCMSMenuItems($category['id_cms_category'], (int) $depth + 1);
             $this->_menu .= '</li>';
         }
         foreach ($pages as $page) {
             $cms = new CMS($page['id_cms'], (int) $id_lang);
             $links = $cms->getLinks((int) $id_lang, array((int) $cms->id));
             $selected = $this->page_name == 'cms' && (int) Tools::getValue('id_cms') == $page['id_cms'] ? ' class="sfHoverForce"' : '';
             $this->_menu .= '<li ' . $selected . '>';
             $this->_menu .= '<a href="' . $links[0]['link'] . '">' . $cms->meta_title . '</a>';
             $this->_menu .= '</li>';
         }
         $this->_menu .= '</ul>';
     }
 }
Ejemplo n.º 17
0
 private function makeMenuMobile()
 {
     $menu_items = $this->getMenuItems();
     $id_lang = (int) $this->context->language->id;
     $id_shop = (int) Shop::getContextShopID();
     $mobile_menu = '';
     $depth_limit = Configuration::get($this->config_name . '_mobile_menu_depth');
     foreach ($menu_items as $item) {
         if (!$item) {
             continue;
         }
         preg_match($this->pattern, $item, $value);
         $id = (int) substr($item, strlen($value[1]), strlen($item));
         switch (substr($item, 0, strlen($value[1]))) {
             case 'CAT':
                 $mobile_menu .= $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, true, $this->user_groups, true, '', $this->hor_sm_order), $depth_limit);
                 break;
             case 'PRD':
                 $product = new Product((int) $id, true, (int) $id_lang);
                 if (!is_null($product->id)) {
                     $mobile_menu .= '<li><a href="' . Tools::HtmlEntitiesUTF8($product->getLink()) . '" title="' . $product->name . '">' . $product->name . '</a></li>' . PHP_EOL;
                 }
                 break;
             case 'CMS':
                 $cms = CMS::getLinks((int) $id_lang, array($id));
                 if (count($cms)) {
                     $mobile_menu .= '<li><a href="' . Tools::HtmlEntitiesUTF8($cms[0]['link']) . '" title="' . Tools::safeOutput($cms[0]['meta_title']) . '">' . Tools::safeOutput($cms[0]['meta_title']) . '</a></li>' . PHP_EOL;
                 }
                 break;
                 // Case to handle the option to show all Manufacturers
             // Case to handle the option to show all Manufacturers
             case 'ALLMAN':
                 $link = new Link();
                 $mobile_menu .= '<li><a href="' . $link->getPageLink('manufacturer') . '" title="' . $this->l('All manufacturers') . '">' . $this->l('All manufacturers') . '</a><ul>' . PHP_EOL;
                 $manufacturers = Manufacturer::getManufacturers();
                 foreach ($manufacturers as $key => $manufacturer) {
                     $mobile_menu .= '<li><a href="' . $link->getManufacturerLink((int) $manufacturer['id_manufacturer'], $manufacturer['link_rewrite']) . '" title="' . Tools::safeOutput($manufacturer['name']) . '">' . Tools::safeOutput($manufacturer['name']) . '</a></li>' . PHP_EOL;
                 }
                 $mobile_menu .= '</ul>';
                 break;
             case 'MAN':
                 $manufacturer = new Manufacturer((int) $id, (int) $id_lang);
                 if (!is_null($manufacturer->id)) {
                     if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) {
                         $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name);
                     } else {
                         $manufacturer->link_rewrite = 0;
                     }
                     $link = new Link();
                     $mobile_menu .= '<li><a href="' . Tools::HtmlEntitiesUTF8($link->getManufacturerLink((int) $id, $manufacturer->link_rewrite)) . '" title="' . Tools::safeOutput($manufacturer->name) . '">' . Tools::safeOutput($manufacturer->name) . '</a></li>' . PHP_EOL;
                 }
                 break;
                 // Case to handle the option to show all Suppliers
             // Case to handle the option to show all Suppliers
             case 'ALLSUP':
                 $link = new Link();
                 $mobile_menu .= '<li><a href="' . $link->getPageLink('supplier') . '" title="' . $this->l('All suppliers') . '">' . $this->l('All suppliers') . '</a><ul>' . PHP_EOL;
                 $suppliers = Supplier::getSuppliers();
                 foreach ($suppliers as $key => $supplier) {
                     $mobile_menu .= '<li><a href="' . $link->getSupplierLink((int) $supplier['id_supplier'], $supplier['link_rewrite']) . '" title="' . Tools::safeOutput($supplier['name']) . '">' . Tools::safeOutput($supplier['name']) . '</a></li>' . PHP_EOL;
                 }
                 $mobile_menu .= '</ul>';
                 break;
             case 'HOME':
                 $link = new Link();
                 $mobile_menu .= '<li><a href="' . $link->getPageLink('index') . '" title="' . $this->l('Home') . '">' . $this->l('Home') . '</a></li>' . PHP_EOL;
                 break;
             case 'SUP':
                 $supplier = new Supplier((int) $id, (int) $id_lang);
                 if (!is_null($supplier->id)) {
                     $link = new Link();
                     $mobile_menu .= '<li><a href="' . Tools::HtmlEntitiesUTF8($link->getSupplierLink((int) $id, $supplier->link_rewrite)) . '" title="' . $supplier->name . '">' . $supplier->name . '</a></li>' . PHP_EOL;
                 }
                 break;
             case 'SHOP':
                 $shop = new Shop((int) $id);
                 if (Validate::isLoadedObject($shop)) {
                     $link = new Link();
                     $mobile_menu .= '<li><a href="' . Tools::HtmlEntitiesUTF8($shop->getBaseURL()) . '" title="' . $shop->name . '">' . $shop->name . '</a></li>' . PHP_EOL;
                 }
                 break;
             case 'LNK':
                 $link = IqitMenuLinks::get((int) $id, (int) $id_lang, (int) $id_shop);
                 if (count($link)) {
                     if (!isset($link[0]['label']) || $link[0]['label'] == '') {
                         $default_language = Configuration::get('PS_LANG_DEFAULT');
                         $link = IqitMenuLinks::get($link[0]['id_linksmenutop'], $default_language, (int) Shop::getContextShopID());
                     }
                     $mobile_menu .= '<li><a href="' . Tools::HtmlEntitiesUTF8($link[0]['link']) . '"' . ($link[0]['new_window'] ? ' onclick="return !window.open(this.href);"' : '') . ' title="' . Tools::safeOutput($link[0]['label']) . '">' . Tools::safeOutput($link[0]['label']) . '</a></li>' . PHP_EOL;
                 }
                 break;
         }
     }
     return $mobile_menu;
 }