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

Side by Side Diff: anwiki/_override/global/global/global.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 | « anwiki/_override/contentclasses/contentclass_menu/contentclass_menu.tpl.php ('k') | no next file » | 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_global extends AnwTemplateDefault_global 3 class AnwTemplateOverride_global extends AnwTemplateDefault_global
4 { 4 {
5 function globalHtml($sHtmlLang, $sHtmlDir, $sTitle, $sHead, $sBody) 5 function globalHtml($sHtmlLang, $sHtmlDir, $sTitle, $sHead, $sBody)
6 { 6 {
7 $HTML = <<<EOF 7 $HTML = <<<EOF
8 <!DOCTYPE html> 8 <!DOCTYPE html>
9 <html lang="{$this->xQuote($sHtmlLang)}" dir="{$this->xQuote($sHtmlDir)}" itemsc ope="itemscope" itemtype="http://schema.org/WebPage"> 9 <html lang="{$this->xQuote($sHtmlLang)}" dir="{$this->xQuote($sHtmlDir)}" itemsc ope="itemscope" itemtype="http://schema.org/WebPage">
10 <head> 10 <head>
11 <title>{$this->xText($sTitle)}</title> 11 <title>{$this->xText($sTitle)}</title>
12 $sHead 12 $sHead
13 </head> 13 </head>
14 14
15 <body> 15 <body>
16 $sBody 16 $sBody
17 </body> 17 </body>
18 </html> 18 </html>
19 EOF; 19 EOF;
20 20
21 $HTML = $this->moveLanguageSelection($HTML);
22 return $this->moveMetaTagsToHead($HTML); 21 return $this->moveMetaTagsToHead($HTML);
23 } 22 }
24 23
25 private function moveLanguageSelection($HTML)
26 {
27 $pattern = '/{{#LANGUAGESELECTION}}(.*){{\/LANGUAGESELECTION}}/s';
28 preg_match($pattern, $HTML, $matches);
29 if (count($matches) > 1)
30 {
31 $HTML = preg_replace($pattern, "", $HTML);
32 $languageSelection = $matches[1];
33 }
34 else
35 $languageSelection = "";
36 $HTML = preg_replace('/<li>\s*<a\b.*?>LANGUAGESELECTION<\/a>\s*<\/li>/', $la nguageSelection, $HTML);
37 return $HTML;
38 }
39
40 private function moveMetaTagsToHead($HTML) 24 private function moveMetaTagsToHead($HTML)
41 { 25 {
42 do 26 do
43 { 27 {
44 $HTML = preg_replace('/(<\/head>.*<body\b.*)(<meta\b[^>]*\/>\s*)/is', '$2$ 1', $HTML, 1, $count); 28 $HTML = preg_replace('/(<\/head>.*<body\b.*)(<meta\b[^>]*\/>\s*)/is', '$2$ 1', $HTML, 1, $count);
45 } while ($count); 29 } while ($count);
46 return $HTML; 30 return $HTML;
47 } 31 }
48 32
49 function globalHead($sHeadContent, $sHeadCss, $sHeadJs) 33 function globalHead($sHeadContent, $sHeadCss, $sHeadJs)
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // This will fail when the database is not configured correctly or when 161 // This will fail when the database is not configured correctly or when
178 // the page footer page doesn't exist yet. That's the case during the 162 // the page footer page doesn't exist yet. That's the case during the
179 // initial installation. 163 // initial installation.
180 } 164 }
181 165
182 return ""; 166 return "";
183 } 167 }
184 } 168 }
185 169
186 ?> 170 ?>
OLDNEW
« no previous file with comments | « anwiki/_override/contentclasses/contentclass_menu/contentclass_menu.tpl.php ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld