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: pap_url.class.php,v 1.3 2006-03-02 10:49:49 ddelon Exp $ |
// CVS : $Id: pap_url.class.php,v 1.4 2006-10-11 18:04:11 jp_milcent Exp $ |
/** |
* Classe de gestion des url de Papyrus |
* |
34,7 → 34,7 |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.3 $ $Date: 2006-03-02 10:49:49 $ |
*@version $Revision: 1.4 $ $Date: 2006-10-11 18:04:11 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
53,11 → 53,21 |
* @var integer |
*/ |
var $id; |
/** Chaine contenant le permalien. |
* |
* @var string |
*/ |
var $permalien = ''; |
/** Booléen indiquant si on affiche ou pas un permalien. |
* |
* @var boolean |
*/ |
var $permalien; |
var $permalien_bool; |
/** Chaine indiquant le type d'url. |
* |
* @var string |
*/ |
var $url_type = 'MENU'; |
/** Code numérique du menu courant |
* |
* @var integer |
76,7 → 86,11 |
function Pap_URL($url = null, $useBrackets = true) |
{ |
$this->__construct($url, $useBrackets); |
// Gestion de la réecriture d'url |
if (defined('PAP_URL_REECRITURE') AND PAP_URL_REECRITURE == '1') { |
$this->setPermalienBool(true); |
} |
} |
/** Méthode setId() - Définit l'id du menu courant |
* |
* @param integer l'identifiant du menu courant. |
103,29 → 117,84 |
{ |
return $this->id; |
} |
/** Méthode setPermalien() - Définit le type d'utilisation des permaliens |
/** Méthode setPermalien() - Définit le permaliens |
* |
* @param string valeur |
* @return mixed false en cas d'erreur |
* @access public |
*/ |
function setPermalien($chaine = '') |
{ |
// Nous vérifions que l'identifiant est bien un entier |
if (is_string($chaine) && $chaine != '') { |
if ($this->permalien != '') { |
$this->permalien .= PAP_URL_REECRITURE_SEP; |
} else { |
$this->permalien = constant('PAP_URL_REECRITURE_'.$this->getUrlType()).PAP_URL_REECRITURE_SEP; |
} |
$this->permalien .= $chaine; |
} else if ($chaine == '') { |
$this->permalien = ''; |
} else { |
return false; |
} |
} |
/** Méthode getPermalien() - Retourne le permalien |
* |
* @return string le permalien |
* @access public |
*/ |
function getPermalien() |
{ |
return $this->permalien; |
} |
/** Méthode setUrlType() - Définit le type d'URL |
* |
* @param string type d'URL (SITE ou MENU) |
* @return mixed false en cas d'erreur |
* @access public |
*/ |
function setUrlType($type) |
{ |
// Nous vérifions que l'identifiant est bien un entier |
if (is_string($type) && ($type == 'MENU' || $type == 'SITE')) { |
$this->url_type = $type; |
} else { |
return false; |
} |
} |
/** Méthode getUrlType() - Retourne le type de l'URL |
* |
* @return string le type d'URL |
* @access public |
*/ |
function getUrlType() |
{ |
return $this->url_type; |
} |
/** Méthode setPermalienBool() - Définit le type d'utilisation des permaliens |
* |
* @param boolean true ou false |
* @return mixed false en cas d'erreur |
* @access public |
*/ |
function setPermalien($bool) |
function setPermalienBool($bool) |
{ |
// Nous vérifions que l'identifiant est bien un entier |
if (is_bool($bool)) { |
$this->permalien = $bool; |
$this->permalien_bool = $bool; |
} else { |
return false; |
} |
} |
/** Méthode getPermalien() - Retourne booléen indiquant si on utilise ou pas les permaliens |
/** Méthode getPermalienBool() - Retourne booléen indiquant si on utilise ou pas les permaliens |
* |
* @return boolean true ou false |
* @access public |
*/ |
function getPermalien() |
function getPermalienBool() |
{ |
return $this->permalien; |
return $this->permalien_bool; |
} |
/** Méthode setCodeAlpha() - Définit le code alphanumérique de l'url |
* |
182,9 → 251,7 |
*/ |
function getURL() |
{ |
|
|
// identifiant de la langue choisie |
// Identifiant de la langue choisie |
if ( (isset($GLOBALS['_GEN_commun']['i18n'])) && (!empty($GLOBALS['_GEN_commun']['i18n'])) ) { |
if ($GLOBALS['_GEN_commun']['i18n']!=GEN_I18N_ID_DEFAUT) { |
$this->addQueryString(GEN_URL_CLE_I18N, $GLOBALS['_GEN_commun']['i18n']); |
196,7 → 263,7 |
// 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'; |
|
if ($this->getUrlType() == 'MENU') { |
// Récupération du nom de l'entrée du menu à afficher |
$requete = 'SELECT gm_code_alpha, gm_code_num, gm_ce_i18n, gm_ce_site '. |
'FROM gen_menu '. |
225,14 → 292,33 |
$bln_url_site = true; |
$ligne_site[$champs_code_site] = $GLOBALS['_GEN_commun']['info_site']->$champs_code_site; |
} |
$this->addQueryString(GEN_URL_CLE_MENU, $ligne[$champs_code_menu]); |
$this->setCodeAlpha($ligne['gm_code_alpha']); |
$this->setCodeNum($ligne['gm_code_num']); |
} else if ($this->getUrlType() == 'SITE') { |
$bln_url_site = true; |
$requete_site = 'SELECT gs_code_alpha, gs_code_num '. |
'FROM gen_site '. |
'WHERE gs_id_site = '.$this->getId().' '; |
|
$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(); |
$this->setCodeAlpha($ligne_site['gs_code_alpha']); |
$this->setCodeNum($ligne_site['gs_code_num']); |
} |
|
// 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]); |
$this->setCodeAlpha($ligne['gm_code_alpha']); |
$this->setCodeNum($ligne['gm_code_num']); |
|
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']); |
} |
242,47 → 328,20 |
} |
} |
|
// Gestion temporéraire de la réecriture |
if (defined('PAP_URL_REECRITURE') AND PAP_URL_REECRITURE == 1) { |
$this->setPermalien(true); |
} |
/*A FAIRE : gestion des urls permanente et réecrite compléte avec format, date... |
|
// 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>'; |
} |
*/ |
|
// Construction du permalien ou pas |
if ($this->getPermalien()) { |
if ($this->getPermalienBool()) { |
// Récupération du chemin jusqu'au fichier principal de Papyrus |
$this->path = (dirname($this->path) == DIRECTORY_SEPARATOR) ? DIRECTORY_SEPARATOR : dirname($this->path); |
if (GEN_URL_RACCOURCI_ID_TYPE_MENU == 'int') { |
$this->path .= $this->getCodeNum(); |
$this->path = (dirname($this->path) == DIRECTORY_SEPARATOR) ? DIRECTORY_SEPARATOR : dirname($this->path).DIRECTORY_SEPARATOR; |
// On vide le permalien construite par les appels à getUrl() avant de le remplir |
$this->setPermalien(); |
if (constant('GEN_URL_RACCOURCI_ID_TYPE_'.$this->getUrlType()) == 'int') { |
$this->setPermalien($this->getCodeNum()); |
} else { |
$this->path .= $this->getCodeAlpha(); |
$this->setPermalien($this->getCodeAlpha()); |
} |
$querystring = ''; |
$this->removeQueryString(GEN_URL_CLE_SITE); |
$this->removeQueryString(GEN_URL_CLE_MENU); |
$querystring = $this->getQueryString(); |
} else { |
$querystring = $this->getQueryString(); |
} |
293,6 → 352,7 |
. $this->pass . (!empty($this->user) ? '@' : '') |
. $this->host . ($this->port == $this->getStandardPort($this->protocol) ? '' : ':' . $this->port) |
. $this->path |
. $this->getPermalien() |
. (!empty($querystring) ? '?' . $querystring : '') |
. (!empty($this->anchor) ? '#' . $this->anchor : ''); |
|
314,6 → 374,7 |
|
return FALSE; |
} |
|
} |
|
// +------------------------------------------------------------------------------------------------------+ |
325,6 → 386,9 |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.3 2006/03/02 10:49:49 ddelon |
* Fusion branche multilinguisme dans branche principale |
* |
* Revision 1.2.2.1 2005/12/27 15:56:00 ddelon |
* Fusion Head vers multilinguisme (wikini double clic) |
* |