Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 840 → Rev 841

/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;
}
}
?>