1 | <?php |
---|
2 | /* |
---|
3 | Maïeul Rouquette Licence GPL 3 |
---|
4 | Spip-Bible |
---|
5 | */ |
---|
6 | include_spip('inc/bible_tableau'); |
---|
7 | |
---|
8 | |
---|
9 | function bible_supprimer_retour($texte){ |
---|
10 | |
---|
11 | $texte = preg_replace("#\t#",'',$texte); |
---|
12 | |
---|
13 | $texte = preg_replace("# {2,}#",'',$texte); |
---|
14 | $texte = preg_replace("#[\r|\n][\r|\n]#",'',$texte); |
---|
15 | |
---|
16 | return $texte; |
---|
17 | } |
---|
18 | function bible_traduire_abreviation($abrev,$lang_original,$lang_traduction){ |
---|
19 | $tableau_gateway = bible_tableau("gateway"); |
---|
20 | $tableau_originales = bible_tableau('original'); |
---|
21 | if (array_key_exists($lang_traduction,$tableau_originales)){ |
---|
22 | return $abrev; |
---|
23 | |
---|
24 | } |
---|
25 | |
---|
26 | $livre = livre_seul($abrev); |
---|
27 | |
---|
28 | $numero = $tableau_gateway[$lang_original][$livre]; |
---|
29 | |
---|
30 | $tableau_inverse = array_flip($tableau_gateway[$lang_traduction]); |
---|
31 | $livre_traduit = $tableau_inverse[$numero]; |
---|
32 | |
---|
33 | return str_replace($livre,$livre_traduit,$abrev); |
---|
34 | |
---|
35 | |
---|
36 | } |
---|
37 | |
---|
38 | function bible_test_livre_seul($i){ |
---|
39 | if (preg_match('#[0-9|,|-]+$#',$i)){ return 'non';} |
---|
40 | else {return 'oui';} |
---|
41 | |
---|
42 | } |
---|
43 | function livre_seul($i){ |
---|
44 | return preg_replace('#[0-9|,|-]+$#','',$i); |
---|
45 | |
---|
46 | } |
---|
47 | function bible_analyser_ref($passage,$traduction){ |
---|
48 | $tableau_traduction = bible_tableau('traduction'); |
---|
49 | $tableau_separateur = bible_tableau('separateur'); |
---|
50 | $tableau_livres = bible_tableau('livres'); |
---|
51 | global $spip_lang; |
---|
52 | $verset_debut = ''; |
---|
53 | |
---|
54 | $lang = $tableau_traduction[$traduction]['lang']; |
---|
55 | $langues_originales = bible_tableau('original'); |
---|
56 | //var_dump($langues_originales); |
---|
57 | array_key_exists($lang,$langues_originales) ? $lang = $spip_lang : $lang = $lang; |
---|
58 | |
---|
59 | $separateur = $tableau_separateur[$lang]; |
---|
60 | |
---|
61 | $livres=$tableau_livres[$lang]; |
---|
62 | |
---|
63 | // phase d'anaylse |
---|
64 | |
---|
65 | $livre = strtolower($livre); |
---|
66 | $tableau = explode('-',$passage); |
---|
67 | if (count($tableau)==2){ |
---|
68 | $fin=$tableau[1]; |
---|
69 | //chercher chapitre et verset de fin |
---|
70 | $tableau2 = explode(',',$fin); |
---|
71 | if (count($tableau2)==1){ |
---|
72 | |
---|
73 | $verset_fin = $tableau2[0];} |
---|
74 | else{ |
---|
75 | $chapitre_fin = $tableau2[0]; |
---|
76 | $verset_fin = $tableau2[1];} |
---|
77 | |
---|
78 | } |
---|
79 | |
---|
80 | $debut = $tableau[0]; |
---|
81 | |
---|
82 | $livre = livre_seul($debut); |
---|
83 | |
---|
84 | if (!array_key_exists($livre,$livres)){ |
---|
85 | return _T('bible:pas_livre'); |
---|
86 | |
---|
87 | } |
---|
88 | |
---|
89 | $debut = str_replace($livre,'',$debut); |
---|
90 | |
---|
91 | |
---|
92 | //problème Isaïe / Esaïe => on converti dans la bonne confession |
---|
93 | if ($lang=='fr' and ($livre == 'Is' or $livre =='Es' )){ |
---|
94 | $livre = $tableau_traduction[$traduction]['isaie']; |
---|
95 | $isaie=true; |
---|
96 | |
---|
97 | |
---|
98 | } |
---|
99 | |
---|
100 | //chercher chapitre et verset du début |
---|
101 | |
---|
102 | $tableau = explode(',',$debut); |
---|
103 | if (count($tableau)==2){ |
---|
104 | $verset_debut = $tableau[1];} |
---|
105 | else{ |
---|
106 | if (count($tableau2)==1){ |
---|
107 | $chapitre_fin=$tableau2[0]; |
---|
108 | $verset_fin=''; |
---|
109 | } |
---|
110 | |
---|
111 | |
---|
112 | } |
---|
113 | $chapitre_debut = $tableau[0]; |
---|
114 | |
---|
115 | |
---|
116 | // si reference courte |
---|
117 | if ($chapitre_fin==''){$chapitre_fin=$chapitre_debut;}; |
---|
118 | |
---|
119 | if ($verset_debut=='' and count($tableau2)==2){$verset_debut=1; |
---|
120 | $verset_fin==''; |
---|
121 | $chapitre_fin=$chapitre_debut;}; |
---|
122 | if ($verset_fin=='' and (count($tableau)==2)){$verset_fin=$verset_debut;} |
---|
123 | return array($livre,$chapitre_debut,$verset_debut,$chapitre_fin,$verset_fin); |
---|
124 | } |
---|
125 | |
---|
126 | function bible($passage,$traduction='jerusalem',$mode_test=false){ |
---|
127 | |
---|
128 | |
---|
129 | $tableau_traduction = bible_tableau('traduction'); |
---|
130 | $tableau_separateur = bible_tableau('separateur'); |
---|
131 | |
---|
132 | global $spip_lang; |
---|
133 | |
---|
134 | $traduction = strtolower($traduction); |
---|
135 | |
---|
136 | $erreur = true; |
---|
137 | |
---|
138 | if (array_key_exists($traduction,$tableau_traduction)){$erreur = false;}; |
---|
139 | |
---|
140 | if ($erreur) { |
---|
141 | return _T('bible:traduction_pas_dispo'); |
---|
142 | } |
---|
143 | $lang = $tableau_traduction[$traduction]['lang']; |
---|
144 | $langues_originales = bible_tableau('original'); |
---|
145 | $lang_original = $lang; |
---|
146 | |
---|
147 | |
---|
148 | //si langue originel |
---|
149 | foreach ($langues_originales as $i=>$dir){ |
---|
150 | if ($i ==$lang){ |
---|
151 | $original = true; |
---|
152 | $lang = $spip_lang; |
---|
153 | $lang_original = $i; |
---|
154 | $dir = $dir; |
---|
155 | include_spip('inc/lang'); |
---|
156 | break; |
---|
157 | } |
---|
158 | |
---|
159 | } |
---|
160 | $separateur = $tableau_separateur[$lang]; |
---|
161 | |
---|
162 | $tableau_analyse = bible_analyser_ref($passage,$traduction); |
---|
163 | if (!is_array($tableau_analyse)){ |
---|
164 | return $tableau_analyse; |
---|
165 | } |
---|
166 | if ($mode_test){ |
---|
167 | return ; |
---|
168 | } |
---|
169 | |
---|
170 | |
---|
171 | |
---|
172 | $livre = $tableau_analyse[0]; |
---|
173 | $chapitre_debut = $tableau_analyse[1]; |
---|
174 | $verset_debut = $tableau_analyse[2]; |
---|
175 | $chapitre_fin = $tableau_analyse[3]; |
---|
176 | $verset_fin = $tableau_analyse[4]; |
---|
177 | |
---|
178 | |
---|
179 | $gateway = $tableau_traduction[$traduction]['gateway']; |
---|
180 | $wissen = $tableau_traduction[$traduction]['wissen']; |
---|
181 | $unbound = $tableau_traduction[$traduction]['unbound']; |
---|
182 | $lire = $tableau_traduction[$traduction]['lire']; |
---|
183 | |
---|
184 | if ($lire){ |
---|
185 | include_spip('traduction/lire'); |
---|
186 | $tableau = recuperer_passage_lire($livre,$chapitre_debut,$verset_debut,$chapitre_fin,$verset_fin,$lire,$lang); |
---|
187 | } |
---|
188 | |
---|
189 | else if ($unbound){ |
---|
190 | include_spip('traduction/unbound'); |
---|
191 | $tableau = recuperer_passage_unbound($livre,$chapitre_debut,$verset_debut,$chapitre_fin,$verset_fin,$unbound,$lang); |
---|
192 | } |
---|
193 | |
---|
194 | |
---|
195 | else if ($wissen){ |
---|
196 | $isaie == true ? $livre = str_replace('Es','Is',$livre) : $passage = $passage; |
---|
197 | include_spip('traduction/wissen'); |
---|
198 | $tableau = recuperer_passage_wissen($livre,$chapitre_debut,$verset_debut,$chapitre_fin,$verset_fin,$wissen,$lang); |
---|
199 | |
---|
200 | } |
---|
201 | |
---|
202 | else if ($gateway){ |
---|
203 | include_spip('traduction/gateway'); |
---|
204 | $tableau = recuperer_passage_gateway($livre,$chapitre_debut,$verset_debut,$chapitre_fin,$verset_fin,$gateway,$lang); |
---|
205 | |
---|
206 | |
---|
207 | } |
---|
208 | |
---|
209 | else{ |
---|
210 | |
---|
211 | include_spip('traduction/'.$traduction); |
---|
212 | $tableau = recuperer_passage($livre,$chapitre_debut,$verset_debut,$chapitre_fin,$verset_fin,$lang); |
---|
213 | } |
---|
214 | include_spip('inc/utils'); |
---|
215 | |
---|
216 | return (array('passage_texte'=>$tableau,'passage'=>$tableau_analyse,'lang_original'=>$lang_original,'spip_lang'=>$spip_lang,'lang'=>$lang,'separateur'=>$separateur)); |
---|
217 | |
---|
218 | } |
---|
219 | function livre_long($i,$lang=''){ |
---|
220 | global $spip_lang; |
---|
221 | $lang =='' ? $lang = $spip_lang : $lang=$lang; |
---|
222 | |
---|
223 | $i = livre_seul($i); |
---|
224 | |
---|
225 | $tableau_livres = bible_tableau('livres'); |
---|
226 | |
---|
227 | return $tableau_livres[$lang][$i]; |
---|
228 | |
---|
229 | } |
---|
230 | function filtre_ref($i){ |
---|
231 | global $spip_lang; |
---|
232 | $tableau_livres = bible_tableau('livres'); |
---|
233 | |
---|
234 | $livre =livre_seul($i); |
---|
235 | $trad = $tableau_livres[$spip_lang][$livre]; |
---|
236 | |
---|
237 | $c = str_replace($livre,'',$i); |
---|
238 | |
---|
239 | return $trad.' '.$c; |
---|
240 | |
---|
241 | |
---|
242 | } |
---|
243 | function bible_afficher_references_direct($ref,$traduction,$lang,$nommer_trad=true){ |
---|
244 | $t = bible_analyser_ref($ref,$traduction); |
---|
245 | $tableau_separateur = bible_tableau('separateur'); |
---|
246 | $lang_version = info_bible_version($traduction,'lang_abrev'); |
---|
247 | $separateur = $tableau_separateur[$lang_version]; |
---|
248 | return afficher_references($t[0],$t[1],$t[2],$t[3],$t[4],$traduction,$separateur,$lang,$nommer_trad); |
---|
249 | } |
---|
250 | function afficher_references($livre,$cd,$vd,$cf,$vf,$trad,$separateur,$lang,$nommer_trad='true'){ |
---|
251 | $tableau_traduction = bible_tableau('traduction'); |
---|
252 | $tableau_livres = bible_tableau('livres'); |
---|
253 | $trad = $tableau_traduction[strtolower($trad)]['traduction']; |
---|
254 | |
---|
255 | $livre_long = $tableau_livres[$lang][$livre] ; |
---|
256 | |
---|
257 | $livre = str_replace('1','1 ',$livre); |
---|
258 | $livre = str_replace('2','2 ',$livre); |
---|
259 | $livre = str_replace('3','3 ',$livre); |
---|
260 | |
---|
261 | $nommer_trad!='false' ? $bloc_fin = ' (<i>'.$trad.'</i>)' : $bloc_fin = ''; |
---|
262 | |
---|
263 | if ($cd==$cf and $vd=='' and $vf==''){ |
---|
264 | |
---|
265 | return '<accronym title=\''.$livre_long."'>".$livre.'</accronym> '.$cd.$bloc_fin; |
---|
266 | |
---|
267 | } |
---|
268 | |
---|
269 | if ($vd=='' and $vf==''){ |
---|
270 | |
---|
271 | return '<accronym title=\''.$livre_long."'>".$livre.'</accronym> '.$cd.'-'.$cf.$bloc_fin; |
---|
272 | |
---|
273 | } |
---|
274 | |
---|
275 | $chaine = '<accronym title=\''.$livre_long."'>".$livre.'</accronym> '.$cd.$separateur." ".$vd; |
---|
276 | |
---|
277 | if ($cd!=$cf){ |
---|
278 | |
---|
279 | $chaine .= '-'.$cf.$separateur.' '.$vf; |
---|
280 | |
---|
281 | } |
---|
282 | elseif ($vd!=$vf) { |
---|
283 | |
---|
284 | $chaine .= '-'.$vf; |
---|
285 | |
---|
286 | } |
---|
287 | |
---|
288 | $chaine.= $bloc_fin; |
---|
289 | |
---|
290 | return $chaine; |
---|
291 | |
---|
292 | } |
---|
293 | function traduction_longue($i){ |
---|
294 | |
---|
295 | $tableau_traduction = bible_tableau('traduction'); |
---|
296 | return $tableau_traduction[$i]['traduction']; |
---|
297 | } |
---|
298 | |
---|
299 | function traduction_defaut($lang){ |
---|
300 | $normal = lire_config('bible/traduction_'.$lang); |
---|
301 | //pour compatibilite |
---|
302 | $normal ='' ? $lire_config =lire_config('bible/traduction') : $normal = $normal; |
---|
303 | return $normal; |
---|
304 | } |
---|
305 | |
---|
306 | |
---|
307 | |
---|
308 | ?> |
---|