[ Index ]
 

Code source de SPIP 1.9.2c

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/ecrire/exec/ -> admin_plugin.php (source)

   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;
  14  
  15  include_spip('inc/config');
  16  include_spip('inc/plugin');
  17  include_spip('inc/presentation');
  18  include_spip('inc/layer');
  19  include_spip('inc/actions');
  20  include_spip('inc/securiser_action');
  21  
  22  // http://doc.spip.org/@exec_admin_plugin
  23  function exec_admin_plugin() {
  24      global $connect_statut;
  25      global $connect_toutes_rubriques;
  26      global $spip_lang_right;
  27      $surligne = "";
  28  
  29      if ($connect_statut != '0minirezo' OR !$connect_toutes_rubriques) {
  30          $commencer_page = charger_fonction('commencer_page', 'inc');
  31          echo $commencer_page(_T('icone_admin_plugin'), "configuration", "plugin");
  32          echo _T('avis_non_acces_page');
  33          echo fin_gauche(), fin_page();
  34          exit;
  35      }
  36  
  37      verif_plugin();
  38      if (isset($_GET['surligne']))
  39          $surligne = $_GET['surligne'];
  40  
  41      global $couleur_claire;
  42      $commencer_page = charger_fonction('commencer_page', 'inc');
  43      echo $commencer_page(_T('icone_admin_plugin'), "configuration", "plugin");
  44      $dir_img_pack = _DIR_IMG_PACK;
  45      echo "<style type='text/css'>\n";
  46      echo <<<EOF
  47  div.cadre-padding ul li {
  48      list-style:none ;
  49  }
  50  div.cadre-padding ul {
  51      padding-left:1em;
  52      margin:.5em 0 .5em 0;
  53  }
  54  div.cadre-padding ul ul {
  55      border-left:5px solid #DFDFDF;
  56  }
  57  div.cadre-padding ul li li {
  58      margin:0;
  59      padding:0 0 0.25em 0;
  60  }
  61  div.cadre-padding ul li li div.nomplugin {
  62      border:1px solid #AFAFAF;
  63      padding:.3em .3em .6em .3em;
  64      font-weight:normal;
  65  }
  66  div.cadre-padding ul li li div.nomplugin a {
  67      outline:0;
  68      outline:0 !important;
  69      -moz-outline:0 !important;
  70  }
  71  div.cadre-padding ul li li div.nomplugin_on {
  72      background:$couleur_claire;
  73  }
  74  div.cadre-padding ul li li div.nomplugin_on>a {
  75      font-weight:bold;
  76  }
  77  
  78  div.cadre-padding div.droite label {
  79      padding:.3em;
  80      background:#EFEFEF;
  81      border:1px dotted #95989F !important;
  82      border:1px solid #95989F;
  83      cursor:pointer;
  84      margin:.2em;
  85      display:block;
  86      width:10.1em;
  87  }
  88  div.cadre-padding input {
  89      cursor:pointer;
  90  }
  91  div.detailplugin {
  92      border-top:1px solid #B5BECF;
  93      padding:.6em;
  94      background:#F5F5F5;
  95  }
  96  div.detailplugin hr {
  97      border-top:1px solid #67707F;
  98      border-bottom:0;
  99      border-left:0;
 100      border-right:0;
 101      }
 102  div.nomplugin label {display:none;}
 103  EOF;
 104      echo "</style>\n";
 105      echo "<br/><br/><br/>";
 106      
 107      echo gros_titre(_T('icone_admin_plugin'),'',false);
 108      // barre_onglets("configuration", "plugin"); // a creer dynamiquement en fonction des plugin charges qui utilisent une page admin ?
 109      
 110      echo debut_gauche('plugin',true);
 111      echo debut_boite_info(true);
 112      $s = "";
 113      $s .= _T('info_gauche_admin_tech');
 114      $s .= "<p><img src='"._DIR_IMG_PACK . "puce-poubelle.gif' width='9' height='9' alt='dev' /> "._T('plugin_etat_developpement')."</p>";
 115      $s .= "<p><img src='"._DIR_IMG_PACK . "puce-orange.gif' width='9' height='9' alt='dev' /> "._T('plugin_etat_test')."</p>";
 116      $s .= "<p><img src='"._DIR_IMG_PACK . "puce-verte.gif' width='9' height='9' alt='dev' /> "._T('plugin_etat_stable')."</p>";
 117      $s .= "<p><img src='"._DIR_IMG_PACK . "puce-rouge.gif' width='9' height='9' alt='dev' /> "._T('plugin_etat_experimental')."</p>";
 118      echo $s;
 119      echo fin_boite_info(true);
 120  
 121      // on fait l'installation ici, cela permet aux scripts d'install de faire des affichages ...
 122      installe_plugins();
 123  
 124      echo debut_droite('plugin',true);
 125  
 126      echo debut_cadre_relief('',true);
 127  
 128      global $couleur_foncee;
 129      echo "<table border='0' cellspacing='0' cellpadding='5' width='100%'>";
 130      echo "<tr><td style='background-color: $couleur_foncee' colspan='4'><b>";
 131      echo "<span style='color: #ffffff;' class='verdana1 spip_medium'>", _T('plugins_liste')."</span></b></td></tr>";
 132  
 133      echo "<tr><td class='serif' colspan='4'>";
 134      echo _T('texte_presente_plugin');
 135  
 136      $action = generer_action_auteur('activer_plugins','activer',generer_url_ecrire("admin_plugin"));
 137      echo "<form action='$action' method='post' >";
 138      echo form_hidden($action);
 139      echo "<div style='text-align:$spip_lang_right'>";
 140      echo "<input type='submit' name='Valider' value='"._T('bouton_valider')."' class='fondo' />";
 141      echo "</div>";
 142  
 143      affiche_arbre_plugins(liste_plugin_files(),liste_chemin_plugin_actifs());
 144  
 145      echo "\n<br />";
 146  
 147      echo "<div style='text-align:$spip_lang_right'>";
 148      echo "<input type='submit' name='Valider' value='"._T('bouton_valider')."' class='fondo' />";
 149      echo "</div>";
 150  
 151      echo "</form></tr></table>\n";
 152  
 153      echo "<br />";
 154  
 155      echo fin_gauche(), fin_page();
 156  
 157  }
 158  
 159  // http://doc.spip.org/@tree_open_close_dir
 160  function tree_open_close_dir(&$current,$target,$deplie=array()){
 161      if ($current == $target) return "";
 162      $tcur = explode("/",$current);
 163      $ttarg = explode("/",$target);
 164      $tcom = array();
 165      $output = "";
 166      // la partie commune
 167      while (reset($tcur)==reset($ttarg)){
 168          $tcom[] = array_shift($tcur);
 169          array_shift($ttarg);
 170      }
 171      // fermer les repertoires courant jusqu'au point de fork
 172      while($close = array_pop($tcur)){
 173          $output .= "</ul>\n";
 174          $output .= fin_block();
 175          $output .= "</li>\n";
 176      }
 177      $chemin = "";
 178      if (count($tcom))
 179          $chemin .= implode("/",$tcom)."/";
 180      // ouvrir les repertoires jusqu'a la cible
 181      while($open = array_shift($ttarg)){
 182          $visible = @isset($deplie[$chemin.$open]);
 183          $chemin .= $open . "/";
 184          $output .= "<li>";
 185          $output .= $visible? bouton_block_visible($chemin):bouton_block_invisible($chemin);
 186          $output .= "<span onclick=\"jQuery(this).prev().click();\">$chemin</span>\n";
 187  
 188          $output .= $visible? debut_block_visible($chemin):debut_block_invisible($chemin);
 189  
 190          $output .= "<ul>\n";
 191      }
 192      $current = $target;
 193      return $output;
 194  }
 195  
 196  // http://doc.spip.org/@affiche_arbre_plugins
 197  function affiche_arbre_plugins($liste_plugins,$liste_plugins_actifs){
 198      $racine = basename(_DIR_PLUGINS);
 199      $init_dir = $current_dir = "";
 200      // liste des repertoires deplies : construit en remontant l'arbo de chaque plugin actif
 201      // des qu'un path est deja note deplie on s'arrete
 202      $deplie = array($racine=>true);
 203      $fast_liste_plugins_actifs=array();
 204      foreach($liste_plugins_actifs as $key=>$plug){
 205          $fast_liste_plugins_actifs["$racine/$plug"]=true;
 206          $dir = dirname("$racine/$plug");$maxiter=100;
 207          while(strlen($dir) && !isset($deplie[$dir]) && $dir!=$racine && $maxiter-->0){
 208              $deplie[$dir] = true;
 209              $dir = dirname($dir);
 210          }
 211      }
 212      
 213      // index repertoires --> plugin
 214      $dir_index=array();
 215      foreach($liste_plugins as $key=>$plug){
 216          $liste_plugins[$key] = "$racine/$plug";
 217          $dir_index[dirname("$racine/$plug")][] = $key;
 218      }
 219      
 220      $visible = @isset($deplie[$current_dir]);
 221      $maxiter=1000;
 222      echo http_script("
 223      jQuery(function(){
 224          jQuery('input.check').click(function(){
 225              jQuery(this).parent().toggleClass('nomplugin_on');
 226          });
 227          jQuery('div.nomplugin a[@rel=info]').click(function(){
 228              if (!jQuery(this).siblings('div.info').html()) {
 229                  jQuery(this).siblings('div.info').prepend(ajax_image_searching).load(
 230                      jQuery(this).attr('href').replace(/admin_plugin/, 'info_plugin')
 231                  );
 232              } else {
 233                  jQuery(this).siblings('div.info').toggle();
 234              }
 235              return false;
 236          });
 237          var pack=jQuery('div.spip_pack');
 238          jQuery(pack).find('a').hide();
 239          jQuery(pack).find('img').bind('click',function(){jQuery(this).siblings('a').toggle();});
 240      });
 241      ");
 242  
 243      echo "<ul>";
 244      while (count($liste_plugins) && $maxiter--){
 245          // le rep suivant
 246          $dir = dirname(reset($liste_plugins));
 247          if ($dir != $current_dir)
 248              echo tree_open_close_dir($current_dir,$dir,$deplie);
 249              
 250          // d'abord tous les plugins du rep courant
 251          if (isset($dir_index[$current_dir]))
 252              foreach($dir_index[$current_dir] as $key){
 253                  $plug = $liste_plugins[$key];
 254                  $actif = @isset($fast_liste_plugins_actifs[$plug]);
 255                  $id = substr(md5($plug),0,16);
 256                  echo "<li>";
 257                  echo ligne_plug(substr($plug,strlen($racine)+1), $actif, $id);
 258                  echo "</li>\n";
 259                  unset($liste_plugins[$key]);
 260              }
 261      }
 262      echo tree_open_close_dir($current_dir,$init_dir);
 263      echo "</ul>";
 264  }
 265  
 266  // http://doc.spip.org/@ligne_plug
 267  function ligne_plug($plug_file, $actif, $id){
 268      global $spip_lang_right;
 269      static $id_input=0;
 270  
 271      $erreur = false;
 272      $vals = array();
 273      $info = plugin_get_infos($plug_file);
 274      $s = "<div class='nomplugin ".($actif?'nomplugin_on':'')."'>";
 275      if (isset($info['erreur'])){
 276          $s .=  "<div style='background:".$GLOBALS['couleur_claire']."'>";
 277          $erreur = true;
 278          foreach($info['erreur'] as $err)
 279              $s .= "/!\ $err <br/>";
 280          $s .=  "</div>";
 281      }
 282      
 283      // bouton de desinstallation
 284      if ($actif && plugin_est_installe($plug_file)){
 285          $s .= "<div style='float:$spip_lang_right' class='spip_pack'>";
 286          $action = generer_action_auteur('desinstaller_plugin',$plug_file,generer_url_ecrire('admin_plugin'));
 287          $s .= "<a href='$action'>"._T('bouton_effacer_tout')."</a>";
 288          $s .= http_img_pack('spip-pack-24.png','spip-pack','','spip-pack');
 289          $s .= "</div>";
 290      }
 291  
 292      $etat = 'dev';
 293      if (isset($info['etat']))
 294          $etat = $info['etat'];
 295      $nom = typo($info['nom']);
 296  
 297      $id = substr(md5("aide_$plug_file"),0,8);
 298      $puce_etat = array(
 299      "dev"=>"<img src='"._DIR_IMG_PACK . "puce-poubelle.gif' width='9' height='9' alt='dev' />",
 300      "test"=>"<img src='"._DIR_IMG_PACK . "puce-orange.gif' width='9' height='9' alt='dev' />",
 301      "stable"=>"<img src='"._DIR_IMG_PACK . "puce-verte.gif' width='9' height='9' alt='dev' />",
 302      "experimental"=>"<img src='"._DIR_IMG_PACK . "puce-rouge.gif' width='9' height='9' alt='dev' />",
 303      );
 304      
 305      if (isset($puce_etat[$etat]))
 306      $s .= $puce_etat[$etat];
 307  
 308      if (!$erreur){
 309          $name = 's' . substr(md5("statusplug_$plug_file"),0,16);
 310          $s .= "<input type='checkbox' name='$name' value='O' id='label_$id_input'";
 311          $s .= $actif?" checked='checked'":"";
 312          $s .= " class='check' />";
 313          $s .= "<label for='label_$id_input'>"._T('activer_plugin')."</label>";
 314      }
 315      $id_input++;
 316  
 317      //$s .= bouton_block_invisible("$plug_file");
 318      $url_stat = generer_url_ecrire(_request('exec'),"plug=".urlencode($plug_file));
 319      $s .= "<a href='$url_stat' rel='info'>$nom</a>";
 320  
 321      $s .= "<div class='info'>";
 322      // afficher les details d'un plug en secours
 323      if (urldecode(_request('plug'))==$plug_file)
 324          $s .= affiche_bloc_plugin($plug_file, $info);
 325      $s .= "</div>";
 326  
 327      $s .= "</div>";
 328      return $s;
 329  }
 330  ?>


Généré le : Wed Nov 21 10:20:27 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics