Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1077 → Rev 1087

/branches/livraison_menes/api/text/wiki_papyrus/Parse/Inclure.php
New file
0,0 → 1,52
<?php
// $Id: Inclure.php,v 1.1 2004-11-26 12:13:28 jpm Exp $
 
 
/**
*
* This class implements a Text_Wiki_Parse to find source text marked as
* an Interwiki link. See the regex for a detailed explanation of the
* text matching procedure; e.g., "InterWikiName:PageName".
*
* @author Paul M. Jones <pmjones@ciaweb.net>
*
* @package Text_Wiki
*
*/
class Text_Wiki_Parse_Inclure extends Text_Wiki_Parse {
var $regex = '/\{\{inclure page="([A-Za-z0-9_]+)"(?: interwiki="([A-Za-z0-9_]+)"|)\}\}/';
/**
*
* Generates a replacement for the matched standalone interwiki text.
* Token options are:
*
* 'site' => The key name for the Text_Wiki interwiki array map,
* usually the name of the interwiki site.
*
* 'page' => The page on the target interwiki to link to.
*
* 'text' => The text to display as the link.
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token to be used as a placeholder in
* the source text, plus any text priot to the match.
*
*/
function process(&$matches)
{
$options = array(
'page' => $matches[1],
'site' => $matches[2],
'text' => $matches[0]
);
return $this->wiki->addToken($this->rule, $options);
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Parse/Categorie.php
New file
0,0 → 1,45
<?php
// $Id: Categorie.php,v 1.2 2005-05-27 13:41:24 jpm Exp $
 
 
/**
*
* This class implements a Text_Wiki_Parse to find source text marked as
* an Interwiki link. See the regex for a detailed explanation of the
* text matching procedure; e.g., "InterWikiName:PageName".
*
* @author Paul M. Jones <pmjones@ciaweb.net>
*
* @package Text_Wiki
*
*/
class Text_Wiki_Parse_Categorie extends Text_Wiki_Parse {
var $regex = '/\{\{Categorie mots="(.+?)"\}\}/';
/**
*
* Remplace l'action par une liste des pages contenant les mots clés choisis
* Les options sont:
*
* 'mots' => les mots clés séparés par des virgules
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token to be used as a placeholder in
* the source text, plus any text priot to the match.
*
*/
function process(&$matches)
{
$options = array(
'mots' => $matches[1]
);
return $this->wiki->addToken($this->rule, $options);
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Parse/Syndication.php
New file
0,0 → 1,51
<?php
// $Id: Syndication.php,v 1.7 2006-11-21 13:35:19 jp_milcent Exp $
 
 
/**
*
* This class implements a Text_Wiki_Parse to find source text marked as
* an Interwiki link. See the regex for a detailed explanation of the
* text matching procedure; e.g., "InterWikiName:PageName".
*
* @author Paul M. Jones <pmjones@ciaweb.net>
*
* @package Text_Wiki
*
*/
class Text_Wiki_Parse_Syndication extends Text_Wiki_Parse {
var $regex = '/\{\{Syndication titre="([^"]+)" url="([^"]+)"( nb=(?:"|)\d+(?:"|))?( nouvellefenetre=(?:"|)(?:0|1)(?:"|))?( formatdate="[^"]+")?( template="[^"]+")?\}\}/';
/**
*
* Remplace l'action par une liste des dernières pages modifièes
* Les options sont:
*
* 'site' => le code alphanumérique du ou des sites que l'on veut afficher
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token to be used as a placeholder in
* the source text, plus any text priot to the match.
*
*/
function process(&$matches)
{
// Gestion des paramêtres obligatoires
$options = array('titre' => $matches[1], 'url' => $matches[2]);
// Gestion des paramêtres optionnels
$tab_param_optionel = array('nb', 'nouvellefenetre', 'formatdate', 'template');
for ($i = 3; $i < count($matches); $i++) {
$tab_param = explode('=', $matches[$i]);
$options[trim($tab_param[0])] = str_replace('"', '', $tab_param[1]);
}
return $this->wiki->addToken($this->rule, $options);
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Parse/Motcles.php
New file
0,0 → 1,65
<?php
// $Id: Motcles.php,v 1.4 2005-07-08 15:14:51 alexandre_tb Exp $
 
 
/**
*
* This class implements a Text_Wiki_Parse to find source text marked as
* an Interwiki link. See the regex for a detailed explanation of the
* text matching procedure; e.g., "InterWikiName:PageName".
*
* @author Paul M. Jones <pmjones@ciaweb.net>
*
* @package Text_Wiki
*
*/
class Text_Wiki_Parse_Motcles extends Text_Wiki_Parse {
var $regex = '/\{\{MotCles mots="(.+?)"(?: condition="(ET|OU|et|ou)"|)(?: categorie="(.+?)"|)(?: condition="(ET|OU|et|ou)"|)(?: ordre="(ASC|DESC|asc|desc)"|)\}\}/';
/**
*
* Remplace l'action par une liste des pages contenant les mots clés choisis
* Les options sont:
*
* 'mots' => les mots clés séparés par des virgules
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token to be used as a placeholder in
* the source text, plus any text priot to the match.
*
*/
function process(&$matches)
{
$options = array(
'mots' => $matches[1],
'condition' => $matches[2],
'categorie' => $matches[3],
'condition2' => $matches[4],
'ordre' => $matches[5]
);
// Les conditions étant écrites en français, ce qui suit les traduit, "et" devient "AND" etc.
if (isset($options['condition'])) {
if ($options['condition'] == 'ET' || $options['condition'] == 'et') {
$options['condition'] = 'AND';
} elseif ($options['condition'] == 'OU' || $options['condition'] == 'ou') {
$options['condition'] = 'OR';
}
}
if (isset($options['condition2'])) {
if ($options['condition2'] == 'ET' || $options['condition2'] == 'et') {
$options['condition2'] = 'AND';
} elseif ($options['condition2'] == 'OU' || $options['condition2'] == 'ou') {
$options['condition2'] = 'OR';
}
}
return $this->wiki->addToken($this->rule, $options);
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Parse/Lien.php
New file
0,0 → 1,48
<?php
// $Id: Lien.php,v 1.2 2006-05-10 19:21:47 ddelon Exp $
 
 
/**
*
* This class implements a Text_Wiki_Parse to find source text marked as
* an Interwiki link. See the regex for a detailed explanation of the
* text matching procedure; e.g., "InterWikiName:PageName".
*
* @author Paul M. Jones <pmjones@ciaweb.net>
*
* @package Text_Wiki
*
*/
class Text_Wiki_Parse_Lien extends Text_Wiki_Parse {
var $regex = '/\{\{Lien ((?:menu)|(?:site))="((?:\w+)|(?:\d+))" (?:(?:titre)="(.*)")* *\}\}/';
/**
*
* Remplace l'action par une liste des dernières pages modifiées
* Les options sont:
*
* 'site' => le code alphanumérique du ou des sites que l'on veut afficher
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token to be used as a placeholder in
* the source text, plus any text priot to the match.
*
*/
function process(&$matches)
{
if (!isset($matches[3])) $matches[3]='';
$options = array(
'niveau' => $matches[1],
'identifiant' => $matches[2],
'titre' => $matches[3]
);
return $this->wiki->addToken($this->rule, $options);
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Parse/Redirection.php
New file
0,0 → 1,46
<?php
// $Id: Redirection.php,v 1.1 2005-09-23 13:58:07 ddelon Exp $
 
 
/**
*
* This class implements a Text_Wiki_Parse to find source text marked as
* an Interwiki link. See the regex for a detailed explanation of the
* text matching procedure; e.g., "InterWikiName:PageName".
*
* @author Paul M. Jones <pmjones@ciaweb.net>
*
* @package Text_Wiki
*
*/
class Text_Wiki_Parse_Redirection extends Text_Wiki_Parse {
var $regex = '/\{\{Redirection url="(.+?)"\}\}/';
/**
*
* Remplace l'action par une liste des pages contenant les mots clés choisis
* Les options sont:
*
* 'mots' => les mots clés séparés par des virgules
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token to be used as a placeholder in
* the source text, plus any text priot to the match.
*
*/
function process(&$matches)
{
$options = array(
'url' => $matches[1]
);
return $this->wiki->addToken($this->rule, $options);
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Parse/Plan.php
New file
0,0 → 1,51
<?php
// $Id: Plan.php,v 1.2 2005-05-25 14:05:31 jpm Exp $
 
 
/**
*
* This class implements a Text_Wiki_Parse to find source text marked as
* an Interwiki link. See the regex for a detailed explanation of the
* text matching procedure; e.g., "InterWikiName:PageName".
*
* @author Paul M. Jones <pmjones@ciaweb.net>
*
* @package Text_Wiki
*
*/
class Text_Wiki_Parse_Plan extends Text_Wiki_Parse {
var $regex = '/\{\{Plan site="((?i:[,-]|\w|\s)+)"(?: permalien="(oui|non)"|)\}\}/';
/**
*
* Remplace l'action par une liste des dernières pages modifiées
* Les options sont:
*
* 'site' => le code alphanumérique du ou des sites que l'on veut afficher
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token to be used as a placeholder in
* the source text, plus any text priot to the match.
*
*/
function process(&$matches)
{
if (isset($matches[2]) && $matches[2] == 'oui') {
$matches[2] = true;
} else {
$matches[2] = false;
}
$options = array(
'site' => $matches[1],
'permalien' => $matches[2]
);
return $this->wiki->addToken($this->rule, $options);
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Parse/Nouveaute.php
New file
0,0 → 1,48
<?php
// $Id: Nouveaute.php,v 1.2 2005-07-08 15:16:54 alexandre_tb Exp $
 
 
/**
*
* This class implements a Text_Wiki_Parse to find source text marked as
* an Interwiki link. See the regex for a detailed explanation of the
* text matching procedure; e.g., "InterWikiName:PageName".
*
* @author Paul M. Jones <pmjones@ciaweb.net>
*
* @package Text_Wiki
*
*/
class Text_Wiki_Parse_Nouveaute extends Text_Wiki_Parse {
var $regex = '/\{\{Nouveaute nombre="([1-9][0-9]*)"(?: categorie="(.+?)"|)(?: type="(mineure|majeure)"|)(?: site="((?i:[,-]|\w|\s)+)"|)\}\}/';
/**
*
* Remplace l'action par une liste des dernières pages modifiées
* Les options sont:
*
* 'nombre' => le nombre de dernière page modifiée que l'on veut afficher
*
* @access public
*
* @param array &$matches The array of matches from parse().
*
* @return A delimited token to be used as a placeholder in
* the source text, plus any text priot to the match.
*
*/
function process(&$matches)
{
$options = array(
'nombre' => $matches[1],
'categorie' => $matches[2],
'type' => $matches[3],
'site' => $matches[4]
);
return $this->wiki->addToken($this->rule, $options);
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Papyrus.class.php
New file
0,0 → 1,319
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.3 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of Papyrus. |
// | |
// | 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: Papyrus.class.php,v 1.8 2006-05-10 16:02:49 ddelon Exp $
/**
* Classe configurant le formatage pour Papyrus.
*
* Ce fichier contient une classe configurant les règles de formatage de Papyrus.
* Nécessite que l'application appelant ce fichier est précédement inclu le fichier de Pear:
* 'Text/Wiki.php';
*
*@package Text_Wiki
*@subpackage Papyrus
//Auteur original :
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.8 $ $Date: 2006-05-10 16:02:49 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
// +------------------------------------------------------------------------------------------------------+
// | CORPS du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
/**
*
* Parse structured wiki text and render into arbitrary formats such as XHTML.
*
* Cette classe fille permet de configurer les régles de formatage pour Papyrus.
* Généralement nous avons à faire à des actions.
*
* @author Paul M. Jones <pmjones@ciaweb.net>
* @package Text_Wiki
* @version 0.23.1
* @license LGPL
*/
class Text_Papyrus extends Text_Wiki {
/**
*
* Liste de règles par défaut du format Papyrs dans leur ordre d'application au texte
* à transformer.
*
* @access public
*
* @var array
*
*/
var $rules = array(
'Inclure', // Action Inclure
'Motcles', // Action Motcles
'Categorie', // Action Categorie
'Nouveaute', // Action Nouveaute
'Plan', // Action Plan
'Lien', // Action Lien
'Syndication', // Action Syndication
'Redirection' // Action Redirection
);
/**
*
* The list of rules to not-apply to the source text.
*
* @access public
*
* @var array
*
*/
var $disable = array();
/**
*
* The delimiter for token numbers of parsed elements in source text.
*
* @access public
*
* @var string
*
*/
var $delim = 12;
function Text_Papyrus($rules = null)
{
//Text_Wiki::Text_Wiki();
if (is_array($rules)) {
$this->rules = $rules;
}
// Nous devons sortir les fichiers de Text_Wiki du dépot Pear car la fonction file_exists de PHP utilisée dans
// la méthode findfile de Text_Wiki renvoie false.
$this->addPath('parse', $this->fixPath(dirname(__FILE__)) .'../../pear/Text/Wiki/Parse/');
$this->addPath('render', $this->fixPath(dirname(__FILE__)) .'../../pear/Text/Wiki/Render/');
// Pour les règles spécifiques à Papyrus:
$this->addPath('parse', $this->fixPath(dirname(__FILE__)) . 'Parse/');
$this->addPath('render', $this->fixPath(dirname(__FILE__)) . 'Render/');
}
/**
*
* Renders tokens back into the source text, based on the requested format.
*
* @access public
*
* @param string $format The target output format, typically 'xhtml'.
* If a rule does not support a given format, the output from that
* rule is rule-specific.
*
* @return string The transformed wiki text.
*
*/
function render($format = 'Xhtml')
{
// the rendering method we're going to use from each rule
$format = ucwords(strtolower($format));
// the eventual output text
$output = '';
// when passing through the parsed source text, keep track of when
// we are in a delimited section
$in_delim = false;
// when in a delimited section, capture the token key number
$key = '';
// load the format object
$this->loadFormatObj($format);
// pre-rendering activity
if (isset($this->formatObj[$format]) && is_object($this->formatObj[$format])) {
$output .= $this->formatObj[$format]->pre();
}
// load the render objects
foreach (array_keys($this->parseObj) as $rule) {
$this->loadRenderObj($format, $rule);
}
// pass through the parsed source text character by character
$k = strlen($this->source);
for ($i = 0; $i < $k; $i++) {
// the current character
$char = $this->source{$i};
// are alredy in a delimited section?
if ($in_delim) {
// yes; are we ending the section?
if ($char == chr($this->delim)) {
// yes, get the replacement text for the delimited
// token number and unset the flag.
$key = (int)$key;
$rule = null;
if (isset($this->tokens[$key][0])) {
$rule = $this->tokens[$key][0];
}
$opts = null;
if (isset($this->tokens[$key][1])) {
$opts = $this->tokens[$key][1];
}
if (isset($this->renderObj[$rule]) && is_object($this->renderObj[$rule])) {
$output .= $this->renderObj[$rule]->token($opts);
}
$in_delim = false;
} else {
// no, add to the dlimited token key number
$key .= $char;
}
} else {
// not currently in a delimited section.
// are we starting into a delimited section?
if ($char == chr($this->delim)) {
// yes, reset the previous key and
// set the flag.
$key = '';
$in_delim = true;
} else {
// no, add to the output as-is
$output .= $char;
}
}
}
// post-rendering activity
if (isset($this->formatObj[$format]) && is_object($this->formatObj[$format])) {
$output .= $this->formatObj[$format]->post();
}
// return the rendered source text.
return $output;
}
/**
*
* Add a token to the Text_Wiki tokens array, and return a delimited
* token number.
*
* @access public
*
* @param array $options An associative array of options for the new
* token array element. The keys and values are specific to the
* rule, and may or may not be common to other rule options. Typical
* options keys are 'text' and 'type' but may include others.
*
* @param boolean $id_only If true, return only the token number, not
* a delimited token string.
*
* @return string|int By default, return the number of the
* newly-created token array element with a delimiter prefix and
* suffix; however, if $id_only is set to true, return only the token
* number (no delimiters).
*
*/
function addToken($rule, $options = array(), $id_only = false)
{
// increment the token ID number. note that if you parse
// multiple times with the same Text_Wiki object, the ID number
// will not reset to zero.
static $id;
if (! isset($id)) {
$id = 0;
} else {
$id ++;
}
// force the options to be an array
settype($options, 'array');
// add the token
$this->tokens[$id] = array(
0 => $rule,
1 => $options
);
// return a value
if ($id_only) {
// return the last token number
return $id;
} else {
// return the token number with delimiters
return chr($this->delim) . $id . chr($this->delim);
}
}
}
 
// +------------------------------------------------------------------------------------------------------+
// | PIED du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
 
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.7 2005/09/23 13:58:07 ddelon
* Php5, Projet et Redirection
*
* Revision 1.6 2005/04/18 16:41:53 jpm
* Ajout des actions Plan et Syndication.
*
* Revision 1.5 2005/04/14 16:35:42 jpm
* Ajout de nouvelles actions pour Papyrus XHTML.
*
* Revision 1.4 2005/01/20 19:39:39 jpm
* Correction bogue du à la fonction file_exists qui renvoie false pour les fichiers présent dans le dossier Pear /usr/local/lib/php/.
*
* Revision 1.3 2004/12/07 12:17:37 jpm
* Correction message d'erreur.
*
* Revision 1.2 2004/11/26 12:13:03 jpm
* Correction de résidu...
*
* Revision 1.1 2004/11/26 12:11:49 jpm
* Ajout des action Papyrus à Text_Wiki.
*
* Revision 1.2 2004/11/25 15:36:41 jpm
* Suppression régle Delimiter car problème avec les délimitations de fin de ligne.
*
* Revision 1.1 2004/11/23 17:25:38 jpm
* Début classe PEAR WIKI pour la syntaxe Wikini.
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/branches/livraison_menes/api/text/wiki_papyrus/Render/Xhtml/Nouveaute.php
New file
0,0 → 1,164
<?php
 
class Text_Wiki_Render_Xhtml_Nouveaute extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// Initialisation des variables
$sortie = '';
$type = '';
$site = '';
$nombre = $options['nombre'];
// Récupération du type
if (isset($options['type'])) {
$type = $options['type'];
}
// Récupération du site
if (isset($options['site'])) {
$site = $options['site'];
}
// Récupération de la catégorie
if (isset($options['categorie'])) {
$categorie = $options['categorie'];
}
$aso_info_menu = GEN_lireInfoMenuContenuDate($GLOBALS['_GEN_commun']['pear_db'], $type, $site, $categorie);
// Formatage des infos en XHTML
$sortie .= '<ul class="page_liste">'."\n";
$i = 0;
foreach ($aso_info_menu as $menu_id => $un_menu) {
if ($i == $nombre) {
break;
}
// Création de l'url
$une_url =& new Pap_URL();
$une_url->setId($menu_id);
// Début affichage d'une entrée de la liste des pages modifiées
if ($un_menu->gmc_ce_type_modification = 1) {
$type_modif = 'mineure';
} elseif ($un_menu->gmc_ce_type_modification = 2) {
$type_modif = 'majeure';
}
$sortie .= '<li class="page_modification_'.$type_modif.'">'."\n";
// Affichage du titre
$sortie .= '<h2 class="page_titre"><a href="'.$une_url->getURL().'">';
if (!empty($un_menu->gm_titre)) {
$sortie .= $un_menu->gm_titre;
} elseif (!empty($un_menu->gm_titre_alternatif)) {
$sortie .= $un_menu->gm_titre_alternatif;
} else {
$sortie .= $un_menu->gm_nom;
}
$sortie .= '</a></h2>'."\n".'<dl>'."\n";
// Affichage de l'auteur(s)
if (!empty($un_menu->gm_auteur)) {
$sortie .= '<dt class="page_auteur"> Auteur(s)&nbsp;: '.'</dt>'."\n";
$sortie .= '<dd>'.$un_menu->gm_auteur.'</dd>'."\n";
}
// Affichage des contributeur(s)
if (!empty($un_menu->gm_contributeur)) {
$sortie .= '<dt class="page_contributeur"> Contributeur(s)&nbsp;: '.'</dt>'."\n";
$sortie .= '<dd>'.$un_menu->gm_contributeur.'</dd>'."\n";
}
// Affichage de la date de la modification de la page
$sortie .= '<dt class="page_modification_date"> '.'Modifié le&nbsp;: '.'</dt>'."\n";
$sortie .= '<dd>'."\n";
if (($jour = date('d', strtotime($un_menu->gmc_date_modification)) ) != 0 ) {
$sortie .= '<span class="page_modification_jour"> '.$jour.'</span>'."\n";
}
if (($mois = $this->_traduireMois(date('m', strtotime($un_menu->gmc_date_modification))) ) != '' ) {
$sortie .= '<span class="page_modification_mois"> '.$mois.'</span>'."\n";
}
if (($annee = date('Y', strtotime($un_menu->gmc_date_modification)) ) != 0 ) {
$sortie .= '<span class="page_modification_annee"> '.$annee.'</span>'."\n";
}
$sortie .= '<span class="page_separateur_date_heure"> - </span>'."\n";
// Affichage de l'horaire de la modification de la page
if (($heure = date('G', strtotime($un_menu->gmc_date_modification)) ) != 0 ) {
$sortie .= '<span class="page_modification_heure">'.$heure.'</span>';
$sortie .= '<span class="page_separateur_heure">:</span>';
$minute = date('i', strtotime($un_menu->gmc_date_modification));
$sortie .= '<span class="page_modification_minute">'.$minute.'</span>'."\n";
/*
if (($seconde = date('s', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
$sortie .= '<span class="page_separateur_heure">:</span>';
$sortie .= '<span class="page_creation_seconde">'.$seconde.'</span>';
}
*/
}
$sortie .= '</dd>'."\n";
// Affichage de la description
if (!empty($un_menu->gm_description_libre)) {
$sortie .= '<dt class="page_description"> Description&nbsp;: '.'</dt>'."\n";
$sortie .= '<dd>'.$un_menu->gm_description_libre.'</dd>'."\n";
}
// Affichage du résumé de la modification
if (!empty($un_menu->gmc_resume_modification)) {
$sortie .= '<dt class="page_resumer_modification_'.$type_modif.'"> Résumer modification&nbsp;: '.'</dt>'."\n";
$sortie .= '<dd>'.$un_menu->gmc_resume_modification.'</dd>'."\n";
}
$sortie .= '</dl>'."\n";
$sortie .= '</li>'."\n";
$i++;
}
$sortie .= '</ul>'."\n";
return $sortie;
}
function _traduireMois($mois_numerique)
{
switch ($mois_numerique) {
case '01' :
return 'janvier';
case '02' :
return 'février';
case '03' :
return 'mars';
case '04' :
return 'avril';
case '05' :
return 'mai';
case '06' :
return 'juin';
case '07' :
return 'juillet';
case '08' :
return 'août';
case '09' :
return 'septembre';
case '10' :
return 'octobre';
case '11' :
return 'novembre';
case '12' :
return 'décembre';
default:
return '';
}
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Render/Xhtml/Inclure.php
New file
0,0 → 1,69
<?php
 
class Text_Wiki_Render_Xhtml_Inclure extends Text_Wiki_Render {
var $conf = array(
'sites' => array(
'Wikipedia' => array('preg' => '/<!-- start content -->(.*)<!-- end content -->/Umsi', 'url' => 'http://fr.wikipedia.org/wiki/%s'),
'Wikipedia_fr' => array('preg' => '/<!-- start content -->(.*)<!-- end content -->/Umsi', 'url' => 'http://fr.wikipedia.org/wiki/%s'),
'Wikipedia_en' => array('preg' => '/<!-- start content -->(.*)<!-- end content -->/Umsi', 'url' => 'http://en.wikipedia.org/wiki/%s'),
'Wikini_eFlore' => array('preg' => '/<div class="page">(.*)<\/div>.*<div class="commentsheader">/Umsi', 'url' => 'http://wiki.tela-botanica.org/eflore/wakka.php?wiki=%s')
),
'css' => null,
'encodage' => 'iso-8859-15'
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$site = $options['site'];
$page = $options['page'];
$text = $options['text'];
$css = $this->formatConf(' class="%s"', 'css');
if (isset($this->conf['sites'][$site])) {
$href = $this->conf['sites'][$site]['url'];
} else {
return $text;
}
// old form where page is at end,
// or new form with %s placeholder for sprintf()?
if (strpos($href, '%s') === false) {
// use the old form
$href = $href . $page;
} else {
// use the new form
$href = sprintf($href, $page);
}
$output = '';
$contenu = file_get_contents($href);
$tab_matches='';
preg_match($this->conf['sites'][$site]['preg'], $contenu, $tab_matches);
$tab_encodage='';
preg_match('/<meta +http-equiv="Content-Type" +content="text\/html; *charset=(.+)"\/>/Ui', $contenu, $tab_encodage);
if (preg_match('/^(?:iso-8859-1|iso-8859-15)$/i', $this->conf['encodage']) && preg_match('/utf-8/i', $tab_encodage[1])) {
$output = utf8_decode($tab_matches[1]);
} else {
$output = $tab_matches[1];
}
return $output;
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Render/Xhtml/Categorie.php
New file
0,0 → 1,116
<?php
 
class Text_Wiki_Render_Xhtml_Categorie extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// Initialisation des variables
$sortie = '';
if (isset($options['mots'])) {
$mots = $options['mots'];
} else {
return '<p>'.' Aucune catégorie passé en paramêtre! '.'</p>';
}
// Récupération des infos
$tab_mots = explode(',', $mots);
for ($i = 0; $i < count($tab_mots); $i++) {
// Suppression des espaces, tabulations... en début et fin de chaine
$tab_mots[$i] = trim($tab_mots[$i]);
}
$aso_info_menu = GEN_lireInfoMenuCategorie($GLOBALS['_GEN_commun']['pear_db'], $tab_mots);
// Formatage des infos en XHTML
$sortie .= '<ul class="page_liste">'."\n";
foreach ($aso_info_menu as $id_menu => $un_menu) {
// Création de l'url
$une_url =& new Pap_URL();
$une_url->setId($id_menu);
$sortie .= '<li>'."\n";
// Affichage de l'auteur(s)
$sortie .= '<span class="page_auteur"> '.$un_menu->gm_auteur.'</span>';
$sortie .= '<span class="page_separateur_auteur"> - </span>';
// Affichage du titre
$sortie .= '<a href="'.$une_url->getURL().'">';
$sortie .= '<span class="page_titre"> '.$un_menu->gm_titre.'</span>';
$sortie .= '</a>';
$sortie .= '<span class="page_separateur_titre"> - </span>';
// Affichage de l'horaire de la création de la page
if (($heure = date('G', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
$sortie .= '<span class="page_creation_heure">'.$heure.'</span>';
$sortie .= '<span class="page_separateur_heure">:</span>';
$minute = date('i', strtotime($un_menu->gm_date_creation));
$sortie .= '<span class="page_creation_minute">'.$minute.'</span>';
if (($seconde = date('s', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
$sortie .= '<span class="page_separateur_heure">:</span>';
$sortie .= '<span class="page_creation_seconde">'.$seconde.'</span>';
}
}
$sortie .= '<span class="page_separateur_date_heure"> - </span>'."\n";
// Affichage de la date de la création de la page
if (($jour = date('d', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
$sortie .= '<span class="page_creation_jour"> '.$jour.'</span>';
}
if (($mois = $this->_traduireMois(date('m', strtotime($un_menu->gm_date_creation))) ) != '' ) {
$sortie .= '<span class="page_creation_mois"> '.$mois.'</span>';
}
if (($annee = date('Y', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
$sortie .= '<span class="page_creation_annee"> '.$annee.'</span>';
}
$sortie .= '</li>'."\n";
}
$sortie .= '</ul>'."\n";
return $sortie;
}
function _traduireMois($mois_numerique)
{
switch ($mois_numerique) {
case '01' :
return 'janvier';
case '02' :
return 'février';
case '03' :
return 'mars';
case '04' :
return 'avril';
case '05' :
return 'mai';
case '06' :
return 'juin';
case '07' :
return 'juillet';
case '08' :
return 'août';
case '09' :
return 'septembre';
case '10' :
return 'octobre';
case '11' :
return 'novembre';
case '12' :
return 'décembre';
default:
return '';
}
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Render/Xhtml/Syndication.php
New file
0,0 → 1,41
<?php
require_once GEN_CHEMIN_API.'syndication_rss/syndication_rss.php';
 
class Text_Wiki_Render_Xhtml_Syndication extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// Initialisation des variables
$sortie = '';
$titre = $options['titre'];
$urls = $options['url'];
$tab_param_optionel = array('nb', 'nouvellefenetre', 'formatdate', 'template');
foreach ($tab_param_optionel as $val) {
if (isset($options[$val])) {
$options[$val] = $options[$val];
} else {
$options[$val] = null;
}
}
$tab_url = array_map('trim', explode(',', $urls));
foreach ($tab_url as $cle => $url) {
$url = str_replace('&amp;', '&', $url) ;
$sortie .= voir_rss($titre, $url, $options['nb'], $options['nouvellefenetre'], $options['formatdate'], $options['template']);
}
return $sortie;
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Render/Xhtml/Motcles.php
New file
0,0 → 1,138
<?php
 
class Text_Wiki_Render_Xhtml_Motcles extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// Initialisation des variables
$sortie = '';
if (isset($options['mots'])) {
$mots = $options['mots'];
} else {
return '<p>'.' Aucun mot-clés passé en paramêtre! '.'</p>';
}
$condition = 'OR';
if (isset($options['condition'])) {
$condition = $options['condition'];
}
$condition2 = 'OR';
if (isset($options['condition2'])) {
$condition2 = $options['condition2'];
}
$ordre = 'ASC';
if (isset($options['ordre'])) {
$ordre = $options['ordre'];
}
if (isset($options['categorie'])) {
$categorie = $options['categorie'] ;
}
// Récupération des infos sur les mots
$tab_mots = explode(',', $mots);
for ($i = 0; $i < count($tab_mots); $i++) {
// Suppression des espaces, tabulations... en début et fin de chaine
$tab_mots[$i] = trim($tab_mots[$i]);
}
// Récupération des infos sur les catégories
$tab_cat = explode(',', $categorie) ;
for ($i = 0; $i < count($tab_cat); $i++) {
// Suppression des espaces, tabulations... en début et fin de chaine
$tab_cat[$i] = trim($tab_cat[$i]);
}
$aso_info_menu = GEN_lireInfoMenuMeta($GLOBALS['_GEN_commun']['pear_db'], $tab_mots, $tab_cat, $condition, $condition2, $ordre);
// Formatage des infos en XHTML
$sortie .= '<ul class="page_liste">'."\n";
foreach ($aso_info_menu as $id_menu => $un_menu) {
// Création de l'url
$une_url =& new Pap_URL();
$une_url->setId($id_menu);
$sortie .= '<li>'."\n";
// Affichage de l'auteur(s)
$sortie .= '<span class="page_auteur"> '.$un_menu->gm_auteur.'</span>'."\n";
$sortie .= '<span class="page_separateur_auteur"> - </span>'."\n";
// Affichage du titre
$sortie .= '<a href="'.$une_url->getURL().'">';
$sortie .= '<span class="page_titre"> '.$un_menu->gm_titre.'</span>';
$sortie .= '</a>'."\n";
$sortie .= '<span class="page_separateur_titre"> - </span>'."\n";
// Affichage de l'horaire de la création de la page
if (($heure = date('G', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
$sortie .= '<span class="page_creation_heure">'.$heure.'</span>';
$sortie .= '<span class="page_separateur_heure">:</span>';
$minute = date('i', strtotime($un_menu->gm_date_creation));
$sortie .= '<span class="page_creation_minute">'.$minute.'</span>';
if (($seconde = date('s', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
$sortie .= '<span class="page_separateur_heure">:</span>';
$sortie .= '<span class="page_creation_seconde">'.$seconde.'</span>';
}
}
$sortie .= "\n".'<span class="page_separateur_date_heure"> - </span>'."\n";
// Affichage de la date de la création de la page
if (($jour = date('d', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
$sortie .= '<span class="page_creation_jour"> '.$jour.'</span>'."\n";
}
if (($mois = $this->_traduireMois(date('m', strtotime($un_menu->gm_date_creation))) ) != '' ) {
$sortie .= '<span class="page_creation_mois"> '.$mois.'</span>'."\n";
}
if (($annee = date('Y', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
$sortie .= '<span class="page_creation_annee"> '.$annee.'</span>'."\n";
}
$sortie .= '</li>'."\n";
}
$sortie .= '</ul>'."\n";
return $sortie;
}
function _traduireMois($mois_numerique)
{
switch ($mois_numerique) {
case '01' :
return 'janvier';
case '02' :
return 'février';
case '03' :
return 'mars';
case '04' :
return 'avril';
case '05' :
return 'mai';
case '06' :
return 'juin';
case '07' :
return 'juillet';
case '08' :
return 'août';
case '09' :
return 'septembre';
case '10' :
return 'octobre';
case '11' :
return 'novembre';
case '12' :
return 'décembre';
default:
return '';
}
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Render/Xhtml/Lien.php
New file
0,0 → 1,143
<?php
 
class Text_Wiki_Render_Xhtml_Lien extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
 
// Initialisation des variables
$sortie = '';
$niveau = $options['niveau'];
$identifiant = $options['identifiant'];
$titre = $options['titre'];
$bdd =& $GLOBALS['_GEN_commun']['pear_db'];
$id_langue = $GLOBALS['_GEN_commun']['i18n']; //identifiant de la langue choisie
if (isset($id_langue) && ($id_langue!='')) {
$langue_url=$id_langue;
} else {
$langue_url=GEN_I18N_ID_DEFAUT;
}
$une_url =& new Pap_URL('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
$nom='';
if ($niveau=="site") {
$requete = 'SELECT distinct * '.
'FROM gen_site ';
if (is_numeric($identifiant)) {
$requete .= 'WHERE gs_code_num = '.$identifiant.' ';
$une_url->addQueryString(GEN_URL_CLE_SITE, $identifiant);
}
$resultat = $bdd->query($requete);
(DB::isError($resultat)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '';
$aso_site = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$resultat->free();
$requete_traduction = 'SELECT * '.
'FROM gen_site_relation, gen_site '.
'WHERE gs_id_site = gsr_id_site_02 ' .
'AND '.$identifiant.' = gs_code_num '.
'AND gsr_id_valeur = 1 '.// 1 = "avoir traduction"
'AND gs_ce_i18n = "'.$langue_url.'" ';
$resultat_traduction = $bdd->query($requete_traduction);
(DB::isError($resultat_traduction)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_traduction->getMessage(), $requete_traduction))
: '';
if ( $resultat_traduction->numRows() > 0 ) {
$aso_site=$resultat_traduction->fetchRow(DB_FETCHMODE_ASSOC);
}
if ($titre=='') {
if (!empty($aso_site['gs_nom'])) {
$titre = $aso_site['gs_nom'];
} else {
$titre = $aso_site['gs_titre'];
}
}
}
// Menu
else {
$requete = 'SELECT distinct * '.
'FROM gen_menu ';
if (is_numeric($identifiant)) {
$requete .= 'WHERE gm_code_num = '.$identifiant.' ';
$une_url->addQueryString(GEN_URL_CLE_MENU, $identifiant);
}
$resultat = $bdd->query($requete);
(DB::isError($resultat)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '';
$aso_menu = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$resultat->free();
$requete_traduction = 'SELECT * '.
'FROM gen_menu_relation, gen_menu '.
'WHERE '.$identifiant.' = gm_code_num ' .
'AND gmr_id_menu_02 = gm_id_menu '.
'AND gmr_id_valeur = 2 '.// 2 = "avoir traduction"
'AND gm_ce_i18n = "'.$langue_url.'" ';
$resultat_traduction = $bdd->query($requete_traduction);
(DB::isError($resultat_traduction)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_traduction->getMessage(), $requete_traduction))
: '';
if ($resultat_traduction->numRows() > 0) {
$aso_menu=$resultat_traduction->fetchRow(DB_FETCHMODE_ASSOC);
}
if ($titre=='') {
if (!empty($aso_menu['gm_nom'])) {
$titre = $aso_menu['gm_nom'];
}
elseif (!empty($menu_valeur['gm_titre'])) {
$titre = $aso_menu['gm_titre'];
}
}
}
if ($langue_url != GEN_I18N_ID_DEFAUT) {
$une_url->addQueryString(GEN_URL_CLE_I18N, $langue_url);
}
// Construction du lien
$sortie = '<a href="'.$une_url->getURL().'">'.htmlentities($titre).'</a>';
return $sortie;
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Render/Xhtml/Redirection.php
New file
0,0 → 1,27
<?php
class Text_Wiki_Render_Xhtml_Redirection extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// Initialisation des variables
$sortie = '';
$url = $options['url'];
$url=ereg_replace('&amp;','&',$url);
header("Location: $url");
exit;
}
}
?>
/branches/livraison_menes/api/text/wiki_papyrus/Render/Xhtml/Plan.php
New file
0,0 → 1,95
<?php
 
class Text_Wiki_Render_Xhtml_Plan extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// Initialisation des variables
$bdd =& $GLOBALS['_GEN_commun']['pear_db'];
$sortie = '';
$sites = $options['site'];
// Récupération de l'affichage ou pas des raccourcis
if (isset($options['permalien'])) {
$permalien = $options['permalien'];
}
$tab_site = array_map('trim', explode(',', $sites));
foreach ($tab_site as $cle => $site) {
if (count($tab_site) > 1) {
$aso_site = GEN_lireInfoSitePrincipalCodeAlpha($bdd, $site, DB_FETCHMODE_ASSOC);
if (!empty($aso_site['gs_titre'])) {
$titre = $aso_site['gs_titre'];
} else {
$titre = $aso_site['gs_nom'];
}
$url_site =& new Pap_URL();
$url_site->setUrlType('SITE');
$url_site->setId($aso_site['gs_id_site']);
$sortie .= '<h2><a href="'.$url_site->getUrl().'">'.htmlentities($titre).'</a></h2>'."\n";
}
$sortie .= '<ul class="plan_site_'.$site.'" >'."\n";
$aso_menus = GEN_retournerTableauMenusSiteCodeAlpha($bdd, $site);
$sortie .= $this->parserTableauMenus($aso_menus, $permalien);
$sortie .= '</ul>'."\n";
}
return $sortie;
}
function parserTableauMenus($aso_menus, $permalien)
{
$sortie = '';
// Création de l'url
foreach ($aso_menus as $menu_id => $menu_valeur) {
if ( $menu_valeur['gm_date_fin_validite'] == ''
|| $menu_valeur['gm_date_fin_validite'] == '0000-00-00 00:00:00'
|| strtotime($menu_valeur['gm_date_fin_validite']) > time()) {
$sortie .= '<li>';
// Création de l'url
$une_url =& new Pap_URL('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
$une_url->setId($menu_id);
// Construction de l'attribut title
$title = '';
if (!empty($menu_valeur['gm_titre'])) {
$title = ' title="'.htmlentities($menu_valeur['gm_titre']).'"';
} elseif (!empty($menu_valeur['gm_titre_alternatif'])) {
$title = ' title="'.htmlentities($menu_valeur['gm_titre_alternatif']).'"';
}
// Construction du lien
$sortie .= '<a href="'.$une_url->getURL().'"'.$title.'>'.htmlentities($menu_valeur['gm_nom']).'</a>';
// Nous affichons ou pas le permalien
if ($permalien) {
$une_url->setPermalien(true);
$sortie .= ' <span class="plan_permalien">'.'('.$une_url->getURL().')'.'</span>';
$une_url->setPermalien(false);
}
// Nous ajoutons les sous-menus s'il y en a.
$retour = $this->parserTableauMenus($menu_valeur['sous_menus'], $permalien);
if ($retour != '') {
$sortie .= "\n".'<ul>'."\n".$retour."\n".'</ul>'."\n";
}
$sortie .= '</li>'."\n";
}
}
return $sortie;
}
}
?>