From e530d8a975dac7e7a893c29a298b6b102be3148b Mon Sep 17 00:00:00 2001 From: Fil <fil@rezo.net> Date: Mon, 6 Feb 2006 15:51:33 +0000 Subject: [PATCH] =?UTF-8?q?un=20peu=20de=20m=C3=A9nage=20dans=20find=5Fin?= =?UTF-8?q?=5Fpath()=20notamment,=20on=20commence=20=C3=A0=20regrouper=20l?= =?UTF-8?q?es=20=C3=A9l=C3=A9ments=20dans=20des=20sous-r=C3=A9pertoires=20?= =?UTF-8?q?nomm=C3=A9s=20:=20lang/=20extract/=20charsest/=20et=20bient?= =?UTF-8?q?=C3=B4t=20exec/=20et=20(peut-=C3=AAtre)=20un=20truc=20pour=20le?= =?UTF-8?q?s=20inc=5F...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/exec_aide_index.php | 2 +- ecrire/exec_lang_raccourcis.php | 10 ++++--- extract_doc.php => ecrire/extract/doc.php | 0 extract_pdf.php => ecrire/extract/pdf.php | 0 extract_rtf.php => ecrire/extract/rtf.php | 0 ecrire/inc_charsets.php | 2 +- ecrire/inc_filtres.php | 6 ++--- ecrire/inc_index.php | 4 +-- ecrire/inc_lang.php | 28 +++++++++---------- ecrire/inc_utils.php | 33 +++++++++++++---------- 10 files changed, 47 insertions(+), 38 deletions(-) rename extract_doc.php => ecrire/extract/doc.php (100%) rename extract_pdf.php => ecrire/extract/pdf.php (100%) rename extract_rtf.php => ecrire/extract/rtf.php (100%) diff --git a/ecrire/exec_aide_index.php b/ecrire/exec_aide_index.php index 72170a3808..57bdb452e6 100644 --- a/ecrire/exec_aide_index.php +++ b/ecrire/exec_aide_index.php @@ -483,7 +483,7 @@ else { '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'> <html lang='".$GLOBALS['spip_lang']."' dir='".($GLOBALS['spip_lang_rtl'] ? 'rtl' : 'ltr')."'> <head> -<title>$title</title>\n"; +<title>"._T('info_aide_en_ligne')."</title>\n"; if ($frame == 'menu') help_menu($aide, $html); diff --git a/ecrire/exec_lang_raccourcis.php b/ecrire/exec_lang_raccourcis.php index 4945c2a203..166305bcc6 100644 --- a/ecrire/exec_lang_raccourcis.php +++ b/ecrire/exec_lang_raccourcis.php @@ -33,6 +33,8 @@ debut_gauche(); $modules = array(); +##### a revoir : des repertoires lang, il peut y en avoir partout sur le chemin +##### cf. aussi fonction ci-dessous if (!$d = @opendir(_DIR_LANG)) return; while (($f = readdir($d)) !== false) { if (ereg('^([a-z_]+)\.php[3]?$', $f, $regs)) @@ -54,6 +56,8 @@ if (count($modules) > 1) { echo fin_cadre_relief(); } +$module = array_pop($modules); + debut_droite(); @@ -63,13 +67,13 @@ afficher_raccourcis($module); fin_page(); } - +##### a revoir aussi (cf. commentaire ci-dessus) function afficher_raccourcis($module = "public") { global $spip_lang; global $couleur_foncee; $lang = $module.'_'.$spip_lang; - if ($fichier_lang = find_in_path($lang._EXTENSION_PHP, 'AUTO', _DIR_LANG)) { + if ($fichier_lang = find_in_path($lang._EXTENSION_PHP, _DIR_LANG)) { $GLOBALS['idx_lang'] = 'i18n_' . $lang; include_local($fichier_lang); @@ -111,7 +115,7 @@ function afficher_raccourcis($module = "public") { echo "<tr bgcolor='$bgcolor'><td class='verdana2'><b><:$aff_nom_module$raccourci:></b></td><td class='arial2'>$texte</td></tr>\n"; } echo "</table>"; - } + } } ?> diff --git a/extract_doc.php b/ecrire/extract/doc.php similarity index 100% rename from extract_doc.php rename to ecrire/extract/doc.php diff --git a/extract_pdf.php b/ecrire/extract/pdf.php similarity index 100% rename from extract_pdf.php rename to ecrire/extract/pdf.php diff --git a/extract_rtf.php b/ecrire/extract/rtf.php similarity index 100% rename from extract_rtf.php rename to ecrire/extract/rtf.php diff --git a/ecrire/inc_charsets.php b/ecrire/inc_charsets.php index 1e8213f0ac..e78c9be981 100644 --- a/ecrire/inc_charsets.php +++ b/ecrire/inc_charsets.php @@ -40,7 +40,7 @@ function load_charset ($charset = 'AUTO', $langue_site = 'AUTO') { else if ($charset == 'windows-1251') $charset = 'cp1251'; else if ($charset == 'windows-1256') $charset = 'cp1256'; - if ($f = find_in_path('charsets/'.$charset.'.php')) { + if ($f = find_in_path('charsets/'.$charset.'.php', _DIR_INCLUDE)) { include($f); return $charset; } else { diff --git a/ecrire/inc_filtres.php b/ecrire/inc_filtres.php index 174f9aa8ee..5d9601c6ee 100644 --- a/ecrire/inc_filtres.php +++ b/ecrire/inc_filtres.php @@ -1969,9 +1969,9 @@ function image_typo() { if (!file_exists($fichier) AND $flag_gd_typo) { - // Il faut completer avec un vrai _SPIP_PATH, de facon a pouvoir livrer des /polices dans les dossiers de squelettes - $font = find_in_path("polices/$police", "ecrire"); - + # que faire si la police n'existe pas ? + $font = find_in_path('polices/'.$police, _DIR_INCLUDE); + $imgbidon = imageCreateTrueColor($largeur, 45); $retour = printWordWrapped($imgbidon, $taille+5, 0, $largeur, $font, $black, $text, $taille); $hauteur = $retour["height"]; diff --git a/ecrire/inc_index.php b/ecrire/inc_index.php index 9cdb9033e7..3467d75630 100644 --- a/ecrire/inc_index.php +++ b/ecrire/inc_index.php @@ -310,8 +310,8 @@ function indexer_contenu_document ($row) { )); // Voir si on sait lire le contenu (eventuellement en chargeant le - // fichier extract_pdf.php dans find_in_path() ) - if ($plugin = find_in_path('extract_'.$extension)) { + // fichier extract/pdf.php dans find_in_path() ) + if ($plugin = find_in_path('extract/'.$extension, _DIR_INCLUDE)) { include_local($plugin); } if (function_exists($lire = $extracteur[$extension])) { diff --git a/ecrire/inc_lang.php b/ecrire/inc_lang.php index 1f64213a04..6383320a46 100644 --- a/ecrire/inc_lang.php +++ b/ecrire/inc_lang.php @@ -15,11 +15,18 @@ if (!defined("_ECRIRE_INC_VERSION")) return; // // Charger un fichier langue // +function chercher_module_lang($module, $lang) { + // 1) dans un repertoire nomme lang/ se trouvant sur le chemin + if ($f = find_in_path('lang/'.$module.'_'.$lang._EXTENSION_PHP)) + return $f; + + // 2) directement dans le chemin, ou dans _DIR_LANG + return find_in_path($module.'_'.$lang._EXTENSION_PHP, _DIR_LANG); +} function charger_langue($lang, $module = 'spip') { - if ($fichier_lang = find_in_path($module.'_'.$lang._EXTENSION_PHP, - 'AUTO', _DIR_LANG)) { + if ($fichier_lang = chercher_module_lang($module, $lang)) { $GLOBALS['idx_lang']='i18n_'.$module.'_'.$lang; include_local($fichier_lang); } else { @@ -28,12 +35,9 @@ function charger_langue($lang, $module = 'spip') { // *par definition* doit exister, et on copie le tableau dans la // var liee a la langue $l = $GLOBALS['meta']['langue_site']; - if (!$fichier_lang = find_in_path($module.'_'.$l._EXTENSION_PHP, - 'AUTO', _DIR_LANG)) { - $l = 'fr'; - $fichier_lang = find_in_path($module.'_'.$l._EXTENSION_PHP, - 'AUTO', _DIR_LANG); - } + if (!$fichier_lang = chercher_module_lang($module, $l)) + $fichier_lang = chercher_module_lang($module, 'fr'); + if ($fichier_lang) { $GLOBALS['idx_lang']='i18n_'.$module.'_' .$l; include_local($fichier_lang); @@ -130,15 +134,11 @@ function traduire_chaine($code, $args) { if (empty($GLOBALS[$var])) { charger_langue($spip_lang, $module); - // surcharge perso -- on cherche local(_xx).php dans le chemin + // surcharge perso -- on cherche (lang/)local(_xx).php if ($f = find_in_path('local' ._EXTENSION_PHP)) surcharger_langue($f); - if ($f = find_in_path('local_'.$spip_lang._EXTENSION_PHP)) - surcharger_langue($f); - // compatibilite ascendante : chercher aussi dans ecrire/lang/ - else if (@is_readable($f = _DIR_LANG . 'local_'.$spip_lang._EXTENSION_PHP)) + if ($f = chercher_module_lang('local', $spip_lang)) surcharger_langue($f); - } if (isset($GLOBALS[$var][$code])) break; } diff --git a/ecrire/inc_utils.php b/ecrire/inc_utils.php index 7307f807a8..3406c036b9 100644 --- a/ecrire/inc_utils.php +++ b/ecrire/inc_utils.php @@ -566,14 +566,26 @@ function texte_script($texte) { // find_in_path() : chercher un fichier nomme x selon le chemin rep1:rep2:rep3 // -function find_in_path ($filename, $path='AUTO', $sinon='') { +function find_in_path ($filename, $sinon='', $path='AUTO') { static $autopath; // Chemin standard depuis l'espace public - if ($path == 'AUTO') { if (!$autopath) { - $autopath = _SPIP_PATH; + + // Depuis l'espace prive, remonter d'un cran, sauf pour : + // - les absolus (/) ; - les locaux (./) ; les remontees (../) + if (_DIR_RACINE) { + $autopath = array(); + foreach (split(':', _SPIP_PATH) as $dir) { + if (preg_match('@^([.]{0,2}/)@', $dir)) + $dir = _DIR_RACINE.$dir; + $autopath[] = $dir; + } + $autopath = join(':', $autopath); + } else + $autopath = _SPIP_PATH; + // Ajouter les repertoires des plugins foreach ($GLOBALS['plugins'] as $plug) $autopath = _DIR_PLUGINS.$plug.'/:'.$autopath; @@ -586,23 +598,16 @@ function find_in_path ($filename, $path='AUTO', $sinon='') { #spip_log("path = $path"); // Parcourir le chemin + if ($sinon) $path .= ':'.$sinon; foreach (split(':', $path) as $dir) { - // Depuis l'espace prive, remonter d'un cran, sauf pour : - // - les absolus (/) ; - les locaux (./) ; les remontees (../) - $racine = preg_match('@^([.]{0,2}/)@', $dir) ? '' : _DIR_RACINE; - // ajouter un / eventuellement manquant - if (substr($dir,-1) <> '/') - $dir .= "/"; + // ajouter un / eventuellement manquant a la fin + if (substr($dir,-1) <> '/') $dir .= "/"; #spip_log("find_in_path: essai $racine $dir $filename"); - if (@is_readable($f = "$racine$dir$filename")) { + if (@is_readable($f = "$dir$filename")) { #spip_log("trouve $f"); return $f; } } - - // sinon essayer $sinon - if ($sinon AND @is_readable($f = "$sinon$filename")) - return $f; } // charger les definitions des plugins -- GitLab