3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2007 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
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 \***************************************************************************/
13 if (!defined("_ECRIRE_INC_VERSION")) return; #securite
16 // http://doc.spip.org/@balise_FORMULAIRE_ADMIN
17 function balise_FORMULAIRE_ADMIN ($p) {
18 return calculer_balise_dynamique($p,'FORMULAIRE_ADMIN', array());
21 # on ne peut rien dire au moment de l'execution du squelette
23 // http://doc.spip.org/@balise_FORMULAIRE_ADMIN_stat
24 function balise_FORMULAIRE_ADMIN_stat($args, $filtres) {
28 # les boutons admin sont mis d'autorite si absents
29 # donc une variable statique controle si FORMULAIRE_ADMIN a ete vu.
30 # Toutefois, si c'est le debuger qui appelle,
31 # il peut avoir recopie le code dans ses donnees et il faut le lui refounir.
32 # Pas question de recompiler: ca fait boucler !
33 # Le debuger transmet donc ses donnees, et cette balise y retrouve son petit.
35 // http://doc.spip.org/@balise_FORMULAIRE_ADMIN_dyn
36 function balise_FORMULAIRE_ADMIN_dyn($float='', $debug='') {
38 global $var_preview, $use_cache, $forcer_debug, $xhtml;
39 global $id_article, $id_breve, $id_rubrique, $id_mot, $id_auteur, $id_syndic;
40 static $dejafait = false
;
42 if (!$GLOBALS['spip_admin'])
45 if (!is_array($debug)) {
51 foreach($debug['sourcefile'] as $k => $v) {
52 if (strpos($v,'administration.') !== false
)
53 return $debug['resultat'][$k . 'tout'];
59 include_spip('inc/urls');
62 // Ne pas afficher le bouton 'Modifier ce...' si l'objet n'existe pas
63 foreach (array('article', 'breve', 'rubrique', 'mot', 'auteur', 'syndic') as $type) {
64 $id_type = id_table_objet($type);
65 if ($n = intval($
$id_type)) {
66 $s = spip_query("SELECT $id_type FROM spip_".table_objet($type)." WHERE $id_type=".$
$id_type);
67 if ($s AND spip_num_rows($s)) {
69 $objet_affiche = $type;
75 $statut = isset($GLOBALS['auteur_session']['statut']) ?
76 $GLOBALS['auteur_session']['statut'] : '';
78 // Bouton statistiques
79 $visites = $popularite = $statistiques = '';
80 if ($GLOBALS['meta']["activer_statistiques"] != "non"
83 AND $statut == '0minirezo'
85 $result = spip_query("SELECT visites, popularite FROM spip_articles WHERE id_article=$id_article AND statut='publie'");
87 if ($row = @spip_fetch_array($result)) {
88 $visites = intval($row['visites']);
89 $popularite = ceil($row['popularite']);
90 $statistiques = str_replace('&', '&', generer_url_ecrire_statistiques($id_article));
98 OR $GLOBALS['bouton_admin_debug']
100 $GLOBALS['var_mode'] == 'debug'
101 AND $GLOBALS['_COOKIE']['spip_debug']
104 $statut == '0minirezo'
108 ) ?
parametre_url(self(),'var_mode', 'debug', '&'): '';
109 $analyser = !$xhtml ?
"" :
110 (($xhtml === 'sax') ?
111 (parametre_url(self(), 'var_mode', 'debug', '&')
112 .'&var_mode_affiche=validation') :
113 ('http://validator.w3.org/check?uri='
114 . rawurlencode("http://" . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
116 // hack - ne pas avoir la rubrique si un autre bouton est deja present
117 if ($id_article OR $id_breve) unset ($id_rubrique);
119 // Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
120 if (!($id_article ||
$id_rubrique ||
$id_auteur ||
$id_breve ||
$id_mot ||
$id_syndic))
121 $ecrire = _DIR_RESTREINT_ABS
;
123 // Bouton "preview" si l'objet demande existe et est previsualisable
126 if (!$GLOBALS['var_preview'] AND (
127 (($GLOBALS['meta']['preview']=='1comite'
128 AND $statut =='1comite')
129 OR ($GLOBALS['meta']['preview']<>''
130 AND $statut =='0minirezo'))
132 $p = ($objet_affiche == 'article' AND $GLOBALS['meta']['post_dates'] != 'oui');
134 if ($objet_affiche == 'article'
135 OR $objet_affiche == 'breve'
136 OR $objet_affiche == 'rubrique'
137 OR $objet_affiche == 'syndic')
138 $preview = spip_num_rows(spip_query("SELECT id_$objet_affiche FROM spip_".table_objet($objet_affiche)." WHERE ".id_table_objet($objet_affiche)."=".$
$id_type." AND ((statut IN ('prop', 'prive')) " . (!$p ?
'' : "OR (statut='publie' AND date>NOW())") .")"));
142 // Regler les boutons dans la langue de l'admin (sinon tant pis)
144 include_spip('inc/lang');
145 include_spip('base/abstract_sql');
146 $login = preg_replace(',^@,','',$GLOBALS['spip_admin']);
147 $alang = spip_abstract_fetsel(array('lang'), array('spip_auteurs'),
148 array("login=" . _q($login)));
149 if ($alang['lang']) {
150 lang_select($alang['lang']);
151 $lang = $GLOBALS['spip_lang'];
156 // Preparer le #ENV des boutons
160 'divclass' => $float,
162 'calcul' => (_request('var_mode') ?
'recalcul' : 'calcul'),
166 $env['preview']=parametre_url(self(),'var_mode','preview','&');
168 $env['debug'] = $debug;
170 $env['popularite'] = $popularite;
171 $env['statistiques'] = $statistiques;
172 $env['visites'] = $visites;
175 $env['use_cache'] = ' *';
177 $env['analyser'] = $analyser;
178 if (isset($GLOBALS['xhtml_error']) AND $GLOBALS['xhtml_error']) {
179 $env['xhtml_error'] = count($GLOBALS['xhtml_error']);
181 foreach (array('article','rubrique','auteur','breve','mot','syndic'=>'site')
183 if (is_int($id)) $id = $obj;
185 $env['id_'.$id] = $
{'id_'.$id};
186 $g = 'generer_url_ecrire_'.$obj;
187 $env['voir_'.$obj] = str_replace('&', '&',
188 $g($
{'id_'.$id}, 'prop'));
192 return array('formulaires/administration', 0, $env);