Jeremy Newman : move the base themes into the templates dir so they can be translated as well , also allow langCode to be used on the theme pages, other misc cleanups in the html class

Jeremy Newman jnewman at winehq.org
Tue Sep 7 09:40:07 CDT 2010


Module: website
Branch: master
Commit: 873a7c2b7157577686576fa56de4b9979c06c36b
URL:    http://source.winehq.org/git/website.git/?a=commit;h=873a7c2b7157577686576fa56de4b9979c06c36b

Author: Jeremy Newman <jnewman at codeweavers.com>
Date:   Tue Sep  7 09:39:00 2010 -0500

move the base themes into the templates dir so they can be translated as well, also allow langCode to be used on the theme pages, other misc cleanups in the html class

---

 include/html.php                                   |   37 +++++++++++--------
 .../en/global}/themes/winehq/content.template      |    3 +-
 .../global}/themes/winehq/content_nobox.template   |    5 +--
 .../global}/themes/winehq/content_print.template   |    0 
 4 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/include/html.php b/include/html.php
index 1b1b3d4..5d4ef31 100644
--- a/include/html.php
+++ b/include/html.php
@@ -1135,7 +1135,7 @@ class html
             $theme = $config->theme;
         
         // debug
-        debug("template", "loading template: theme:[".$theme."] lang: [".$this->lang."] template:[".$template."]");
+        debug("template", "loading template: theme:[{$theme}] lang: [{$this->lang}] template:[{$template}]");
         
         // load from cache if we have already loaded before
         if (isset($this->template_cache[$template]))
@@ -1150,22 +1150,24 @@ class html
                 // load from local template repository
                 case "base":
                 case "local":
-                    if (file_exists($this->_file_root."/templates/".$this->lang."/".$template.".template"))
-                        $in = join("",file($this->_file_root."/templates/".$this->lang."/".$template.".template"));
-                    else if (($config->lang != $this->lang) and file_exists($this->_file_root."/templates/".$config->lang."/".$template.".template"))
-                        $in = join("",file($this->_file_root."/templates/".$config->lang."/".$template.".template"));
+                    if (file_exists("{$this->_file_root}/templates/{$this->lang}/{$template}.template"))
+                        $in = join("",file("{$this->_file_root}/templates/{$this->lang}/{$template}.template"));
+                    else if (($config->lang != $this->lang) and file_exists("{$this->_file_root}/templates/{$config->lang}/{$template}.template"))
+                        $in = join("",file("{$this->_file_root}/templates/{$config->lang}/{$template}.template"));
                     break;
                 
                 // load from global
                 case "global":
-                    if (file_exists($this->_file_root."/templates/global/".$template.".template"))
-                        $in = join("",file($this->_file_root."/templates/global/".$template.".template"));
+                    if (file_exists("{$this->_file_root}/templates/global/{$template}.template"))
+                        $in = join("",file("{$this->_file_root}/templates/global/{$template}.template"));
                     break;
 
                 // load template from theme
                 default:
-                    if (file_exists($this->_file_root."/include/themes/".$theme."/".$template.".template"))
-                        $in = join("",file($this->_file_root."/include/themes/".$theme."/".$template.".template"));                
+                    if (file_exists("{$this->_file_root}/templates/{$this->lang}/global/themes/{$theme}/{$template}.template"))
+                        $in = join("",file("{$this->_file_root}/templates/{$this->lang}/global/themes/{$theme}/{$template}.template"));
+                    else if (($config->lang != $this->lang) and file_exists("{$this->_file_root}/templates/{$config->lang}/global/themes/{$theme}/{$template}.template"))
+                        $in = join("",file("{$this->_file_root}/templates/{$config->lang}/global/themes/{$theme}/{$template}.template"));              
             }
         }
 
@@ -1174,10 +1176,10 @@ class html
         {
             $in = '';
             $this->in404 = 1;
-            if (file_exists($this->_file_root."/templates/".$this->lang."/global/404.template"))
-                $in .= join("",file($this->_file_root."/templates/".$this->lang."/global/404.template"));
-            else if (file_exists($this->_file_root."/templates/".$config->lang."/global/404.template"))
-                $in .= join("",file($this->_file_root."/templates/".$config->lang."/global/404.template"));
+            if (file_exists("{$this->_file_root}/templates/{$this->lang}/global/404.template"))
+                $in .= join("",file("{$this->_file_root}/templates/{$this->lang}/global/404.template"));
+            else if (file_exists("{$this->_file_root}/templates/{$config->lang}/global/404.template"))
+                $in .= join("",file("{$this->_file_root}/templates/{$config->lang}/global/404.template"));
             else
                 $in .= $this->h1("404 Not Found!");
         }
