PageRenderTime 48ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/spip/ecrire/inc/presentation.php

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