New file |
0,0 → 1,220 |
<?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 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: pap_url.class.php,v 1.1 2005-04-14 13:56:25 jpm Exp $ |
/** |
* Classe de gestion des url de Papyrus |
* |
* Permet de gérer la réecriture des url. |
* |
*@package Papyrus |
*@subpackage Classes |
//Auteur original : |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.1 $ $Date: 2005-04-14 13:56:25 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
|
|
// +------------------------------------------------------------------------------------------------------+ |
// | CORPS du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
class Pap_URL extends Net_URL { |
/** Identifiant du menu |
* |
* @var integer |
*/ |
var $id; |
/** |
* PHP4 Constructeur |
* |
* @see __construct() |
*/ |
function Pap_URL($url = null, $useBrackets = true) |
{ |
$this->__construct($url, $useBrackets); |
} |
/** Méthode setId() - Définit l'id du menu courant |
* |
* @param integer l'identifiant du menu courant. |
* @return mixed false en cas d'erreur |
* @access public |
*/ |
function setId($id) |
{ |
// Nous transformons en entier l'identifiant |
settype($id, "integer"); |
// Nous vérifions que l'identifiant est bien un entier |
if (is_integer($id)) { |
$this->id = $id; |
} else { |
return false; |
} |
} |
/** Méthode getId() - Retourne l'id du menu courant |
* |
* @return integer l'identifiant du menu courant. |
* @access public |
*/ |
function getId() |
{ |
return $this->id; |
} |
/** |
* Méthode getURL() - Retourne l'url |
* |
* @return string l'url complète. |
* @access public |
*/ |
function getURL() |
{ |
if ($this->getId() != '') { |
// Préparation des noms des champs des codes pour le site et le menu |
$champs_code_site = (GEN_URL_ID_TYPE_SITE == 'int') ? 'gs_code_num' : 'gs_code_alpha'; |
$champs_code_menu = (GEN_URL_ID_TYPE_MENU == 'int') ? 'gm_code_num' : 'gm_code_alpha'; |
|
// Récupération du nom de l'entrée du menu à afficher |
$requete = 'SELECT '.$champs_code_menu.', gm_ce_i18n, gm_ce_site '. |
'FROM gen_menu '. |
'WHERE gm_id_menu = '.$this->id.' '; |
|
$resultat = $GLOBALS['_GEN_commun']['pear_db']->query($requete); |
(DB::isError($resultat)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : ''; |
|
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC); |
$resultat->free(); |
// Nous vérifions si nous avons à faire à un menu commun ou pas |
if ($ligne['gm_ce_site'] != 0) { |
// Récupération des infos sur le site |
$bln_url_site = false; |
$requete_site = 'SELECT '.$champs_code_site.' '. |
'FROM gen_site '. |
'WHERE gs_id_site = '.$ligne['gm_ce_site'].' '; |
|
$resultat_site = $GLOBALS['_GEN_commun']['pear_db']->query($requete_site); |
(DB::isError($resultat_site)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_site->getMessage(), $requete_site)) : ''; |
|
$ligne_site = $resultat_site->fetchRow(DB_FETCHMODE_ASSOC); |
$resultat_site->free(); |
} else { |
// Menu commun |
$bln_url_site = true; |
$ligne_site[$champs_code_site] = $GLOBALS['_GEN_commun']['info_site']->$champs_code_site; |
} |
// Préparation de l'url de l'entrée |
if ($bln_url_site) { |
$this->addQueryString(GEN_URL_CLE_SITE, $ligne_site[$champs_code_site]); |
} |
$this->addQueryString(GEN_URL_CLE_MENU, $ligne[$champs_code_menu]); |
|
if ( (isset($GLOBALS['_GEN_commun']['url_i18n'])) && (!empty($GLOBALS['_GEN_commun']['url_i18n'])) ) { |
$this->addQueryString(GEN_URL_CLE_I18N, $GLOBALS['_GEN_commun']['url_i18n']); |
} |
|
if ( (isset($GLOBALS['_GEN_commun']['url_date'])) && (!empty($GLOBALS['_GEN_commun']['url_date'])) ) { |
$this->addQueryString(GEN_URL_CLE_DATE, $GLOBALS['_GEN_commun']['url_date']); |
} |
|
if ( (isset($GLOBALS['_GEN_commun']['url_format'])) && (!empty($GLOBALS['_GEN_commun']['url_format'])) ) { |
$this->addQueryString(GEN_URL_CLE_FORMAT, $GLOBALS['_GEN_commun']['url_format']); |
} |
} |
/* A FAIRE : gestion des urls permanente et réecrite |
if (defined('PAP_URL_REECRITURE') AND PAP_URL_REECRITURE == 1) { |
// Récupération du chemin jusqu'au fichier principal de Papyrus |
$this->path = dirname($this->path) == DIRECTORY_SEPARATOR ? '' : dirname($this->path); |
|
// Ajout des composant de l'url absolu du document courant |
if ($site = $this->retournerUnParametre(GEN_URL_CLE_SITE)) { |
$this->path .= DIRECTORY_SEPARATOR.GEN_URL_CLE_SITE.'_'.$site; |
$this->removeQueryString(GEN_URL_CLE_SITE); |
} |
if ($menu = $this->retournerUnParametre(GEN_URL_CLE_MENU)) { |
$this->path .= DIRECTORY_SEPARATOR.GEN_URL_CLE_MENU.'_'.$menu; |
$this->removeQueryString(GEN_URL_CLE_MENU); |
} |
if ($i18n = $this->retournerUnParametre(GEN_URL_CLE_I18N)) { |
$this->path .= DIRECTORY_SEPARATOR.GEN_URL_CLE_I18N.'_'.$i18n; |
$this->removeQueryString(GEN_URL_CLE_I18N); |
} |
if ($date = $this->retournerUnParametre(GEN_URL_CLE_DATE)) { |
$this->path .= DIRECTORY_SEPARATOR.GEN_URL_CLE_DATE.'_'.$date; |
$this->removeQueryString(GEN_URL_CLE_DATE); |
} |
if ($format = $this->retournerUnParametre(GEN_URL_CLE_FORMAT)) { |
$this->path .= DIRECTORY_SEPARATOR.GEN_URL_CLE_FORMAT.'_'.$format; |
$this->removeQueryString(GEN_URL_CLE_FORMAT); |
} |
echo $this->path.'<br>'; |
} |
*/ |
$querystring = $this->getQueryString(); |
$this->url = $this->protocol . '://' |
. $this->user . (!empty($this->pass) ? ':' : '') |
. $this->pass . (!empty($this->user) ? '@' : '') |
. $this->host . ($this->port == $this->getStandardPort($this->protocol) ? '' : ':' . $this->port) |
. $this->path |
. (!empty($querystring) ? '?' . $querystring : '') |
. (!empty($this->anchor) ? '#' . $this->anchor : ''); |
|
return $this->url; |
} |
|
/** Méthode retournant la valeur d'un paramêtre de l'URL. |
* |
* @return mixed la valeur du paramêtre demandé ou false |
* @access public |
*/ |
function retournerUnParametre($parametre) |
{ |
if (!empty($this->querystring)) { |
if (isset($this->querystring[$parametre])) { |
return $this->querystring[$parametre]; |
} |
} |
|
return FALSE; |
} |
} |
|
// +------------------------------------------------------------------------------------------------------+ |
// | PIED du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
|
|
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |