3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2011 *
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;
15 // http://doc.spip.org/@balise_FORMULAIRE_ADMIN
16 function balise_FORMULAIRE_ADMIN ($p) {
17 return calculer_balise_dynamique($p,'FORMULAIRE_ADMIN', array());
20 # on ne peut rien dire au moment de l'execution du squelette
22 // http://doc.spip.org/@balise_FORMULAIRE_ADMIN_stat
23 function balise_FORMULAIRE_ADMIN_stat($args, $context_compil) {
27 # les boutons admin sont mis d'autorite si absents
28 # donc une variable statique controle si FORMULAIRE_ADMIN a ete vu.
29 # Toutefois, si c'est le debuger qui appelle,
30 # il peut avoir recopie le code dans ses donnees et il faut le lui refounir.
31 # Pas question de recompiler: ca fait boucler !
32 # Le debuger transmet donc ses donnees, et cette balise y retrouve son petit.
34 // http://doc.spip.org/@balise_FORMULAIRE_ADMIN_dyn
35 function balise_FORMULAIRE_ADMIN_dyn($float='', $debug='') {
37 global $var_preview, $use_cache;
38 static $dejafait = false;
40 if (!@$_COOKIE['spip_admin'])
43 if (!is_array($debug)) {
48 if (empty($debug['sourcefile'])) return '';
49 foreach($debug['sourcefile'] as $k => $v) {
50 if (strpos($v,'administration.') !== false)
51 return $debug['resultat'][$k . 'tout'];
57 include_spip('inc/autoriser');
58 include_spip('base/abstract_sql');
63 // Preparer le #ENV des boutons
67 // Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
69 $env['ecrire'] = _DIR_RESTREINT_ABS
;
71 $env['divclass'] = $float;
72 $env['lang'] = admin_lang();
73 $env['calcul'] = (_request('var_mode') ?
'recalcul' : 'calcul');
74 $env['debug'] = $var_preview ?
"" : admin_debug();
75 $env['analyser'] = (!$env['debug'] AND !$GLOBALS['xhtml']) ?
'' : admin_valider();
76 $env['inclure'] = ($GLOBALS['var_inclure']?
'inclure':'');
79 $env['use_cache'] = ' *';
81 if (isset($debug['validation'])) {
82 $env['xhtml_error'] = $debug['validation'];
85 $env['_pipeline'] = 'formulaire_admin';
87 return array('formulaires/administration', 0, $env);
90 // Afficher le bouton 'Modifier ce...'
91 // s'il y a un $id_XXX defini globalement par spip_register_globals
92 // Attention a l'ordre dans la boucle:
93 // on ne veut pas la rubrique si un autre bouton est possible
95 // http://doc.spip.org/@admin_objet
96 function admin_objet()
98 include_spip('inc/urls');
101 foreach (array('mot','auteur','rubrique','breve','article','syndic'=>'site')
103 if (is_int($id)) $id = $obj;
104 $_id_type = id_table_objet($id);
105 if (isset($GLOBALS['contexte'][$_id_type]) AND $id_type = $GLOBALS['contexte'][$_id_type]) {
106 $id_type = sql_getfetsel($_id_type, table_objet_sql($id), "$_id_type=".intval($id_type));
108 $env[$_id_type] = $id_type;
110 $env['id_objet'] = $id_type;
111 $g = 'generer_url_ecrire_'.$obj;
113 str_replace('&', '&', $g($id_type, '','', 'prop'));
114 if ($id == 'article' OR $id == 'breve') {
115 unset($env['id_rubrique']);
116 unset($env['voir_rubrique']);
117 if ($l = admin_stats($id, $id_type, $var_preview)) {
118 $env['visites'] = $l[0];
119 $env['popularite'] = $l[1];
120 $env['statistiques'] = $l[2];
122 if (admin_preview($id, $id_type))
123 $env['preview']=parametre_url(self(),'var_mode','preview','&');
132 // http://doc.spip.org/@admin_preview
133 function admin_preview($id, $id_type)
135 if ($GLOBALS['var_preview']) return '';
137 if (!($id == 'article'
144 include_spip('inc/autoriser');
145 if (!autoriser('previsualiser')) return '';
147 $notpub = sql_in("statut", array('prop', 'prive'));
149 if ($id == 'article' AND $GLOBALS['meta']['post_dates'] != 'oui')
150 $notpub .= " OR (statut='publie' AND date>".sql_quote(date('Y-m-d H:i:s')).")";
152 return sql_fetsel('1', table_objet_sql($id), id_table_objet($id)."=".$id_type." AND ($notpub)");
156 // Regler les boutons dans la langue de l'admin (sinon tant pis)
159 // http://doc.spip.org/@admin_lang
160 function admin_lang()
162 $alang = sql_getfetsel('lang', 'spip_auteurs', "login=" . sql_quote(preg_replace(',^@,','',@$_COOKIE['spip_admin'])));
163 if (!$alang) return '';
165 $l = lang_select($alang);
166 $alang = $GLOBALS['spip_lang'];
167 if ($l) lang_select();
171 // http://doc.spip.org/@admin_valider
172 function admin_valider()
176 return ((@$xhtml !== 'true') ?
177 (parametre_url(self(), 'var_mode', 'debug', '&')
178 .'&var_mode_affiche=validation') :
179 ('http://validator.w3.org/check?uri='
180 . rawurlencode("http://" . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
183 // http://doc.spip.org/@admin_debug
184 function admin_debug()
187 (isset($GLOBALS['forcer_debug']) AND $GLOBALS['forcer_debug'])
188 OR (isset($GLOBALS['bouton_admin_debug']) AND $GLOBALS['bouton_admin_debug'])
190 isset($GLOBALS['var_mode'])
191 AND $GLOBALS['var_mode'] == 'debug'
192 AND $_COOKIE['spip_debug']
194 ) AND autoriser('debug')
196 ?
parametre_url(self(),'var_mode', 'debug', '&'): '';
200 // Tant que les stats ne sont pas passees dans une extension, il faut les traiter ici
201 // http://doc.spip.org/@admin_stats
202 function admin_stats($id, $id_type, $var_preview)
204 if ($GLOBALS['meta']["activer_statistiques"] != "non"
207 AND autoriser('voirstats')
209 $row = sql_fetsel("visites, popularite", "spip_articles", "id_article=$id_type AND statut='publie'");
212 return array(intval($row['visites']),
213 ceil($row['popularite']),
214 str_replace('&', '&', generer_url_ecrire_statistiques($id_type)));