Subversion Repositories Applications.papyrus

Rev

Rev 433 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1                                                                                      |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org)                                         |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of Integrateur Wikini.                                                             |
// |                                                                                                      |
// | Foobar is free software; you can redistribute it and/or modify                                       |
// | it under the terms of the GNU General Public License as published by                                 |
// | the Free Software Foundation; either version 2 of the License, or                                    |
// | (at your option) any later version.                                                                  |
// |                                                                                                      |
// | Foobar is distributed in the hope that it will be useful,                                            |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
// | GNU General Public License for more details.                                                         |
// |                                                                                                      |
// | You should have received a copy of the GNU General Public License                                    |
// | along with Foobar; if not, write to the Free Software                                                |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: integrateur_wikini.php,v 1.2 2005-08-25 08:59:12 ddelon Exp $
/**
* Integrateur de page Wikini
*
* Application permettant d'intégrer des pages wikini dans Papyrus.
*
*@package IntegrateurWikini
//Auteur original :
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author        Aucun
*@copyright     Tela-Botanica 2000-2004
*@version       $Revision: 1.2 $ $Date: 2005-08-25 08:59:12 $
*
// +------------------------------------------------------------------------------------------------------+
// |                                            ENTETE du PROGRAMME                                       |
// +------------------------------------------------------------------------------------------------------+
/** Inclusion de la classe PEAR de gestion des URL. */
require_once 'Net/URL.php';
/** Inclusion du fichier de configuration général de IntegrateurWikini.*/
require_once 'client'.GEN_SEP.'integrateur_wikini'.GEN_SEP.'configuration'.GEN_SEP.'iw_config.inc.php';

/** Inclusion du fichier permettant d'encoder du texte mais pas les balises XHTML.*/
require_once IW_CHEMIN_BIBLIO.'iw_encodage.fonct.php';
/** Inclusion du fichier permettant d'inclure les données dans du XHTML.*/
require_once IW_CHEMIN_BIBLIO.'iw_affichage_xhtml.fonct.php';

global $wiki;
global $wiki_p;

if ( ! isset( $_REQUEST['wiki'] ) ) {
    $_REQUEST['wiki'] = $GLOBALS['_GEN_commun']['info_application']->page;
}

$server=$_SERVER['PHP_SELF'];
$_SERVER['PHP_SELF']="wakka.php";

// Utilise le wakkaconfig de la racine ...
// TODO : generer un wakkaconfig en fonction des parametres, dans un temp et l'ecrire
// juste avant ... : bof (car conflits possibles).
// Ou alors : on utilise un wakkaconfig generique à minima ...
// Dans tous les cas, il faut gerer le WakaConfig Generique !
// Prevoir de revoir la contrib menu ... qui doit être switchable, ou plutot,
// Customiser son menu avec papyrus ...

ob_start();
include_once '/home/david/workspace/papyrus/wikini/wikini_01/wakka.php';
ob_end_clean();

$_SERVER['PHP_SELF']=$server;


// On surcharge la classe Wiki pour en faire ce qu'on en veut
Class Wiki_Papyrus extends Wiki {
    function Format($text, $formatter = "wakka") {
                return $this->IncludeBuffered("/home/david/workspace/papyrus/wikini/wikini_01/formatters/".$formatter.".php", "<i>Impossible de trouver le formateur \"$formatter\"</i>", compact("text")); 
        }
        function Header() {
                
                $sortie='';
                $sortie.='<h1 class="wiki_name">';
                // Todo : Initialiser : wakka_nom
                $sortie.= $this->config["wakka_name"];
                $sortie.='</h1>';
                $sortie.='<h1 class="page_name">';
                $sortie.='<a href="';
                $sortie.=$this->config["base_url"];
                $sortie.='RechercheTexte&amp;phrase=';
                $sortie.=htmlentities($this->GetPageTag());
                $sortie.='">';
                $sortie.=htmlentities($this->GetPageTag()); 
                $sortie.='</a>';
                $sortie.='</h1>';

                $sortie.='<div class="header">';
                $sortie.= $this->ComposeLinkToPage($this->config["root_page"]).'::';
                $sortie.= $this->config["navigation_links"] ? $this->Format($this->config["navigation_links"])." :: \n" : "";
                $sortie.='Vous &ecirc;tes ';
                $sortie.= $this->Format($this->GetUserName());
                if ($user = $this->GetUser()) { 
                        $sortie.="(<a href=\"".$this->config["base_url"]."ParametresUtilisateur&amp;action=logout\">D&eacute;connexion</a>)\n";
                }
                $sortie.='</div>';
                return $sortie;
        }
        
        function Footer() {
                return;
        }       
}


// Appel du fichier de traduction des textes de l'application Integrateur Wikini
if (file_exists(IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php')) {
    /** Inclusion du fichier de traduction de l'application Integrateur Wikini. */
    include_once IW_CHEMIN_LANGUES.'iw_langue_'.IW_I18N.'.inc.php';
} else {
    /** Inclusion du fichier de traduction fr par défaut. */
    include_once IW_CHEMIN_LANGUES.'iw_langue_fr.inc.php';
}


// +------------------------------------------------------------------------------------------------------+
// |                                            CORPS du PROGRAMME                                        |
// +------------------------------------------------------------------------------------------------------+
/** Fonction afficherContenuCorps() - Fonction appelé par le gestionnaire Papyrus.
*
* Elle retourne le contenu de l'application.
*
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
*/
function afficherContenuCorps()
{
        global $wiki;
        
        $sortie='';
        
    $wakkaConfig = $GLOBALS['wikini_config_defaut'];
    $wiki  = new Wiki_Papyrus($wakkaConfig);

        // Gestion de la variable de session "linktracking"
    if ( ! isset( $_SESSION['linktracking'] ) ) {
        $_SESSION['linktracking'] = 1;
    }

    // Suppression des slash.
    $_REQUEST['wiki'] = preg_replace("/^\//", '',  $_REQUEST['wiki']);

    // split into page/method
    if ( preg_match( "#^(.+?)/(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
        list(, $page, $method) = $matches;
    } else if ( preg_match( "#^(.*)$#",  $_REQUEST['wiki'], $matches ) ) {
        list(, $page) = $matches;
    }
    
    // Vérification de la méthode d'affichage employée!
    if ( ! isset( $method ) ) {
        $method = '';
    }
                
    //Récupération du contenu de la page Wikini
    
    ob_start();
    
    $server=$_SERVER['PHP_SELF'];
        $_SERVER['PHP_SELF']="wakka.php";
    
        $wiki->Run($page, $method);
    
    $_SERVER['PHP_SELF']=$server;
    
    $sortie.= ob_get_contents();
    ob_end_clean();



        return remplacerEntiteHTLM("<div id=\"wikini_page\" ondblclick=\"document.location='".$wiki->href("edit")."';"."\">"."\n".$sortie.'</div>'."\n"); 
                        
                
}


// TODO : qu'affiche-t-on en pied ?
/** Fonction afficherContenuPied() - Fonction appelé par le gestionnaire Papyrus.
*
* Elle retourne le pied de l'application.
*
* @return  string  du code XHTML correspondant au pied renvoyé par l'application.
*/
function afficherContenuPied()
{
    return inclusion_html('pied_page');
}
?>