Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1028 → Rev 1029

/trunk/papyrus/bibliotheque/fonctions/pap_site.fonct.php
19,7 → 19,7
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: pap_site.fonct.php,v 1.4 2005-04-19 17:21:19 jpm Exp $
// CVS : $Id: pap_site.fonct.php,v 1.5 2006-10-11 18:04:11 jp_milcent Exp $
/**
* Bibliothèque de fonctions concernant les sites.
*
38,7 → 38,7
//Autres auteurs :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.4 $ $Date: 2005-04-19 17:21:19 $
*@version $Revision: 1.5 $ $Date: 2006-10-11 18:04:11 $
// +------------------------------------------------------------------------------------------------------+
*/
 
207,9 → 207,76
return $tab_type;
}
 
/** Fonction GEN_retournerSiteCodeNum() - Renvoie le code num d'un site en fonction du code Alphanumérique
*
* Retourne le code numérique d'un site en fonction du code alphanumérique.
*
* @param mixed une instance de la classe Pear DB.
* @param string le code alphanumérique d'un site.
* @return mixed le code numérique du site sinon false.
*/
function GEN_retournerSiteCodeNum(&$db, $code_alphanum)
{
//----------------------------------------------------------------------------
// Recherche des informations sur le menu
$requete = 'SELECT gs_code_num '.
'FROM gen_site '.
'WHERE gs_code_alpha = "'.$code_alphanum.'"';
 
$resultat = $db->query($requete);
(DB::isError($resultat)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '';
 
if ($resultat->numRows() != 1) {
return false;
}
 
//----------------------------------------------------------------------------
// Récupération des infos
$info_site = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
$code_num = $info_site->gs_code_num;
$resultat->free();
 
return $code_num;
}
 
/** Fonction GEN_retournerSiteCodeAlpha() - Renvoie le code alphanumérique d'un site en fonction du code numérique
*
* Retourne le code alphanumérique d'un site en fonction du code numérique.
*
* @param mixed une instance de la classse Pear DB.
* @param string le code numérique d'un site.
* @return mixed le code alphanumérique du site sinon false.
*/
function GEN_retournerSiteCodeAlpha(&$db, $code_num)
{
//----------------------------------------------------------------------------
// Recherche des informations sur le menu
$requete = 'SELECT gs_code_alpha '.
'FROM gen_site '.
'WHERE gs_code_num = '.$code_num;
 
$resultat = $db->query($requete);
(DB::isError($resultat)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '';
 
if ($resultat->numRows() != 1) {
return false;
}
 
//----------------------------------------------------------------------------
// Récupération des infos
$info_site = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
$code_alphanum = $info_site->gs_code_alpha;
$resultat->free();
 
return $code_alphanum;
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.4 2005/04/19 17:21:19 jpm
* Utilisation des références d'objets.
*
* Revision 1.3 2004/12/03 19:22:30 jpm
* Ajout d'une fonction retournant les types de sites externes gérés par Papyrus.
*
/trunk/papyrus/bibliotheque/classes/pap_url.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: 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,6 → 86,10
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
*
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,11 → 251,9
*/
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) {
if ($GLOBALS['_GEN_commun']['i18n'] != GEN_I18N_ID_DEFAUT) {
$this->addQueryString(GEN_URL_CLE_I18N, $GLOBALS['_GEN_commun']['i18n']);
}
}
196,24 → 263,43
// 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 gm_code_alpha, gm_code_num, 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 gs_code_alpha, gs_code_num '.
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 '.
'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 gs_code_alpha, gs_code_num '.
'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;
}
$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 = '.$ligne['gm_ce_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)) : '';
220,19 → 306,19
$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;
$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()) {
// Construction du permalien ou pas
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)
*
337,4 → 401,4
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
?>