71 lines
2.1 KiB
PHP
Raw Normal View History

<?php
class Link extends LinkCore
{
public function getGuideLink($guide_post, $alias = null, $ssl = false, $id_lang = NULL)
{
if (is_object($guide_post)) {
$id = (int)($guide_post->id);
$alias = $guide_post->link_rewrite;
}
else {
$id = (int)($guide_post);
}
if ($this->allow == 1) {
$url = __PS_BASE_URI__.$this->getLangLink((int)($id_lang)).'guide/';
$url .= $id.($alias?'-'.$alias:'');
}
else {
$url = $this->moduleGuideDir($ssl).'page.php?id_guide_post='.$id.'&id_lang='.$id_lang;
}
return $url;
}
private function moduleGuideDir($ssl)
{
$base = (($ssl AND Configuration::get('PS_SSL_ENABLED')) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true));
2017-03-08 16:10:35 +01:00
return $base._MODULE_DIR_.'/'.Module::getModuleNameFromClass('AdminGuidePosts').'/';
}
2017-03-08 16:10:35 +01:00
2017-03-09 10:53:26 +01:00
public function getPageLink($filename, $ssl = false, $id_lang = NULL)
2017-03-08 16:10:35 +01:00
{
global $cookie;
if ($id_lang == NULL)
$id_lang = (int)($cookie->id_lang);
if (array_key_exists($filename.'_'.$id_lang, self::$cache['page']) AND !empty(self::$cache['page'][$filename.'_'.$id_lang]))
$uri_path = self::$cache['page'][$filename.'_'.$id_lang];
else
{
if ($this->allow == 1)
{
$url_rewrite = '';
if ($filename != 'index.php')
{
$pagename = substr($filename, 0, -4);
$url_rewrite = Db::getInstance()->getValue('
SELECT url_rewrite
FROM `'._DB_PREFIX_.'meta` m
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta)
WHERE id_lang = '.(int)($id_lang).' AND `page` = \''.pSQL($pagename).'\'');
$uri_path = $this->getLangLink((int)$id_lang).($url_rewrite ? $url_rewrite : $filename);
}
else
$uri_path = $this->getLangLink((int)$id_lang);
}
else
{
$uri_path = '';
if ($filename != 'index.php')
$uri_path = $filename;
}
self::$cache['page'][$filename.'_'.$id_lang] = $uri_path;
}
2017-03-08 17:19:26 +01:00
$protocol = (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PORT'] == '443')?'https://':'http://';
2017-03-08 16:10:35 +01:00
return $protocol.Tools::getShopDomainSsl().__PS_BASE_URI__.ltrim($uri_path, '/');
}
}