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; }
public function renderChoicesSelect() { $spacer = str_repeat(' ', $this->spacer_size); $items = $this->getMenuItems(); $html = '<select multiple="multiple" id="availableItems" style="width: 300px; height: 160px;">'; $html .= '<optgroup label="' . $this->l('CMS') . '">'; $html .= $this->getCMSOptions(0, 1, $this->context->language->id, $items); $html .= '</optgroup>'; // BEGIN SUPPLIER $html .= '<optgroup label="' . $this->l('Supplier') . '">'; // Option to show all Suppliers $html .= '<option value="ALLSUP0">' . $this->l('All suppliers') . '</option>'; $suppliers = Supplier::getSuppliers(false, $this->context->language->id); foreach ($suppliers as $supplier) { if (!in_array('SUP' . $supplier['id_supplier'], $items)) { $html .= '<option value="SUP' . $supplier['id_supplier'] . '">' . $spacer . $supplier['name'] . '</option>'; } } $html .= '</optgroup>'; // BEGIN Manufacturer $html .= '<optgroup label="' . $this->l('Manufacturer') . '">'; // Option to show all Manufacturers $html .= '<option value="ALLMAN0">' . $this->l('All manufacturers') . '</option>'; $manufacturers = Manufacturer::getManufacturers(false, $this->context->language->id); foreach ($manufacturers as $manufacturer) { if (!in_array('MAN' . $manufacturer['id_manufacturer'], $items)) { $html .= '<option value="MAN' . $manufacturer['id_manufacturer'] . '">' . $spacer . $manufacturer['name'] . '</option>'; } } $html .= '</optgroup>'; // BEGIN Categories $shop = new Shop((int) Shop::getContextShopID()); $html .= '<optgroup label="' . $this->l('Categories') . '">'; $html .= $this->generateCategoriesOption(Category::getNestedCategories(null, (int) $this->context->language->id, true), $items); $html .= '</optgroup>'; // BEGIN Shops if (Shop::isFeatureActive()) { $html .= '<optgroup label="' . $this->l('Shops') . '">'; $shops = Shop::getShopsCollection(); foreach ($shops as $shop) { if (!$shop->setUrl() && !$shop->getBaseURL()) { continue; } if (!in_array('SHOP' . (int) $shop->id, $items)) { $html .= '<option value="SHOP' . (int) $shop->id . '">' . $spacer . $shop->name . '</option>'; } } $html .= '</optgroup>'; } // BEGIN Products $html .= '<optgroup label="' . $this->l('Products') . '">'; $html .= '<option value="PRODUCT" style="font-style:italic">' . $spacer . $this->l('Choose product ID') . '</option>'; $html .= '</optgroup>'; // BEGIN Menu Top Links $html .= '<optgroup label="' . $this->l('Menu Top Links') . '">'; $links = MenuTopLinks_mod::gets($this->context->language->id, null, (int) Shop::getContextShopID()); foreach ($links as $link) { if ($link['label'] == '') { $default_language = Configuration::get('PS_LANG_DEFAULT'); $link = MenuTopLinks_mod::get($link['id_linksmenutop'], $default_language, (int) Shop::getContextShopID()); if (!in_array('LNK' . (int) $link[0]['id_linksmenutop'], $items)) { $html .= '<option value="LNK' . (int) $link[0]['id_linksmenutop'] . '">' . $spacer . $link[0]['label'] . '</option>'; } } elseif (!in_array('LNK' . (int) $link['id_linksmenutop'], $items)) { $html .= '<option value="LNK' . (int) $link['id_linksmenutop'] . '">' . $spacer . $link['label'] . '</option>'; } } $html .= '</optgroup>'; $html .= '</select>'; return $html; }