Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1144 → Rev 1133

/trunk/api/text/wiki_papyrus/Papyrus.class.php
21,7 → 21,7
// | 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.11 2006-12-12 13:33:57 jp_milcent Exp $
// CVS : $Id: Papyrus.class.php,v 1.10 2006-12-08 20:16:27 jp_milcent Exp $
/**
* Classe configurant le formatage pour Papyrus.
*
36,7 → 36,7
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.11 $ $Date: 2006-12-12 13:33:57 $
*@version $Revision: 1.10 $ $Date: 2006-12-08 20:16:27 $
// +------------------------------------------------------------------------------------------------------+
*/
 
72,6 → 72,7
*
*/
var $rules = array(
'Motcles', // Action Motcles
'Nouveaute', // Action Nouveaute
'Plan', // Action Plan
'Syndication', // Action Syndication
282,9 → 283,6
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.10 2006/12/08 20:16:27 jp_milcent
* Suppression de l'action Lien remplacée par une applette.
*
* Revision 1.9 2006/12/08 15:29:33 jp_milcent
* Suppression des actions transformées en applette.
*
/trunk/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 '';
}
}
}
?>
/trunk/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);
}
}
?>