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