mirror of
https://github.com/ShaYmez/FreeSTAR-Status-Engine.git
synced 2024-11-23 12:48:39 -05:00
Add template doc, fixup rendering locale select
This commit is contained in:
parent
61f563c9b0
commit
5dd9a2a1bd
@ -14,12 +14,13 @@ class LocaleNegotiator
|
||||
*/
|
||||
function __construct($default_language)
|
||||
{
|
||||
$tmp = glob(__DIR__ . '/locale/*' , GLOB_ONLYDIR);
|
||||
$tmp = glob(__DIR__ . '/../locale/*' , GLOB_ONLYDIR);
|
||||
$this->default_language = $default_language;
|
||||
//Works only if the server supports the locale
|
||||
//This basically means $accepted_langs[<lang_code>] = "<lang name>";
|
||||
foreach ($accepted_langs as $key => $value) {
|
||||
$this->accepted_langs[basename($value)] = self::mb_ucfirst(locale_get_display_language($lang, $lang));
|
||||
foreach ($tmp as $key => $value) {
|
||||
$lang = basename($value);
|
||||
$this->accepted_langs[$lang] = self::mb_ucfirst(locale_get_display_language($lang, $lang));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,10 +11,11 @@ define("DEFAULT_LANGUAGE", "en_GB");
|
||||
|
||||
require("classes/locale-negotiator.php");
|
||||
|
||||
$negotiator = new LocaleNegotiator(DEFAULT_LANGUAGE);
|
||||
|
||||
if (!isset($_SESSION['locale'])||isset($_GET['lang']))
|
||||
{
|
||||
$override = ((isset($_GET['lang']))?$_GET['lang']:null);
|
||||
$negotiator = new LocaleNegotiator(DEFAULT_LANGUAGE);
|
||||
$best_match = $negotiator->negotiate($override);
|
||||
$_SESSION['locale'] = $best_match;
|
||||
setlocale(LC_ALL, $_SESSION['locale'].".UTF-8");
|
||||
|
17
template.php
17
template.php
@ -1,5 +1,13 @@
|
||||
<?php
|
||||
class Template(){
|
||||
/**
|
||||
* Class that encapsulates methods to render header and footer
|
||||
*/
|
||||
class Template{
|
||||
/**
|
||||
* Renders header
|
||||
* @param String $page_name name of the page to be displayed as title
|
||||
* @param Boolean $admin decides whether to show admin menu
|
||||
*/
|
||||
public static function render_header($page_name, $admin = false){
|
||||
if (!$admin)
|
||||
{
|
||||
@ -77,9 +85,14 @@ class Template(){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders footer
|
||||
* @param Boolean $admin decides whether to load admin scripts
|
||||
*/
|
||||
public static function render_footer($admin = false)
|
||||
{
|
||||
global $lang_names;
|
||||
global $negotiator;
|
||||
$lang_names = $negotiator->get_accepted_langs();
|
||||
?>
|
||||
</div>
|
||||
<div id="footerwrap">
|
||||
|
Loading…
Reference in New Issue
Block a user