@@ -1206,11 +1208,14 @@ class html
         $vars['curtime_year'] = date('Y', time());
         
         // language vars
-        if (defined("PAGE") and (PAGE == "home" or PAGE == "lang"))
+        if (defined("PAGE"))
         {
             $vars['langCode'] =& $this->lang;
-            $vars['langCur'] =& $GLOBALS['data']->languages[$this->lang]['name'];
-            $vars['langChange'] =& $GLOBALS['data']->languages[$this->lang]['change'];
+            if (PAGE == "home" or PAGE == "lang")
+            {
+                $vars['langCur'] =& $GLOBALS['data']->languages[$this->lang]['name'];
+                $vars['langChange'] =& $GLOBALS['data']->languages[$this->lang]['change'];
+            }
         }
         
         // add config vars
diff --git a/include/themes/winehq/content.template b/templates/en/global/themes/winehq/content.template
similarity index 96%
rename from include/themes/winehq/content.template
rename to templates/en/global/themes/winehq/content.template
index 272ae0a..cd405ff 100644
--- a/include/themes/winehq/content.template
+++ b/templates/en/global/themes/winehq/content.template
@@ -9,7 +9,6 @@
     <meta name="keywords" content="windows, linux, macintosh, solaris, freebsd">
     <meta name="robots" content="index, follow">
     <meta name="copyright" content="Copyright {$curtime_year}. WineHQ.org All Rights Reserved.">
-    <meta name="author" content="Jeremy Newman">
     <meta name="language" content="English">
     <meta name="revisit-after" content="1">
     <link rel="stylesheet" href="{$root}/styles.css" type="text/css" media="screen">
@@ -39,7 +38,7 @@
     <input type="hidden" name="ie" value="UTF-8">
     <span style="color: #ffffff;">Search:</span> <input type="text" name="q" size="20">
   </form>
-  <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en"></script>
+  <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang={$langCode}"></script>
 </div>
 
 
diff --git a/include/themes/winehq/content_nobox.template b/templates/en/global/themes/winehq/content_nobox.template
similarity index 93%
rename from include/themes/winehq/content_nobox.template
rename to templates/en/global/themes/winehq/content_nobox.template
index 71a083a..8eaa440 100644
--- a/include/themes/winehq/content_nobox.template
+++ b/templates/en/global/themes/winehq/content_nobox.template
@@ -9,7 +9,6 @@
     <meta name="keywords" content="windows, linux, macintosh, solaris, freebsd">
     <meta name="robots" content="index, follow">
     <meta name="copyright" content="Copyright {$curtime_year}. WineHQ.org All Rights Reserved.">
-    <meta name="author" content="Jeremy Newman">
     <meta name="language" content="English">
     <meta name="revisit-after" content="1">
     <link rel="stylesheet" href="{$root}/styles.css" type="text/css" media="screen">
@@ -33,13 +32,13 @@
 
 
 <div id="search_box">
-  <form action="{$root}/search" id="cse-search-box" style="margin: 0; padding: 0;">
+  <form action="{$root}/search/" id="cse-search-box" style="margin: 0; padding: 0;">
     <input type="hidden" name="cx" value="partner-pub-0971840239976722:w9sqbcsxtyf">
     <input type="hidden" name="cof" value="FORID:10">
     <input type="hidden" name="ie" value="UTF-8">
     <span style="color: #ffffff;">Search:</span> <input type="text" name="q" size="20">
   </form>
-  <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en"></script>
+  <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang={$langCode}"></script>
 </div>
 
 
diff --git a/include/themes/winehq/content_print.template b/templates/en/global/themes/winehq/content_print.template
similarity index 100%
rename from include/themes/winehq/content_print.template
rename to templates/en/global/themes/winehq/content_print.template




More information about the wine-cvs mailing list