Subversion Repositories Applications.papyrus

Rev

Rev 333 | Rev 754 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 333 Rev 343
Line 19... Line 19...
19
// |                                                                                                      |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id: pap_url.class.php,v 1.1 2005-04-14 13:56:25 jpm Exp $
24
// CVS : $Id: pap_url.class.php,v 1.2 2005-04-18 16:40:50 jpm Exp $
25
/**
25
/**
26
* Classe de gestion des url de Papyrus
26
* Classe de gestion des url de Papyrus
27
*
27
*
28
* Permet de gérer la réecriture des url.
28
* Permet de gérer la réecriture des url.
29
*
29
*
Line 32... Line 32...
32
//Auteur original :
32
//Auteur original :
33
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
33
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
34
//Autres auteurs :
34
//Autres auteurs :
35
*@author        Aucun
35
*@author        Aucun
36
*@copyright     Tela-Botanica 2000-2004
36
*@copyright     Tela-Botanica 2000-2004
37
*@version       $Revision: 1.1 $ $Date: 2005-04-14 13:56:25 $
37
*@version       $Revision: 1.2 $ $Date: 2005-04-18 16:40:50 $
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
39
*/
39
*/
Line 40... Line 40...
40
 
40
 
41
// +------------------------------------------------------------------------------------------------------+
41
// +------------------------------------------------------------------------------------------------------+
Line 51... Line 51...
51
    /** Identifiant du menu
51
    /** Identifiant du menu
52
    *
52
    *
53
    * @var integer
53
    * @var integer
54
    */
54
    */
55
    var $id;
55
    var $id;
-
 
56
    /** Booléen indiquant si on affiche ou pas un permalien.
-
 
57
    *
-
 
58
    * @var boolean
-
 
59
    */
-
 
60
    var $permalien;
-
 
61
    /** Code numérique du menu courant
-
 
62
    *
-
 
63
    * @var integer
-
 
64
    */
-
 
65
    var $code_num;
-
 
66
    /** Code alphanumérique du menu courant
-
 
67
    *
-
 
68
    * @var string
-
 
69
    */
-
 
70
    var $code_alpha;
56
    /**
71
    /**
57
    * PHP4 Constructeur
72
    * PHP4 Constructeur
58
    *
73
    *
59
    * @see __construct()
74
    * @see __construct()
60
    */
75
    */
Line 86... Line 101...
86
    */
101
    */
87
    function getId()
102
    function getId()
88
    {
103
    {
89
        return $this->id;
104
        return $this->id;
90
    }
105
    }
-
 
106
    /** Méthode setPermalien() - Définit le type d'utilisation des permaliens
-
 
107
    * 
-
 
108
    * @param boolean true ou false
-
 
109
    * @return mixed false en cas d'erreur 
-
 
110
    * @access public
-
 
111
    */
-
 
112
    function setPermalien($bool)
-
 
113
    {
-
 
114
        // Nous vérifions que l'identifiant est bien un entier
-
 
115
        if (is_bool($bool)) {
-
 
116
            $this->permalien = $bool;
-
 
117
        } else {
-
 
118
            return false;
-
 
119
        }
-
 
120
    }
-
 
121
    /** Méthode getPermalien() - Retourne booléen indiquant si on utilise ou pas les permaliens
-
 
122
    * 
-
 
123
    * @return boolean true ou false
-
 
124
    * @access public
-
 
125
    */
-
 
126
    function getPermalien()
-
 
127
    {
-
 
128
        return $this->permalien;
-
 
129
    }
-
 
130
    /** Méthode setCodeAlpha() - Définit le code alphanumérique de l'url
-
 
131
    * 
-
 
132
    * @param string le code alphanumérique pour l'url du menu
-
 
133
    * @return mixed false en cas d'erreur 
-
 
134
    * @access public
-
 
135
    */
-
 
136
    function setCodeAlpha($code_alpha)
-
 
137
    {
-
 
138
        if (is_string($code_alpha)) {
-
 
139
            $this->code_alpha = $code_alpha;
-
 
140
        } else {
-
 
141
            return false;
-
 
142
        }
-
 
143
    }
-
 
144
    /** Méthode getCodeNum() - Retourne le code numérique de l'url
-
 
145
    * 
-
 
146
    * @return string le code numérique pour l'url du menu
-
 
147
    * @access public
-
 
148
    */
-
 
149
    function getCodeNum()
-
 
150
    {
-
 
151
        return $this->code_num;
-
 
152
    }
-
 
153
    /** Méthode setCodeNum() - Définit le code numérique de l'url
-
 
154
    * 
-
 
155
    * @param string le code numérique pour l'url du menu
-
 
156
    * @return mixed false en cas d'erreur 
-
 
157
    * @access public
-
 
158
    */
-
 
159
    function setCodeNum($code_num)
-
 
160
    {
-
 
161
        if (is_integer($code_num)) {
-
 
162
            $this->code_num = $code_num;
-
 
163
        } else {
-
 
164
            return false;
-
 
165
        }
-
 
166
    }
-
 
167
    
-
 
168
    /** Méthode getCodeAlpha() - Retourne le code alphanumérique de l'url
-
 
169
    * 
-
 
170
    * @return string le code alphanumérique pour l'url du menu
-
 
171
    * @access public
-
 
172
    */
-
 
173
    function getCodeAlpha()
-
 
174
    {
-
 
175
        return $this->code_alpha;
-
 
176
    }
91
    /**
177
    /**
92
    * Méthode getURL() - Retourne l'url
178
    * Méthode getURL() - Retourne l'url
93
    *
179
    *
94
    * @return string l'url complète.
180
    * @return string l'url complète.
95
    * @access public
181
    * @access public
96
    */
182
    */
97
    function getURL()
183
    function getURL()
98
    {
184
    {
-
 
185
        // Nous regardons si un id de menu existe
99
        if ($this->getId() != '') {
186
        if ($this->getId() != '') {
100
            // Préparation des noms des champs des codes pour le site et le menu
187
            // Préparation des noms des champs des codes pour le site et le menu
101
            $champs_code_site = (GEN_URL_ID_TYPE_SITE == 'int') ? 'gs_code_num' : 'gs_code_alpha';
188
            $champs_code_site = (GEN_URL_ID_TYPE_SITE == 'int') ? 'gs_code_num' : 'gs_code_alpha';
102
            $champs_code_menu = (GEN_URL_ID_TYPE_MENU == 'int') ? 'gm_code_num' : 'gm_code_alpha';
189
            $champs_code_menu = (GEN_URL_ID_TYPE_MENU == 'int') ? 'gm_code_num' : 'gm_code_alpha';
Line 103... Line 190...
103
            
190
            
104
            // Récupération du nom de l'entrée du menu à afficher
191
            // Récupération du nom de l'entrée du menu à afficher
105
            $requete =  'SELECT '.$champs_code_menu.', gm_ce_i18n, gm_ce_site '.
192
            $requete =  'SELECT gm_code_alpha, gm_code_num, gm_ce_i18n, gm_ce_site '.
106
                        'FROM gen_menu '.
193
                        'FROM gen_menu '.
Line 107... Line 194...
107
                        'WHERE gm_id_menu = '.$this->id.' ';
194
                        'WHERE gm_id_menu = '.$this->id.' ';
108
            
195
            
Line 113... Line 200...
113
            $resultat->free();
200
            $resultat->free();
114
            // Nous vérifions si nous avons à faire à un menu commun ou pas
201
            // Nous vérifions si nous avons à faire à un menu commun ou pas
115
            if ($ligne['gm_ce_site'] != 0) {
202
            if ($ligne['gm_ce_site'] != 0) {
116
                // Récupération des infos sur le site
203
                // Récupération des infos sur le site
117
                $bln_url_site = false;
204
                $bln_url_site = false;
118
                $requete_site = 'SELECT '.$champs_code_site.' '.
205
                $requete_site = 'SELECT gs_code_alpha, gs_code_num '.
119
                                'FROM gen_site '.
206
                                'FROM gen_site '.
120
                                'WHERE gs_id_site = '.$ligne['gm_ce_site'].' ';
207
                                'WHERE gs_id_site = '.$ligne['gm_ce_site'].' ';
Line 121... Line 208...
121
                
208
                
122
                $resultat_site = $GLOBALS['_GEN_commun']['pear_db']->query($requete_site);
209
                $resultat_site = $GLOBALS['_GEN_commun']['pear_db']->query($requete_site);
Line 132... Line 219...
132
            // Préparation de l'url de l'entrée
219
            // Préparation de l'url de l'entrée
133
            if ($bln_url_site) {
220
            if ($bln_url_site) {
134
                $this->addQueryString(GEN_URL_CLE_SITE, $ligne_site[$champs_code_site]);
221
                $this->addQueryString(GEN_URL_CLE_SITE, $ligne_site[$champs_code_site]);
135
            }
222
            }
136
            $this->addQueryString(GEN_URL_CLE_MENU, $ligne[$champs_code_menu]);
223
            $this->addQueryString(GEN_URL_CLE_MENU, $ligne[$champs_code_menu]);
-
 
224
            $this->setCodeAlpha($ligne['gm_code_alpha']);
-
 
225
            $this->setCodeNum($ligne['gm_code_num']);
Line 137... Line 226...
137
            
226
            
138
            if ( (isset($GLOBALS['_GEN_commun']['url_i18n'])) && (!empty($GLOBALS['_GEN_commun']['url_i18n'])) ) {
227
            if ( (isset($GLOBALS['_GEN_commun']['url_i18n'])) && (!empty($GLOBALS['_GEN_commun']['url_i18n'])) ) {
139
                $this->addQueryString(GEN_URL_CLE_I18N, $GLOBALS['_GEN_commun']['url_i18n']);
228
                $this->addQueryString(GEN_URL_CLE_I18N, $GLOBALS['_GEN_commun']['url_i18n']);
Line 145... Line 234...
145
            
234
            
146
            if ( (isset($GLOBALS['_GEN_commun']['url_format'])) && (!empty($GLOBALS['_GEN_commun']['url_format'])) ) {
235
            if ( (isset($GLOBALS['_GEN_commun']['url_format'])) && (!empty($GLOBALS['_GEN_commun']['url_format'])) ) {
147
                $this->addQueryString(GEN_URL_CLE_FORMAT, $GLOBALS['_GEN_commun']['url_format']);
236
                $this->addQueryString(GEN_URL_CLE_FORMAT, $GLOBALS['_GEN_commun']['url_format']);
148
            }
237
            }
-
 
238
        }
149
        }
239
        
150
        /* A FAIRE : gestion des urls permanente et réecrite
240
        // Gestion temporéraire de la réecriture
151
        if (defined('PAP_URL_REECRITURE') AND PAP_URL_REECRITURE == 1) {
241
        if (defined('PAP_URL_REECRITURE') AND PAP_URL_REECRITURE == 1) {
-
 
242
            $this->setPermalien(true);
152
            // Récupération du chemin jusqu'au fichier principal de Papyrus
243
        }
Line 153... Line 244...
153
            $this->path = dirname($this->path) == DIRECTORY_SEPARATOR ? '' : dirname($this->path);
244
        /*A FAIRE : gestion des urls permanente et réecrite compléte avec format, date...
154
            
245
            
155
            // Ajout des composant de l'url absolu du document courant
246
            // Ajout des composant de l'url absolu du document courant
156
            if ($site = $this->retournerUnParametre(GEN_URL_CLE_SITE)) {
247
            if ($site = $this->retournerUnParametre(GEN_URL_CLE_SITE)) {
Line 174... Line 265...
174
                $this->removeQueryString(GEN_URL_CLE_FORMAT);
265
                $this->removeQueryString(GEN_URL_CLE_FORMAT);
175
            }
266
            }
176
            echo $this->path.'<br>';
267
            echo $this->path.'<br>';
177
        }
268
        }
178
        */
269
        */
-
 
270
        
-
 
271
        // Construction du permalien ou pas
-
 
272
        if ($this->getPermalien()) {
-
 
273
            // Récupération du chemin jusqu'au fichier principal de Papyrus
-
 
274
            $this->path = (dirname($this->path) == DIRECTORY_SEPARATOR) ? DIRECTORY_SEPARATOR : dirname($this->path);
-
 
275
            if (GEN_URL_RACCOURCI_ID_TYPE_MENU == 'int') {
-
 
276
                $this->path .= $this->getCodeNum();
-
 
277
            } else {
-
 
278
                $this->path .= $this->getCodeAlpha();
-
 
279
            }
-
 
280
            $querystring = '';
-
 
281
        } else {
179
        $querystring = $this->getQueryString();
282
            $querystring = $this->getQueryString();
-
 
283
        }
-
 
284
        
-
 
285
        // Construction de l'url
180
        $this->url = $this->protocol . '://'
286
        $this->url = $this->protocol . '://'
181
                   . $this->user . (!empty($this->pass) ? ':' : '')
287
                   . $this->user . (!empty($this->pass) ? ':' : '')
182
                   . $this->pass . (!empty($this->user) ? '@' : '')
288
                   . $this->pass . (!empty($this->user) ? '@' : '')
183
                   . $this->host . ($this->port == $this->getStandardPort($this->protocol) ? '' : ':' . $this->port)
289
                   . $this->host . ($this->port == $this->getStandardPort($this->protocol) ? '' : ':' . $this->port)
184
                   . $this->path
290
                   . $this->path
Line 212... Line 318...
212
 
318
 
213
 
319
 
214
/* +--Fin du code ----------------------------------------------------------------------------------------+
320
/* +--Fin du code ----------------------------------------------------------------------------------------+
-
 
321
*
-
 
322
* $Log: not supported by cvs2svn $
-
 
323
* Revision 1.1  2005/04/14 13:56:25  jpm
215
*
324
* Ajout de la classe URL de Papyrus.
216
* $Log: not supported by cvs2svn $
325
*
217
*
326
*
218
* +-- Fin du code ----------------------------------------------------------------------------------------+
327
* +-- Fin du code ----------------------------------------------------------------------------------------+
219
*/
328
*/