From: x2003bruneau Date: Thu, 1 Feb 2007 17:24:01 +0000 (+0000) Subject: UTF-8 fixes X-Git-Tag: xorg/0.9.14~307 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=493b6abebf3d6c35691f66fd1bfdc063efaab576;p=platal.git UTF-8 fixes -> 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 --- diff --git a/AUTHORS b/AUTHORS index 56067f4..ecb0cc2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,14 +1,14 @@ Polytechnique.org TEAM : Pierre Habouzit project manager - Jean Sébastien Bedo + Jean Sébastien Bedo Florent Bruneau Sophie Charbonnier Yann Chevalier Jean-Marc Coic Pascal Corpet Guillaume Gommard - Jeremy Lainé + Jeremy Lainé Raphael Marichez Vincent Palatin diff --git a/ChangeLog b/ChangeLog index 85a7cc1..c666141 100644 --- 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) * CAT: Florian El Ahdab (LeChat) - * FAL: Raphaël Marichez (Falco) + * FAL: Raphaël Marichez (Falco) * FRU: Florent Bruneau (Fruneau) - * JS : Jean Sébastien Bedo + * JS : Jean Sébastien Bedo * MC : Pierre Habouzit (MadCoder) * mYk: Aymeric Augustin (mYk) * OG : Olivier Guillaumin - * SHK: Jeremy Lainé (Sharky) + * SHK: Jeremy Lainé (Sharky) * VP : Vincent Palatin - * XdX: Alexandre Hô (XandreX) + * XdX: Alexandre Hô (XandreX) ================================================================================ -vim:et:ts=4:sw=4:tw=80: +vim:et:ts=4:sw=4:tw=80:enc=utf-8: diff --git a/classes/platalpage.php b/classes/platalpage.php index d517e62..c07f6c6 100644 --- a/classes/platalpage.php +++ b/classes/platalpage.php @@ -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); diff --git a/include/ical.inc.php b/include/ical.inc.php index fbc878e..792e860 100644 --- a/include/ical.inc.php +++ b/include/ical.inc.php @@ -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"; diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index b4d43f8..02e5248 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -241,7 +241,7 @@ class NLArticle public function toHtml() { - $title = "

".htmlentities($this->title()).'

'; + $title = "

".pl_entities($this->title()).'

'; $body = enriched_to_text($this->_body,true); $app = enriched_to_text($this->_append,true); diff --git a/include/platal.inc.php b/include/platal.inc.php index a130ac1..ae1a15c 100644 --- a/include/platal.inc.php +++ b/include/platal.inc.php @@ -76,7 +76,7 @@ function pl_error_handler($errno, $errstr, $errfile, $errline) } } - $errstr = htmlentities($errstr); + $errstr = utf8_encode(htmlentities($errstr)); $GLOBALS['pl_errors'][] = "
". "{$errortype[$errno]} $errstr
". @@ -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: ?> diff --git a/include/vcard.inc.php b/include/vcard.inc.php index 555e267..01ec339 100644 --- a/include/vcard.inc.php +++ b/include/vcard.inc.php @@ -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"); } } diff --git a/modules/auth.php b/modules/auth.php index 1667903..20098cb 100644 --- a/modules/auth.php +++ b/modules/auth.php @@ -78,7 +78,7 @@ class AuthModule extends PLModule WHERE $where ORDER BY nom"); - $res = "\n\n\n\n"; + $res = "\n\n\n\n"; while (list ($prenom1,$nom1,$email1) = $all->next()) { $res .= "\n"; @@ -90,7 +90,7 @@ class AuthModule extends PLModule $res .= "\n\n"; - header('Content-Type: text/xml; charset="ISO-8859-1"'); + header('Content-Type: text/xml; charset="UTF-8"'); echo $res; } exit; diff --git a/modules/events.php b/modules/events.php index 67a7961..3881aa0 100644 --- a/modules/events.php +++ b/modules/events.php @@ -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)); } diff --git a/modules/lists.php b/modules/lists.php index f35f4c6..0b454a6 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -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')) { diff --git a/modules/lists/lists.inc.php b/modules/lists/lists.inc.php index a6d978c..f126022 100644 --- a/modules/lists/lists.inc.php +++ b/modules/lists/lists.inc.php @@ -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); } diff --git a/modules/platal.php b/modules/platal.php index 0abd992..34985f4 100644 --- a/modules/platal.php +++ b/modules/platal.php @@ -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); diff --git a/modules/search.php b/modules/search.php index fd61899..b960b69 100644 --- a/modules/search.php +++ b/modules/search.php @@ -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); diff --git a/modules/xnetevents.php b/modules/xnetevents.php index 269f5a2..ff366b2 100644 --- a/modules/xnetevents.php +++ b/modules/xnetevents.php @@ -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: '); diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 27e7acc..3c2f74b 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -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'"; diff --git a/plugins/compiler.icon.php b/plugins/compiler.icon.php index 1dda8aa..330ac2a 100644 --- a/plugins/compiler.icon.php +++ b/plugins/compiler.icon.php @@ -18,16 +18,17 @@ * 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; diff --git a/plugins/function.select_db_table.php b/plugins/function.select_db_table.php index 9da1fdd..7c598e8 100644 --- a/plugins/function.select_db_table.php +++ b/plugins/function.select_db_table.php @@ -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 .= ''; } - $html .= ''; + $html .= ''; $optgrp = $my_grp; } $html .= sprintf("\n", diff --git a/templates/axletter/letter.tpl b/templates/axletter/letter.tpl index 92d52c1..92d712b 100644 --- a/templates/axletter/letter.tpl +++ b/templates/axletter/letter.tpl @@ -51,7 +51,7 @@ ne plus recevoir : [https://www.polytechnique.org/ax/out{if $hash}/{$hash}{/if}] {/if} {else} {if $is_mail} - + diff --git a/templates/newsletter/nl.tpl b/templates/newsletter/nl.tpl index cd80156..e1e496f 100644 --- a/templates/newsletter/nl.tpl +++ b/templates/newsletter/nl.tpl @@ -69,7 +69,7 @@ ne plus recevoir : [https://www.polytechnique.org/nl/out] {/if} {else} {if $is_mail} - + diff --git a/templates/xnet/skin.tpl b/templates/xnet/skin.tpl index 37a4c28..0a7a655 100644 --- a/templates/xnet/skin.tpl +++ b/templates/xnet/skin.tpl @@ -19,12 +19,12 @@ {* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} {* *} {**************************************************************************} - + - +