[SPIP] ~2.1.12 -->2.1.25
[velocampus/web/www.git] / www / ecrire / inc / presentation.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2014 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13 if (!defined('_ECRIRE_INC_VERSION')) return;
14
15 include_spip('inc/agenda'); // inclut inc/layer, inc/texte, inc/filtre
16 include_spip('inc/boutons');
17 include_spip('inc/actions');
18 include_spip('inc/puce_statut');
19
20 define('_ACTIVER_PUCE_RAPIDE', true);
21 define('_SIGNALER_ECHOS', true);
22 define('_INTERFACE_ONGLETS', false);
23
24 // http://doc.spip.org/@echo_log
25 function echo_log($f, $ret) {
26 spip_log("Page " . self() . " function $f: echo ".substr($ret,0,50)."...",'echo');
27 echo
28 (_SIGNALER_ECHOS?"#Echo par $f#" :"")
29 . $ret;
30 }
31 // Faux HR, avec controle de couleur
32
33 // http://doc.spip.org/@hr
34 function hr($color, $retour = false) {
35 $ret = "\n<div style='height: 1px; margin-top: 5px; padding-top: 5px; border-top: 1px solid $color;'></div>";
36
37 if ($retour) return $ret; else echo_log('hr',$ret);
38 }
39
40 //
41 // Cadres
42 //
43 // http://doc.spip.org/@afficher_onglets_pages
44 function afficher_onglets_pages($ordre,$onglets){
45 static $onglet_compteur = 0;
46 $res = "";
47 $corps = "";
48 $cpt = 0;
49 $actif = 0;
50 // ordre des onglets
51 foreach($ordre as $id => $label) {
52 $cpt++;
53 $disabled = strlen(trim($onglets[$id]))?"":" class='tabs-disabled'";
54 if (!$actif && !$disabled) $actif = $cpt;
55 $res .= "<li$disabled><a rel='$cpt' href='#$id'><span>" . $label . "</span></a></li>";
56 }
57 $res = "<ul class='tabs-nav'>$res</ul>";
58 foreach((_INTERFACE_ONGLETS ? array_keys($ordre):array_keys($onglets)) as $id){
59 $res .= "<div id='$id' class='tabs-container'>" . $onglets[$id] . "<div class='nettoyeur'></div></div>";
60 }
61 $onglet_compteur++;
62 return "<div class='boite_onglets' id='boite_onglet_$onglet_compteur'>$res</div>"
63 . (_INTERFACE_ONGLETS ?
64 http_script("$('#boite_onglet_$onglet_compteur').tabs(".($actif?"$actif,":"")."{ fxAutoHeight: true });
65 if (!$.browser.safari)
66 $('ul.tabs-nav li').hover(
67 function(){
68 \$('#boite_onglet_$onglet_compteur').triggerTab(parseInt(\$(this).attr('rel')));
69 return false;
70 }
71 ,
72 function(){}
73 );")
74 :"");
75 }
76
77 // http://doc.spip.org/@debut_cadre
78 function debut_cadre($style, $icone = "", $fonction = "", $titre = "", $id="", $class="", $padding=true) {
79 global $spip_display;
80 static $accesskey = 97; // a
81
82 //zoom:1 fixes all expanding blocks in IE, see authors block in articles.php
83 //being not standard, next step can be putting this kind of hacks in a different stylesheet
84 //visible to IE only using conditional comments.
85
86 // accesskey pour accessibilite espace prive
87 if ($accesskey <= 122) // z
88 {
89 $accesskey_c = chr($accesskey++);
90 $ret = "<a id='access-$accesskey_c' href='#access-$accesskey_c' accesskey='$accesskey_c'></a>";
91 } else $ret ='';
92
93 $ret .= "\n<div "
94 . ($id?"id='$id' ":"")
95 ."class='cadre cadre-$style"
96 . ($class?" $class":"")
97 ."'>";
98
99 if ($spip_display != 1 AND $spip_display != 4 AND strlen($icone) > 1) {
100 if ($fonction) {
101
102 $ret .= http_img_pack("$fonction", "", " class='cadre-icone' ".http_style_background($icone, "no-repeat; padding: 0px; margin: 0px"));
103 }
104 else $ret .= http_img_pack("$icone", "", " class='cadre-icone'");
105 }
106
107 if (strlen($titre) > 0) {
108 if (strpos($titre,'titrem')!==false) {
109 $ret .= $titre;
110 } elseif ($spip_display == 4) {
111 $ret .= "\n<h3 class='cadre-titre'>$titre</h3>";
112 } else {
113 $ret .= bouton_block_depliable($titre,-1);
114 }
115 }
116
117 $ret .= "<div". ($padding ?" class='cadre_padding'" : '') .">";
118
119 return $ret;
120 }
121
122 // http://doc.spip.org/@fin_cadre
123 function fin_cadre($style='') {
124
125 $ret = "<div class='nettoyeur'></div></div>".
126 "</div>\n";
127
128 /*if ($style != "forum" AND $style != "thread-forum")
129 $ret .= "<div style='height: 5px;'></div>\n";*/
130
131 return $ret;
132 }
133
134
135 // http://doc.spip.org/@debut_cadre_relief
136 function debut_cadre_relief($icone='', $return = false, $fonction='', $titre = '', $id="", $class=""){
137 $retour_aff = debut_cadre('r', $icone, $fonction, $titre, $id, $class);
138
139 if ($return) return $retour_aff; else echo($retour_aff);
140 }
141
142 // http://doc.spip.org/@fin_cadre_relief
143 function fin_cadre_relief($return = false){
144 $retour_aff = fin_cadre('r');
145
146 if ($return) return $retour_aff; else echo($retour_aff);
147 }
148
149
150 // http://doc.spip.org/@debut_cadre_enfonce
151 function debut_cadre_enfonce($icone='', $return = false, $fonction='', $titre = '', $id="", $class=""){
152 $retour_aff = debut_cadre('e', $icone, $fonction, $titre, $id, $class);
153
154 if ($return) return $retour_aff; else echo($retour_aff);
155 }
156
157 // http://doc.spip.org/@fin_cadre_enfonce
158 function fin_cadre_enfonce($return = false){
159
160 $retour_aff = fin_cadre('e');
161
162 if ($return) return $retour_aff; else echo_log('fin_cadre_enfonce',$retour_aff);
163 }
164
165
166 // http://doc.spip.org/@debut_cadre_sous_rub
167 function debut_cadre_sous_rub($icone='', $return = false, $fonction='', $titre = '', $id="", $class=""){
168 $retour_aff = debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class);
169 if ($return) return $retour_aff; else echo_log('debut_cadre_sous_rub',$retour_aff);
170 }
171
172 // http://doc.spip.org/@fin_cadre_sous_rub
173 function fin_cadre_sous_rub($return = false){
174 $retour_aff = fin_cadre('sous_rub');
175 if ($return) return $retour_aff; else echo_log('fin_cadre_sous_rub',$retour_aff);
176 }
177
178
179
180 // http://doc.spip.org/@debut_cadre_forum
181 function debut_cadre_forum($icone='', $return = false, $fonction='', $titre = '', $id="", $class=""){
182 $retour_aff = debut_cadre('forum', $icone, $fonction, $titre, $id, $class);
183
184 if ($return) return $retour_aff; else echo_log('debut_cadre_forum',$retour_aff);
185 }
186
187 // http://doc.spip.org/@fin_cadre_forum
188 function fin_cadre_forum($return = false){
189 $retour_aff = fin_cadre('forum');
190
191 if ($return) return $retour_aff; else echo_log('fin_cadre_forum',$retour_aff);
192 }
193
194 // http://doc.spip.org/@debut_cadre_thread_forum
195 function debut_cadre_thread_forum($icone='', $return = false, $fonction='', $titre = '', $id="", $class=""){
196 $retour_aff = debut_cadre('thread-forum', $icone, $fonction, $titre, $id, $class);
197
198 if ($return) return $retour_aff; else echo_log('debut_cadre_thread_forum',$retour_aff);
199 }
200
201 // http://doc.spip.org/@fin_cadre_thread_forum
202 function fin_cadre_thread_forum($return = false){
203 $retour_aff = fin_cadre('thread-forum');
204
205 if ($return) return $retour_aff; else echo_log('fin_cadre_thread_forum',$retour_aff);
206 }
207
208
209 // http://doc.spip.org/@debut_cadre_couleur
210 function debut_cadre_couleur($icone='', $return = false, $fonction='', $titre='', $id="", $class=""){
211 $retour_aff = debut_cadre('couleur', $icone, $fonction, $titre, $id, $class);
212
213 if ($return) return $retour_aff; else echo_log('debut_cadre_couleur',$retour_aff);
214 }
215
216 // http://doc.spip.org/@fin_cadre_couleur
217 function fin_cadre_couleur($return = false){
218 $retour_aff = fin_cadre('couleur');
219
220 if ($return) return $retour_aff; else echo_log('fin_cadre_couleur',$retour_aff);
221 }
222
223
224 // http://doc.spip.org/@debut_cadre_couleur_foncee
225 function debut_cadre_couleur_foncee($icone='', $return = false, $fonction='', $titre='', $id="", $class=""){
226 $retour_aff = debut_cadre('couleur-foncee', $icone, $fonction, $titre, $id, $class);
227
228 if ($return) return $retour_aff; else echo_log('debut_cadre_couleur_foncee',$retour_aff);
229 }
230
231 // http://doc.spip.org/@fin_cadre_couleur_foncee
232 function fin_cadre_couleur_foncee($return = false){
233 $retour_aff = fin_cadre('couleur-foncee');
234
235 if ($return) return $retour_aff; else echo_log('fin_cadre_couleur_foncee',$retour_aff);
236 }
237
238 // http://doc.spip.org/@debut_cadre_trait_couleur
239 function debut_cadre_trait_couleur($icone='', $return = false, $fonction='', $titre='', $id="", $class=""){
240 $retour_aff = debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class);
241 if ($return) return $retour_aff; else echo_log('debut_cadre_trait_couleur',$retour_aff);
242 }
243
244 // http://doc.spip.org/@fin_cadre_trait_couleur
245 function fin_cadre_trait_couleur($return = false){
246 $retour_aff = fin_cadre('trait-couleur');
247
248 if ($return) return $retour_aff; else echo_log('fin_cadre_trait_couleur',$retour_aff);
249 }
250
251
252 //
253 // une boite alerte
254 //
255 // http://doc.spip.org/@debut_boite_alerte
256 function debut_boite_alerte() {
257 return debut_cadre('alerte', '', '', '', '', '');
258 }
259
260 // http://doc.spip.org/@fin_boite_alerte
261 function fin_boite_alerte() {
262 return fin_cadre('alerte');
263 }
264
265
266 //
267 // une boite info
268 //
269 // http://doc.spip.org/@debut_boite_info
270 function debut_boite_info($return=false) {
271 $r = debut_cadre('info', '', '', '', '', 'verdana1');
272 if ($return) return $r; else echo_log('debut_boite_info',$r);
273 }
274
275 // http://doc.spip.org/@fin_boite_info
276 function fin_boite_info($return=false) {
277 $r = fin_cadre('info');
278 if ($return) return $r; else echo_log('fin_boite_info',$r);
279 }
280
281
282 //
283 // La boite des raccourcis
284 // Se place a droite si l'ecran est en mode panoramique.
285
286 // http://doc.spip.org/@bloc_des_raccourcis
287 function bloc_des_raccourcis($bloc) {
288 global $spip_display;
289
290 return "\n"
291 . creer_colonne_droite('',true)
292 . debut_cadre_enfonce('',true)
293 . (($spip_display != 4)
294 ? ("\n<div style='font-size: x-small' class='verdana1'><b>"
295 ._T('titre_cadre_raccourcis')
296 ."</b>")
297 : ( "<h3>"._T('titre_cadre_raccourcis')."</h3><ul>"))
298 . $bloc
299 . (($spip_display != 4) ? "</div>" : "</ul>")
300 . fin_cadre_enfonce(true);
301 }
302
303 // Afficher un petit "+" pour lien vers autre page
304
305 // http://doc.spip.org/@afficher_plus
306 function afficher_plus($lien) {
307 global $spip_lang_right, $spip_display;
308
309 if ($spip_display != 4) {
310 return "\n<a href='$lien' style='float:$spip_lang_right; padding-right: 10px;'>" .
311 http_img_pack("plus.gif", "+", "") ."</a>";
312 }
313 }
314
315 //
316 // Fonctions d'affichage
317 //
318
319 // http://doc.spip.org/@afficher_objets
320 function afficher_objets($type, $titre_table,$requete,$formater='',$force=false){
321 $afficher_objets = charger_fonction('afficher_objets','inc');
322 return $afficher_objets($type, $titre_table,$requete,$formater,$force);
323 }
324
325 // http://doc.spip.org/@navigation_pagination
326 function navigation_pagination($num_rows, $nb_aff=10, $href=null, $debut, $tmp_var=null, $on='') {
327
328 $texte = '';
329 $self = parametre_url(self(), 'date', '');
330 $deb_aff = intval($debut);
331
332 for ($i = 0; $i < $num_rows; $i += $nb_aff){
333 $deb = $i + 1;
334
335 // Pagination : si on est trop loin, on met des '...'
336 if (abs($deb-$deb_aff)>101) {
337 if ($deb<$deb_aff) {
338 if (!isset($premiere)) {
339 $premiere = '0 ... ';
340 $texte .= $premiere;
341 }
342 } else {
343 $derniere = ' | ... '.$num_rows;
344 $texte .= $derniere;
345 break;
346 }
347 } else {
348
349 $fin = $i + $nb_aff;
350 if ($fin > $num_rows)
351 $fin = $num_rows;
352
353 if ($deb > 1)
354 $texte .= " |\n";
355 if ($deb_aff + 1 >= $deb AND $deb_aff + 1 <= $fin) {
356 $texte .= "<b>$deb</b>";
357 }
358 else {
359 $script = parametre_url($self, $tmp_var, $deb-1);
360 if ($on) $on = generer_onclic_ajax($href, $tmp_var, $deb-1);
361 $texte .= "<a href=\"$script\"$on>$deb</a>";
362 }
363 }
364 }
365
366 return $texte;
367 }
368
369 // http://doc.spip.org/@generer_onclic_ajax
370 function generer_onclic_ajax($url, $idom, $val)
371 {
372 return "\nonclick=\"return charger_id_url('"
373 . parametre_url($url, $idom, $val)
374 . "','"
375 . $idom
376 . '\');"';
377 }
378
379 // http://doc.spip.org/@avoir_visiteurs
380 function avoir_visiteurs($past=false, $accepter=true) {
381 if ($GLOBALS['meta']["forums_publics"] == 'abo') return true;
382 if ($accepter AND $GLOBALS['meta']["accepter_visiteurs"] <> 'non') return true;
383 if (sql_countsel('spip_articles', "accepter_forum='abo'"))return true;
384 if (!$past) return false;
385 return sql_countsel('spip_auteurs', "statut NOT IN ('0minirezo','1comite', 'nouveau', '5poubelle')");
386 }
387
388
389 // http://doc.spip.org/@forum_logo
390 function forum_logo($statut)
391 {
392 if ($statut == "prive") return "forum-interne-24.gif";
393 else if ($statut == "privadm") return "forum-admin-24.gif";
394 else if ($statut == "privrac") return "forum-interne-24.gif";
395 else return "forum-public-24.gif";
396 }
397
398
399 // Retourne les parametres de personnalisation css de l'espace prive
400 // (ltr et couleurs) ce qui permet une ecriture comme :
401 // generer_url_public('style_prive', parametres_css_prive())
402 // qu'il est alors possible de recuperer dans le squelette style_prive.html avec
403 // #SET{claire,##ENV{couleur_claire,edf3fe}}
404 // #SET{foncee,##ENV{couleur_foncee,3874b0}}
405 // #SET{left,#ENV{ltr}|choixsiegal{left,left,right}}
406 // #SET{right,#ENV{ltr}|choixsiegal{left,right,left}}
407 // http://doc.spip.org/@parametres_css_prive
408 function parametres_css_prive(){
409 global $visiteur_session;
410 global $browser_name, $browser_version;
411
412 $ie = "";
413 include_spip('inc/layer');
414 if ($browser_name=='MSIE')
415 $ie = "&ie=$browser_version";
416
417 $v = "&v=".$GLOBALS['spip_version_code'];
418
419 $p = "&p=".substr(md5($GLOBALS['meta']['plugin']),0,4);
420
421 $c = (is_array($visiteur_session)
422 AND is_array($visiteur_session['prefs']))
423 ? $visiteur_session['prefs']['couleur']
424 : 1;
425
426 $couleurs = charger_fonction('couleurs', 'inc');
427 return 'ltr=' . $GLOBALS['spip_lang_left'] . '&'. $couleurs($c) . $v . $p . $ie ;
428 }
429
430
431 // http://doc.spip.org/@envoi_link
432 function envoi_link($nom_site_spip, $minipres=false, $js='') {
433 global $spip_display, $spip_lang;
434
435 $paramcss = parametres_css_prive();
436
437 // CSS de secours en cas de non fonct de la suivante
438 $res = '<link rel="stylesheet" type="text/css" href="'
439 . url_absolue(find_in_path('prive/style_prive_defaut.css'))
440 . '" id="cssprivee" />' . "\n"
441
442 // CSS calendrier
443 . (($GLOBALS['meta']['messagerie_agenda'] != 'non')
444 ? '<link rel="stylesheet" type="text/css" href="'
445 . url_absolue(find_in_path('agenda.css')) .'" />' . "\n"
446 : '')
447
448 // CSS des raccourcis
449 . '<link rel="stylesheet" type="text/css" href="'
450 . url_absolue(find_in_path('prive/spip_style.css'))
451 . '" media="all" />' . "\n"
452
453 // CSS imprimante (masque des trucs, a completer)
454 . '<link rel="stylesheet" type="text/css" href="'
455 . url_absolue(find_in_path('prive/spip_style_print.css'))
456 . '" media="print" />' . "\n"
457
458 // CSS "visible au chargement" differente selon js actif ou non
459
460 . '<link rel="stylesheet" type="text/css" href="'
461 . url_absolue(find_in_path('prive/spip_style_'
462 . (_SPIP_AJAX ? 'invisible' : 'visible')
463 . '.css'))
464 .'" />' . "\n"
465
466 // CSS espace prive : la vraie
467 . '<link rel="stylesheet" type="text/css" href="'
468 . generer_url_public('style_prive', $paramcss) .'" />' . "\n"
469 . "<!--[if lt IE 8]>\n"
470 . '<link rel="stylesheet" type="text/css" href="'
471 . generer_url_public('style_prive_ie', $paramcss) .'" />' . "\n"
472 . "<![endif]-->\n"
473
474 // CSS optionelle minipres
475 . ($minipres?'<link rel="stylesheet" type="text/css" href="'
476 . url_absolue(find_in_path('prive/minipres.css')).'" />' . "\n":"");
477
478 $favicon = find_in_path('spip.ico');
479
480 // favicon.ico
481 $res .= '<link rel="shortcut icon" href="'
482 . url_absolue($favicon)
483 . "\" type='image/x-icon' />\n";
484
485 $js = debut_javascript($js);
486
487 if ($spip_display == 4) return $res . $js;
488
489 $nom = entites_html($nom_site_spip);
490
491 $res .= "<link rel='alternate' type='application/rss+xml' title=\"$nom\" href='"
492 . generer_url_public('backend') . "' />\n";
493 $res .= "<link rel='help' type='text/html' title=\""._T('icone_aide_ligne') .
494 "\" href='"
495 . generer_url_ecrire('aide_index',"var_lang=$spip_lang")
496 ."' />\n";
497 if ($GLOBALS['meta']["activer_breves"] != "non")
498 $res .= "<link rel='alternate' type='application/rss+xml' title=\""
499 . $nom
500 . " ("._T("info_breves_03")
501 . ")\" href='" . generer_url_public('backend-breves') . "' />\n";
502
503 return $res . $js;
504 }
505
506 // http://doc.spip.org/@debut_javascript
507 function debut_javascript($fin='')
508 {
509 global $spip_lang_left, $browser_name, $browser_version;
510 include_spip('inc/charsets');
511
512 // tester les capacites JS :
513
514 // On envoie un script ajah ; si le script reussit le cookie passera a +1
515 // on installe egalement un <noscript></noscript> qui charge une image qui
516 // pose un cookie valant -1
517
518 $testeur = str_replace('&amp;', '\\x26', generer_url_ecrire('test_ajax', 'js=1'));
519
520 if (_SPIP_AJAX AND !defined('_TESTER_NOSCRIPT')) {
521 // pour le pied de page (deja defini si on est validation XML)
522 define('_TESTER_NOSCRIPT',
523 "<noscript>\n<div style='display:none;'><img src='"
524 . generer_url_ecrire('test_ajax', 'js=-1')
525 . "' width='1' height='1' alt='' /></div></noscript>\n");
526 }
527
528 if (!defined('_LARGEUR_ICONES_BANDEAU'))
529 include_spip('inc/bandeau');
530
531 $inline = ((isset($_COOKIE['spip_accepte_ajax']) && $_COOKIE['spip_accepte_ajax'] >= 1)
532 ? ''
533 : "jQuery.ajax({'url':'$testeur'});") .
534 (_OUTILS_DEVELOPPEURS ?"var _OUTILS_DEVELOPPEURS=true;":"") .
535 "\nvar ajax_image_searching = \n'<img src=\"".url_absolue(chemin_image("searching.gif"))."\" alt=\"\" />';" .
536 "\nvar stat = " . (($GLOBALS['meta']["activer_statistiques"] != 'non') ? 1 : 0) .
537 "\nvar largeur_icone = " .
538 intval(_LARGEUR_ICONES_BANDEAU) .
539 "\nvar bug_offsetwidth = " .
540 // uniquement affichage ltr: bug Mozilla dans offsetWidth quand ecran inverse!
541 ((($spip_lang_left == "left") &&
542 (($browser_name != "MSIE") ||
543 ($browser_version >= 6))) ? 1 : 0) .
544 "\nvar confirm_changer_statut = '" .
545 unicode_to_javascript(addslashes(html2unicode(_T("confirm_changer_statut")))) .
546 "';\n";
547 return
548 // envoi le fichier JS de config si browser ok.
549 $GLOBALS['browser_layer'] .
550 //plugin needed to fix the select showing through the submenus o IE6
551 (($browser_name == "MSIE" && $browser_version <= 6) ? http_script('', 'bgiframe.js'):'' ) .
552 http_script('', 'presentation.js') .
553 http_script('', 'gadgets.js') .
554 http_script($inline . $fin);
555 }
556
557 // Fonctions onglets
558
559
560 // http://doc.spip.org/@debut_onglet
561 function debut_onglet(){
562
563 return "
564 \n<div style='padding: 7px;'><table cellpadding='0' cellspacing='0' border='0' class='centered'><tr>
565 ";
566 }
567
568 // http://doc.spip.org/@fin_onglet
569 function fin_onglet(){
570 return "</tr></table></div>\n";
571 }
572
573 // http://doc.spip.org/@onglet
574 function onglet($texte, $lien, $onglet_ref, $onglet, $icone=""){
575 global $spip_display, $spip_lang_left ;
576
577 $res = "<td>";
578 $res .= "\n<div style='position: relative;'>";
579 if ($spip_display != 1) {
580 if (strlen($icone) > 0) {
581 $res .= "\n<div style='z-index: 2; position: absolute; top: 0px; $spip_lang_left: 5px;'>" .
582 http_img_pack("$icone", "", "") . "</div>";
583 $style = " top: 7px; padding-$spip_lang_left: 32px; z-index: 1;";
584 } else {
585 $style = " top: 7px;";
586 }
587 }
588
589 if ($onglet != $onglet_ref) {
590 $res .= "\n<div onmouseover=\"changeclass(this, 'onglet_on');\" onmouseout=\"changeclass(this, 'onglet');\" class='onglet' style='position: relative;$style'><a href='$lien'>$texte</a></div>";
591 $res .= "</div>";
592 } else {
593 $res .= "\n<div class='onglet_off' style='position: relative;$style'>$texte</div>";
594 $res .= "</div>";
595 }
596 $res .= "</td>";
597 return $res;
598 }
599
600 // http://doc.spip.org/@icone
601 function icone($texte, $lien, $fond, $fonction="", $align="", $echo=false){
602 $retour = "<div style='padding-top: 20px;width:100px' class='icone36'>" . icone_inline($texte, $lien, $fond, $fonction, $align) . "</div>";
603 if ($echo) echo_log('icone',$retour); else return $retour;
604 }
605
606 // http://doc.spip.org/@icone_inline
607 function icone_inline($texte, $lien, $fond, $fonction="", $align="", $ajax=false, $javascript=''){
608 global $spip_display;
609
610 if ($fonction == "supprimer.gif") {
611 $style = 'icone36 danger';
612 } else {
613 $style = 'icone36';
614 if (strlen($fonction) < 3) $fonction = "rien.gif";
615 }
616 $style .= " " . substr(basename($fond),0,-4);
617
618 if ($spip_display == 1){
619 $hauteur = 20;
620 $largeur = 100;
621 $title = $alt = "";
622 }
623 else if ($spip_display == 3){
624 $hauteur = 30;
625 $largeur = 30;
626 $title = "\ntitle=\"$texte\"";
627 $alt = $texte;
628 }
629 else {
630 $hauteur = 70;
631 $largeur = 100;
632 $title = '';
633 $alt = $texte;
634 }
635
636 $size = 24;
637 if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i",$fond,$match))
638 $size = $match[1];
639 if ($spip_display != 1 AND $spip_display != 4){
640 if ($fonction != "rien.gif"){
641 $icone = http_img_pack($fonction, $alt, "$title width='$size' height='$size'\n" .
642 http_style_background($fond, "no-repeat center center"));
643 }
644 else {
645 $icone = http_img_pack($fond, $alt, "$title width='$size' height='$size'");
646 }
647 } else $icone = '';
648
649 // cas d'ajax_action_auteur: faut defaire le boulot
650 // (il faudrait fusionner avec le cas $javascript)
651 if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i",$lien,$r))
652 list($x,$lien,$atts,$texte)= $r;
653 else $atts = '';
654
655 if ($align && $align!='center') $align = "float: $align; ";
656
657 $icone = "<a style='$align' class='$style'"
658 . $atts
659 . (!$ajax ? '' : (' onclick=' . ajax_action_declencheur($lien,$ajax)))
660 . $javascript
661 . "\nhref='"
662 . $lien
663 . "'>"
664 . $icone
665 . (($spip_display == 3) ? '' : "<span>$texte</span>")
666 . "</a>\n";
667
668 if ($align <> 'center') return $icone;
669 $style = " style='text-align:center;'";
670 return "<div$style>$icone</div>";
671 }
672
673 // http://doc.spip.org/@icone_horizontale
674 function icone_horizontale($texte, $lien, $fond = "", $fonction = "", $af = true, $javascript='') {
675 global $spip_display;
676
677 $retour = '';
678 // cas d'ajax_action_auteur: faut defaire le boulot
679 // (il faudrait fusionner avec le cas $javascript)
680 if (preg_match(",^<a href='([^']*)'([^>]*)>(.*)</a>$,i",$lien,$r))
681 list($x,$lien,$atts,$texte)= $r;
682 else $atts = '';
683 $lien = "\nhref='$lien'$atts";
684
685 if ($spip_display != 4) {
686
687 if ($spip_display != 1) {
688 $retour .= "\n<table class='cellule-h-table' cellpadding='0' style='vertical-align: middle'>"
689 . "\n<tr><td><a $javascript$lien class='cellule-h'>"
690 . "<span class='cell-i'>" ;
691 if ($fonction){
692 $retour .= http_img_pack($fonction, $texte, http_style_background($fond, "center center no-repeat"));
693 }
694 else {
695 $retour .= http_img_pack($fond, $texte, "");
696 }
697 $retour .= "</span></a></td>"
698 . "\n<td class='cellule-h-lien'><a $javascript$lien class='cellule-h'>"
699 . $texte
700 . "</a></td></tr></table>\n";
701 }
702 else {
703 $retour .= "\n<div><a class='cellule-h-texte' $javascript$lien>$texte</a></div>\n";
704 }
705 if ($fonction == "supprimer.gif")
706 $retour = "\n<div class='danger'>$retour</div>";
707 } else {
708 $retour = "\n<li><a$lien>$texte</a></li>";
709 }
710
711 if ($af) echo_log('icone_horizontale',$retour); else return $retour;
712 }
713
714 // http://doc.spip.org/@icone_horizontale_display
715 function icone_horizontale_display($texte, $lien, $fond = "", $fonction = "", $af = true, $js='') {
716 global $spip_display, $spip_lang_left;
717 $img = icone_horizontale($texte, $lien, $fond, $fonction, $af, $js);
718 if ($spip_display != 4)
719 return "<div style='float: $spip_lang_left; width:140px;'>$img</div>\n";
720 else return "<ul>$img</ul>";
721 }
722
723 // Fonction standard pour le pipeline 'boite_infos'
724 // http://doc.spip.org/@f_boite_infos
725 function f_boite_infos($flux) {
726 $args = $flux['args'];
727 $type = $args['type'];
728 unset($args['row']);
729 $flux['data'] .= recuperer_fond("prive/infos/$type",$args);
730 return $flux;
731 }
732
733
734 // http://doc.spip.org/@gros_titre
735 function gros_titre($titre, $ze_logo='', $aff=true){
736 global $spip_display;
737 $res = "\n<h1>";
738 if ($spip_display != 4) {
739 $res .= $ze_logo.' ';
740 }
741 $res .= typo($titre)."</h1>\n";
742 if ($aff) echo_log('gros_titre',$res); else return $res;
743 }
744
745
746 //
747 // Cadre centre (haut de page)
748 //
749
750 // http://doc.spip.org/@debut_grand_cadre
751 function debut_grand_cadre($return=false){
752 $res = "\n<div class='table_page'>\n";
753 if ($return) return $res; else echo_log('debut_grand_cadre',$res);
754 }
755
756 // http://doc.spip.org/@fin_grand_cadre
757 function fin_grand_cadre($return=false){
758 $res = "\n</div>";
759 if ($return) return $res; else echo_log('fin_grand_cadre',$res);
760 }
761
762 // Cadre formulaires
763
764 // http://doc.spip.org/@debut_cadre_formulaire
765 function debut_cadre_formulaire($style='', $return=false){
766 $x = "\n<div class='cadre-formulaire'" .
767 (!$style ? "" : " style='$style'") .
768 ">";
769 if ($return) return $x; else echo_log('debut_cadre_formulaire',$x);
770 }
771
772 // http://doc.spip.org/@fin_cadre_formulaire
773 function fin_cadre_formulaire($return=false){
774 if ($return) return "</div>\n"; else echo_log('fin_cadre_formulaire', "</div>\n");
775 }
776
777
778 // http://doc.spip.org/@formulaire_recherche
779 function formulaire_recherche($page, $complement=""){
780 $recherche = _request('recherche');
781 $recherche_aff = entites_html($recherche);
782 if (!strlen($recherche)) {
783 $recherche_aff = _T('info_rechercher');
784 $onfocus = " onfocus=\"this.value='';\"";
785 } else $onfocus = '';
786
787 $form = '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
788 $form .= "<input type='image' src='" . chemin_image('loupe.png') . "' name='submit' class='submit' alt='"._T('info_rechercher')."' />";
789 return "<div class='spip_recherche'>".generer_form_ecrire($page, $form . $complement, " method='get'")."</div>";
790 }
791
792 //
793 // Debut de la colonne de gauche
794 //
795
796 // http://doc.spip.org/@debut_gauche
797 function debut_gauche($rubrique = "accueil", $return=false) {
798 global $spip_display;
799 global $spip_ecran, $spip_lang_rtl, $spip_lang_left;
800
801 // div navigation fermee par creer_colonne_droite qui ouvre
802 // div extra lui-meme ferme par debut_droite qui ouvre
803 // div contenu lui-meme ferme par fin_gauche() ainsi que
804 // div conteneur
805
806 $res = "<br /><div id='conteneur' class='".(_INTERFACE_ONGLETS ? "onglets" : "no_onglets") ."'>
807 \n<div id='navigation'>\n";
808
809 if ($spip_display == 4) $res .= "<!-- ";
810
811 if ($return) return $res; else echo_log('debut_gauche',$res);
812 }
813
814 // http://doc.spip.org/@fin_gauche
815 function fin_gauche()
816 {
817 return "</div></div><div class='nettoyeur'></div>";
818 }
819
820 //
821 // Presentation de l''interface privee, marge de droite
822 //
823
824 // http://doc.spip.org/@creer_colonne_droite
825 function creer_colonne_droite($rubrique="", $return= false){
826 static $deja_colonne_droite;
827 global $spip_ecran, $spip_lang_rtl, $spip_lang_left;
828
829 if ((!($spip_ecran == "large")) OR $deja_colonne_droite) return '';
830 $deja_colonne_droite = true;
831
832 $res = "\n</div><div id='extra'>";
833
834 if ($return) return $res; else echo_log('creer_colonne_droite',$res);
835 }
836
837 // http://doc.spip.org/@formulaire_large
838 function formulaire_large()
839 {
840 return isset($_GET['exec'])?preg_match(',^((articles|breves|rubriques)_edit|poster_forum_prive),', $_GET['exec']):false;
841 }
842
843 // http://doc.spip.org/@debut_droite
844 function debut_droite($rubrique="", $return= false) {
845 global $spip_ecran, $spip_display, $spip_lang_left;
846
847 $res = '';
848
849 if ($spip_display == 4) $res .= " -->";
850
851 $res .= liste_articles_bloques();
852
853 $res .= creer_colonne_droite($rubrique, true)
854 . "</div>";
855
856 $res .= "\n<div id='contenu'>";
857
858 // touche d'acces rapide au debut du contenu : z
859 // Attention avant c'etait 's' mais c'est incompatible avec
860 // le ctrl-s qui fait "enregistrer"
861 $res .= "\n<a id='saut' href='#saut' accesskey='z'></a>\n";
862
863 if ($return) return $res; else echo_log('debut_droite',$res);
864 }
865
866 // http://doc.spip.org/@liste_articles_bloques
867 function liste_articles_bloques()
868 {
869 global $connect_id_auteur;
870
871 $res = '';
872 if ($GLOBALS['meta']["articles_modif"] != "non") {
873 include_spip('inc/drapeau_edition');
874 $articles_ouverts = liste_drapeau_edition ($connect_id_auteur, 'article');
875 if (count($articles_ouverts)) {
876 $res .=
877 debut_cadre('bandeau-rubriques',"article-24.gif",'',_T('info_cours_edition'))
878 . "\n<div class='plan-articles-bloques'>";
879 foreach ($articles_ouverts as $row) {
880 $ze_article = $row['id_article'];
881 $ze_titre = $row['titre'];
882 $statut = $row["statut"];
883
884 $res .= "\n<div class='$statut'>"
885 . "\n<div style='float:right; '>"
886 . debloquer_article($ze_article,_T('lien_liberer'))
887 . "</div>"
888 . "<a href='"
889 . generer_url_ecrire("articles","id_article=$ze_article")
890 . "'>$ze_titre</a>"
891 . "</div>";
892 }
893
894 if (count($articles_ouverts) >= 4) {
895 $res .= "\n<div style='text-align:right; '>"
896 . debloquer_article('tous', _T('lien_liberer_tous'))
897 . "</div>";
898 }
899 $res .= fin_cadre('bandeau-rubriques') . "</div>";
900 }
901 }
902 return $res;
903 }
904
905 //
906 // Fin de page de l'interface privee.
907 // Elle comporte une image invisible declenchant une tache de fond
908
909 // http://doc.spip.org/@fin_page
910 function fin_page()
911 {
912 global $spip_display;
913
914 return debut_grand_cadre(true)
915 . (($spip_display == 4)
916 ? ("<div><a href='"
917 . generer_action_auteur('preferer','display:2', self('&'))
918 . "'>"
919 . _T("access_interface_graphique")
920 . "</a></div>")
921 : ("<div style='text-align: right; ' class='verdana1 spip_xx-small'>"
922 . info_copyright()
923 . "<br />"
924 . info_maj_spip()
925 . _T('info_copyright_doc',
926 array('spipnet' => $GLOBALS['home_server']
927 . '/' . $GLOBALS['spip_lang']))
928 . '</div>'))
929
930 . fin_grand_cadre(true)
931 . "</div>\n" // cf. div centered ouverte dans conmmencer_page()
932 . $GLOBALS['rejoue_session']
933 . '<div style="background-image: url(\''
934 . generer_url_action('cron')
935 . '\');"></div>'
936 . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '')
937 . "</body></html>\n";
938 }
939
940 function info_maj_spip(){
941
942 $maj = $GLOBALS['meta']['info_maj_spip'];
943 if (!$maj)
944 return "";
945
946 $maj = explode('|',$maj);
947 // c'est une ancienne notif, on a fait la maj depuis !
948 if ($GLOBALS['spip_version_branche']!==array_shift($maj))
949 return "";
950
951 if (!autoriser('webmestre'))
952 return "";
953
954 $maj = implode('|',$maj);
955 if (strncmp($maj,"<a",2)==0) $maj = extraire_attribut ($maj, 'title');
956 $lien = "http://www.spip.net/".$GLOBALS['spip_lang']."_download";
957 $maj = "<a class='info_maj_spip' href='$lien'><strong>" .
958 _T('nouvelle_version_spip',array('version'=>$maj)) .
959 '</strong></a>.';
960
961 return "$maj<br />";
962 }
963
964 // http://doc.spip.org/@info_copyright
965 function info_copyright() {
966 global $spip_version_affichee, $spip_lang;
967
968 $version = $spip_version_affichee;
969
970 //
971 // Mention, le cas echeant, de la revision SVN courante
972 //
973 if ($svn_revision = version_svn_courante(_DIR_RACINE)) {
974 $version .= ' ' . (($svn_revision < 0) ? 'SVN ':'')
975 . "[<a href='http://core.spip.org/trac/spip/changeset/"
976 . abs($svn_revision) . "' onclick=\"window.open(this.href); return false;\">"
977 . abs($svn_revision) . "</a>]";
978 }
979
980 return _T('info_copyright',
981 array('spip' => "<b>SPIP $version</b> ",
982 'lien_gpl' =>
983 "<a href='". generer_url_ecrire("aide_index", "aide=licence&var_lang=$spip_lang") . "' onclick=\"window.open(this.href, 'spip_aide', 'scrollbars=yes,resizable=yes,width=740,height=580'); return false;\">" . _T('info_copyright_gpl')."</a>"));
984
985 }
986
987 // http://doc.spip.org/@debloquer_article
988 function debloquer_article($arg, $texte) {
989
990 // cas d'un article pas liberable : on est sur sa page d'edition
991 if (_request('exec') == 'articles_edit'
992 AND $arg == _request('id_article'))
993 return '';
994
995 $lien = parametre_url(self(), 'debloquer_article', '', '&');
996 return "<a href='" .
997 generer_action_auteur('instituer_collaboration', $arg, $lien) .
998 "' title=\"" .
999 attribut_html($texte) .
1000 "\">"
1001 . ($arg == 'tous' ? "$texte&nbsp;" : '')
1002 . http_img_pack("croix-rouge.gif", ($arg=='tous' ? "" : "X"),
1003 "width='7' height='7' ") .
1004 "</a>";
1005 }
1006
1007
1008 //
1009 // Afficher la hierarchie des rubriques
1010 //
1011
1012 // http://doc.spip.org/@afficher_hierarchie
1013 function afficher_hierarchie($id_parent, $message='',$id_objet=0,$type='',$id_secteur=0,$restreint='') {
1014 global $spip_lang_left,$spip_lang_right;
1015
1016 $out = "";
1017 $nav = "";
1018 if ($id_objet) {
1019 # desactiver le selecteur de rubrique sur le chemin
1020 # $nav = chercher_rubrique($message,$id_objet, $id_parent, $type, $id_secteur, $restreint,true);
1021 $nav = $nav ?"<div class='none'>$nav</div>":"";
1022 }
1023
1024 $parents = '';
1025 $style1 = "$spip_lang_left center no-repeat; padding-$spip_lang_left: 15px";
1026 $style2 = "margin-$spip_lang_left: 15px;";
1027 $tag = "a";
1028 $on = ' on';
1029
1030 $id_rubrique = $id_parent;
1031 while ($id_rubrique) {
1032
1033 $res = sql_fetsel("id_parent, titre, lang", "spip_rubriques", "id_rubrique=".intval($id_rubrique));
1034
1035 if (!$res){ // rubrique inexistante
1036 $id_rubrique = 0;
1037 break;
1038 }
1039
1040 $id_parent = $res['id_parent'];
1041 changer_typo($res['lang']);
1042
1043 $class = (!$id_parent) ? "secteur"
1044 : (acces_restreint_rubrique($id_rubrique)
1045 ? "admin" : "rubrique");
1046
1047 $parents = "<ul><li><span class='bloc'><em> &gt; </em><$tag class='$class$on'"
1048 . ($tag=='a'?" href='". generer_url_ecrire("naviguer","id_rubrique=$id_rubrique")."'":"")
1049 . ">"
1050 . supprimer_numero(typo(sinon($res['titre'], _T('ecrire:info_sans_titre'))))
1051 . "</$tag></span>"
1052 . $parents
1053 . "</li></ul>";
1054
1055 $id_rubrique = $id_parent;
1056 $tag = 'a';
1057 $on = '';
1058 }
1059
1060 $out .= $nav
1061 . "\n<ul id='chemin' class='verdana3' dir='".lang_dir()."'"
1062 //. http_style_background("racine-site-12.gif", $style1)
1063 . "><li><span class='bloc'><$tag class='racine$on'"
1064 . ($tag=='a'?" href='". generer_url_ecrire("naviguer","id_rubrique=$id_rubrique")."'":"")
1065 . ">"._T('info_racine_site')."</$tag>"
1066 . "</span>"
1067 . $parents
1068 . aide ("rubhier")
1069 . "</li></ul>"
1070 . ($nav?
1071 "&nbsp;<a href='#' onclick=\"$(this).prev().prev().toggle('fast');return false;\" class='verdana2'>"
1072 . _T('bouton_changer') ."</a>"
1073 :"");
1074
1075 $out = pipeline('affiche_hierarchie',array('args'=>array(
1076 'id_parent'=>$id_parent,
1077 'message'=>$message,
1078 'id_objet'=>$id_objet,
1079 'objet'=>$type,
1080 'id_secteur'=>$id_secteur,
1081 'restreint'=>$restreint),
1082 'data'=>$out));
1083
1084 return $out;
1085 }
1086
1087 // Pour construire des menu avec SELECTED
1088 // http://doc.spip.org/@mySel
1089 function mySel($varaut,$variable, $option = NULL) {
1090 $res = ' value="'.$varaut.'"' . (($variable==$varaut) ? ' selected="selected"' : '');
1091
1092 return (!isset($option) ? $res : "<option$res>$option</option>\n");
1093 }
1094
1095
1096 // Voir en ligne, ou apercu, ou rien (renvoie tout le bloc)
1097 // http://doc.spip.org/@voir_en_ligne
1098 function voir_en_ligne ($type, $id, $statut=false, $image='racine-24.gif', $af = true, $inline=true) {
1099
1100 $en_ligne = $message = '';
1101 switch ($type) {
1102 case 'article':
1103 if ($statut == "publie" AND $GLOBALS['meta']["post_dates"] == 'non') {
1104 $n = sql_fetsel("id_article", "spip_articles", "id_article=$id AND date<=".sql_quote(date('Y-m-d H:i:s')));
1105 if (!$n) $statut = 'prop';
1106 }
1107 if ($statut == 'publie')
1108 $en_ligne = 'calcul';
1109 else if ($statut == 'prop')
1110 $en_ligne = 'preview';
1111 break;
1112 case 'rubrique':
1113 if ($id > 0)
1114 if ($statut == 'publie')
1115 $en_ligne = 'calcul';
1116 else
1117 $en_ligne = 'preview';
1118 break;
1119 case 'breve':
1120 case 'site':
1121 if ($statut == 'publie')
1122 $en_ligne = 'calcul';
1123 else if ($statut == 'prop')
1124 $en_ligne = 'preview';
1125 break;
1126 case 'mot':
1127 $en_ligne = 'calcul';
1128 break;
1129 case 'auteur':
1130 $n = sql_fetsel('A.id_article', 'spip_auteurs_articles AS L LEFT JOIN spip_articles AS A ON L.id_article=A.id_article', "A.statut='publie' AND L.id_auteur=".sql_quote($id));
1131 if ($n) $en_ligne = 'calcul';
1132 else $en_ligne = 'preview';
1133 break;
1134 default: return '';
1135 }
1136
1137 if ($en_ligne == 'calcul')
1138 $message = _T('icone_voir_en_ligne');
1139 else if ($en_ligne == 'preview'
1140 AND autoriser('previsualiser'))
1141 $message = _T('previsualiser');
1142 else
1143 return '';
1144
1145 $h = generer_url_action('redirect', "type=$type&id=$id&var_mode=$en_ligne");
1146
1147 return $inline
1148 ? icone_inline($message, $h, $image, "rien.gif", $GLOBALS['spip_lang_left'])
1149 : icone_horizontale($message, $h, $image, "rien.gif",$af);
1150
1151 }
1152
1153 // http://doc.spip.org/@bouton_spip_rss
1154 function bouton_spip_rss($op, $args=array(), $lang='', $title='RSS') {
1155
1156 global $spip_lang_right;
1157 include_spip('inc/acces');
1158 $clic = http_img_pack('feed.png', 'RSS', '', $title);
1159 $args = param_low_sec($op, $args, $lang, 'rss');
1160 $url = generer_url_public('rss', $args);
1161 return "<a style='float: $spip_lang_right;' href='$url'>$clic</a>";
1162 }
1163 ?>