Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 840 → Rev 841

/trunk/api/text/wiki_papyrus/Parse/Lien.php
New file
0,0 → 1,46
<?php
// $Id: Lien.php,v 1.1 2006-05-10 16:02:49 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+))" *\}\}/';
/**
*
* 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)
{
$options = array(
'niveau' => $matches[1],
'identifiant' => $matches[2]
);
return $this->wiki->addToken($this->rule, $options);
}
}
?>
/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.7 2005-09-23 13:58:07 ddelon Exp $
// CVS : $Id: Papyrus.class.php,v 1.8 2006-05-10 16:02:49 ddelon Exp $
/**
* Classe configurant le formatage pour Papyrus.
*
36,7 → 36,7
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.7 $ $Date: 2005-09-23 13:58:07 $
*@version $Revision: 1.8 $ $Date: 2006-05-10 16:02:49 $
// +------------------------------------------------------------------------------------------------------+
*/
 
77,8 → 77,10
'Categorie', // Action Categorie
'Nouveaute', // Action Nouveaute
'Plan', // Action Plan
'Lien', // Action Lien
'Syndication', // Action Syndication
'Redirection' // Action Redirection
);
/**
284,6 → 286,9
/* +--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.
*
/trunk/api/text/wiki_papyrus/Render/Xhtml/Lien.php
New file
0,0 → 1,141
<?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'];
$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']);
$titre='';
$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 (!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 (!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;
}
}
?>