PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/spip/ecrire/balise/formulaire_admin.php

https://github.com/eyeswebcrea/espace-couture-sittler.fr
PHP | 221 lines | 143 code | 43 blank | 35 comment | 35 complexity | d89b02f2ab0e4781ff5203de3731a1fd 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. // http://doc.spip.org/@balise_FORMULAIRE_ADMIN
  13. function balise_FORMULAIRE_ADMIN ($p) {
  14. return calculer_balise_dynamique($p,'FORMULAIRE_ADMIN', array());
  15. }
  16. # on ne peut rien dire au moment de l'execution du squelette
  17. // http://doc.spip.org/@balise_FORMULAIRE_ADMIN_stat
  18. function balise_FORMULAIRE_ADMIN_stat($args, $context_compil) {
  19. return $args;
  20. }
  21. # les boutons admin sont mis d'autorite si absents
  22. # donc une variable statique controle si FORMULAIRE_ADMIN a ete vu.
  23. # Toutefois, si c'est le debuger qui appelle,
  24. # il peut avoir recopie le code dans ses donnees et il faut le lui refounir.
  25. # Pas question de recompiler: ca fait boucler !
  26. # Le debuger transmet donc ses donnees, et cette balise y retrouve son petit.
  27. // http://doc.spip.org/@balise_FORMULAIRE_ADMIN_dyn
  28. function balise_FORMULAIRE_ADMIN_dyn($float='', $debug='') {
  29. global $var_preview, $use_cache;
  30. static $dejafait = false;
  31. if (!@$_COOKIE['spip_admin'])
  32. return '';
  33. if (!is_array($debug)) {
  34. if ($dejafait)
  35. return '';
  36. } else {
  37. if ($dejafait) {
  38. if (empty($debug['sourcefile'])) return '';
  39. foreach($debug['sourcefile'] as $k => $v) {
  40. if (strpos($v,'administration.') !== false)
  41. return $debug['resultat'][$k . 'tout'];
  42. }
  43. return '';
  44. }
  45. }
  46. include_spip('inc/autoriser');
  47. include_spip('base/abstract_sql');
  48. $dejafait = true;
  49. // Preparer le #ENV des boutons
  50. $env = admin_objet();
  51. // Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
  52. if (!$env)
  53. $env['ecrire'] = _DIR_RESTREINT_ABS;
  54. $env['divclass'] = $float;
  55. $env['lang'] = admin_lang();
  56. $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
  57. $env['debug'] = $var_preview ? "" : admin_debug();
  58. $env['analyser'] = (!$env['debug'] AND !$GLOBALS['xhtml']) ? '' : admin_valider();
  59. $env['inclure'] = ($GLOBALS['var_inclure']?'inclure':'');
  60. if (!$use_cache)
  61. $env['use_cache'] = ' *';
  62. if (isset($debug['validation'])) {
  63. $env['xhtml_error'] = $debug['validation'];
  64. }
  65. $env['_pipeline'] = 'formulaire_admin';
  66. return array('formulaires/administration', 0, $env);
  67. }
  68. // Afficher le bouton 'Modifier ce...'
  69. // s'il y a un $id_XXX defini globalement par spip_register_globals
  70. // Attention a l'ordre dans la boucle:
  71. // on ne veut pas la rubrique si un autre bouton est possible
  72. // http://doc.spip.org/@admin_objet
  73. function admin_objet()
  74. {
  75. include_spip('inc/urls');
  76. $env = array();
  77. foreach (array('mot','auteur','rubrique','breve','article','syndic'=>'site')
  78. as $id => $obj) {
  79. if (is_int($id)) $id = $obj;
  80. $_id_type = id_table_objet($id);
  81. if (isset($GLOBALS['contexte'][$_id_type]) AND $id_type = $GLOBALS['contexte'][$_id_type]) {
  82. $id_type = sql_getfetsel($_id_type, table_objet_sql($id), "$_id_type=".intval($id_type));
  83. if ($id_type) {
  84. $env[$_id_type] = $id_type;
  85. $env['objet'] = $id;
  86. $env['id_objet'] = $id_type;
  87. $g = 'generer_url_ecrire_'.$obj;
  88. $env['voir_'.$obj] =
  89. str_replace('&amp;', '&', $g($id_type, '','', 'prop'));
  90. if ($id == 'article' OR $id == 'breve') {
  91. unset($env['id_rubrique']);
  92. unset($env['voir_rubrique']);
  93. if ($l = admin_stats($id, $id_type, $var_preview)) {
  94. $env['visites'] = $l[0];
  95. $env['popularite'] = $l[1];
  96. $env['statistiques'] = $l[2];
  97. }
  98. if (admin_preview($id, $id_type))
  99. $env['preview']=parametre_url(self(),'var_mode','preview','&');
  100. }
  101. }
  102. }
  103. }
  104. return $env;
  105. }
  106. // http://doc.spip.org/@admin_preview
  107. function admin_preview($id, $id_type)
  108. {
  109. if ($GLOBALS['var_preview']) return '';
  110. if (!($id == 'article'
  111. OR $id == 'breve'
  112. OR $id == 'rubrique'
  113. OR $id == 'syndic'))
  114. return '';
  115. include_spip('inc/autoriser');
  116. if (!autoriser('previsualiser')) return '';
  117. $notpub = sql_in("statut", array('prop', 'prive'));
  118. if ($id == 'article' AND $GLOBALS['meta']['post_dates'] != 'oui')
  119. $notpub .= " OR (statut='publie' AND date>".sql_quote(date('Y-m-d H:i:s')).")";
  120. return sql_fetsel('1', table_objet_sql($id), id_table_objet($id)."=".$id_type." AND ($notpub)");
  121. }
  122. //
  123. // Regler les boutons dans la langue de l'admin (sinon tant pis)
  124. //
  125. // http://doc.spip.org/@admin_lang
  126. function admin_lang()
  127. {
  128. $alang = sql_getfetsel('lang', 'spip_auteurs', "login=" . sql_quote(preg_replace(',^@,','',@$_COOKIE['spip_admin'])));
  129. if (!$alang) return '';
  130. $l = lang_select($alang);
  131. $alang = $GLOBALS['spip_lang'];
  132. if ($l) lang_select();
  133. return $alang;
  134. }
  135. // http://doc.spip.org/@admin_valider
  136. function admin_valider()
  137. {
  138. global $xhtml;
  139. return ((@$xhtml !== 'true') ?
  140. (parametre_url(self(), 'var_mode', 'debug', '&')
  141. .'&var_mode_affiche=validation') :
  142. ('http://validator.w3.org/check?uri='
  143. . rawurlencode("http://" . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
  144. }
  145. // http://doc.spip.org/@admin_debug
  146. function admin_debug()
  147. {
  148. return ((
  149. (isset($GLOBALS['forcer_debug']) AND $GLOBALS['forcer_debug'])
  150. OR (isset($GLOBALS['bouton_admin_debug']) AND $GLOBALS['bouton_admin_debug'])
  151. OR (
  152. isset($GLOBALS['var_mode'])
  153. AND $GLOBALS['var_mode'] == 'debug'
  154. AND $_COOKIE['spip_debug']
  155. )
  156. ) AND autoriser('debug')
  157. )
  158. ? parametre_url(self(),'var_mode', 'debug', '&'): '';
  159. }
  160. // Tant que les stats ne sont pas passees dans une extension, il faut les traiter ici
  161. // http://doc.spip.org/@admin_stats
  162. function admin_stats($id, $id_type, $var_preview)
  163. {
  164. if ($GLOBALS['meta']["activer_statistiques"] != "non"
  165. AND $id = 'article'
  166. AND !$var_preview
  167. AND autoriser('voirstats')
  168. ) {
  169. $row = sql_fetsel("visites, popularite", "spip_articles", "id_article=$id_type AND statut='publie'");
  170. if ($row) {
  171. return array(intval($row['visites']),
  172. ceil($row['popularite']),
  173. str_replace('&amp;', '&', generer_url_ecrire_statistiques($id_type)));
  174. }
  175. }
  176. return false;
  177. }
  178. ?>