本文整理汇总了PHP中Translatable::get_homepage_link_by_locale方法的典型用法代码示例。如果您正苦于以下问题:PHP Translatable::get_homepage_link_by_locale方法的具体用法?PHP Translatable::get_homepage_link_by_locale怎么用?PHP Translatable::get_homepage_link_by_locale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translatable
的用法示例。
在下文中一共展示了Translatable::get_homepage_link_by_locale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_homepage_link
/**
* Get the full form (e.g. /home/) relative link to the home page for the current HTTP_HOST value. Note that the
* link is trimmed of leading and trailing slashes before returning to ensure consistency.
*
* @return string
*/
public static function get_homepage_link()
{
if (!self::$cached_homepage_link) {
// TODO Move to 'homepagefordomain' module
if (class_exists('HomepageForDomainExtension')) {
$host = str_replace('www.', null, $_SERVER['HTTP_HOST']);
$SQL_host = Convert::raw2sql($host);
$candidates = DataObject::get('SiteTree', "\"HomepageForDomain\" LIKE '%{$SQL_host}%'");
if ($candidates) {
foreach ($candidates as $candidate) {
if (preg_match('/(,|^) *' . preg_quote($host) . ' *(,|$)/', $candidate->HomepageForDomain)) {
self::$cached_homepage_link = trim($candidate->RelativeLink(true), '/');
}
}
}
}
if (!self::$cached_homepage_link) {
// TODO Move to 'translatable' module
if (class_exists('Translatable') && Object::has_extension('SiteTree', 'Translatable') && ($link = Translatable::get_homepage_link_by_locale(Translatable::get_current_locale()))) {
self::$cached_homepage_link = $link;
} else {
self::$cached_homepage_link = self::get_default_homepage_link();
}
}
}
return self::$cached_homepage_link;
}
示例2: get_homepage_link
/**
* Get the full form (e.g. /home/) relative link to the home page for the current HTTP_HOST value. Note that the
* link is trimmed of leading and trailing slashes before returning to ensure consistency.
*
* @return string
*/
public static function get_homepage_link()
{
if (!self::$cached_homepage_link) {
// @todo Move to 'homepagefordomain' module
if (class_exists('HomepageForDomainExtension')) {
$host = str_replace('www.', null, $_SERVER['HTTP_HOST']);
$candidates = SiteTree::get()->where(array('"SiteTree"."HomepageForDomain" LIKE ?' => "%{$host}%"));
if ($candidates) {
foreach ($candidates as $candidate) {
if (preg_match('/(,|^) *' . preg_quote($host) . ' *(,|$)/', $candidate->HomepageForDomain)) {
self::$cached_homepage_link = trim($candidate->RelativeLink(true), '/');
}
}
}
}
if (!self::$cached_homepage_link) {
// TODO Move to 'translatable' module
if (class_exists('Translatable') && SiteTree::has_extension('Translatable') && ($link = Translatable::get_homepage_link_by_locale(Translatable::get_current_locale()))) {
self::$cached_homepage_link = $link;
} else {
self::$cached_homepage_link = Config::inst()->get('RootURLController', 'default_homepage_link');
}
}
}
return self::$cached_homepage_link;
}