Merge branch 'master' into 'master'

adaptation Windows + Correction bugs

- Adaptations du code pour fonctionner sur Windows (bascule entre langages notamment qui ne fonctionnait pas chez moi)
- corrections de petits bugs (affichage de warning, encodage UTF-8)

See merge request !14
This commit is contained in:
JosephK 2014-11-18 16:43:37 +01:00
commit a1cdbf4e73
5 changed files with 49 additions and 40 deletions

View File

@ -79,11 +79,13 @@ $dsondage=$sondage->FetchObject(false);
// Send email (only once during the session) to alert admin of the change he made. ==> two modifications (comment, title, description, ...) on differents polls in the same session will generate only one mail.
$email_admin = $dsondage->mail_admin;
$poll_title = $dsondage->titre;
$smtp_allowed = $config['use_smtp'];
function send_mail_admin() {
global $email_admin;
global $poll_title;
global $numsondageadmin;
if($config['use_smtp']==true){
global $smtp_allowed;
if($smtp_allowed==true){
if(!isset($_SESSION["mail_admin_sent"])) {
Utils::sendEmail( $email_admin,
_("[ADMINISTRATOR] New settings for your poll") . ' ' . stripslashes( $poll_title ),
@ -836,45 +838,43 @@ if (substr($dsondage->format, 0, 1)=="D") {
for ($i = 0; $i < count($toutsujet); $i++) {
// Current date
$current = $toutsujet[$i];
$current = $toutsujet[$i];//format date@hour. ex : 2020292820@10:00
$horoCur = explode("@",$current); //horoCur[0] = date, horoCur[1] = hour
if (isset($toutsujet[$i+1])){
$next = $toutsujet[$i+1];
$horoNext = explode("@",$next);
}
$border[$i] = false;
$radio_title[$i] = strftime($date_format['txt_short'],$current);
$radio_title[$i] = strftime($date_format['txt_short'],$horoCur[0]);
// Months
$td_headers[$i] = 'M'.($i+1-$colspan_month);
if (isset($toutsujet[$i+1]) && strftime("%B", $current) == strftime("%B", $toutsujet[$i+1]) && strftime("%Y", $current) == strftime("%Y", $toutsujet[$i+1])){
if (isset($toutsujet[$i+1]) && strftime("%B", $horoCur[0]) == strftime("%B", $horoNext[0]) && strftime("%Y", $horoCur[0]) == strftime("%Y", $horoNext[0])){
$colspan_month++;
} else {
$border[$i] = true;
$tr_months .= '<th colspan="'.$colspan_month.'" class="bg-primary month" id="M'.($i+1-$colspan_month).'">'.strftime("%B",$current).' '.strftime("%Y", $current).'</th>';
$tr_months .= '<th colspan="'.$colspan_month.'" class="bg-primary month" id="M'.($i+1-$colspan_month).'">'.strftime("%B",$horoCur[0]).' '.strftime("%Y", $horoCur[0]).'</th>';
$colspan_month=1;
}
// Days
$td_headers[$i] .= ' D'.($i+1-$colspan_day);
if (isset($toutsujet[$i+1]) && strftime($date_format['txt_day'],$current)==strftime($date_format['txt_day'],$toutsujet[$i+1]) && strftime("%B",$current)==strftime("%B",$toutsujet[$i+1])){
if (isset($toutsujet[$i+1]) && strftime($date_format['txt_day'],$horoCur[0])==strftime($date_format['txt_day'],$horoNext[0]) && strftime("%B",$horoCur[0])==strftime("%B",$horoNext[0])){
$colspan_day++;
} else {
$rbd = ($border[$i]) ? ' rbd' : '';
$tr_days .= '<th colspan="'.$colspan_day.'" class="bg-primary day'.$rbd.'" id="D'.($i+1-$colspan_day).'">'.strftime($date_format['txt_day'],$current).'</th>';
$tr_days .= '<th colspan="'.$colspan_day.'" class="bg-primary day'.$rbd.'" id="D'.($i+1-$colspan_day).'">'.strftime($date_format['txt_day'],$horoCur[0]).'</th>';
$colspan_day=1;
}
// Hours
$rbd = ($border[$i]) ? ' rbd' : '';
if (strpos($current,'@') !== false) {
$hour = substr($current, strpos($current, '@')-count($current)+2);
if ($hour != "") {
$tr_hours .= '<th class="bg-info'.$rbd.'" id="H'.$i.'" title="'.$hour.'">'.$hour.'</th>';
$radio_title[$i] .= ' - '.$hour;
if ($horoCur[1] !== "") {
$tr_hours .= '<th class="bg-info'.$rbd.'" id="H'.$i.'" title="'.$horoCur[1].'">'.$horoCur[1].'</th>';
$radio_title[$i] .= ' - '.$horoCur[1];
$td_headers[$i] .= ' H'.$i;
} else {
$tr_hours .= '<th class="bg-info'.$rbd.'"></th>';
}
} else {
$tr_hours .= '<th class="bg-info'.$rbd.'"></th>';
}

View File

@ -36,8 +36,18 @@ if (isset($_POST['lang']) && is_string($_POST['lang']) && in_array($_POST['lang'
}
$locale = $mlocale . '.utf8';
putenv('LANGUAGE=');
$locale = $mlocale . '.utf8';//unix format
if (strtoupper(substr(PHP_OS,0,3))=='WIN'){
putenv("LC_ALL=$mlocale"); //Windows env. needed to switch between languages
switch ($mlocale){
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 'de_DE' : $locale = "deu";break;
case 'es_ES' : $locale = "esp";break;
}
}
putenv('LANGUAGE=');//sert à quoi?
setlocale(LC_ALL, $locale);
setlocale(LC_TIME, $locale);
setlocale(LC_MESSAGES, $locale);
@ -48,7 +58,7 @@ bind_textdomain_codeset($domain, 'UTF-8');
textdomain($domain);
/* temp, for compatibility :*/
$a = explode('_', $locale);
$a = explode('_', $mlocale);
$_SESSION['langue'] = strtoupper($a[0]);
/* <html lang="$lang"> */

View File

@ -94,7 +94,7 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp
// Expiration date is initialised with config parameter. Value will be modified in step 4 if user has defined an other date
$_SESSION["champdatefin"]= time()+ (86400 * $config['default_poll_duration']); //60 sec * 60 min * 24 hours * config
$removal_date= strftime($date_format['txt_full'], ($_SESSION["champdatefin"]));//textual date
$removal_date= utf8_encode(strftime($date_format['txt_full'], ($_SESSION["champdatefin"])));//textual date
// Summary
$summary = '<ol>';

View File

@ -29,7 +29,7 @@ if (is_readable('bandeaux_local.php')) {
}
// Step 1/3 : error if $_SESSION from info_sondage are not valid
if (!Utils::issetAndNoEmpty('nom', $_SESSION) && !Utils::issetAndNoEmpty('adresse', $_SESSION) && !Utils::issetAndNoEmpty('commentaires', $_SESSION) && !Utils::issetAndNoEmpty('mail', $_SESSION)) {
if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmpty('nom', $_SESSION) === false || (($config['use_smtp']) ? Utils::issetAndNoEmpty('adresse', $_SESSION) === false : false)) {
Utils::print_header ( _("Error!") );
bandeau_titre(_("Error!"));
@ -124,7 +124,7 @@ if (!Utils::issetAndNoEmpty('nom', $_SESSION) && !Utils::issetAndNoEmpty('adress
$temp_array = array_unique($_SESSION["totalchoixjour"]);
sort($temp_array);
$removal_date=strftime($date_format['txt_full'], end($temp_array)+ (86400 * $config['default_poll_duration']));
$removal_date=utf8_encode(strftime($date_format['txt_full'], end($temp_array)+ (86400 * $config['default_poll_duration'])));
// Sumary
$summary = '<ul>';
@ -213,8 +213,8 @@ if (!Utils::issetAndNoEmpty('nom', $_SESSION) && !Utils::issetAndNoEmpty('adress
</legend>'."\n";
// Fields hours : 3 by default
for ($j=0;$j<max(count($_SESSION['horaires'.$i]),3);$j++) {
$hour_value = isset($_SESSION['horaires'.$i][$j]) ? $_SESSION['horaires'.$i][$j] : '';
for ($j=0;$j<max(count(isset($_SESSION["horaires".$i]) ? $_SESSION["horaires".$i] : 0),3);$j++) {
$hour_value = isset($_SESSION["horaires".$i][$j]) ? $_SESSION["horaires".$i][$j] : '';
echo '
<div class="col-sm-2">
<label for="d'.$i.'-h'.$j.'" class="sr-only control-label">'. _("Time") .' '. ($j+1) .'</label>

View File

@ -333,44 +333,43 @@ if ($dsondage->format=="D"||$dsondage->format=="D+"||$dsondage->format=="D-") {
// Current date
$current = $toutsujet[$i];
$horoCur = explode("@",$current); //horoCur[0] = date, horoCur[1] = hour
if (isset($toutsujet[$i+1])){
$next = $toutsujet[$i+1];
$horoNext = explode("@",$next);
}
$border[$i] = false;
$radio_title[$i] = strftime($date_format['txt_short'],$current);
$radio_title[$i] = strftime($date_format['txt_short'],$horoCur[0]);
// Months
$td_headers[$i] = 'M'.($i+1-$colspan_month);
if (isset($toutsujet[$i+1]) && strftime("%B", $current) == strftime("%B", $toutsujet[$i+1]) && strftime("%Y", $current) == strftime("%Y", $toutsujet[$i+1])){
if (isset($toutsujet[$i+1]) && strftime("%B", $horoCur[0]) == strftime("%B", $horoNext[0]) && strftime("%Y", $horoCur[0]) == strftime("%Y", $horoNext[0])){
$colspan_month++;
} else {
$border[$i] = true;
$tr_months .= '<th colspan="'.$colspan_month.'" class="bg-primary month" id="M'.($i+1-$colspan_month).'">'.strftime("%B",$current).' '.strftime("%Y", $current).'</th>';
$tr_months .= '<th colspan="'.$colspan_month.'" class="bg-primary month" id="M'.($i+1-$colspan_month).'">'.strftime("%B",$horoCur[0]).' '.strftime("%Y", $horoCur[0]).'</th>';
$colspan_month=1;
}
// Days
$td_headers[$i] .= ' D'.($i+1-$colspan_day);
if (isset($toutsujet[$i+1]) && strftime($date_format['txt_day'],$current)==strftime($date_format['txt_day'],$toutsujet[$i+1])&&strftime("%B",$current)==strftime("%B",$toutsujet[$i+1])){
if (isset($toutsujet[$i+1]) && strftime($date_format['txt_day'],$horoCur[0])==strftime($date_format['txt_day'],$horoNext[0])&&strftime("%B",$horoCur[0])==strftime("%B",$horoNext[0])){
$colspan_day++;
} else {
$rbd = ($border[$i]) ? ' rbd' : '';
$tr_days .= '<th colspan="'.$colspan_day.'" class="bg-primary day'.$rbd.'" id="D'.($i+1-$colspan_day).'">'.strftime($date_format['txt_day'],$current).'</th>';
$tr_days .= '<th colspan="'.$colspan_day.'" class="bg-primary day'.$rbd.'" id="D'.($i+1-$colspan_day).'">'.strftime($date_format['txt_day'],$horoCur[0]).'</th>';
$colspan_day=1;
}
// Hours
$rbd = ($border[$i]) ? ' rbd' : '';
if (strpos($current,'@') !== false) {
$hour = substr($current, strpos($current, '@')-count($current)+2);
if ($hour != "") {
$tr_hours .= '<th class="bg-info'.$rbd.'" id="H'.$i.'" title="'.$hour.'">'.$hour.'</th>';
$radio_title[$i] .= ' - '.$hour;
if ($horoCur[1] !== "") {
$tr_hours .= '<th class="bg-info'.$rbd.'" id="H'.$i.'" title="'.$horoCur[1].'">'.$horoCur[1].'</th>';
$radio_title[$i] .= ' - '.$horoCur[1];
$td_headers[$i] .= ' H'.$i;
} else {
$tr_hours .= '<th class="bg-info'.$rbd.'"></th>';
}
} else {
$tr_hours .= '<th class="bg-info'.$rbd.'"></th>';
}
@ -473,7 +472,7 @@ echo'
$user_mod = false;
//affichage des resultats actuels
$somme = array();
$somme[] = 0;
$compteur = 0;
while ($data = $user_studs->FetchNextObject(false)) {