1 | <?php |
---|
2 | |
---|
3 | /***************************************************************************\ |
---|
4 | * SPIP, Systeme de publication pour l'internet * |
---|
5 | * * |
---|
6 | * Copyright (c) 2001-2007 * |
---|
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; #securite |
---|
14 | |
---|
15 | |
---|
16 | // http://doc.spip.org/@balise_FORMULAIRE_ADMIN |
---|
17 | function balise_FORMULAIRE_ADMIN ($p) { |
---|
18 | return calculer_balise_dynamique($p,'FORMULAIRE_ADMIN', array()); |
---|
19 | } |
---|
20 | |
---|
21 | # on ne peut rien dire au moment de l'execution du squelette |
---|
22 | |
---|
23 | // http://doc.spip.org/@balise_FORMULAIRE_ADMIN_stat |
---|
24 | function balise_FORMULAIRE_ADMIN_stat($args, $filtres) { |
---|
25 | return $args; |
---|
26 | } |
---|
27 | |
---|
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. |
---|
34 | |
---|
35 | // http://doc.spip.org/@balise_FORMULAIRE_ADMIN_dyn |
---|
36 | function balise_FORMULAIRE_ADMIN_dyn($float='', $debug='') { |
---|
37 | |
---|
38 | global $var_preview, $use_cache, $forcer_debug, $xhtml; |
---|
39 | global $id_individu, $id_article, $id_breve, $id_rubrique, $id_mot, $id_auteur, $id_syndic; |
---|
40 | static $dejafait = false; |
---|
41 | |
---|
42 | if (!$GLOBALS['spip_admin']) |
---|
43 | return ''; |
---|
44 | |
---|
45 | if (!is_array($debug)) { |
---|
46 | if ($dejafait) |
---|
47 | return ''; |
---|
48 | } else { |
---|
49 | if ($dejafait) { |
---|
50 | $res = ''; |
---|
51 | foreach($debug['sourcefile'] as $k => $v) { |
---|
52 | if (strpos($v,'administration.') !== false) |
---|
53 | return $debug['resultat'][$k . 'tout']; |
---|
54 | } |
---|
55 | return ''; |
---|
56 | } |
---|
57 | } |
---|
58 | $dejafait = true; |
---|
59 | include_spip('inc/urls'); |
---|
60 | $objet_affiche = ''; |
---|
61 | |
---|
62 | // Ne pas afficher le bouton 'Modifier ce...' si l'objet n'existe pas |
---|
63 | foreach (array('individu', '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)) { |
---|
68 | $$id_type = $n; |
---|
69 | $objet_affiche = $type; |
---|
70 | break; |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | $statut = isset($GLOBALS['auteur_session']['statut']) ? |
---|
76 | $GLOBALS['auteur_session']['statut'] : ''; |
---|
77 | |
---|
78 | // Bouton statistiques |
---|
79 | $visites = $popularite = $statistiques = ''; |
---|
80 | if ($GLOBALS['meta']["activer_statistiques"] != "non" |
---|
81 | AND $id_article |
---|
82 | AND !$var_preview |
---|
83 | AND $statut == '0minirezo' |
---|
84 | ) { |
---|
85 | $result = spip_query("SELECT visites, popularite FROM spip_articles WHERE id_article=$id_article AND statut='publie'"); |
---|
86 | |
---|
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)); |
---|
91 | } |
---|
92 | } |
---|
93 | |
---|
94 | // Bouton de debug |
---|
95 | $debug = |
---|
96 | ( |
---|
97 | ( $forcer_debug |
---|
98 | OR $GLOBALS['bouton_admin_debug'] |
---|
99 | OR ( |
---|
100 | $GLOBALS['var_mode'] == 'debug' |
---|
101 | AND $GLOBALS['_COOKIE']['spip_debug'] |
---|
102 | ) |
---|
103 | ) AND ( |
---|
104 | $statut == '0minirezo' |
---|
105 | ) AND ( |
---|
106 | !$var_preview |
---|
107 | ) |
---|
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()))); |
---|
115 | |
---|
116 | // hack - ne pas avoir la rubrique si un autre bouton est deja present |
---|
117 | if ($id_article OR $id_breve) unset ($id_rubrique); |
---|
118 | |
---|
119 | // Pas de "modifier ce..." ? -> donner "acces a l'espace prive" |
---|
120 | if (!($id_individu || $id_article || $id_rubrique || $id_auteur || $id_breve || $id_mot || $id_syndic)) |
---|
121 | $ecrire = _DIR_RESTREINT_ABS; |
---|
122 | else $ecrire = ''; |
---|
123 | // Bouton "preview" si l'objet demande existe et est previsualisable |
---|
124 | $preview = false; |
---|
125 | |
---|
126 | if (!$GLOBALS['var_preview'] AND ( |
---|
127 | (($GLOBALS['meta']['preview']=='1comite' |
---|
128 | AND $statut =='1comite') |
---|
129 | OR ($GLOBALS['meta']['preview']<>'' |
---|
130 | AND $statut =='0minirezo')) |
---|
131 | )) { |
---|
132 | $p = ($objet_affiche == 'article' AND $GLOBALS['meta']['post_dates'] != 'oui'); |
---|
133 | |
---|
134 | if ($objet_affiche == 'article' |
---|
135 | OR $objet_affiche == 'individu' |
---|
136 | OR $objet_affiche == 'breve' |
---|
137 | OR $objet_affiche == 'rubrique' |
---|
138 | OR $objet_affiche == 'syndic') |
---|
139 | $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())") .")")); |
---|
140 | } |
---|
141 | |
---|
142 | // |
---|
143 | // Regler les boutons dans la langue de l'admin (sinon tant pis) |
---|
144 | // |
---|
145 | include_spip('inc/lang'); |
---|
146 | include_spip('base/abstract_sql'); |
---|
147 | $login = preg_replace(',^@,','',$GLOBALS['spip_admin']); |
---|
148 | $alang = spip_abstract_fetsel(array('lang'), array('spip_auteurs'), |
---|
149 | array("login=" . _q($login))); |
---|
150 | if ($alang['lang']) { |
---|
151 | lang_select($alang['lang']); |
---|
152 | $lang = $GLOBALS['spip_lang']; |
---|
153 | lang_dselect(); |
---|
154 | } else |
---|
155 | $lang = ''; |
---|
156 | |
---|
157 | // Preparer le #ENV des boutons |
---|
158 | $env = array( |
---|
159 | 'ecrire' => $ecrire, |
---|
160 | 'action' => self(), |
---|
161 | 'divclass' => $float, |
---|
162 | 'lang' => $lang, |
---|
163 | 'calcul' => (_request('var_mode') ? 'recalcul' : 'calcul'), |
---|
164 | ); |
---|
165 | |
---|
166 | if ($preview) |
---|
167 | $env['preview']=parametre_url(self(),'var_mode','preview','&'); |
---|
168 | if ($debug) |
---|
169 | $env['debug'] = $debug; |
---|
170 | if ($statistiques) { |
---|
171 | $env['popularite'] = $popularite; |
---|
172 | $env['statistiques'] = $statistiques; |
---|
173 | $env['visites'] = $visites; |
---|
174 | } |
---|
175 | if (!$use_cache) |
---|
176 | $env['use_cache'] = ' *'; |
---|
177 | if ($analyser) |
---|
178 | $env['analyser'] = $analyser; |
---|
179 | if (isset($GLOBALS['xhtml_error']) AND $GLOBALS['xhtml_error']) { |
---|
180 | $env['xhtml_error'] = count($GLOBALS['xhtml_error']); |
---|
181 | } |
---|
182 | foreach (array('individu', 'article','rubrique','auteur','breve','mot','syndic'=>'site') |
---|
183 | as $id => $obj) { |
---|
184 | if (is_int($id)) $id = $obj; |
---|
185 | if (${'id_'.$id}) { |
---|
186 | $env['id_'.$id] = ${'id_'.$id}; |
---|
187 | $g = 'generer_url_ecrire_'.$obj; |
---|
188 | $env['voir_'.$obj] = str_replace('&', '&', |
---|
189 | $g(${'id_'.$id}, 'prop')); |
---|
190 | } |
---|
191 | } |
---|
192 | |
---|
193 | return array('formulaires/administration', 0, $env); |
---|
194 | } |
---|
195 | |
---|
196 | ?> |
---|