protected function _prepareHook($params) { $languages = Language::getLanguages(true, $this->context->shop->id); if (!count($languages)) { return false; } $link = new Link(); if ((int) Configuration::get('PS_REWRITING_SETTINGS')) { $default_rewrite = array(); if (Dispatcher::getInstance()->getController() == 'product' && ($id_product = (int) Tools::getValue('id_product'))) { $rewrite_infos = Product::getUrlRewriteInformations((int) $id_product); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = $link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']); } } if (Dispatcher::getInstance()->getController() == 'category' && ($id_category = (int) Tools::getValue('id_category'))) { $rewrite_infos = Category::getUrlRewriteInformations((int) $id_category); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']); } } if (Dispatcher::getInstance()->getController() == 'cms' && (($id_cms = (int) Tools::getValue('id_cms')) || ($id_cms_category = (int) Tools::getValue('id_cms_category')))) { $rewrite_infos = isset($id_cms) && !isset($id_cms_category) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category); foreach ($rewrite_infos as $infos) { $arr_link = isset($id_cms) && !isset($id_cms_category) ? $link->getCMSLink($id_cms, $infos['link_rewrite'], null, $infos['id_lang']) : $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']); $default_rewrite[$infos['id_lang']] = $arr_link; } } $this->smarty->assign('lang_rewrite_urls', $default_rewrite); } return true; }
public static function getLinks($id_lang, $selection = null) { $result = Db::getInstance()->ExecuteS(' SELECT c.id_cms, cl.link_rewrite, cl.meta_title FROM ' . _DB_PREFIX_ . 'cms c LEFT JOIN ' . _DB_PREFIX_ . 'cms_lang cl ON (c.id_cms = cl.id_cms AND cl.id_lang = ' . intval($id_lang) . ') ' . ($selection !== null ? 'WHERE c.id_cms IN (' . implode(',', array_map('intval', $selection)) . ')' : '')); $link = new Link(); $links = array(); if ($result) { foreach ($result as $row) { $row['link'] = $link->getCMSLink($row['id_cms'], $row['link_rewrite']); $links[] = $row; } } return $links; }
public function widgetShow($params) { global $smarty, $cookie; $linkTpl = ' <a href="%1$s" class="widgetctooltip%4$s" rel="cms_%3$d">%2$s</a>'; $additionalParams = ''; foreach (self::$_additionalParams as $prefix => $param) { if (isset($params[$param])) { $additionalParams .= ' ' . $prefix . $params[$param]; } } $cms = self::getShortCMSInfo($params['id'], $cookie->id_lang); if (!Tools::isEmpty($cms['meta_title'])) { $widgetPath = $this->widgetUri(); $this->setCss($widgetPath . 'css/style.css'); $this->setJs($widgetPath . 'js/tooltip.js'); $link = new Link(); return sprintf($linkTpl, $link->getCMSLink($params['id'], $cms['link_rewrite']), $cms['meta_title'], $params['id'], $additionalParams); } }
/** * Returns module content for header * * @param array $params Parameters * @return string Content */ public function hookTop($params) { global $smarty; $languages = Language::getLanguages(); if (!count($languages)) { return; } $link = new Link(); if ((int) Configuration::get('PS_REWRITING_SETTINGS')) { $default_rewrite = array(); $phpSelf = isset($_SERVER['PHP_SELF']) ? substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__)) : ''; if ($phpSelf == 'product.php' and $id_product = (int) Tools::getValue('id_product')) { $rewrite_infos = Product::getUrlRewriteInformations((int) $id_product); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = $link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']); } } if ($phpSelf == 'category.php' and $id_category = (int) Tools::getValue('id_category')) { $rewrite_infos = Category::getUrlRewriteInformations((int) $id_category); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']); } } if ($phpSelf == 'cms.php' and ($id_cms = (int) Tools::getValue('id_cms') or $id_cms_category = (int) Tools::getValue('id_cms_category'))) { $rewrite_infos = (isset($id_cms) and !isset($id_cms_category)) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category); foreach ($rewrite_infos as $infos) { $arr_link = (isset($id_cms) and !isset($id_cms_category)) ? $link->getCMSLink($id_cms, $infos['link_rewrite'], NULL, $infos['id_lang']) : $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']); $default_rewrite[$infos['id_lang']] = $arr_link; } } if (count($default_rewrite)) { $smarty->assign('lang_rewrite_urls', $default_rewrite); } } $smarty->assign('languages', $languages); return $this->display(__FILE__, 'blocklanguages.tpl'); }
private function _postProcess() { Configuration::updateValue('GSITEMAP_ALL_CMS', (int) Tools::getValue('GSITEMAP_ALL_CMS')); Configuration::updateValue('GSITEMAP_ALL_PRODUCTS', (int) Tools::getValue('GSITEMAP_ALL_PRODUCTS')); $link = new Link(); $langs = Language::getLanguages(); $xmlString = <<<XML <?xml version="1.0" encoding="UTF-8" ?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"> </urlset> XML; $xml = new SimpleXMLElement($xmlString); if (Configuration::get('PS_REWRITING_SETTINGS') and sizeof($langs) > 1) { foreach ($langs as $lang) { $this->_addSitemapNode($xml, Tools::getShopDomain(true, true) . __PS_BASE_URI__ . $lang['iso_code'] . '/', '1.00', 'daily', date('Y-m-d')); } } else { $this->_addSitemapNode($xml, Tools::getShopDomain(true, true) . __PS_BASE_URI__, '1.00', 'daily', date('Y-m-d')); } /* CMS Generator */ if (Configuration::get('GSITEMAP_ALL_CMS') or !Module::isInstalled('blockcms')) { $sql_cms = ' SELECT DISTINCT ' . (Configuration::get('PS_REWRITING_SETTINGS') ? 'cl.id_cms, cl.link_rewrite, cl.id_lang' : 'cl.id_cms') . ' FROM ' . _DB_PREFIX_ . 'cms_lang cl LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (cl.id_lang = l.id_lang) WHERE l.`active` = 1 ORDER BY cl.id_cms, cl.id_lang ASC'; } elseif (Module::isInstalled('blockcms')) { $sql_cms = ' SELECT DISTINCT ' . (Configuration::get('PS_REWRITING_SETTINGS') ? 'cl.id_cms, cl.link_rewrite, cl.id_lang' : 'cl.id_cms') . ' FROM ' . _DB_PREFIX_ . 'cms_block_page b LEFT JOIN ' . _DB_PREFIX_ . 'cms_lang cl ON (b.id_cms = cl.id_cms) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (cl.id_lang = l.id_lang) WHERE l.`active` = 1 ORDER BY cl.id_cms, cl.id_lang ASC'; } $cmss = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql_cms); foreach ($cmss as $cms) { $tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $link->getCMSLink((int) $cms['id_cms'], $cms['link_rewrite'], false, (int) $cms['id_lang']) : $link->getCMSLink((int) $cms['id_cms']); $this->_addSitemapNode($xml, $tmpLink, '0.8', 'daily'); } /* Categories Generator */ if (Configuration::get('PS_REWRITING_SETTINGS')) { $categories = Db::getInstance()->ExecuteS(' SELECT c.id_category, c.level_depth, link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd, cl.id_lang FROM ' . _DB_PREFIX_ . 'category c LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON c.id_category = cl.id_category LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON cl.id_lang = l.id_lang WHERE l.`active` = 1 AND c.`active` = 1 AND c.id_category != 1 ORDER BY cl.id_category, cl.id_lang ASC'); } else { $categories = Db::getInstance()->ExecuteS('SELECT c.id_category, c.level_depth, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd FROM ' . _DB_PREFIX_ . 'category c ORDER BY c.id_category ASC'); } foreach ($categories as $category) { if (($priority = 0.9 - $category['level_depth'] / 10) < 0.1) { $priority = 0.1; } $tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $link->getCategoryLink((int) $category['id_category'], $category['link_rewrite'], (int) $category['id_lang']) : $link->getCategoryLink((int) $category['id_category']); $this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($category['date_upd'], 0, 10)); } $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT p.id_product, pl.link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') date_upd, pl.id_lang, cl.`link_rewrite` category, ean13, i.id_image, il.legend legend_image, ( SELECT MIN(level_depth) FROM ' . _DB_PREFIX_ . 'product p2 LEFT JOIN ' . _DB_PREFIX_ . 'category_product cp2 ON p2.id_product = cp2.id_product LEFT JOIN ' . _DB_PREFIX_ . 'category c2 ON cp2.id_category = c2.id_category WHERE p2.id_product = p.id_product AND p2.`active` = 1 AND c2.`active` = 1) AS level_depth FROM ' . _DB_PREFIX_ . 'product p LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (p.id_product = pl.id_product) LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND pl.`id_lang` = cl.`id_lang`) LEFT JOIN ' . _DB_PREFIX_ . 'image i ON p.id_product = i.id_product LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND pl.`id_lang` = il.`id_lang`) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (pl.id_lang = l.id_lang) WHERE l.`active` = 1 AND p.`active` = 1 ' . (Configuration::get('GSITEMAP_ALL_PRODUCTS') ? '' : 'HAVING level_depth IS NOT NULL') . ' ORDER BY pl.id_product, pl.id_lang ASC'); $tmp = null; $res = null; foreach ($products as $product) { if ($tmp == $product['id_product']) { $res[$tmp]['images'][] = array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']); } else { $tmp = $product['id_product']; $res[$tmp] = $product; unset($res[$tmp]['id_image'], $res[$tmp]['legend_image']); $res[$tmp]['images'][] = array('id_image' => $product['id_image'], 'legend_image' => $product['legend_image']); } } foreach ($res as $product) { if (($priority = 0.7 - $product['level_depth'] / 10) < 0.1) { $priority = 0.1; } $tmpLink = $link->getProductLink((int) $product['id_product'], $product['link_rewrite'], $product['category'], $product['ean13'], (int) $product['id_lang']); $sitemap = $this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($product['date_upd'], 0, 10)); $sitemap = $this->_addSitemapNodeImage($sitemap, $product); } /* Add classic pages (contact, best sales, new products...) */ $pages = array('authentication' => true, 'best-sales' => false, 'contact-form' => true, 'discount' => false, 'index' => false, 'manufacturer' => false, 'new-products' => false, 'prices-drop' => false, 'supplier' => false, 'store' => false); // Don't show suppliers and manufacturers if they are disallowed if (!Module::getInstanceByName('blockmanufacturer')->id && !Configuration::get('PS_DISPLAY_SUPPLIERS')) { unset($pages['manufacturer']); } if (!Module::getInstanceByName('blocksupplier')->id && !Configuration::get('PS_DISPLAY_SUPPLIERS')) { unset($pages['supplier']); } // Generate nodes for pages if (Configuration::get('PS_REWRITING_SETTINGS')) { foreach ($pages as $page => $ssl) { foreach ($langs as $lang) { $this->_addSitemapNode($xml, $link->getPageLink($page . '.php', $ssl, $lang['id_lang']), '0.5', 'monthly'); } } } else { foreach ($pages as $page => $ssl) { $this->_addSitemapNode($xml, $link->getPageLink($page . '.php', $ssl), '0.5', 'monthly'); } } $xmlString = $xml->asXML(); $fp = fopen(GSITEMAP_FILE, 'w'); fwrite($fp, $xmlString); fclose($fp); $res = file_exists(GSITEMAP_FILE); $this->_html .= '<h3 class="' . ($res ? 'conf confirm' : 'alert error') . '" style="margin-bottom: 20px">'; $this->_html .= $res ? $this->l('Sitemap file generated') : $this->l('Error while creating sitemap file'); $this->_html .= '</h3>'; }
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); } } } } }
public function hookProductTabContent($params) { $tab_type = Configuration::get('LG_CONSULTAS_TAB_CONTENT'); $icon_display = Configuration::get('LG_CONSULTAS_ICON_DISPLAY'); $icon_color = Configuration::get('LG_CONSULTAS_ICON_COLOR'); $defaultdisplay = Configuration::get('LG_CONSULTAS_DEFAULT'); $extradisplay = Configuration::get('LG_CONSULTAS_EXTRA'); $link = new Link(); $cmspage = $link->getCMSLink(Configuration::get('LG_CONSULTAS_CMS')); $question = Db::getInstance()->executeS('SELECT * ' . 'FROM ' . _DB_PREFIX_ . 'lgconsultas ' . 'WHERE id_producto = ' . (int) Tools::getValue('id_product', 0) . ' AND validado = 1'); $question_number = count($question); //1 show as responsive block //2 separate tab content if ((int) $tab_type == 2) { $consultas = $this->getConsultasProducto((int) Tools::getValue('id_product', 0)); $this->smarty->assign(array('id_product' => (int) Tools::getValue('id_product', 0), 'consultas' => $consultas)); } $this->context->smarty->assign(array('question_number' => $question_number, 'tab_type' => $tab_type, 'icon_display' => $icon_display, 'icon_color' => $icon_color, 'defaultdisplay' => $defaultdisplay, 'extradisplay' => $extradisplay, 'cmspage' => $cmspage)); return $this->display(__FILE__, '/views/templates/front/tab_faq_15.tpl'); }
/** * return the link elements for the CMS object * * @param array $link_sitemap contain all the links for the Google Sitemap file to be generated * @param string $lang the language of link to add * @param int $index the index of the current Google Sitemap file * @param int $i the count of elements added to sitemap main array * @param int $id_cms the CMS object identifier * * @return bool */ private function _getCmsLink(&$link_sitemap, $lang, &$index, &$i, $id_cms = 0) { $link = new Link(); if (method_exists('ShopUrl', 'resetMainDomainCache')) { ShopUrl::resetMainDomainCache(); } $cmss_id = Db::getInstance()->ExecuteS('SELECT c.`id_cms` FROM `' . _DB_PREFIX_ . 'cms` c INNER JOIN `' . _DB_PREFIX_ . 'cms_lang` cl ON c.`id_cms` = cl.`id_cms` ' . ($this->tableColumnExists(_DB_PREFIX_ . 'supplier_shop') ? 'INNER JOIN `' . _DB_PREFIX_ . 'cms_shop` cs ON c.`id_cms` = cs.`id_cms` ' : '') . 'INNER JOIN `' . _DB_PREFIX_ . 'cms_category` cc ON c.id_cms_category = cc.id_cms_category AND cc.active = 1 WHERE c.`active` =1 AND c.`id_cms` > ' . (int) $id_cms . ($this->tableColumnExists(_DB_PREFIX_ . 'supplier_shop') ? ' AND cs.id_shop = ' . (int) $this->context->shop->id : '') . ' AND cl.`id_lang` = ' . (int) $lang['id_lang'] . ' ORDER BY c.`id_cms` ASC'); foreach ($cmss_id as $cms_id) { $cms = new CMS((int) $cms_id['id_cms'], $lang['id_lang']); $cms->link_rewrite = urlencode(is_array($cms->link_rewrite) ? $cms->link_rewrite[(int) $lang['id_lang']] : $cms->link_rewrite); $url = $link->getCMSLink($cms, null, null, $lang['id_lang']); if (!$this->_addLinkToSitemap($link_sitemap, array('type' => 'cms', 'page' => 'cms', 'link' => $url, 'image' => false), $lang['iso_code'], $index, $i, $cms_id['id_cms'])) { return false; } } return true; }
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; }
public static function getLinks($id_lang, $selection = NULL, $active = true) { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT c.id_cms, cl.link_rewrite, cl.meta_title FROM ' . _DB_PREFIX_ . 'cms c LEFT JOIN ' . _DB_PREFIX_ . 'cms_lang cl ON (c.id_cms = cl.id_cms AND cl.id_lang = ' . (int) $id_lang . ') WHERE 1 ' . ($selection !== NULL ? ' AND c.id_cms IN (' . implode(',', array_map('intval', $selection)) . ')' : '') . ($active ? ' AND c.`active` = 1 ' : '') . 'ORDER BY c.`position`'); $link = new Link(); $links = array(); if ($result) { foreach ($result as $row) { $row['link'] = $link->getCMSLink((int) $row['id_cms'], $row['link_rewrite']); $links[] = $row; } } return $links; }
public static function getLinks($id_lang, $selection = null, $active = true, $ssl = false) { $results = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT c.id_cms, cl.link_rewrite, cl.meta_title FROM ' . _DB_PREFIX_ . 'cms c LEFT JOIN ' . _DB_PREFIX_ . 'cms_lang cl ON (c.id_cms = cl.id_cms AND cl.id_lang = ' . (int) $id_lang . ') WHERE 1 ' . (!empty($selection) ? ' AND c.id_cms IN (' . implode(',', array_map('intval', $selection)) . ')' : '') . ($active ? ' AND c.`active` = 1 ' : '') . 'ORDER BY c.`position`'); if ($results) { $link = new Link(); foreach ($results as &$row) { $row['link'] = $link->getCMSLink((int) $row['id_cms'], $row['link_rewrite'], (bool) $ssl, (int) $id_lang); } } return $results; }
private function _postProcess() { $link = new Link(); $defaultLanguage = Configuration::get('PS_LANG_DEFAULT'); $ruBackup = $_SERVER['REQUEST_URI']; $snBackup = $_SERVER['SCRIPT_NAME']; $getBackup = $_GET; $xml = new SimpleXMLElement('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> </urlset>'); $sitemap = $xml->addChild('url'); $sitemap->addChild('loc', 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__); $sitemap->addChild('priority', '1.00'); $sitemap->addChild('lastmod', date("Y-m-d")); $sitemap->addChild('changefreq', 'daily'); $cmss = Db::getInstance()->ExecuteS(' SELECT DISTINCT b.id_cms, cl.link_rewrite, cl.id_lang FROM ' . _DB_PREFIX_ . 'block_cms b LEFT JOIN ' . _DB_PREFIX_ . 'cms_lang cl ON (b.id_cms = cl.id_cms) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (cl.id_lang = l.id_lang) WHERE l.`active` = 1 ORDER BY cl.id_cms, cl.id_lang ASC'); foreach ($cmss as $cms) { $sitemap = $xml->addChild('url'); $tmpLink = $link->getCMSLink($cms['id_cms'], $cms['link_rewrite']); $_GET = array('id_cms' => $cms['id_cms']); if ($cms['id_lang'] != $defaultLanguage) { $_SERVER['REQUEST_URI'] = substr($tmpLink, strpos($tmpLink, __PS_BASE_URI__)); $_SERVER['SCRIPT_NAME'] = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')); $link = new Link(); $tmpLink = $link->getLanguageLink(intval($cms['id_lang'])); $tmpLink = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . $tmpLink; } $sitemap->addChild('loc', htmlspecialchars($tmpLink)); $sitemap->addChild('priority', '0.8'); $sitemap->addChild('changefreq', 'monthly'); } $categories = Db::getInstance()->ExecuteS(' SELECT c.id_category, c.level_depth, link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd, cl.id_lang FROM ' . _DB_PREFIX_ . 'category c LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON c.id_category = cl.id_category LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON cl.id_lang = l.id_lang WHERE l.`active` = 1 AND c.`active` = 1 AND c.id_category != 1 ORDER BY cl.id_category, cl.id_lang ASC'); foreach ($categories as $category) { if (($priority = 0.9 - $category['level_depth'] / 10) < 0.1) { $priority = 0.1; } $sitemap = $xml->addChild('url'); $tmpLink = $link->getCategoryLink($category['id_category'], $category['link_rewrite']); $_GET = array('id_category' => $category['id_category']); if ($category['id_lang'] != $defaultLanguage) { $_SERVER['REQUEST_URI'] = substr($tmpLink, strpos($tmpLink, __PS_BASE_URI__)); $_SERVER['SCRIPT_NAME'] = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')); $link = new Link(); $tmpLink = $link->getLanguageLink(intval($category['id_lang'])); $tmpLink = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . $tmpLink; } $sitemap->addChild('loc', htmlspecialchars($tmpLink)); $sitemap->addChild('priority', $priority); $sitemap->addChild('lastmod', substr($category['date_upd'], 0, 10)); $sitemap->addChild('changefreq', 'weekly'); } $products = Db::getInstance()->ExecuteS(' SELECT p.id_product, pl.link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd, pl.id_lang, cl.`link_rewrite` AS category, ean13, ( SELECT MIN(level_depth) FROM ' . _DB_PREFIX_ . 'product p2 LEFT JOIN ' . _DB_PREFIX_ . 'category_product cp2 ON p2.id_product = cp2.id_product LEFT JOIN ' . _DB_PREFIX_ . 'category c2 ON cp2.id_category = c2.id_category WHERE p2.id_product = p.id_product AND p2.`active` = 1 AND c2.`active` = 1) AS level_depth FROM ' . _DB_PREFIX_ . 'product p LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON p.id_product = pl.id_product LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND pl.`id_lang` = cl.`id_lang`) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON pl.id_lang = l.id_lang WHERE l.`active` = 1 AND p.`active` = 1 ORDER BY pl.id_product, pl.id_lang ASC'); foreach ($products as $product) { if (($priority = 0.7 - $product['level_depth'] / 10) < 0.1) { $priority = 0.1; } $sitemap = $xml->addChild('url'); $tmpLink = $link->getProductLink($product['id_product'], $product['link_rewrite'], $product['category'], $product['ean13']); $_GET = array('id_product' => $product['id_product']); if ($product['id_lang'] != $defaultLanguage) { $_SERVER['REQUEST_URI'] = substr($tmpLink, strpos($tmpLink, __PS_BASE_URI__)); $_SERVER['SCRIPT_NAME'] = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')); $link = new Link(); $tmpLink = $link->getLanguageLink(intval($product['id_lang'])); $tmpLink = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . $tmpLink; } $sitemap->addChild('loc', htmlspecialchars($tmpLink)); $sitemap->addChild('priority', $priority); $sitemap->addChild('lastmod', substr($product['date_upd'], 0, 10)); $sitemap->addChild('changefreq', 'weekly'); } $images = Db::getInstance()->ExecuteS(' SELECT * FROM ' . _DB_PREFIX_ . 'product p LEFT JOIN ' . _DB_PREFIX_ . 'image i ON p.id_product = i.id_product LEFT JOIN ' . _DB_PREFIX_ . 'image_lang il ON i.id_image = il.id_image AND il.id_lang = ' . intval($defaultLanguage) . ' WHERE p.`active` = 1 ORDER BY p.id_product'); foreach ($images as $image) { $sitemap = $xml->addChild('url'); $tmpLink = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . $link->getImageLink(Tools::link_rewrite($image['legend']), $image['id_product'] . '-' . $image['id_image']); $sitemap->addChild('loc', htmlspecialchars($tmpLink)); $sitemap->addChild('priority', 0.4); $sitemap->addChild('lastmod', substr($image['date_upd'], 0, 10)); $sitemap->addChild('changefreq', 'monthly'); } $xmlString = $xml->asXML(); $fp = fopen(GSITEMAP_FILE, 'w'); fwrite($fp, $xmlString, Tools::strlen($xmlString)); fclose($fp); $res = file_exists(GSITEMAP_FILE); $this->_html .= '<h3 class="' . ($res ? 'conf confirm' : 'alert error') . '" style="margin-bottom: 20px">'; $this->_html .= $res ? $this->l('Sitemap file successfully generated') : $this->l('Error while creating sitemap file'); $this->_html .= '</h3>'; $_SERVER['REQUEST_URI'] = $ruBackup; $_SERVER['SCRIPT_NAME'] = $snBackup; $_GET = $getBackup; }
public static function getRecurseCategory($id_lang = _USER_ID_LANG_, $current = 1, $active = 1, $links = 0) { $category = Db::getInstance()->getRow(' SELECT c.`id_cms_category`, c.`id_parent`, c.`level_depth`, cl.`name`, cl.`link_rewrite` FROM `' . _DB_PREFIX_ . 'cms_category` c JOIN `' . _DB_PREFIX_ . 'cms_category_lang` cl ON c.`id_cms_category` = cl.`id_cms_category` WHERE c.`id_cms_category` = ' . (int) $current . ' AND `id_lang` = ' . (int) $id_lang); $result = Db::getInstance()->ExecuteS(' SELECT c.`id_cms_category` FROM `' . _DB_PREFIX_ . 'cms_category` c WHERE c.`id_parent` = ' . (int) $current . ($active ? ' AND c.`active` = 1' : '')); foreach ($result as $row) { $category['children'][] = self::getRecurseCategory($id_lang, $row['id_cms_category'], $active, $links); } $category['cms'] = Db::getInstance()->ExecuteS(' SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite` FROM `' . _DB_PREFIX_ . 'cms` c JOIN `' . _DB_PREFIX_ . 'cms_lang` cl ON c.`id_cms` = cl.`id_cms` WHERE `id_cms_category` = ' . (int) $current . ' AND cl.`id_lang` = ' . (int) $id_lang . ($active ? ' AND c.`active` = 1' : '') . ' ORDER BY c.`position`'); if ($links == 1) { $link = new Link(); $category['link'] = $link->getCMSCategoryLink($current, $category['link_rewrite']); foreach ($category['cms'] as $key => $cms) { $category['cms'][$key]['link'] = $link->getCMSLink($cms['id_cms'], $cms['link_rewrite']); } } return $category; }
public static function getCMStitles($location) { global $cookie; $cmsCategories = Db::getInstance()->ExecuteS(' SELECT bc.`id_cms_block`, bc.`id_cms_category`, bc.`display_store`, ccl.`link_rewrite`, ccl.`name` category_name, bcl.`name` block_name FROM `' . _DB_PREFIX_ . 'cms_block` bc INNER JOIN `' . _DB_PREFIX_ . 'cms_category_lang` ccl ON (bc.`id_cms_category` = ccl.`id_cms_category`) INNER JOIN `' . _DB_PREFIX_ . 'cms_block_lang` bcl ON (bc.`id_cms_block` = bcl.`id_cms_block`) WHERE bc.`location` = ' . (int) $location . ' AND ccl.`id_lang` = ' . (int) $cookie->id_lang . ' AND bcl.`id_lang` = ' . (int) $cookie->id_lang . ' ORDER BY `position`'); $content = array(); $link = new Link(); if (is_array($cmsCategories) and sizeof($cmsCategories)) { foreach ($cmsCategories as $cmsCategory) { $key = (int) $cmsCategory['id_cms_block']; $content[$key]['display_store'] = $cmsCategory['display_store']; $content[$key]['cms'] = Db::getInstance()->ExecuteS(' SELECT cl.`id_cms`, cl.`meta_title`, cl.`link_rewrite` FROM `' . _DB_PREFIX_ . 'cms_block_page` bcp INNER JOIN `' . _DB_PREFIX_ . 'cms_lang` cl ON (bcp.`id_cms` = cl.`id_cms`) INNER JOIN `' . _DB_PREFIX_ . 'cms` c ON (bcp.`id_cms` = c.`id_cms`) WHERE bcp.`id_cms_block` = ' . (int) $cmsCategory['id_cms_block'] . ' AND cl.`id_lang` = ' . (int) $cookie->id_lang . ' AND bcp.`is_category` = 0 AND c.`active` = 1 ORDER BY `position`'); $links = array(); if (sizeof($content[$key]['cms'])) { foreach ($content[$key]['cms'] as $row) { $row['link'] = $link->getCMSLink((int) $row['id_cms'], $row['link_rewrite']); $links[] = $row; } } $content[$key]['cms'] = $links; $content[$key]['categories'] = Db::getInstance()->ExecuteS(' SELECT bcp.`id_cms`, cl.`name`, cl.`link_rewrite` FROM `' . _DB_PREFIX_ . 'cms_block_page` bcp INNER JOIN `' . _DB_PREFIX_ . 'cms_category_lang` cl ON (bcp.`id_cms` = cl.`id_cms_category`) WHERE bcp.`id_cms_block` = ' . (int) $cmsCategory['id_cms_block'] . ' AND cl.`id_lang` = ' . (int) $cookie->id_lang . ' AND bcp.`is_category` = 1'); $links = array(); if (sizeof($content[$key]['categories'])) { foreach ($content[$key]['categories'] as $row) { $row['link'] = $link->getCMSCategoryLink((int) $row['id_cms'], $row['link_rewrite']); $links[] = $row; } } $content[$key]['categories'] = $links; $content[$key]['name'] = $cmsCategory['block_name']; $content[$key]['category_link'] = $link->getCMSCategoryLink((int) $cmsCategory['id_cms_category'], $cmsCategory['link_rewrite']); $content[$key]['category_name'] = $cmsCategory['category_name']; } } return $content; }
private function _postProcess() { Configuration::updateValue('GSITEMAP_ALL_CMS', intval(Tools::getValue('GSITEMAP_ALL_CMS'))); Configuration::updateValue('GSITEMAP_ALL_PRODUCTS', intval(Tools::getValue('GSITEMAP_ALL_PRODUCTS'))); $link = new Link(); $xmlString = <<<XML <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> </urlset> XML; $xml = new SimpleXMLElement($xmlString); $this->_addSitemapNode($xml, 'http://' . Tools::getHttpHost(false, true) . __PS_BASE_URI__, '1.00', 'daily', date('Y-m-d')); if (Configuration::get('GSITEMAP_ALL_CMS')) { $sql_cms = ' SELECT DISTINCT cl.id_cms, cl.link_rewrite, cl.id_lang FROM ' . _DB_PREFIX_ . 'cms_lang cl LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (cl.id_lang = l.id_lang) WHERE l.`active` = 1 ORDER BY cl.id_cms, cl.id_lang ASC'; } else { $sql_cms = ' SELECT DISTINCT b.id_cms, cl.link_rewrite, cl.id_lang FROM ' . _DB_PREFIX_ . 'block_cms b LEFT JOIN ' . _DB_PREFIX_ . 'cms_lang cl ON (b.id_cms = cl.id_cms) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (cl.id_lang = l.id_lang) WHERE l.`active` = 1 ORDER BY cl.id_cms, cl.id_lang ASC'; } $cmss = Db::getInstance()->ExecuteS($sql_cms); foreach ($cmss as $cms) { $this->_addSitemapNode($xml, $link->getCMSLink(intval($cms['id_cms']), $cms['link_rewrite'], intval($cms['id_lang'])), '0.8', 'daily'); } $categories = Db::getInstance()->ExecuteS(' SELECT c.id_category, c.level_depth, link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd, cl.id_lang FROM ' . _DB_PREFIX_ . 'category c LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON c.id_category = cl.id_category LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON cl.id_lang = l.id_lang WHERE l.`active` = 1 AND c.`active` = 1 AND c.id_category != 1 ORDER BY cl.id_category, cl.id_lang ASC'); foreach ($categories as $category) { if (($priority = 0.9 - $category['level_depth'] / 10) < 0.1) { $priority = 0.1; } $tmpLink = $link->getCategoryLink(intval($category['id_category']), $category['link_rewrite'], intval($category['id_lang'])); $this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($category['date_upd'], 0, 10)); } $products = Db::getInstance()->ExecuteS(' SELECT p.id_product, pl.link_rewrite, DATE_FORMAT(IF(date_upd,date_upd,date_add), \'%Y-%m-%d\') AS date_upd, pl.id_lang, cl.`link_rewrite` AS category, ean13, ( SELECT MIN(level_depth) FROM ' . _DB_PREFIX_ . 'product p2 LEFT JOIN ' . _DB_PREFIX_ . 'category_product cp2 ON p2.id_product = cp2.id_product LEFT JOIN ' . _DB_PREFIX_ . 'category c2 ON cp2.id_category = c2.id_category WHERE p2.id_product = p.id_product AND p2.`active` = 1 AND c2.`active` = 1) AS level_depth FROM ' . _DB_PREFIX_ . 'product p LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON p.id_product = pl.id_product LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND pl.`id_lang` = cl.`id_lang`) LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON pl.id_lang = l.id_lang WHERE l.`active` = 1 AND p.`active` = 1 ' . (Configuration::get('GSITEMAP_ALL_PRODUCTS') ? '' : 'HAVING level_depth IS NOT NULL') . ' ORDER BY pl.id_product, pl.id_lang ASC'); foreach ($products as $product) { if (($priority = 0.7 - $product['level_depth'] / 10) < 0.1) { $priority = 0.1; } $tmpLink = $link->getProductLink(intval($product['id_product']), $product['link_rewrite'], $product['category'], $product['ean13'], intval($product['id_lang'])); $this->_addSitemapNode($xml, htmlspecialchars($tmpLink), $priority, 'weekly', substr($product['date_upd'], 0, 10)); } /* Add classic pages (contact, best sales, new products...) */ $pages = array('authentication', 'best-sales', 'category', 'contact-form', 'discount', 'index', 'manufacturer', 'new-products', 'prices-drop', 'search', 'supplier'); foreach ($pages as $page) { $this->_addSitemapNode($xml, htmlspecialchars('http://' . Tools::getHttpHost(false, true) . __PS_BASE_URI__ . $page . '.php'), '0.5', 'monthly'); } $xmlString = $xml->asXML(); $fp = fopen(GSITEMAP_FILE, 'w'); fwrite($fp, $xmlString); fclose($fp); $res = file_exists(GSITEMAP_FILE); $this->_html .= '<h3 class="' . ($res ? 'conf confirm' : 'alert error') . '" style="margin-bottom: 20px">'; $this->_html .= $res ? $this->l('Sitemap file successfully generated') : $this->l('Error while creating sitemap file'); $this->_html .= '</h3>'; }
/** * Mise à jour de l'objet cms pour remplacer les variables d'url des lien * @param string : contenu ou il faut remplacer les liens * @return string : contenu avec les liens remplacés */ public static function updateCmsLinksDisplay($content = null) { //Inclusion de la classe des widgets include_once dirname(__FILE__) . '/classes/Widget.php'; if ($content === null) { return; } //Dans prestashop 1.6 les caractères { et } sont encodés if (_PS_VERSION_ > '1.6') { $content = urldecode($content); } $link_model = new Link(); //Mise à jour des liens vers les pages cms preg_match_all('#{{cms url=([0-9])}}#', $content, $cms_links); if (isset($cms_links[1]) && sizeof($cms_links[1])) { foreach ($cms_links[1] as $link) { $link_url = $link_model->getCMSLink($link); $content = preg_replace('#{{cms url=' . $link . '}}#', $link_url, $content); } } //Mise à jour des liens vers les pages categories preg_match_all('#{{category url=([0-9])}}#', $content, $category_links); if (isset($category_links[1]) && sizeof($category_links[1])) { foreach ($category_links[1] as $category_link) { $category_link_url = $link_model->getCategoryLink($category_link); $content = preg_replace('#{{category url=' . $category_link . '}}#', $category_link_url, $content); } } //Mise à jour des liens vers les pages produits preg_match_all('#{{product url=([0-9])}}#', $content, $product_links); if (isset($product_links[1]) && sizeof($product_links[1])) { foreach ($product_links[1] as $product_link) { $product_link_url = $link_model->getProductLink($product_link); $content = preg_replace('#{{product url=' . $product_link . '}}#', $product_link_url, $content); } } //Mise à jour des liens d'ajout au panier preg_match_all('#{{cart url=([0-9])}}#', $content, $product_links); if (isset($product_links[1]) && sizeof($product_links[1])) { foreach ($product_links[1] as $product_link) { $product_cart_url = sprintf('index.php?controller=cart&add=1&qty=1&id_product=%s&token=%s', $product_link, Tools::getToken()); $content = preg_replace('#{{cart url=' . $product_link . '}}#', $product_cart_url, $content); } } //Gestion des widgets preg_match_all('#{{widget name="(.*)"(.*)}}#U', $content, $widgets); if (isset($widgets[1]) && sizeof($widgets[1])) { $i = 0; foreach ($widgets[1] as $widget) { $widget = trim($widget); if (is_file(dirname(__FILE__) . '/classes/' . $widget . '.php')) { include_once dirname(__FILE__) . '/classes/' . $widget . '.php'; $widgetParams = $widgets[2][$i]; try { $widgetObject = new $widget($widgetParams); $widgetContent = $widgetObject->display(); $content = str_replace('{{widget name="' . $widget . '"' . $widgetParams . '}}', $widgetContent, $content); } catch (PrestaShopExceptionCore $e) { echo $e->getMessage(); } } $i++; } } return $content; }
function frontGetModuleContents($module, $cacheKey = '') { if (!$this->isCached('pagelink.' . $module['layout'] . '.tpl', Tools::encrypt($cacheKey))) { $contents = array(); $langId = $this->context->language->id; $shopId = $this->context->shop->id; $items = Db::getInstance()->executeS("Select r.*, rl.name, rl.link \n\t\t\t\tFrom " . _DB_PREFIX_ . "pagelink_item AS r \n\t\t\t\tInner Join " . _DB_PREFIX_ . "pagelink_item_lang AS rl On r.id = rl.menuitem_id \n\t\t\t\tWhere r.parent_id = 0 AND r.module_id = " . $module['id'] . " AND r.status = 1 AND rl.id_lang = " . $langId . " Order By r.ordering"); if ($items) { foreach ($items as &$item) { $icon = $this->getImageSrc($item['icon'], true); $item['icon_type'] = $icon->type; $item['full_path'] = $icon->img; if ($item['link_type'] == 'PAG-authentication') { if ($this->context->customer->logged) { $item['link'] = $this->context->link->getPageLink('index', true, NULL, "mylogout"); $item['name'] = $this->l('Sign out'); $item['custom_class'] = 'nav-logout'; } else { $item['link'] = $this->frontGenerationUrl($item['link_type'], $item['link']); } } elseif ($item['link_type'] == 'PRODUCT-0') { $item['link'] = $this->frontGenerationUrl('PRD-' . $item['product_id'], $item['link']); } elseif ($item['link_type'] == 'CURRENCY-BOX') { $item['currencies'] = array('name' => $this->context->currency->name, 'iso_code' => $this->context->currency->iso_code, 'sign' => $this->context->currency->sign); } elseif ($item['link_type'] == 'LANGUAGE-BOX') { $languages = Language::getLanguages(true, $this->context->shop->id); if (count($languages) > 0) { $link = new Link(); if ((int) Configuration::get('PS_REWRITING_SETTINGS')) { $default_rewrite = array(); if (Dispatcher::getInstance()->getController() == 'product' && ($id_product = (int) Tools::getValue('id_product'))) { $rewrite_infos = Product::getUrlRewriteInformations((int) $id_product); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = $link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']); } } if (Dispatcher::getInstance()->getController() == 'category' && ($id_category = (int) Tools::getValue('id_category'))) { $rewrite_infos = Category::getUrlRewriteInformations((int) $id_category); foreach ($rewrite_infos as $infos) { $default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']); } } if (Dispatcher::getInstance()->getController() == 'cms' && (($id_cms = (int) Tools::getValue('id_cms')) || ($id_cms_category = (int) Tools::getValue('id_cms_category')))) { $rewrite_infos = isset($id_cms) && !isset($id_cms_category) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category); foreach ($rewrite_infos as $infos) { $arr_link = isset($id_cms) && !isset($id_cms_category) ? $link->getCMSLink($id_cms, $infos['link_rewrite'], null, $infos['id_lang']) : $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']); $default_rewrite[$infos['id_lang']] = $arr_link; } } $this->smarty->assign(array('lang_rewrite_urls' => $default_rewrite, 'lang_name' => $this->context->language->name, 'lang_iso_code' => $this->context->language->iso_code)); } } } else { $item['link'] = $this->frontGenerationUrl($item['link_type'], $item['link']); } $item['submenus'] = $this->frontGetSubMenus($module['id'], $item['id']); } } $this->context->smarty->assign(array('module_layout' => $module['layout'], 'display_name' => $module['display_name'], 'custom_class' => $module['custom_class'], 'name' => $module['name'], 'menuContents' => $items)); } return $this->display(__FILE__, 'pagelink.' . $module['layout'] . '.tpl', Tools::encrypt($cacheKey)); }