Change locale to fr_FR.UTF-8
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Fri, 2 Feb 2007 14:15:22 +0000 (14:15 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Fri, 2 Feb 2007 14:15:22 +0000 (14:15 +0000)
Convert wiki to utf-8
Add scripts to:
-> convert wiki
-> convert the geoloc tables

git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1463 839d8a87-29fc-0310-9880-83ba4fa771e5

configs/platal.ini
include/wiki/farmconfig.php
plugins/modifier.date_format.php
upgrade/0.9.14/connect.db.inc.php [new symlink]
upgrade/0.9.14/geoloc.utf8.php [new file with mode: 0755]
upgrade/0.9.14/wiki.utf8.sh [new file with mode: 0644]

index e7c76c4..bfe0b10 100644 (file)
@@ -1,5 +1,5 @@
 [Core]
-locale   = "fr_FR"
+locale   = "fr_FR.UTF-8"
 timezone = "Europe/Paris"
 
 [Banana]
index 827029f..7c2a12c 100644 (file)
@@ -18,6 +18,7 @@ $InterMapFiles[]  = $globals->spoolroot.'/configs/pmwiki.intermap.txt';
 $Skin             = 'empty';
 
 @include_once("$FarmD/cookbook/e-protect.php");
+include_once($FarmD.'/scripts/xlpage-utf-8.php');
 
 // Theme-ing {{{
 
index 17469b0..8c22bcc 100644 (file)
@@ -36,11 +36,11 @@ function smarty_modifier_date_format($string, $format = '%x', $default_date=null
     }
 
     if ( $t != -1 ) {
-        return utf8_encode(strftime($f , $t));
+        return strftime($f , $t);
     } else {
         require_once('Date.php');
         $date = new Date($d);
-        return utf8_encode($date->format($f));
+        return $date->format($f);
     }
 }
 
diff --git a/upgrade/0.9.14/connect.db.inc.php b/upgrade/0.9.14/connect.db.inc.php
new file mode 120000 (symlink)
index 0000000..442fab7
--- /dev/null
@@ -0,0 +1 @@
+../../bin/connect.db.inc.php
\ No newline at end of file
diff --git a/upgrade/0.9.14/geoloc.utf8.php b/upgrade/0.9.14/geoloc.utf8.php
new file mode 100755 (executable)
index 0000000..6ec1649
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/php5
+<?php
+
+require_once 'connect.db.inc.php';
+
+function is_utf8($s)
+{
+    return @iconv('utf-8', 'utf-8', $s) == $s;
+}
+
+$tables = array ('city', 'city_in_maps', 'maps', 'pays', 'region');
+XDB::execute("SET NAMES 'latin1'");
+foreach ($tables as $table) {
+    $res = XDB::query("SELECT * FROM geoloc_$table");
+    if (!$res) {
+        echo "$table\n";
+        continue;
+    }
+    $all = $res->fetchAllAssoc();
+    foreach ($all as &$array) {
+        $from = array();
+        $to   = array();
+        foreach ($array as $key=>$value) {
+            $from[] = $key . '="' . mysql_real_escape_string($value) . '"';
+            $valued = utf8_decode($value);
+            if (is_utf8($value) && $valued != $value) {
+                $to[] = $key . '="' . mysql_real_escape_string($valued) .'"';
+            }
+        }
+        if (!empty($to)) {
+            $to = implode(', ', $to);
+            $from = implode(' AND ', $from);
+            $sql = "UPDATE geoloc_$table SET $to WHERE $from";
+            if (!XDB::execute($sql)) {
+                echo "Echec : $sql\n";
+            }
+        }
+    }
+}
+
+?>
diff --git a/upgrade/0.9.14/wiki.utf8.sh b/upgrade/0.9.14/wiki.utf8.sh
new file mode 100644 (file)
index 0000000..06a90d5
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+WIKISPOOLDIR='../../spool/wiki.d/'
+
+find $WIKISPOOLDIR -name 'cache_*' -or -name 'tmp_*' -exec rm {} ";"
+for i in `find $WIKISPOOLDIR -type f`; do
+    mv $i $i.latin1
+    iconv -t UTF-8 $i.latin1 > $i
+done
+
+echo "Les pages de wiki ont ete converites en UTF-8"
+echo "Verifie que tout c'est bien passe en presse ^D"
+cat
+
+find $WIKISPOOLDIR -name '*.latin1' -exec rm {} ";"