UTF-8 fixes
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Thu, 1 Feb 2007 17:24:01 +0000 (17:24 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Thu, 1 Feb 2007 17:24:01 +0000 (17:24 +0000)
-> add pl_entities and pl_entity_decode (same as htmlentities with UTF-8 support by default)

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

20 files changed:
AUTHORS
ChangeLog
classes/platalpage.php
include/ical.inc.php
include/newsletter.inc.php
include/platal.inc.php
include/vcard.inc.php
modules/auth.php
modules/events.php
modules/lists.php
modules/lists/lists.inc.php
modules/platal.php
modules/search.php
modules/xnetevents.php
modules/xnetgrp.php
plugins/compiler.icon.php
plugins/function.select_db_table.php
templates/axletter/letter.tpl
templates/newsletter/nl.tpl
templates/xnet/skin.tpl

diff --git a/AUTHORS b/AUTHORS
index 56067f4..ecb0cc2 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,14 +1,14 @@
 Polytechnique.org TEAM :
 
     Pierre Habouzit         <pierre.habouzit@m4x.org>       project manager
-    Jean Sébastien Bedo     <jean-sebastien.bedo@m4x.org>
+    Jean Sébastien Bedo     <jean-sebastien.bedo@m4x.org>
     Florent Bruneau         <florent.bruneau@m4x.org>
     Sophie Charbonnier      <sophie.charbonnier@m4x.org>
     Yann Chevalier          <yann.chevalier@m4x.org>
     Jean-Marc Coic          <jean-marc.coic@m4x.org>
     Pascal Corpet           <pascal.corpet@m4x.org>
     Guillaume Gommard       <guillaume.gommard@m4x.org>
-    Jeremy Lainé            <jeremy.laine@m4x.org>
+    Jeremy Lainé            <jeremy.laine@m4x.org>
     Raphael Marichez        <raphael.marichez@m4x.org>
     Vincent Palatin         <vincent.palatin@m4x.org>
 
index 85a7cc1..c666141 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -137,7 +137,7 @@ Bug/Wish:
         - #484: Sort Table Editor by clicking on column title.             -Car
 
     * Core:
-        - #473: Use 'événement' instead of 'évènement'.                    -FRU
+        - #473: Use 'événement' instead of 'évènement'.                    -FRU
         - #475: More understandable bug report form.                       -FRU
         - #545: Fix encoding issues with some Windows special chars        -FRU
         - #548: More informations for recovery for homonyms.               -FRU
@@ -932,15 +932,15 @@ ACRONYMS:
 
     * Car: Pascal Corpet        (Caribou)   <pascal.corpet@m4x.org>
     * CAT: Florian El Ahdab     (LeChat)    <florian.el-ahdab@m4x.org>
-    * FAL: Raphaël Marichez     (Falco)     <raphael.marichez@m4x.org>
+    * FAL: Raphaël Marichez     (Falco)     <raphael.marichez@m4x.org>
     * FRU: Florent Bruneau      (Fruneau)   <florent.bruneau@m4x.org>
-    * JS : Jean Sébastien Bedo              <jean-sebastien.bedo@m4x.org>
+    * JS : Jean Sébastien Bedo              <jean-sebastien.bedo@m4x.org>
     * MC : Pierre Habouzit      (MadCoder)  <pierre.habouzit@m4x.org>
     * mYk: Aymeric Augustin     (mYk)       <aymeric.augustin@m4x.org>
     * OG : Olivier Guillaumin               <olivier.guillaumin@m4x.org>
-    * SHK: Jeremy Lainé         (Sharky)    <jeremy.laine@m4x.org>
+    * SHK: Jeremy Lainé         (Sharky)    <jeremy.laine@m4x.org>
     * VP : Vincent Palatin                  <vincent.palatin@m4x.org>
-    * XdX: Alexandre Hô         (XandreX)   <alexandre.ho@m4x.org>
+    * XdX: Alexandre Hô         (XandreX)   <alexandre.ho@m4x.org>
 
 ================================================================================
-vim:et:ts=4:sw=4:tw=80:
+vim:et:ts=4:sw=4:tw=80:enc=utf-8:
index d517e62..c07f6c6 100644 (file)
@@ -105,7 +105,7 @@ class PlatalPage extends Smarty
         }
         $this->register_outputfilter('hide_emails');
         $this->addJsLink('wiki.js');
-        header("Accept-Charset: iso-8859-15, latin9, us-ascii, ascii");
+        header("Accept-Charset: utf-8");
 
         if (!$globals->debug) {
             error_reporting(0);
index fbc878e..792e860 100644 (file)
@@ -27,9 +27,7 @@ function display_ical($param) {
         $txt .= ';'.$param['param'];
     if (isset($param['value'])) {
         if ($txt) $txt .= ':';
-        $txt .= utf8_encode(
-                    preg_replace('/[,;:]/', '\\\\$0',
-                    preg_replace("/(\r\n|\r|\n)/", '\n', $param['value'])));
+        $txt .= preg_replace('/[,;:]/', '\\\\$0', preg_replace("/(\r\n|\r|\n)/", '\n', $param['value']));
     }
     $length = strlen($txt);
     $endline = "\n";
index b4d43f8..02e5248 100644 (file)
@@ -241,7 +241,7 @@ class NLArticle
 
     public function toHtml()
     {
-        $title = "<h2 class='xorg_nl'><a id='art{$this->_aid}'></a>".htmlentities($this->title()).'</h2>';
+        $title = "<h2 class='xorg_nl'><a id='art{$this->_aid}'></a>".pl_entities($this->title()).'</h2>';
         $body  = enriched_to_text($this->_body,true);
         $app   = enriched_to_text($this->_append,true);
     
index a130ac1..ae1a15c 100644 (file)
@@ -76,7 +76,7 @@ function pl_error_handler($errno, $errstr, $errfile, $errline)
         }
     }
 
-    $errstr = htmlentities($errstr);
+    $errstr = utf8_encode(htmlentities($errstr));
     $GLOBALS['pl_errors'][] =
         "<div class='phperror'>".
         "<strong>{$errortype[$errno]}</strong> <em>$errstr</em><br />".
@@ -131,5 +131,15 @@ function pl_redirect($path, $query = null, $fragment = null)
     http_redirect($globals->baseurl . '/' . pl_url($path, $query, $fragment));
 }
 
+function pl_entities($text, $mode = ENT_COMPAT)
+{
+    return htmlentities($text, $mode, 'UTF-8');
+}
+
+function pl_entity_decode($text, $mode = ENT_COMPAT)
+{
+    return html_entity_decode($text, $mode, 'UTF-8');
+}
+
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 555e267..01ec339 100644 (file)
@@ -126,7 +126,7 @@ class VCard
 
         header("Pragma: ");
         header("Cache-Control: ");
-        header("Content-type: text/x-vcard; charset=iso-8859-15");
+        header("Content-type: text/x-vcard; charset=UTF-8");
         header("Content-Transfer-Encoding: 8bit");
     }
 }
index 1667903..20098cb 100644 (file)
@@ -78,7 +78,7 @@ class AuthModule extends PLModule
                       WHERE  $where
                    ORDER BY  nom");
 
-            $res = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n<membres>\n\n";
+            $res = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<membres>\n\n";
 
             while (list ($prenom1,$nom1,$email1) = $all->next()) {
                     $res .= "<membre>\n";
@@ -90,7 +90,7 @@ class AuthModule extends PLModule
 
             $res .= "</membres>\n\n";
 
-            header('Content-Type: text/xml; charset="ISO-8859-1"');
+            header('Content-Type: text/xml; charset="UTF-8"');
             echo $res;
         }
         exit;
index 67a7961..3881aa0 100644 (file)
@@ -230,7 +230,7 @@ class EventsModule extends PLModule
 
     function handler_tips(&$page, $tips = null)
     {
-        header('Content-Type: text/html; charset="ISO-8859-15"');
+        header('Content-Type: text/html; charset="UTF-8"');
         $page->changeTpl('include/tips.tpl', NO_SKIN);
         $page->assign('tips', $this->get_tips($tips));
     }
