/** * */ public function listLanguageLinks() { $page = Digitalus_Builder::getPage(); $currentLanguage = $page->getLanguage(); $availableLanguages = $page->getAvailableLanguages(); $xhtml = $this->view->getTranslation('You are reading this page in') . ' ' . $this->view->getTranslation(Digitalus_Language::getFullName($currentLanguage)) . '.'; if (is_array($availableLanguages)) { $languageLinks = array(); $uri = new Digitalus_Uri(); $base = $uri->toString(); foreach ($availableLanguages as $locale => $name) { if (!empty($locale) && $locale != $currentLanguage) { $url = $base . '/p/language/' . $locale; $languageLinks[] = '<a href="' . $url . '">' . $this->view->getTranslation($name) . '</a>'; } } if (is_array($languageLinks) && count($languageLinks) > 0) { foreach ($languageLinks as $language) { $languageLinksTranslated[] = $this->view->getTranslation($language); } $xhtml .= ' ' . $this->view->getTranslation('This page is also translated into') . ' ' . implode(', ', $languageLinks); } } return '<p>' . $xhtml . '</p>'; }
public static function getCurrentPageName($onlyLast = true) { $uri = new Digitalus_Uri(); $uriString = $uri->toString(); if (true === $onlyLast) { return Digitalus_Toolbox_String::getSelfFromPath($uriString); } return Digitalus_Toolbox_String::stripLeading('/', $uriString); }
protected function _setActive($item = null) { if (empty($item)) { $item = $this->getItem(); } $uri = new Digitalus_Uri(); $uriString = strtolower($uri->toString()); if (strtolower(Digitalus_Toolbox_Page::getCurrentPageName()) == strtolower($item->name) || empty($uriString) && strtolower(Digitalus_Toolbox_Page::getHomePageName($item)) == strtolower(Digitalus_Toolbox_Page::getUrl($item))) { $active = true; } else { $active = false; } $this->setActive($active); }