[ Index ]
 

Code source de SPIP 1.9.2c

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/ecrire/exec/ -> aide_index.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/minipres');
  16  include_spip('inc/headers');
  17  include_spip('inc/layer');
  18  include_spip('inc/texte');
  19  
  20  /////////////////////////////
  21  // La frame de base
  22  //
  23  // http://doc.spip.org/@help_frame
  24  function help_frame ($aide, $lang) {
  25  
  26      $frame_menu = "<frame src='" . generer_url_ecrire('aide_index', "aide=$aide&var_lang=$lang&frame=menu", false, true) . "' name=\"gauche\" scrolling=\"auto\" />\n";
  27      $frame_body = "<frame src='" . generer_url_ecrire('aide_index', "aide=$aide&var_lang=$lang&frame=body", false, true) . "' name=\"droite\" scrolling=\"auto\" />\n";
  28  
  29      if ($GLOBALS['spip_lang_rtl']) {
  30        echo '<frameset cols="*,160" border="0" frameborder="0" framespacing="0">', $frame_body,$frame_menu, '</frameset>';
  31      }
  32      else {
  33        echo '<frameset cols="160,*" border="0" frameborder="0" framespacing="0">', $frame_menu,$frame_body, '</frameset>';
  34      }
  35  }
  36  
  37  
  38  
  39  /////////////////////////////
  40  // Le contenu demande
  41  //
  42  
  43  // Erreur aide non disponible
  44  // http://doc.spip.org/@erreur_aide_indisponible
  45  function erreur_aide_indisponible() {
  46      global $help_server;
  47      echo minipres(_T('forum_titre_erreur'),
  48           "<div>$help_server: "._T('aide_non_disponible')."</div><div align='right'>".menu_langues('var_lang_ecrire')."</div>");
  49      exit;
  50  }
  51  
  52  // Selection de l'aide correspondant a la langue demandee
  53  // http://doc.spip.org/@fichier_aide
  54  function fichier_aide($lang_aide = '') {
  55      global $help_server;
  56  
  57      if (!$lang_aide) $lang_aide = $GLOBALS['spip_lang'];
  58      $fichier_aide = _DIR_CACHE . "aide-$lang_aide-aide.html";
  59      $lastm = @filemtime($fichier_aide);
  60      $lastversion = @filemtime(_DIR_RESTREINT . 'inc_version.php');
  61  
  62      // en cache et a jour ?
  63      if (@is_readable($fichier_aide) AND ($lastm >= $lastversion)) {
  64          lire_fichier($fichier_aide, $contenu);
  65      } else {
  66          
  67        // Non, chercher les tables de la loi 
  68          if (isset($help_server)) {
  69              include_spip('inc/distant');
  70              if ($contenu = recuperer_page("$help_server/$lang_aide-aide.html")) {
  71                // mettre en cache (tant pis si on peut pas)
  72                  ecrire_fichier ($fichier_aide, $contenu);
  73                  $lastm = time();
  74              }
  75              
  76          } else $contenu = '';
  77      }
  78  
  79      if (strlen($contenu) > 500) return array($contenu, $lastm);
  80  
  81      // c'est cuit
  82      erreur_aide_indisponible();
  83  }
  84  
  85  define('_STYLE_AIDE_BODY', '
  86  <style type="text/css"><!--
  87  .spip_cadre {
  88      width : 100%;
  89      background-color: #FFFFFF;
  90      padding: 5px;
  91  }
  92  .spip_quote {
  93      margin-left : 40px;
  94      margin-top : 10px;
  95      margin-bottom : 10px;
  96      border : solid 1px #aaaaaa;
  97      background-color: #dddddd;
  98      padding: 5px;
  99  }
 100  
 101  a {text-decoration: none;}
 102  a:hover {color:#FF9900; text-decoration: underline;
 103  }
 104  
 105  body {
 106      font-family: Georgia, Garamond, Times New Roman, serif;
 107  }
 108  h3.spip {
 109      font-family: Verdana,Arial,Sans,sans-serif;
 110      font-weight: bold;
 111      font-size: 115%;
 112      text-align: center;
 113  }
 114  
 115  table.spip {
 116  }
 117  
 118  table.spip tr.row_first {
 119      background-color: #FCF4D0;
 120  }
 121  
 122  table.spip tr.row_odd {
 123      background-color: #C0C0C0;
 124  }
 125  
 126  table.spip tr.row_even {
 127      background-color: #F0F0F0;
 128  }
 129  
 130  table.spip td {
 131      padding: 1px;
 132      text-align: left;
 133      vertical-align: center;
 134  }
 135  
 136  --></style>');
 137  
 138  // http://doc.spip.org/@help_body
 139  function help_body($aide, $html, $lang_aide='') {
 140    global $help_server, $spip_lang_rtl;
 141  
 142      // Recuperation du contenu de l'aide demandee
 143  
 144      if ($aide) {
 145          $html = analyse_aide($html, $aide);
 146          if (!$html) {
 147              erreur_aide_indisponible();
 148          }
 149      } else {
 150          // panneau d'accueil
 151          $html = "<div align='center'>
 152              <img src='" . _DIR_IMG_PACK.
 153            "logo-spip.gif' alt='SPIP' style='width: 267px; height: 170px; border: 0px' />
 154              <br />
 155              <div align='center' style='font-variant: small-caps;'>
 156              Syst&egrave;me de publication pour l'Internet
 157              </div></div>
 158              <div style='position:absolute; bottom: 10px; right:20px;
 159              font-size: 12px; '>" .
 160          preg_replace(",<a ,i", "<a class='target_blank' ",_T('info_copyright_doc')).
 161              '</div>';
 162      }
 163  
 164      // Recherche des images de l'aide
 165      $suite = $html;
 166      $html = "";
 167      while (preg_match("@(<img([^<>]* +)? src=['\"])"
 168          . "((AIDE|IMG)/([-_a-zA-Z0-9]*/?)([^'\"<>]*))@i",
 169      $suite, $r)) {
 170          $p = strpos($suite, $r[0]);
 171          $img = str_replace('/', '-', $r[3]);
 172          $html .= substr($suite, 0, $p) .
 173            $r[1] . 
 174            generer_url_ecrire('aide_index', "img=$img", false, true);
 175          $suite = substr($suite, $p + strlen($r[0]));
 176      }
 177      
 178      echo '<script type="text/javascript"><!--
 179  
 180  jQuery(function(){
 181      jQuery("a.target_blank").click(function(){
 182          window.open(this.href);
 183          return false;
 184      });
 185  });
 186  
 187  //--></script>
 188  ';
 189      echo _STYLE_AIDE_BODY, "</head>\n";
 190  
 191      echo '<body bgcolor="#FFFFFF" text="#000000" topmargin="24" leftmargin="24" marginwidth="24" marginheight="24"';
 192      if ($spip_lang_rtl)
 193          echo " dir='rtl'";
 194      echo " lang='$lang_aide'>";
 195  
 196      if ($aide == 'spip') {
 197          echo "<table border='0' width='100%' height='60%'>
 198  <tr style='width: 100%' height='60%'>
 199  <td style='width: 100%' height='60%' align='center' valign='middle'>
 200  <img src='", generer_url_ecrire('aide_index', 'img=AIDE--logo-spip.gif', false, true),
 201            "' alt='SPIP' style='width: 300px; height: 170px; border: 0px;' />
 202  </td></tr></table>";
 203      }
 204  
 205      // Il faut que la langue de typo() soit celle de l'aide en ligne
 206      changer_typo($lang_aide);
 207  
 208      $html = justifier($html . $suite );
 209      // Remplacer les liens externes par des liens ouvrants (a cause des frames)
 210      $html = ereg_replace('<a href="(http://[^"]+)"([^>]*)>', '<a href="\\1"\\2 class="target_blank">', $html);
 211  
 212      echo $html, '</body>';
 213  }
 214  
 215  
 216  /////////////////////////////////////
 217  // Recuperer une image dans le cache
 218  //
 219  // http://doc.spip.org/@help_img
 220  function help_img($regs) {
 221      global $help_server;
 222  
 223      list ($cache, $rep, $lang, $file, $ext) = $regs;
 224  
 225      header("Content-Type: image/$ext");
 226      header("Expires: ".gmdate("D, d M Y H:i:s", time()+24*3600) .' GMT');
 227  
 228      if ($rep=="IMG" AND $lang=="cache"
 229      AND @file_exists($img_tex = _DIR_VAR.'cache-TeX/'.preg_replace(',^TeX-,', '', $file))) {
 230            readfile($img_tex);
 231      } else if (@file_exists($img = _DIR_CACHE . 'aide-'.$cache)) {
 232          readfile($img);
 233      } else if (@file_exists($img = _DIR_RACINE . 'AIDE/aide-'.$cache)) {
 234          readfile($img);
 235      } else if ($help_server) {
 236          include_spip('inc/distant');
 237          if (ecrire_fichier(_DIR_CACHE . 'aide-test', "test")
 238          AND ($contenu =
 239          recuperer_page("$help_server/$rep/$lang/$file"))) {
 240              echo $contenu;
 241              ecrire_fichier (_DIR_CACHE . 'aide-'.$cache, $contenu);
 242          } else
 243              redirige_par_entete("$help_server/$rep/$lang/$file");
 244      }
 245      exit;
 246  }
 247  
 248  
 249  define('AIDE_STYLE_MENU', '<style type="text/css">
 250  <!--
 251      a {text-decoration: none; }
 252      A:Hover {text-decoration: underline;}
 253  
 254      .article-inactif {
 255          float: '.$GLOBALS['spip_lang_left'].';
 256          text-align: '.$GLOBALS['spip_lang_left'].';
 257          width: 80%;
 258          background: ' . "url(" . _DIR_IMG_PACK . 'triangle'.$GLOBALS['spip_lang_rtl'].'.gif) ' . $GLOBALS['spip_lang_left'].' center no-repeat;
 259          margin: 2px;
 260          padding: 0px;
 261          padding-'.$GLOBALS['spip_lang_left'].': 20px;
 262          font-family: Arial, Sans, sans-serif;
 263          font-size: 12px;
 264      }
 265      .article-actif {
 266          float: '.$GLOBALS['spip_lang_right'].';
 267          text-align: '.$GLOBALS['spip_lang_right'].';
 268          width: 80%;
 269          background: ' . "url(" . _DIR_IMG_PACK . 'triangle'.$GLOBALS['spip_lang_rtl'].'.gif) ' . $GLOBALS['spip_lang_right'].' center no-repeat;
 270          margin: 4px;
 271          padding: 0px;
 272          padding-'.$GLOBALS['spip_lang_right'].': 20px;
 273          font-family: Arial, Sans, sans-serif;
 274          font-size: 12px;
 275          font-weight: bold;
 276          color: black;
 277      }
 278      .article-actif:hover {
 279          text-decoration: none;
 280      }
 281      .rubrique {
 282          width: 90%;
 283          margin: 0px;
 284          margin-top: 6px;
 285          margin-bottom: 4px;
 286          padding: 4px;
 287          font-family: Trebuchet MS, Arial, Sans, sans-serif;
 288          font-size: 14px;
 289          font-weight: bold;
 290          color: black;
 291          background-color: #EEEECC;
 292          -moz-border-radius: 4px;
 293      }
 294  -->
 295  </style>');
 296  
 297  ///////////////////////////////////////
 298  // Le menu de gauche
 299  //
 300  // http://doc.spip.org/@help_menu
 301  function help_menu($aide, $html, $lang_aide='') {
 302      global $spip_lang_rtl; 
 303  
 304      echo AIDE_STYLE_MENU, '<script type="text/javascript"><!--
 305  var curr_article;
 306  // http://doc.spip.org/@activer_article
 307  function activer_article(id) {
 308      if (curr_article)
 309          jQuery("#"+curr_article).removeClass("article-actif").addClass("article-inactif");
 310      if (id) {
 311          jQuery("#"+id).removeClass("article-inactif").addClass("article-actif");
 312          curr_article = id;
 313      }
 314  }
 315  
 316  jQuery(function(){
 317      jQuery("a.target_droite").click(function(){
 318          window.open(this.href,"droite");
 319          return false;
 320      });
 321  });
 322  
 323  //--></script>
 324  ',
 325      $GLOBALS['browser_layer'],
 326      '
 327  </head>
 328  <body bgcolor="#FFFFFF" text="#000000" link="#E86519" vlink="#6E003A" alink="#FF9900" topmargin="5" leftmargin="5" marginwidth="5" marginheight="5"';
 329  
 330      if ($spip_lang_rtl)
 331          echo " dir='rtl'";
 332      echo " lang='$lang_aide'>";
 333  
 334  
 335      // Recuperation et analyse de la structure de l'aide demandee
 336      $sections = analyse_aide($html);
 337      $rubrique_vue = false;
 338      foreach ($sections as $section) {
 339          if ($section[1] == '1') {
 340              if ($rubrique_vue)
 341                  fin_rubrique();
 342              rubrique($section[3].$section[5]);
 343              $rubrique_vue = true;
 344          } else
 345              article($section[5], $section[3]);
 346      }
 347      fin_rubrique();
 348  }
 349  
 350  
 351  // http://doc.spip.org/@rubrique
 352  function rubrique($titre, $statut = "redac") {
 353      global $ligne_rubrique;
 354      global $block_rubrique;
 355      global $titre_rubrique;
 356      global $afficher_rubrique, $ouvrir_rubrique;
 357      global $larubrique;
 358  
 359      global $aide_statut;
 360  
 361      $afficher_rubrique = 0;
 362  
 363      if (($statut == "admin" AND $aide_statut == "admin") OR ($statut == "redac")) {
 364          $larubrique++;
 365          $titre_rubrique = $titre;
 366          $ligne_rubrique = array();
 367          $block_rubrique = "block$larubrique";
 368          $afficher_rubrique = 1;
 369          $ouvrir_rubrique = 0;
 370      }
 371  }
 372  
 373  // http://doc.spip.org/@fin_rubrique
 374  function fin_rubrique() {
 375      global $ligne_rubrique;
 376      global $block_rubrique;
 377      global $titre_rubrique;
 378      global $afficher_rubrique, $ouvrir_rubrique;
 379      global $texte;
 380  
 381      if ($afficher_rubrique && count($ligne_rubrique)) {
 382          echo "<div class='rubrique'>";
 383          if ($ouvrir_rubrique)
 384              echo bouton_block_visible($block_rubrique);
 385          else 
 386              echo bouton_block_invisible($block_rubrique);
 387          echo $titre_rubrique;
 388          echo "</div>\n";
 389          if ($ouvrir_rubrique)
 390              echo debut_block_visible($block_rubrique);
 391          else
 392              echo debut_block_invisible($block_rubrique);
 393          echo "\n";
 394          reset($ligne_rubrique);
 395          while (list(, $ligne) = each($ligne_rubrique)) {
 396              echo $texte[$ligne];
 397          }
 398          echo fin_block();
 399          echo "\n\n";
 400      }
 401  }
 402  
 403  // http://doc.spip.org/@article
 404  function article($titre, $lien, $statut = "redac") {
 405      global $aide;
 406      global $ligne;
 407      global $ligne_rubrique;
 408      global $rubrique;
 409      global $texte;
 410      global $afficher_rubrique, $ouvrir_rubrique;
 411      global $aide_statut;
 412      global $spip_lang;
 413  
 414      if ($afficher_rubrique AND (($statut == "admin" AND $aide_statut == "admin") OR ($statut == "redac"))) {
 415          $ligne_rubrique[] = ++$ligne;
 416          
 417          $texte[$ligne] = '';
 418          $id = "ligne$ligne";
 419  
 420          if ($aide == $lien) {
 421              $ouvrir_rubrique = 1;
 422              $class = "article-actif";
 423              $texte[$ligne] .= "<script type='text/javascript'><!--\ncurr_article = '$id';\n// --></script>\n";
 424          }
 425          else {
 426              $class = "article-inactif";
 427          }
 428          $texte[$ligne] .= "<a class='$class target_droite' id='$id'
 429   href='" . generer_url_ecrire("aide_index", "aide=$lien&frame=body&var_lang=$spip_lang", false, true) .
 430            "' onclick=\"activer_article('$id');return true;\">$titre</a><br style='clear:both;' />\n";
 431      }
 432  }
 433  
 434  
 435  // http://doc.spip.org/@analyse_aide
 436  function analyse_aide($html, $aide=false) {
 437  
 438      // pas de sujet precis: retourner le tableau des sujets
 439      if (!$aide) {
 440          preg_match_all(',<h([12])( class="spip")?'. '>([^/]+?)(/(.+?))?</h\1>,ism',
 441      $html, $regs, PREG_SET_ORDER);
 442          return $regs;
 443      }
 444  
 445      // sinon retourner le chapitre demande
 446      $preg = ',<h2( class="spip")?'    . ">$aide/(.+?)</h2>(.*)$,ism";
 447      preg_match($preg, $html, $regs);
 448      return preg_replace(',<h[12].*,ism', '', $regs[3]);
 449  }
 450  
 451  //
 452  // Distribuer le travail
 453  //
 454  // http://doc.spip.org/@exec_aide_index_dist
 455  function exec_aide_index_dist()
 456  {
 457    global $img, $frame, $aide, $var_lang, $lang, $help_server, $spip_lang;
 458  
 459  if ($var_lang) changer_langue($var_lang);
 460  if ($lang) changer_langue($lang); # pour le cas ou on a fait appel au menu de changement de langue (aide absente dans la langue x)
 461   else $lang = $spip_lang;
 462  
 463  if (preg_match(',^([^-.]*)-([^-.]*)-([^\.]*\.(gif|jpg|png))$,', $img, $regs))
 464      help_img($regs);
 465  else {
 466      list($html, $lastmodified) = fichier_aide();
 467  
 468      // si on a la doc dans un fichier, controler if_modified_since
 469      if ($lastmodified) {
 470          $gmoddate = gmdate("D, d M Y H:i:s", $lastmodified);
 471          header("Last-Modified: ".$gmoddate." GMT");
 472          if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
 473              # MSoft IIS is dumb
 474          AND !preg_match(',IIS/,', $_SERVER['SERVER_SOFTWARE'])) {
 475  
 476              $if_modified_since = preg_replace('/;.*/', '',
 477                  $_SERVER['HTTP_IF_MODIFIED_SINCE']);
 478              $if_modified_since = trim(str_replace('GMT', '', $if_modified_since));
 479              if ($if_modified_since == $gmoddate) {
 480                  http_status(304);
 481                  exit;
 482              }
 483          }
 484      } 
 485  
 486      header("Content-Type: text/html; charset=utf-8");
 487      echo _DOCTYPE_AIDE, html_lang_attributes();
 488      echo "<head><title>", _T('info_aide_en_ligne'),    "</title>\n";
 489      include_spip("inc/filtres");
 490      echo f_jQuery("");
 491  
 492      if ($frame == 'menu')
 493          help_menu($aide, $html, $lang);
 494      else if ($frame == 'body') {
 495          help_body($aide, $html, $lang);
 496      } else {
 497          echo '</head>';
 498          help_frame($aide, $lang);
 499      }
 500      echo "\n</html>";
 501   }
 502  }
 503  ?>


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