private function makeMenu()
 {
     $menu = '';
     $menu_items = $this->getMenuItems();
     $id_lang = (int) $this->context->language->id;
     $id_shop = (int) Shop::getContextShopID();
     $head = $this->_itemHead;
     $tail = $this->_itemTail;
     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->getCategory($menu, (int) $id);
                 break;
             case 'PRD':
                 $selected = $this->page_name == 'product' && Tools::getValue('id_product') == $id ? ' active' : '';
                 $product = new Product((int) $id, true, (int) $id_lang);
                 if (!is_null($product->id)) {
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $product->getLink() . '"><span>' . $product->name . '</span></a></li>' . $tail . PHP_EOL;
                 }
                 break;
             case 'CMS':
                 $selected = $this->page_name == 'cms' && Tools::getValue('id_cms') == $id ? ' active' : '';
                 $cms = CMS::getLinks((int) $id_lang, array($id));
                 if (count($cms)) {
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $cms[0]['link'] . '"><span>' . $cms[0]['meta_title'] . '</span></a></li>' . $tail . PHP_EOL;
                 }
                 break;
             case 'CMS_CAT':
                 $category = new CMSCategory((int) $id, (int) $id_lang);
                 if (count($category)) {
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $category->getLink() . '"><span>' . $category->name . '</span></a>';
                     $this->getCMSMenuItems($menu, $category->id);
                     $menu .= '</li>' . $tail . PHP_EOL;
                 }
                 break;
             case 'MAN':
                 $selected = $this->page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id ? ' active' : '';
                 $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, false);
                     } else {
                         $manufacturer->link_rewrite = 0;
                     }
                     $link = new Link();
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $link->getManufacturerLink((int) $id, $manufacturer->link_rewrite) . '"><span>' . $manufacturer->name . '</span></a></li>' . $tail . PHP_EOL;
                 }
                 break;
             case 'SUP':
                 $selected = $this->page_name == 'supplier' && Tools::getValue('id_supplier') == $id ? ' active' : '';
                 $supplier = new Supplier((int) $id, (int) $id_lang);
                 if (!is_null($supplier->id)) {
                     $link = new Link();
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $link->getSupplierLink((int) $id, $supplier->link_rewrite) . '"><span>' . $supplier->name . '</span></a></li>' . $tail . PHP_EOL;
                 }
                 break;
             case 'SHOP':
                 $selected = $this->page_name == 'index' && $this->context->shop->id == $id ? ' active' : '';
                 $shop = new Shop((int) $id);
                 if (Validate::isLoadedObject($shop)) {
                     $link = new Link();
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $shop->getBaseURL() . '"><span>' . $shop->name . '</span></a></li>' . $tail . PHP_EOL;
                 }
                 break;
             case 'LNK':
                 $link = MenuTopLinks_mod::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_mod::get($link[0]['id_linksmenutop'], $default_language, (int) Shop::getContextShopID());
                     }
                     $menu .= $head . '<li class="' . $this->_itemClass . $selected . '"><a href="' . $link[0]['link'] . '"' . ($link[0]['new_window'] ? ' target="_blank"' : '') . '><span>' . $link[0]['label'] . '</span></a></li>' . $tail . PHP_EOL;
                 }
                 break;
         }
     }
     return $menu;
 }
コード例 #2
0
 protected function makeMenu()
 {
     $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->_menu .= $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, false, $this->user_groups));
                 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 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 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;
         }
     }
 }
コード例 #3
0
ファイル: blocktopmenu.php プロジェクト: greench/prestashop
 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;
         }
     }
 }
コード例 #4
0
ファイル: gsitemap.php プロジェクト: ventsiwad/presta_addons
    /**
     * @param array  $link_sitemap contain all the links for the Google Sitemap file to be generated
     * @param string $lang         language of link to add
     * @param int    $index        index of the current Google Sitemap file
     * @param int    $i            count of elements added to sitemap main array
     * @param int    $id_supplier  supplier object identifier
     *
     * @return bool
     */
    private function _getSupplierLink(&$link_sitemap, $lang, &$index, &$i, $id_supplier = 0)
    {
        $link = new Link();
        if (method_exists('ShopUrl', 'resetMainDomainCache')) {
            ShopUrl::resetMainDomainCache();
        }
        $suppliers_id = Db::getInstance()->ExecuteS('SELECT s.`id_supplier` FROM `' . _DB_PREFIX_ . 'supplier` s
			INNER JOIN `' . _DB_PREFIX_ . 'supplier_lang` sl ON s.`id_supplier` = sl.`id_supplier` ' . ($this->tableColumnExists(_DB_PREFIX_ . 'supplier_shop') ? 'INNER JOIN `' . _DB_PREFIX_ . 'supplier_shop` ss ON s.`id_supplier` = ss.`id_supplier`' : '') . ' 
			WHERE s.`active` = 1 AND s.`id_supplier` > ' . (int) $id_supplier . ($this->tableColumnExists(_DB_PREFIX_ . 'supplier_shop') ? ' AND ss.`id_shop` = ' . (int) $this->context->shop->id : '') . ' 
			AND sl.`id_lang` = ' . (int) $lang['id_lang'] . ' 
			ORDER BY s.`id_supplier` ASC');
        foreach ($suppliers_id as $supplier_id) {
            $supplier = new Supplier((int) $supplier_id['id_supplier'], $lang['id_lang']);
            $url = $link->getSupplierLink($supplier, $supplier->link_rewrite, $lang['id_lang']);
            $image_link = 'http://' . Tools::getMediaServer(_THEME_SUP_DIR_) . _THEME_SUP_DIR_ . (!file_exists(_THEME_SUP_DIR_ . '/' . (int) $supplier->id . '-medium_default.jpg') ? $lang['iso_code'] . '-default' : (int) $supplier->id) . '-medium_default.jpg';
            $image_link = !in_array(rtrim(Context::getContext()->shop->virtual_uri, '/'), explode('/', $image_link)) ? str_replace(array('https', Context::getContext()->shop->domain . Context::getContext()->shop->physical_uri), array('http', Context::getContext()->shop->domain . Context::getContext()->shop->physical_uri . Context::getContext()->shop->virtual_uri), $image_link) : $image_link;
            $file_headers = Configuration::get('GSITEMAP_CHECK_IMAGE_FILE') ? @get_headers($image_link) : true;
            $supplier_image = array();
            if ($file_headers[0] != 'HTTP/1.1 404 Not Found' || $file_headers === true) {
                $supplier_image = array('title_img' => htmlspecialchars(strip_tags($supplier->name)), 'link' => 'http' . (Configuration::get('PS_SSL_ENABLED') ? 's' : '') . '://' . Tools::getMediaServer(_THEME_SUP_DIR_) . _THEME_SUP_DIR_ . (!file_exists(_THEME_SUP_DIR_ . '/' . (int) $supplier->id . '-medium_default.jpg') ? $lang['iso_code'] . '-default' : (int) $supplier->id) . '-medium_default.jpg');
            }
            if (!$this->_addLinkToSitemap($link_sitemap, array('type' => 'supplier', 'page' => 'supplier', 'lastmod' => $supplier->date_upd, 'link' => $url, 'image' => $supplier_image), $lang['iso_code'], $index, $i, $supplier_id['id_supplier'])) {
                return false;
            }
        }
        return true;
    }
コード例 #5
0
ファイル: tdmegamenu.php プロジェクト: reshman/swkart-presta
 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;
 }
コード例 #6
0
ファイル: Sbmegamenu.php プロジェクト: ahmedonee/morinella
 public function getLink($menu)
 {
     if ($this->edit_string) {
         return '#';
     }
     $link = new Link();
     $id_lang = Context::getContext()->language->id;
     $value = (int) $menu['item'];
     $result = '';
     switch ($menu['type']) {
         case 'product':
             if (Validate::isLoadedObject($obj_pro = new Product($value, true, $id_lang))) {
                 $result = $link->getProductLink((int) $obj_pro->id, $obj_pro->link_rewrite, null, null, $id_lang);
             }
             break;
         case 'category':
             if (Validate::isLoadedObject($obj_cate = new Category($value, $id_lang))) {
                 $result = $link->getCategoryLink((int) $obj_cate->id, $obj_cate->link_rewrite, $id_lang);
             }
             break;
         case 'cms':
             if (Validate::isLoadedObject($obj_cms = new CMS($value, $id_lang))) {
                 $result = $link->getCMSLink((int) $obj_cms->id, $obj_cms->link_rewrite, $id_lang);
             }
             break;
         case 'url':
             $value = $menu['url'];
             if ($value == 'index' || $value == 'index.php') {
                 $result = $link->getPageLink('index.php', false, $id_lang);
                 break;
             }
             $regex = '((https?|ftp)\\:\\/\\/)?';
             // SCHEME
             $regex .= '([a-z0-9+!*(),;?&=\\$_.-]+(\\:[a-z0-9+!*(),;?&=\\$_.-]+)?@)?';
             // User and Pass
             $regex .= '([a-z0-9-.]*)\\.([a-z]{2,3})';
             // Host or IP
             $regex .= '(\\:[0-9]{2,5})?';
             // Port
             $regex .= '(\\/([a-z0-9+\\$_-]\\.?)+)*\\/?';
             // Path
             $regex .= '(\\?[a-z+&\\$_.-][a-z0-9;:@&%=+\\/\\$_.-]*)?';
             // GET Query
             $regex .= '(#[a-z_.-][a-z0-9+\\$_.-]*)?';
             // Anchor
             if ($value == '#' || preg_match("/^{$regex}\$/", $value)) {
                 $result = $value;
                 break;
             }
             $result = $link->getPageLink($value, false, $id_lang);
             break;
         case 'manufacture':
             if (Validate::isLoadedObject($obj_manu = new Manufacturer($value, $id_lang))) {
                 $result = $link->getManufacturerLink((int) $obj_manu->id, $obj_manu->link_rewrite, $id_lang);
             }
             break;
         case 'supplier':
             if (Validate::isLoadedObject($obj_supp = new Supplier($value, $id_lang))) {
                 $result = $link->getSupplierLink((int) $obj_supp->id, $obj_supp->link_rewrite, $id_lang);
             }
             break;
         default:
             $result = '#';
             break;
     }
     return $result;
 }
コード例 #7
0
 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>';
 }
コード例 #8
0
 public static function getSuppliers()
 {
     global $cookie;
     $results = array();
     $suppliers = Supplier::getSuppliers(false, $cookie->id_lang);
     foreach ($suppliers as $_supplier) {
         $supplier = new Supplier(intVal($_supplier['id_supplier']));
         $title = $supplier->name;
         if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) {
             $supplier->link_rewrite = Tools::link_rewrite($title, false);
         } else {
             $supplier->link_rewrite = 0;
         }
         $_link = new Link();
         $link = $_link->getSupplierLink($supplier->id, $supplier->link_rewrite);
         $results[] = array('id' => $supplier->id, 'type' => 'supplier', 'title' => $title, 'link' => $link, 'childrens' => array());
     }
     return $results;
 }
