Fix the selected item on langs selection

This commit is contained in:
Olivier PEREZ 2015-01-02 00:19:56 +01:00
parent a8345cf7f8
commit ca365ff348
4 changed files with 24 additions and 25 deletions

View File

@ -38,13 +38,13 @@ if (isset($_POST['lang']) && is_string($_POST['lang']) && in_array($_POST['lang'
$locale = $mlocale . '.utf8';//unix format $locale = $mlocale . '.utf8';//unix format
if (strtoupper(substr(PHP_OS,0,3))=='WIN'){ if (strtoupper(substr(PHP_OS,0,3))=='WIN'){
putenv("LC_ALL=$mlocale"); //Windows env. needed to switch between languages putenv("LC_ALL=$mlocale"); //Windows env. needed to switch between languages
switch ($mlocale){ switch ($mlocale){
case 'fr_FR' : $locale = "fra";break; //$locale in windows locale format, needed to use php function that handle text : strftime() case 'fr_FR' : $locale = "fra";break; //$locale in windows locale format, needed to use php function that handle text : strftime()
case 'en_GB' : $locale = "english";break; //see http://msdn.microsoft.com/en-us/library/39cwe7zf%28v=vs.90%29.aspx case 'en_GB' : $locale = "english";break; //see http://msdn.microsoft.com/en-us/library/39cwe7zf%28v=vs.90%29.aspx
case 'de_DE' : $locale = "deu";break; case 'de_DE' : $locale = "deu";break;
case 'es_ES' : $locale = "esp";break; case 'es_ES' : $locale = "esp";break;
} }
} }
putenv('LANGUAGE=');//sert à quoi? putenv('LANGUAGE=');//sert à quoi?
@ -66,14 +66,12 @@ $lang = ($_SESSION['langue']!='') ? strtolower($_SESSION['langue']) : 'fr';
/* Date Format */ /* Date Format */
$date_format['txt_full'] = _("%A, den %e. %B %Y"); //summary in choix_date.php and removal date in choix_(date|autre).php $date_format['txt_full'] = _('%A, den %e. %B %Y'); //summary in choix_date.php and removal date in choix_(date|autre).php
$date_format['txt_short'] = "%A %e %B %Y"; // radio title $date_format['txt_short'] = _('%A %e %B %Y'); // radio title
$date_format['txt_day'] = "%a %e"; $date_format['txt_day'] = _('%a %e');
$date_format['txt_date'] = _("%Y-%m-%d"); $date_format['txt_date'] = _('%Y-%m-%d');
if (strtoupper(substr(PHP_OS,0,3))=='WIN'){ //%e can't be used on Windows platform, use %#d instead if (strtoupper(substr(PHP_OS,0,3))=='WIN'){ //%e can't be used on Windows platform, use %#d instead
foreach($date_format as $k => $v) { foreach($date_format as $k => $v) {
$date_format[$k] = preg_replace('#(?<!%)((?:%%)*)%e#','\1%#d', $v); //replace %e by %#d for windows $date_format[$k] = preg_replace('#(?<!%)((?:%%)*)%e#','\1%#d', $v); //replace %e by %#d for windows
} }
} }

View File

@ -19,21 +19,26 @@
use Framadate\FramaDB; use Framadate\FramaDB;
use Framadate\Utils; use Framadate\Utils;
if (session_id() == '') {
session_start();
}
if (ini_get('date.timezone') == '') { if (ini_get('date.timezone') == '') {
date_default_timezone_set('Europe/Paris'); date_default_timezone_set('Europe/Paris');
} }
include_once __DIR__ . '/constants.php'; include_once __DIR__ . '/constants.php';
include_once __DIR__ . '/i18n.php';
// Autoloading of dependencies with Composer // Autoloading of dependencies with Composer
require_once __DIR__ . '/../../vendor/autoload.php'; require_once __DIR__ . '/../../vendor/autoload.php';
include_once __DIR__ . '/i18n.php';
// Smarty // Smarty
require_once __DIR__ . '/../../vendor/smarty/smarty/libs/Smarty.class.php'; require_once __DIR__ . '/../../vendor/smarty/smarty/libs/Smarty.class.php';
$smarty = new \Smarty(); $smarty = new \Smarty();
$smarty->template_dir = 'tpl/'; $smarty->setTemplateDir('tpl/');
$smarty->compile_dir = 'tpl_c/'; $smarty->setCompileDir('tpl_c/');
$smarty->cache_dir = 'cache/'; $smarty->setCacheDir('cache/');
$smarty->caching = false; $smarty->caching = false;
$smarty->assign('APPLICATION_NAME', NOMAPPLICATION); $smarty->assign('APPLICATION_NAME', NOMAPPLICATION);
@ -48,9 +53,5 @@ function smarty_modifier_poll_url($poll_id, $admin=false){return Utils::getUrlSo
function smarty_modifier_markdown($md) {return Utils::markdown($md);} function smarty_modifier_markdown($md) {return Utils::markdown($md);}
// End- Smarty // End- Smarty
if (session_id() == '') {
session_start();
}
$connect = new FramaDB(DB_CONNECTION_STRING, DB_USER, DB_PASSWORD); $connect = new FramaDB(DB_CONNECTION_STRING, DB_USER, DB_PASSWORD);
$err = 0; $err = 0;

View File

@ -28,7 +28,7 @@ function bandeau_titre($titre)
echo ' echo '
<header role="banner">'; <header role="banner">';
if(count($ALLOWED_LANGUAGES)>1){ if(count($ALLOWED_LANGUAGES)>1){
echo '<form method="post" action="#"> echo '<form method="post" action="">
<div class="input-group input-group-sm pull-right col-md-2 col-xs-4"> <div class="input-group input-group-sm pull-right col-md-2 col-xs-4">
<select name="lang" class="form-control" title="'. _("Select the language") .'" >' . liste_lang() . '</select> <select name="lang" class="form-control" title="'. _("Select the language") .'" >' . liste_lang() . '</select>
<span class="input-group-btn"> <span class="input-group-btn">

View File

@ -1,10 +1,10 @@
<header role="banner"> <header role="banner">
{if count($langs)>1} {if count($langs)>1}
<form method="post" action="#"> <form method="post" action="">
<div class="input-group input-group-sm pull-right col-md-2 col-xs-4"> <div class="input-group input-group-sm pull-right col-md-2 col-xs-4">
<select name="lang" class="form-control" title="${_("Select the language")}" > <select name="lang" class="form-control" title="${_("Select the language")}" >
{foreach $langs as $lang_key=>$lang_value} {foreach $langs as $lang_key=>$lang_value}
<option lang="{$lang_key|truncate:2:''}" selected value="{$lang_key}">{$lang_value}</option> <option lang="{substr($lang_key, 0, 2)}" {if substr($lang_key, 0, 2)==$lang}selected{/if} value="{$lang_key}">{$lang_value}</option>
{/foreach} {/foreach}
</select> </select>
<span class="input-group-btn"> <span class="input-group-btn">