Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Translations can now be switched

Still have to dynamically build the translation list

* Changed language selector to a dropdown
* A cookie is set for language choice and read back
* CSS further simplified
* Moved the access warning messages into the blank space next to the RSS link
  • Loading branch information...
commit 342c80e27f96b0acd4e4d5adfec8250a1ac2b0e8 1 parent 81b94a2
@Kroc authored
View
46 start.php
@@ -35,8 +35,9 @@
//(`FORUM_TIMEZONE` is set in the config and defaults to 'UTC')
date_default_timezone_set (FORUM_TIMEZONE);
+
/* constants: some stuff we don’t expect to change
- ---------------------------------------------------------------------------------------------------------------------- */
+ ====================================================================================================================== */
define ('FORUM_ROOT', dirname (__FILE__)); //full server-path for absolute references
define ('FORUM_PATH', str_replace ( //relative from webroot--if running in a folder:
array ('\\', '//'), '/', //- replace Windows forward-slash with backslash
@@ -48,7 +49,7 @@
);
/* common input
- ====================================================================================================================== */
+ ---------------------------------------------------------------------------------------------------------------------- */
//all our pages use 'path' (often optional) to specify the sub-forum being viewed, so this is done here
define ('PATH', preg_match ('/^(?:[^\.\/&]+\/)+$/', @$_GET['path']) ? $_GET['path'] : '');
//these two get used an awful lot
@@ -63,20 +64,6 @@
@chdir (FORUM_ROOT.PATH_DIR) or die ('Invalid path');
-/* theme & translation
- ====================================================================================================================== */
-//load the user’s theme configuration, if it exists
-@include FORUM_ROOT.'/themes/'.FORUM_THEME.'/theme.config.php';
-//include the theme defaults
-@(include FORUM_ROOT.'/themes/'.FORUM_THEME.'/theme.config.default.php') or die ('theme.config.default.php missing!');
-
-//include the language translations
-$LANG = array ();
-foreach (explode (' ', THEME_LANGS) as $lang) @include FORUM_ROOT.'/themes/'.FORUM_THEME."/lang.$lang.php";
-
-define ('LANG', 'en');
-
-
/* access control
====================================================================================================================== */
/* name / password authorisation:
@@ -160,6 +147,33 @@
));
+/* theme & translation
+ ====================================================================================================================== */
+//load the user’s theme configuration, if it exists
+@include FORUM_ROOT.'/themes/'.FORUM_THEME.'/theme.config.php';
+//include the theme defaults
+@(include FORUM_ROOT.'/themes/'.FORUM_THEME.'/theme.config.default.php') or die ('theme.config.default.php missing!');
+
+//include the language translations
+$LANG = array ();
+foreach (explode (' ', THEME_LANGS) as $lang) @include FORUM_ROOT.'/themes/'.FORUM_THEME."/lang.$lang.php";
+
+//was the language changed?
+if (@$_POST['lang']) {
+ //set the language cookie for 30 days
+ setcookie ("lang", $_POST['lang'], time ()+60*60*24*30, FORUM_PATH, $_POST['HTTP_HOST'], FORUM_HTTPS);
+ define ('LANG', $_POST['lang']);
+
+//does a cookie already exist to set the language?
+} elseif (@$_COOKIE['lang'] && in_array ($_COOKIE['lang'], @explode (' ', THEME_LANGS))) {
+ define ('LANG', $_COOKIE['lang']);
+
+} else {
+ //use default language
+ define ('LANG', THEME_LANG);
+}
+
+
/* send HTTP headers
====================================================================================================================== */
//if enabled, enforce HTTPS
View
BIN  themes/greyscale/img/lang.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
44 themes/greyscale/index.html
@@ -32,24 +32,26 @@
--></form>
<nav>
- <form id="lang">
- <input type="submit" name="lang:en" value="en" />
- <input type="submit" name="lang:fr" value="fr" />
- <input type="submit" name="lang:it" value="it" />
- <input type="submit" name="lang:de" value="de" />
- <input type="submit" name="lang:es" value="es" />
+ <form id="nnf_lang" method="post">
+ <img src="/themes/greyscale/img/lang.png" width="20" height="20" alt="Language:" title="Language:" />
+ <select name="lang">
+ <option class="nnf_lang" value="en">English</option>
+ <option class="nnf_lang" value="x-pig-latin">Igpay Atinlay</option>
+ </select>
+ <input id="lang-set" type="image" src="/themes/greyscale/img/go.png" width="20" height="20" alt="Set Language" />
</form>
<ol id="index">
<li><a href="/">Index</a></li>
<li class="nnf_breadcrumb"> » <a class="nnf_subforum-name" href="/sub-forum">Sub-forum</a></li>
</ol>
</nav>
+
+ <section id="nnf_about"><p>
+ If a fourm / sub-forum contains an ‘about.html’ file, it's contents will be loaded into this element.
+ If ‘about.html’ doesn’t exist the whole element will be removed.
+ </p></section>
</header>
<!-- =================================================================================================================== -->
-<section id="nnf_about"><p>
- If a fourm / sub-forum contains an ‘about.html’ file, it's contents will be loaded into this element.
- If ‘about.html’ doesn’t exist the whole element will be removed.
-</p></section>
<section id="nnf_folders">
<h1>Sub-Forums</h1>
<ol class="ui"><li class="nnf_folder">
@@ -59,18 +61,18 @@
</li></ol>
</section>
-<p id="rights" class="nnf_forum-lock-threads">
- Only <a href="#mods">moderators or members</a> can start new threads here [<a href="?signin">sign-in</a>],
- but <em>anybody</em> can reply to existing threads.
-</p>
-<p id="rights" class="nnf_forum-lock-posts">
- Only <a href="#mods">moderators or members</a> can participate here.
- <a href="?signin">Sign-in</a> if you are a moderator or member in order to post.
-</p>
-
-<p id="links">
- <a id="nnf_rss" href="index.xml">RSS</a>
+<p id="info">
<a id="nnf_add" href="#nnf_new-form">Add Thread</a>
+ <a id="nnf_rss" href="index.xml">RSS</a>
+
+ <span class="nnf_forum-lock-threads">
+ Only <a href="#mods">moderators or members</a> can start new threads here [<a href="?signin">sign-in</a>],
+ but <em>anybody</em> can reply to existing threads.
+ </span>
+ <span class="nnf_forum-lock-posts">
+ Only <a href="#mods">moderators or members</a> can participate here.
+ <a href="?signin">Sign-in</a> if you are a moderator or member in order to post.
+ </span>
</p>
<section id="nnf_threads">
View
1  themes/greyscale/lang.example.php
@@ -17,6 +17,7 @@
*/
+$LANG['en']['name'] = 'English';
$LANG['en']['strings'] = array (
/* xpath/shorthand: replacement text: description:
View
1  themes/greyscale/lang.x-pig-latin.php
@@ -17,6 +17,7 @@
*/
+$LANG['x-pig-latin']['name'] = 'Igpay Atinlay';
$LANG['x-pig-latin']['strings'] = array (
/* xpath/shorthand: replacement text: description:
View
46 themes/greyscale/theme.css
@@ -12,7 +12,7 @@
header, nav, section, article, /* this doesn’t get set on browsers without an HTML5 parser (e.g. Firefox 3.6) */
footer {display: block;}
-html, body {width: 100%; margin: 0; padding: 0; border: 0;}
+html, body {width: 100%; margin: 0; padding: 0; border: 0; color: #888;}
html {font: 16px/20px Corbel, "URW Gothic L", "Liberation Sans", "Trebuchet MS", sans-serif;
background: white url("img/bg.png") fixed repeat-x bottom center; word-wrap: break-word;
/* CSS3 gradients for browsers that support it: */
@@ -33,7 +33,7 @@ h1 {margin: 0; padding: 20px 0 20px 60px;
font-weight: bold; font-size: 22px; line-height: 20px; color: #f7f6f7;
background: #222;}
-p {margin: 0; padding: 20px 20px 0;
+p {margin: 0; padding: 0 20px 20px;
/* fonts in Linux are pretty awful, so we go for a "centruy gothic" like font for titles
and other UI ("URW Gothic L"), but a normal-looking Arial-like for the post text */
font-family: Corbel, "Liberation Sans", "Trebuchet MS", sans-serif}
@@ -75,23 +75,16 @@ pre, code {font: 12.5px/20px Monaco, Consolas, "Liberation Mono", monospace, m
text-indent: 60px;}
#mast h1 a img {position: absolute; margin: 4px 0 0 -45px; border: none;}
-#mast nav {padding-top: 80px; text-transform: uppercase; color: #888;}
+#mast nav {padding-top: 80px;}
/* the breadcrumb for sub-forums */
-#index {margin: 0; padding: 0 0 0 60px;
+#index {margin: 0; padding: 0 0 20px 60px; text-transform: uppercase;
background: url("img/here.png") no-repeat 24px 0;}
#index li {display: inline;}
-/* 'Add' / 'Reply' and 'RSS' buttons */
-#links {text-align: right; text-transform: uppercase;}
-#nnf_add, #nnf_reply, #nnf_rss {margin-left: 20px; padding-left: 25px;}
-#nnf_add, #nnf_reply {background: url("img/add.png") no-repeat 0 50%;}
-#nnf_rss {background: url("img/rss.png") no-repeat 0 50%;}
-
/* search box: */
#search {float: right; *float: none; /*< IE6 & 7 work without floating */
height: 20px; width: 210px; /*< IE6/7 get height wrong */
- /* `auto` on the left margin (instead of `70%`) is required for IE6/7 to get this right */
margin: 0; padding: 20px 10px 20px; overflow: hidden;
border: none; /* very bizarely, the positioning magically adds a border in Firefox! */
text-align: right; background: none;}
@@ -112,24 +105,31 @@ input[type=search]:focus {outline: none;}
#go {position: relative; margin-left: -20px; top: -20px;}
/* language selector: */
-#lang {float: right; border: none; text-align: right;}
-#lang input {display: inline; float: left; margin: -10px 0 0 5px; padding: 10px 10px;
- border: 1px solid #eee; background: none; cursor: pointer;}
-#lang input:hover {background: #eee;}
+#nnf_lang {float: right; padding-right: 20px; border: none; text-align: right;}
+#nnf_lang img {vertical-align: middle;}
+#nnf_lang input {vertical-align: bottom;}
+
+/* the admin's custom header message, 'about.html' */
+#nnf_about {margin-bottom: 0; background: none;}
/* the access warning message that appears on locked forums / threads */
-#rights {margin: 0 auto; text-align: center; color: #888;}
-#rights a {color: #666;}
+#info {overflow: auto;}
+#info a {color: #666;}
+/* 'Add' / 'Reply' and 'RSS' buttons */
+#nnf_add, #nnf_reply, #nnf_rss {float: right; padding-left: 25px;
+ text-align: right; text-transform: uppercase; color: #222 !important;}
+#nnf_add, #nnf_reply {margin-left: 20px;
+ background: url("img/add.png") no-repeat 0 50%;}
+#nnf_rss {background: url("img/rss.png") no-repeat 0 50%;}
+
/* index page
====================================================================================================================== */
-section {margin: 20px auto 0;
+section {margin: 0 0 20px; color: #222;
background: #f7f6f7;}
section h1 {background: #222 none no-repeat 15px 15px;}
-#nnf_about {background: none; margin-top: 0;}
-
/* page list */
section nav {position: relative; height: 40px; overflow: hidden; padding: 0 1px;
font-family: Calibri, "Liberation Sans", Tahoma, sans-serif; line-height: 40px;
@@ -189,6 +189,7 @@ ol.ui li img {position: absolute; margin-left: -20px; margin-top: 2px;}
article {padding: 0 20px 19px; border: 1px solid #444;
/* surreal, surreal IE6 bug. *without* a bottom-border, the layout goes out of sync */
border-width: 0 1px 1px;}
+article p {padding: 20px 0 0 0;}
/* close the border within the 20px rhythm on the initial post */
#nnf_post article {padding-bottom: 19px !important; border-bottom-width: 1px;}
@@ -324,9 +325,6 @@ input[type=text],
/* site footer
====================================================================================================================== */
-#mods {margin: 0 auto; overflow: hidden;}
-#mods p {color: #888;}
-
#nnf_admin {float: right;}
a#nnf_lock, a#nnf_unlock {margin-left: 20px; padding-left: 25px; text-transform: uppercase;}
/* lock / unlock icons courtesy of <picol.org>, under a Creative Commons Share-Alike 3.0 licence
@@ -334,7 +332,7 @@ a#nnf_lock, a#nnf_unlock {margin-left: 20px; padding-left: 25px; text-transform:
a#nnf_lock {background: url("img/security_closed_16.png") no-repeat 0 50%;}
a#nnf_unlock {background: url("img/security_open_16.png") no-repeat 0 50%;}
-footer {position: absolute; height: 60px; margin: 20px 0 0; padding: 0 0 20px; left: 0; right: 0;
+footer {position: absolute; height: 60px; margin: 0; padding: 20px 0 0; left: 0; right: 0;
width: 100%; /*< IE6, which doesn't fully understand 'left; right' */
background: #222;}
View
27 themes/greyscale/thread.html
@@ -32,12 +32,13 @@
--></form>
<nav>
- <form id="lang">
- <input type="submit" name="lang:en" value="en" />
- <input type="submit" name="lang:fr" value="fr" />
- <input type="submit" name="lang:it" value="it" />
- <input type="submit" name="lang:de" value="de" />
- <input type="submit" name="lang:es" value="es" />
+ <form id="nnf_lang" method="post">
+ <img src="/themes/greyscale/img/lang.png" width="20" height="20" alt="Language:" title="Language:" />
+ <select name="lang">
+ <option class="nnf_lang" value="en">English</option>
+ <option class="nnf_lang" value="x-pig-latin">Igpay Atinlay</option>
+ </select>
+ <input id="lang-set" type="image" src="/themes/greyscale/img/go.png" width="20" height="20" alt="Set Language" />
</form>
<ol id="index">
<li><a href="/">Index</a></li>
@@ -63,14 +64,14 @@ <h1 id="nnf_post-title">Thread Title</h1>
</article>
</section>
-<p id="links">
- <a id="nnf_rss" href="thread_title.rss">RSS</a>
+<p id="info">
<a id="nnf_reply" href="#nnf_reply-form">Reply</a>
-</p>
-
-<p id="rights" class="nnf_forum-locked">
- Only <a href="#mods">moderators or members</a> can reply to this thread.
- <a href="?signin">Sign-in</a> if you are a moderator or member in order to post.
+ <a id="nnf_rss" href="thread_title.rss">RSS</a>
+
+ <span class="nnf_forum-locked">
+ Only <a href="#mods">moderators or members</a> can reply to this thread.
+ <a href="?signin">Sign-in</a> if you are a moderator or member in order to post.
+ </span>
</p>
<section id="nnf_replies">
Please sign in to comment.
Something went wrong with that request. Please try again.