コード例 #9
0
ファイル: magicredirect.php プロジェクト: acreno/pm-ps
 public function hookActionObjectUpdateAfter($params)
 {
     if (isset($params['object']) && !empty($params['object'])) {
         $object = $params['object'];
         $type = get_class($object);
         if (!in_array($type, array('Product', 'Manufacturer', 'Supplier', 'Category', 'CMS', 'CMSCategory'))) {
             // Ok not our job
             return;
         }
         $shops = $this->getShopsIds();
         $link = new Link();
         $redirect_list = array();
         // Incremental way, it's a bugfix, for supplier for example
         $shop_urls = array();
         $shop_urls[] = 'https:';
         $shop_urls[] = 'http:';
         foreach ($shops as $id_shop) {
             $shop = new ShopUrl($id_shop);
             $shop_urls[] = str_replace(array('http://', 'https://'), '', $shop->getURL(true));
             $shop_urls[] = str_replace(array('http://', 'https://'), '', $shop->getURL(false));
         }
         $shop_urls = array_unique($shop_urls);
         foreach ($shops as $id_shop) {
             // foreach langs, foreach shops ...
             $langs = Language::getLanguages(false, $id_shop, true);
             foreach ($langs as $id_lang) {
                 switch ($type) {
                     case 'Manufacturer':
                         $old_link = $link->getManufacturerLink($object, null, null, null, $id_lang, $id_shop);
                         break;
                     case 'Supplier':
                         $old_link = $link->getSupplierLink($object, null, null, null, $id_lang, $id_shop);
                         break;
                     case 'CMS':
                         $old_link = $link->getCMSLink($object, null, null, $id_lang, $id_shop);
                         break;
                     case 'Product':
                         $old_link = $link->getProductLink($object, null, null, null, $id_lang, $id_shop);
                         break;
                     case 'Category':
                         $old_link = $link->getCategoryLink($object, null, $id_lang, null, $id_shop);
                         break;
                     case 'CMSCategory':
                         $old_link = $link->getCMSCategoryLink($object, null, $id_lang, $id_shop);
                         break;
                     default:
                         // UFO
                         break;
                 }
                 // Escape shops urls, it's a multishop relative approach
                 $old = str_replace($shop_urls, '', $old_link);
                 $old = '/' . ltrim($old, '/');
                 // Avoid duplicates, simplify complex mapings
                 $md5 = md5($old);
                 if (!isset($redirect_list[$md5])) {
                     $redirect_list[$md5]['old'] = $old;
                     $redirect_list[$md5]['shops'][] = $id_shop;
                 } elseif (!in_array($id_shop, $redirect_list[$md5]['shops'])) {
                     $redirect_list[$md5]['shops'][] = $id_shop;
                 }
             }
         }
         if (!empty($redirect_list)) {
             foreach ($redirect_list as $redirect) {
                 foreach ($redirect['shops'] as $id_shop) {
                     $this->checkConflict($redirect['old'], $id_shop);
                 }
             }
         }
     }
 }
コード例 #10
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;
         }
     }
 }
コード例 #11
0
ファイル: gsitemap.php プロジェクト: Evil1991/PrestaShop-1.4
 private function _getSupplierLink(&$link_sitemap, $lang, &$index, &$i, $id_supplier = 0)
 {
     $link = new Link();
     $suppliers_id = Db::getInstance()->ExecuteS('SELECT `id_supplier` FROM `' . _DB_PREFIX_ . 'supplier` WHERE `active` = 1 AND `id_supplier` > ' . (int) $id_supplier . ' ORDER BY `id_supplier` ASC');
     foreach ($suppliers_id as $supplier_id) {
         $supplier = new Supplier((int) $supplier_id['id_supplier'], $lang['id_lang']);
         $url = $link->getSupplierLink($supplier, $supplier->link_rewrite, $lang['id_lang']);
         $image_link = 'http' . (Configuration::get('PS_SSL_ENABLED') ? 's' : '') . '://' . Tools::getMediaServer(_THEME_SUP_DIR_) . _THEME_SUP_DIR_ . (!file_exists(_THEME_SUP_DIR_ . '/' . (int) $supplier->id . '-medium_default.jpg') ? $lang['iso_code'] . '-default' : (int) $supplier->id) . '-medium_default.jpg';
         $file_headers = @get_headers($image_link);
         if ($file_headers[0] != 'HTTP/1.1 404 Not Found') {
             if (!$this->_addLinkToSitemap($link_sitemap, array('type' => 'supplier', 'page' => 'supplier', 'link' => 'http' . (Configuration::get('PS_SSL_ENABLED') ? 's' : '') . '://' . Tools::getMediaServer(_THEME_SUP_DIR_) . _THEME_SUP_DIR_ . (!file_exists(_THEME_SUP_DIR_ . '/' . (int) $supplier->id . '-medium_default.jpg') ? $lang['iso_code'] . '-default' : (int) $supplier->id) . '-medium_default.jpg', 'image' => array('title_img' => $supplier->name)), $lang['iso_code'], $index, $i, $supplier_id['id_supplier'])) {
                 return false;
             }
         }
         if (!$this->_addLinkToSitemap($link_sitemap, array('type' => 'supplier', 'page' => 'supplier', 'link' => $url, 'image' => false), $lang['iso_code'], $index, $i, $supplier_id['id_supplier'])) {
             return false;
         }
     }
     return true;
 }