[ Index ]
 

Code source de WikiNi 0.4.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/actions/ -> include.php (source)

   1  <?php
   2  /*
   3  include.php : Permet d'inclure une page Wiki dans un autre page
   4  
   5  Copyright 2003  Eric FELDSTEIN
   6  Copyright 2003  Charles NEPOTE
   7  This program is free software; you can redistribute it and/or modify
   8  it under the terms of the GNU General Public License as published by
   9  the Free Software Foundation; either version 2 of the License, or
  10  (at your option) any later version.
  11  
  12  This program is distributed in the hope that it will be useful,
  13  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  GNU General Public License for more details.
  16  
  17  You should have received a copy of the GNU General Public License
  18  along with this program; if not, write to the Free Software
  19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20  */
  21  
  22  /* Paramètres :
  23   -- page : nom wiki de la page a inclure (obligatoire)
  24   -- class : nom de la classe de style à inclure (facultatif)
  25  */ 
  26  
  27  
  28  // récuperation du parametres
  29  $incPageName = $this->GetParameter("page");
  30  // TODO : améliorer le traitement des classes
  31  if ($this->GetParameter("class")) {
  32      $classes='';
  33      $array_classes = explode(" ", $this->GetParameter("class"));
  34      foreach ($array_classes as $c)
  35      {
  36          if ($c && preg_match('`^[A-Za-z0-9-_]+$`', $c))
  37          {
  38              $classes .= ($classes ? ' ':'') . "include_$c";
  39          }
  40      }
  41  }
  42  
  43  // Affichage de la page ou d'un message d'erreur
  44  if (empty($incPageName)) {
  45      echo $this->Format("//Le paramètre \"page\" est manquant.//");
  46  } else {
  47      if (eregi("^".$incPageName."$",$this->GetPageTag())) {
  48          echo $this->Format("//Impossible à une page de s'inclure dans elle même.//");
  49      } else {
  50          if (!$this->HasAccess("read",$incPageName)){
  51              echo $this->Format("//Lecture de la page inclue $page non autorisée.//");
  52          } else {
  53              $incPage = $this->LoadPage($incPageName);
  54              $output = $this->Format($incPage["body"]);
  55              if ($classes) echo "<div class=\"", $classes,"\">\n", $output, "</div>\n";
  56              else echo $output;
  57          }
  58      }
  59  }
  60  
  61  ?>


Généré le : Mon Nov 26 12:05:46 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics