Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: anwiki/_override/actions/action_view/action_view.tpl.php

Issue 9148089: Less hacky implementation of the language selection (Closed)
Patch Set: Created Jan. 9, 2013, 1:54 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | anwiki/_override/contentclasses/contentclass_menu/contentclass_menu.tpl.php » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: anwiki/_override/actions/action_view/action_view.tpl.php
===================================================================
--- a/anwiki/_override/actions/action_view/action_view.tpl.php
+++ b/anwiki/_override/actions/action_view/action_view.tpl.php
@@ -1,91 +1,17 @@
<?php
class AnwTemplateOverride_action_view extends AnwTemplateDefault_action_view
{
function viewPage($sContentHtmlDir, $sCss, $title, $content, $editiontime, $aoTranslations)
{
$HTML = <<<EOF
- {$this->pageTranslations($aoTranslations)}
-
<div class="$sCss" dir="$sContentHtmlDir">
$content
</div>
EOF;
return $HTML;
}
-
- function pageTranslations($aoTranslations)
- {
- $languages = $this->getLanguages($aoTranslations);
- $currentLanguage = array_shift($languages);
- $currentLang = $currentLanguage['lang'];
- $currentText = $currentLanguage['text'];
-
- $HTML = <<<EOF
-
-{{#LANGUAGESELECTION}}
-<li id="language">
- <div id="current-language">
- <div id="flag-$currentLang" class="flag sprite"></div><span>$currentText</span>
- <span id="language-arrow" class="sprite"></span>
- </div>
- <ul id="language-selector">
-EOF;
-
- foreach ($languages as $language)
- {
- $url = $language['url'];
- $linkStyle = $language['linkStyle'];
- $lang = $language['lang'];
- $text = $language['text'];
-
- $HTML .= <<<EOF
-
- <li class="language-entry"><a href="$url" style="$linkStyle"><div id="flag-$lang" class="flag sprite"></div>$text</a></li>
-EOF;
- }
-
- $HTML .= <<<EOF
-
- </ul>
-</li>
-{{/LANGUAGESELECTION}}
-EOF;
- return $HTML;
- }
-
- private function getLanguages($aoTranslations)
- {
- $languages = array();
-
- foreach ($aoTranslations as $amInfo)
- {
- $oPage = $amInfo['page'];
- $bCurrent = $amInfo['current'];
- $sLang = $this->xQuote($oPage->getLang());
- $sLinkStyle = $amInfo['online'] ? '' : ' text-decoration:line-through;';
- $sText = $this->xText(self::g_('lang_' . $sLang, array(),
- AnwAction::getActionLang()));
-
- $entry = array("lang" => $sLang, "linkStyle" => $sLinkStyle,
- "text" => $sText);
-
- if ($bCurrent)
- array_unshift($languages, $entry);
- else
- {
- $asParams = $_GET;
- unset($asParams[AnwActionPage::GET_PAGENAME]); //avoid loop
- unset($asParams['browser']);
- $sUrl = AnwUtils::link($oPage, "view", $asParams);
- $entry['url'] = $this->xQuote($sUrl);
- array_push($languages, $entry);
- }
- }
-
- return $languages;
- }
}
?>
« no previous file with comments | « no previous file | anwiki/_override/contentclasses/contentclass_menu/contentclass_menu.tpl.php » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld