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

Side by Side 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:31 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <?php 1 <?php
2 2
3 class AnwTemplateOverride_action_view extends AnwTemplateDefault_action_view 3 class AnwTemplateOverride_action_view extends AnwTemplateDefault_action_view
4 { 4 {
5 function viewPage($sContentHtmlDir, $sCss, $title, $content, $editiontime, $ao Translations) 5 function viewPage($sContentHtmlDir, $sCss, $title, $content, $editiontime, $ao Translations)
6 { 6 {
7 $HTML = <<<EOF 7 $HTML = <<<EOF
8 8
9 {$this->pageTranslations($aoTranslations)}
10
11 <div class="$sCss" dir="$sContentHtmlDir"> 9 <div class="$sCss" dir="$sContentHtmlDir">
12 $content 10 $content
13 </div> 11 </div>
14 EOF; 12 EOF;
15 return $HTML; 13 return $HTML;
16 } 14 }
17
18 function pageTranslations($aoTranslations)
19 {
20 $languages = $this->getLanguages($aoTranslations);
21 $currentLanguage = array_shift($languages);
22 $currentLang = $currentLanguage['lang'];
23 $currentText = $currentLanguage['text'];
24
25 $HTML = <<<EOF
26
27 {{#LANGUAGESELECTION}}
28 <li id="language">
29 <div id="current-language">
30 <div id="flag-$currentLang" class="flag sprite"></div><span>$currentText</sp an>
31 <span id="language-arrow" class="sprite"></span>
32 </div>
33 <ul id="language-selector">
34 EOF;
35
36 foreach ($languages as $language)
37 {
38 $url = $language['url'];
39 $linkStyle = $language['linkStyle'];
40 $lang = $language['lang'];
41 $text = $language['text'];
42
43 $HTML .= <<<EOF
44
45 <li class="language-entry"><a href="$url" style="$linkStyle"><div id="flag-$ lang" class="flag sprite"></div>$text</a></li>
46 EOF;
47 }
48
49 $HTML .= <<<EOF
50
51 </ul>
52 </li>
53 {{/LANGUAGESELECTION}}
54 EOF;
55 return $HTML;
56 }
57
58 private function getLanguages($aoTranslations)
59 {
60 $languages = array();
61
62 foreach ($aoTranslations as $amInfo)
63 {
64 $oPage = $amInfo['page'];
65 $bCurrent = $amInfo['current'];
66 $sLang = $this->xQuote($oPage->getLang());
67 $sLinkStyle = $amInfo['online'] ? '' : ' text-decoration:line-through;';
68 $sText = $this->xText(self::g_('lang_' . $sLang, array(),
69 AnwAction::getActionLang()));
70
71 $entry = array("lang" => $sLang, "linkStyle" => $sLinkStyle,
72 "text" => $sText);
73
74 if ($bCurrent)
75 array_unshift($languages, $entry);
76 else
77 {
78 $asParams = $_GET;
79 unset($asParams[AnwActionPage::GET_PAGENAME]); //avoid loop
80 unset($asParams['browser']);
81 $sUrl = AnwUtils::link($oPage, "view", $asParams);
82 $entry['url'] = $this->xQuote($sUrl);
83 array_push($languages, $entry);
84 }
85 }
86
87 return $languages;
88 }
89 } 15 }
90 16
91 ?> 17 ?>
OLDNEW
« 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