136 lines
4.5 KiB
PHP
136 lines
4.5 KiB
PHP
<?php
|
|
|
|
class Link extends LinkCore
|
|
{
|
|
public static $urls_products = array();
|
|
public static $urls_categories = array();
|
|
public static $urls_manufacturers = array();
|
|
public static $urls_cms = array();
|
|
|
|
// CMS
|
|
public static $urls_categories_cms = array();
|
|
public static $urls_posts_cms = array();
|
|
public static $urls_editos_cms = array();
|
|
|
|
public static $url_home_edito = '';
|
|
public static $url_home_store = '';
|
|
|
|
|
|
public function getVideosLink($id = 1, $id_lang = null, $id_shop = null,
|
|
$ipa = 0, $force_routes = false, $relative_protocol = false) {
|
|
|
|
if (!$id_lang)
|
|
$id_lang = Context::getContext()->language->id;
|
|
if (!$id_shop)
|
|
$id_shop = Context::getContext()->shop->id;
|
|
|
|
$url = $this->getBaseLink($id_shop, null, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop);
|
|
|
|
|
|
$link = ManageSeoUrl::getByType($id, ManageSeoUrl::TYPE_VIDEO, FALSE, $id_lang, $id_shop);
|
|
self::$url_home_store = $url.$link->link_rewrite;
|
|
return $url.$link->link_rewrite;
|
|
}
|
|
|
|
public function getHomeStoreLink($id = 1, $id_lang = null, $id_shop = null,
|
|
$ipa = 0, $force_routes = false, $relative_protocol = false) {
|
|
|
|
if (!$id_lang)
|
|
$id_lang = Context::getContext()->language->id;
|
|
if (!$id_shop)
|
|
$id_shop = Context::getContext()->shop->id;
|
|
|
|
$url = $this->getBaseLink($id_shop, null, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop);
|
|
|
|
if(empty(self::$url_home_store)) {
|
|
$link = ManageSeoUrl::getByType($id, ManageSeoUrl::TYPE_STORE_HOME, FALSE, $id_lang, $id_shop);
|
|
self::$url_home_store = $url.$link->link_rewrite;
|
|
return $url.$link->link_rewrite;
|
|
} else {
|
|
return self::$url_home_store;
|
|
}
|
|
}
|
|
|
|
public function getCategoryCmsLink($id_category_cms, $id_lang = null, $id_shop = null,
|
|
$ipa = 0, $force_routes = false, $relative_protocol = false) {
|
|
|
|
if (!$id_lang)
|
|
$id_lang = Context::getContext()->language->id;
|
|
if (!$id_shop)
|
|
$id_shop = Context::getContext()->shop->id;
|
|
|
|
$url = $this->getBaseLink($id_shop, null, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop);
|
|
|
|
if(!isset(self::$urls_categories_cms[$id_category_cms])) {
|
|
$link = ManageSeoUrl::getByType($id_category_cms, ManageSeoUrl::TYPE_CATEGORY_CMS, FALSE, $id_lang, $id_shop);
|
|
self::$urls_categories_cms[$id_category_cms] = $url.$link->link_rewrite;
|
|
return $url.$link->link_rewrite;
|
|
} else {
|
|
return self::$urls_categories_cms[$id_category_cms];
|
|
}
|
|
}
|
|
|
|
|
|
public function getPostCmsLink($id_post_cms, $id_lang = null, $id_shop = null,
|
|
$ipa = 0, $force_routes = false, $relative_protocol = false) {
|
|
|
|
if (!$id_lang)
|
|
$id_lang = Context::getContext()->language->id;
|
|
if (!$id_shop)
|
|
$id_shop = Context::getContext()->shop->id;
|
|
|
|
$url = $this->getBaseLink($id_shop, null, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop);
|
|
|
|
if(!isset(self::$urls_posts_cms[$id_post_cms])) {
|
|
$link = ManageSeoUrl::getByType($id_post_cms, ManageSeoUrl::TYPE_POST_CMS, FALSE, $id_lang, $id_shop);
|
|
if(Validate::isLoadedObject($link)){
|
|
self::$urls_posts_cms[$id_post_cms] = $url.$link->link_rewrite;
|
|
return $url.$link->link_rewrite;
|
|
}
|
|
} else {
|
|
return self::$urls_posts_cms[$id_post_cms];
|
|
}
|
|
}
|
|
|
|
|
|
public function getPostEditoLink($id_post_edito, $id_lang = null, $id_shop = null,
|
|
$ipa = 0, $force_routes = false, $relative_protocol = false) {
|
|
|
|
if (!$id_lang)
|
|
$id_lang = Context::getContext()->language->id;
|
|
if (!$id_shop)
|
|
$id_shop = Context::getContext()->shop->id;
|
|
|
|
$url = $this->getBaseLink($id_shop, null, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop);
|
|
|
|
if(!isset(self::$urls_editos_cms[$id_post_edito])) {
|
|
$link = ManageSeoUrl::getByType($id_post_edito, ManageSeoUrl::TYPE_POST_EDITO, FALSE, $id_lang, $id_shop);
|
|
self::$urls_editos_cms[$id_post_edito] = $url.$link->link_rewrite;
|
|
return $url.$link->link_rewrite;
|
|
} else {
|
|
return self::$urls_editos_cms[$id_post_edito];
|
|
}
|
|
}
|
|
|
|
public function getHomeEditoLink($id = 1, $id_lang = null, $id_shop = null,
|
|
$ipa = 0, $force_routes = false, $relative_protocol = false) {
|
|
|
|
if (!$id_lang)
|
|
$id_lang = Context::getContext()->language->id;
|
|
if (!$id_shop)
|
|
$id_shop = Context::getContext()->shop->id;
|
|
|
|
$url = $this->getBaseLink($id_shop, null, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop);
|
|
|
|
if(empty(self::$url_home_edito)) {
|
|
$link = ManageSeoUrl::getByType($id, ManageSeoUrl::TYPE_HOME_EDITO, FALSE, $id_lang, $id_shop);
|
|
self::$url_home_edito = $url.$link->link_rewrite;
|
|
return $url.$link->link_rewrite;
|
|
} else {
|
|
return self::$url_home_edito;
|
|
}
|
|
}
|
|
|
|
}
|
|
|