diff --git a/ecrire/inc/charsets.php b/ecrire/inc/charsets.php index 44272fc233d108f8473466efba6d43a2f51d3f75..2099f480d98b1ce74bd757612c06c8aaf88c2d31 100644 --- a/ecrire/inc/charsets.php +++ b/ecrire/inc/charsets.php @@ -489,6 +489,9 @@ function translitteration($texte, $charset='AUTO', $complexe='') { $table_translit ='translit'.$complexe; + // 0. Supprimer les caracteres illegaux + $texte = corriger_caracteres($texte); + // 1. Passer le charset et les é en utf-8 $texte = unicode_to_utf_8(html2unicode(charset2unicode($texte, $charset, true))); @@ -598,6 +601,35 @@ function transcoder_page($texte, $headers='') { return importer_charset($texte, $charset); } + +// +// Gerer les outils mb_string +// +function spip_substr($c, $start=0, $end='') { + if (init_mb_string()) { + if ($end) + return mb_substr($c, $start, $end); + else + return mb_substr($c, $start); + } + + // methode substr normale + else { + if ($end) + return substr($c, $start, $end); + else + return substr($c, $start); + } +} + +function spip_strlen($c) { + if (init_mb_string()) + return mb_strlen($c); + else + return strlen($c); +} + + // Initialisation $GLOBALS['CHARSET'] = Array(); diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php index 355cfee6f3e83d87a24e739f3cd784835b5639cb..31eb0440f21e6e6a420134d4afa490ec90a7f373 100644 --- a/ecrire/inc/filtres.php +++ b/ecrire/inc/filtres.php @@ -13,6 +13,8 @@ if (!defined("_ECRIRE_INC_VERSION")) return; +include_spip('inc/charsets'); + // Appliquer un filtre (eventuellement defini dans la matrice) aux donnees // et arguments function filtrer($filtre) { @@ -45,19 +47,13 @@ function entites_html($texte) { // Transformer les é dans le charset local function filtrer_entites($texte) { - include_spip('inc/charsets'); +# include_spip('inc/charsets'); // filtrer $texte = html2unicode($texte); // remettre le tout dans le charset cible return unicode2charset($texte); } -// Tout mettre en entites pour l'export backend (sauf iso-8859-1) -function entites_unicode($texte) { - include_spip('inc/charsets'); - return charset2unicode($texte); -} - // caracteres de controle - http://www.w3.org/TR/REC-xml/#charsets function supprimer_caracteres_illegaux($texte) { $from = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"; @@ -101,11 +97,6 @@ function corriger_caracteres ($texte) { return $texte; } -function translitterer_caracteres ($texte, $charset='AUTO', $complex='') { - include_spip('inc/charsets'); - return translitteration(corriger_caracteres($texte), $charset, $complexe); -} - // Encode du HTML pour transmission XML function texte_backend($texte) { @@ -126,7 +117,7 @@ function texte_backend($texte) { $texte = entites_html($texte); // verifier le charset - $texte = entites_unicode($texte); + $texte = charset2unicode($texte); // Caracteres problematiques en iso-latin 1 if ($GLOBALS['meta']['charset'] == 'iso-8859-1') { @@ -194,7 +185,7 @@ function PtoBR($texte){ function lignes_longues($texte, $l = 70) { // Passer en utf-8 pour ne pas avoir de coupes trop courtes avec les &#xxxx; // qui prennent 7 caracteres - include_spip('inc/charsets'); + #include_spip('inc/charsets'); $texte = unicode_to_utf_8(charset2unicode( $texte, $GLOBALS['meta']['charset'], true)); @@ -652,7 +643,7 @@ function style_align($bof) { // function filtrer_ical($texte) { - include_spip('inc/charsets'); + #include_spip('inc/charsets'); $texte = html2unicode($texte); $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8'); $texte = ereg_replace("\n", " ", $texte); @@ -2569,4 +2560,8 @@ function form_hidden($action) { return $hidden; } + +### fonction depreciee, laissee ici pour compat ascendante 1.9 +function entites_unicode($texte) { return charset2unicode($texte); } + ?> diff --git a/ecrire/inc/texte.php b/ecrire/inc/texte.php index 194f077577da500fa248a9429ec6e66ee5b44698..1cfa21a777dd38bde08cce4188074f508b0491b1 100644 --- a/ecrire/inc/texte.php +++ b/ecrire/inc/texte.php @@ -15,6 +15,8 @@ if (!defined("_ECRIRE_INC_VERSION")) return; include_spip('inc/filtres'); +include_spip('inc/charsets'); +include_spip('inc/lang'); // Verifier les variables de personnalisation tester_variable('debut_intertitre', "\n<h3 class=\"spip\">"); @@ -37,7 +39,7 @@ function definir_puce() { // Attention au sens, qui n'est pas defini de la meme facon dans // l'espace prive (spip_lang est la langue de l'interface, lang_dir // celle du texte) et public (spip_lang est la langue du texte) - include_spip('inc/lang'); + #include_spip('inc/lang'); $dir = _DIR_RESTREINT ? lang_dir($GLOBALS['spip_lang']) : $GLOBALS['lang_dir']; $p = ($dir == 'rtl') ? 'puce_rtl' : 'puce'; @@ -199,37 +201,6 @@ function echappe_retour($letexte, $source='') { } -// -// Gerer les outils mb_string -// -function spip_substr($c, $start=0, $end='') { - include_spip('inc/charsets'); - if (init_mb_string()) { - if ($end) - return mb_substr($c, $start, $end); - else - return mb_substr($c, $start); - } - - // methode substr normale - else { - if ($end) - return substr($c, $start, $end); - else - return substr($c, $start); - } -} - -function spip_strlen($c) { - include_spip('inc/charsets'); - if (init_mb_string()) - return mb_strlen($c); - else - return strlen($c); -} -// fin mb_string - - function couper($texte, $taille=50) { $texte = substr($texte, 0, 400 + 2*$taille); /* eviter de travailler sur 10ko pour extraire 150 caracteres */ @@ -386,7 +357,7 @@ function typo_fr($letexte) { ); $chars = array(160 => '~', 187 => '»', 171 => '«', 148 => '”', 147 => '“', 176 => '°'); - include_spip('inc/charsets'); + #include_spip('inc/charsets'); while (list($c, $r) = each($chars)) { $c = unicode2charset(charset2unicode(chr($c), 'iso-8859-1', 'forcer')); $trans[$c] = $r; @@ -494,7 +465,7 @@ function typo($letexte, $echapper=true) { // un texte anglais en interface francaise (ou l'inverse) ; // sinon determiner la typo en fonction de la langue if (!$lang = $GLOBALS['lang_typo']) { - include_spip('inc/lang'); + #include_spip('inc/lang'); $lang = lang_typo($GLOBALS['spip_lang']); } if ($lang == 'fr') diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index 31c0e696f5ed26532af3948245e8e51e8b306f4d..4815210d1fb0af4f3dd2b20a3a34baa7c3c60c6c 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -74,51 +74,30 @@ function include_fonction($nom, $dossier='exec') { // une fonction remplacant include_ecrire, et autorisant les surcharges // function include_spip($f, $include = true) { - static $included_files = array(); + // deja charge (nom) ? - if (isset($included_files[$f])) - return $included_files[$f]; + if (isset($GLOBALS['meta']['noyau'][_DIR_RESTREINT][$f])) { + $s = $GLOBALS['meta']['noyau'][_DIR_RESTREINT][$f]; + if ($include && $s) { + include_once $s; + } + return $s; + } // Hack pour pouvoir appeler cette fonction depuis mes_options. define('_DIR_INCLUDE', _DIR_RESTREINT); - - // chercher le fichier dans le chemin (eventuellement, surcharge) - - // est-ce dans les chemins du noyau (optimises) ? - if (_DIR_RESTREINT) { - if (isset($GLOBALS['meta']['noyau'][$f])) { - $s = $GLOBALS['meta']['noyau'][$f]; - if (!$s) return false; - } - // sinon on se souvient qu'il faudra ecrire le noyau dans public/global - else - define('ecrire_noyau', 1); - } - - if (!isset($s) - AND !$s = find_in_path($f . '.php') + if (!$s = find_in_path($f . '.php') AND (!_EXTENSION_PHP OR !$s = find_in_path($f . '.php3'))) { - if (_DIR_RESTREINT) - $GLOBALS['meta']['noyau'][$f] = false; - return $included_files[$f] = false; + return $GLOBALS['meta']['noyau'][_DIR_RESTREINT][$f] = false; } - // deja charge (chemin complet) ? - if (isset($included_files[$s])) { - if (_DIR_RESTREINT) - $GLOBALS['meta']['noyau'][$f] = $included_files[$s]; - return $included_files[$f] = $included_files[$s]; - } - else { - if (_DIR_RESTREINT) - $GLOBALS['meta']['noyau'][$f] = $s; - $included_files[$f] = $included_files[$s] = $s; - } + $GLOBALS['meta']['noyau'][_DIR_RESTREINT][$f] = $s; + define('ecrire_noyau', 1); // alors on le charge (sauf si on ne voulait que son chemin) if ($include) { - include($s); + include_once $s; } return $s; @@ -450,17 +429,19 @@ function lire_meta($nom) { // Traduction des textes de SPIP // function _T($texte, $args = '') { - include_spip('inc/lang'); + # petite optimisation pour ne passer qu'une fois dans include_spip + static $c; $c OR $c = include_spip('inc/lang'); + $text = traduire_chaine($texte, $args); if (!empty($GLOBALS['xhtml'])) { include_spip('inc/charsets'); $text = html2unicode($text, true /* secure */); } - return $text ? $text : - // pour les chaines non traduites - (($n = strpos($texte,':')) === false ? $texte : - substr($texte, $n+1)); + return $text ? $text : + // pour les chaines non traduites + (($n = strpos($texte,':')) === false ? $texte : + substr($texte, $n+1)); } // chaines en cours de traduction diff --git a/ecrire/index.php b/ecrire/index.php index ced7e2dc555a7f2bc7f979ffe5a5ef347411efe8..708fb7d792337549b296888582616f427c0e6152 100644 --- a/ecrire/index.php +++ b/ecrire/index.php @@ -169,7 +169,9 @@ if (!isset($reinstall)) { // // Controle d'interruption d'une longue restauration // -if ($GLOBALS['_COOKIE']['spip_admin'] AND $GLOBALS['meta']["debut_restauration"]) +if ($GLOBALS['_COOKIE']['spip_admin'] +AND $GLOBALS['meta']["debut_restauration"] +AND !($exec=='js_menu_rubriques')) $exec = 'import_all'; $var_f = include_fonction($exec);