index f35f4c6..0b454a6 100644 (file)
@@ -114,7 +114,7 @@ class ListsModule extends PLModule
 
     function handler_ajax(&$page, $list = null)
     {
-        header('Content-Type: text/html; charset="iso-8859-15"');
+        header('Content-Type: text/html; charset="UTF-8"');
         $domain = $this->prepare_client($page);
         $page->changeTpl('lists/liste.inc.tpl', NO_SKIN);
         if (Get::has('unsubscribe')) {
index a6d978c..f126022 100644 (file)
@@ -78,7 +78,7 @@ function list_sort_members(&$members, $tri_promo = true) {
 
 function _list_header_decode($charset, $c, $str) {
     $s = ($c == 'Q' || $c == 'q') ? quoted_printable_decode($str) : base64_decode($str);
-    $s = iconv($charset, 'iso-8859-15', $s);
+    $s = iconv($charset, 'UTF-8', $s);
     return str_replace('_', ' ', $s);
 }
 
index 0abd992..34985f4 100644 (file)
@@ -83,7 +83,7 @@ class PlatalModule extends PLModule
     {
         $page->changeTpl('platal/changeLog.tpl');
 
-        $clog = htmlentities(file_get_contents(dirname(__FILE__).'/../ChangeLog'));
+        $clog = pl_entities(file_get_contents(dirname(__FILE__).'/../ChangeLog'));
         $clog = preg_replace('!(#[0-9]+(,[0-9]+)*)!e', 'bugize("\1")', $clog);
         $clog = preg_replace('!vim:.*$!', '', $clog);
         $page->assign('ChangeLog', $clog);
index fd61899..b960b69 100644 (file)
@@ -252,7 +252,7 @@ class SearchModule extends PLModule
 
     function handler_region(&$page, $country = null)
     {
-        header('Content-Type: text/html; charset="iso-8859-15"');
+        header('Content-Type: text/html; charset="UTF-8"');
         require_once("geoloc.inc.php");
         $page->ChangeTpl('search/adv.region.form.tpl', NO_SKIN);
         $page->assign('region', "");
@@ -261,7 +261,7 @@ class SearchModule extends PLModule
 
     function handler_grade(&$page, $school = null)
     {
-        header('Content-Type: text/html; charset="iso-8859-15"');
+        header('Content-Type: text/html; charset="UTF-8"');
         $page->ChangeTpl('search/adv.grade.form.tpl', NO_SKIN);
         $page->assign('grade', '');
         $this->get_diplomas($school);
index 269f5a2..ff366b2 100644 (file)
@@ -266,7 +266,7 @@ class XnetEventsModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        header('Content-type: text/x-csv; encoding=iso-8859-1');
+        header('Content-type: text/x-csv; encoding=UTF-8');
         header('Pragma: ');
         header('Cache-Control: ');
 
index 27e7acc..3c2f74b 100644 (file)
@@ -717,7 +717,7 @@ class XnetGrpModule extends PLModule
 
     function handler_admin_member_new_ajax(&$page)
     {
-        header('Content-Type: text/html; charset="iso-8859-15"');
+        header('Content-Type: text/html; charset="UTF-8"');
         $page->changeTpl('xnetgrp/membres-new-search.tpl', NO_SKIN);
         list($nom, $prenom) = str_replace(array('-', ' ', "'"), '%', array(Env::v('nom'), Env::v('prenom')));
         $where = "perms = 'pending'";
index 1dda8aa..330ac2a 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
+require_once 'platal.inc.php';
 
 function smarty_compiler_icon($tag_attrs, &$compiler)
 {
     extract($compiler->_parse_attrs($tag_attrs));
 
     if (isset($title)) {
-        $title = 'title="'.htmlentities(trim($title, '\'"'), ENT_QUOTES).'" ';
+        $title = 'title="'. pl_entities(trim($title, '\'"'), ENT_QUOTES).'" ';
     }
 
-    $name = htmlentities(trim($name, '\'"'), ENT_QUOTES);
+    $name = pl_entities(trim($name, '\'"'), ENT_QUOTES);
     $name = "images/icons/$name.gif";
     if ($full) {
         global $globals;
index 9da1fdd..7c598e8 100644 (file)
@@ -19,6 +19,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
+require_once 'platal.inc.php';
 
 function select_options($table,$valeur,$champ="text",$pad=false,
                         $where="",$join="",$group="")
@@ -44,7 +45,7 @@ function select_options($table,$valeur,$champ="text",$pad=false,
             if (!is_null($optgrp)) {
                 $html .= '</optgroup>';
             }
-            $html .= '<optgroup label="' . htmlentities($my_grp, ENT_QUOTES) . '">';
+            $html .= '<optgroup label="' . pl_entities($my_grp, ENT_QUOTES) . '">';
             $optgrp = $my_grp;
         }
         $html .= sprintf("<option value=\"%s\" %s>%s</option>\n", 
index 92d52c1..92d712b 100644 (file)
@@ -51,7 +51,7 @@ ne plus recevoir : [https://www.polytechnique.org/ax/out{if $hash}/{$hash}{/if}]
 {/if}
 {else}
 {if $is_mail}
-<?xml version="1.0" encoding="iso-8859-15"?>
+<?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"> 
   <head>  
index cd80156..e1e496f 100644 (file)
@@ -69,7 +69,7 @@ ne plus recevoir : [https://www.polytechnique.org/nl/out]
 {/if}
 {else}
 {if $is_mail}
-<?xml version="1.0" encoding="iso-8859-15"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"> 
   <head>  
index 37a4c28..0a7a655 100644 (file)
 {*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
 {*                                                                        *}
 {**************************************************************************}
-<?xml version="1.0" encoding="iso-8859-15"?>
+<?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <base href="{$globals->baseurl}/" />
-    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     <meta name="description" content="Les associations polytechniciennes" />
     <meta name="keywords" content="Ecole polytechnique, associations polytechniciennes, groupes X, binets" />