Line 17... |
Line 17... |
17 |
// | |
|
17 |
// | |
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
19 |
// | License along with this library; if not, write to the Free Software |
|
19 |
// | License along with this library; if not, write to the Free Software |
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
22 |
// CVS : $Id: menu.php,v 1.10 2004-11-15 17:40:02 jpm Exp $
|
22 |
// CVS : $Id: menu.php,v 1.11 2004-11-26 19:02:22 jpm Exp $
|
23 |
/**
|
23 |
/**
|
24 |
* Applette : menu
|
24 |
* Applette : menu
|
25 |
*
|
25 |
*
|
26 |
* Génère une liste de listes comportant tous les niveaux des menus "classiques" d'un site.
|
26 |
* Génère une liste de listes comportant tous les niveaux des menus "classiques" d'un site.
|
27 |
* Nécessite :
|
27 |
* Nécessite :
|
Line 36... |
Line 36... |
36 |
//Auteur original :
|
36 |
//Auteur original :
|
37 |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
37 |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
38 |
//Autres auteurs :
|
38 |
//Autres auteurs :
|
39 |
*@author Aucun
|
39 |
*@author Aucun
|
40 |
*@copyright Tela-Botanica 2000-2004
|
40 |
*@copyright Tela-Botanica 2000-2004
|
41 |
*@version $Revision: 1.10 $ $Date: 2004-11-15 17:40:02 $
|
41 |
*@version $Revision: 1.11 $ $Date: 2004-11-26 19:02:22 $
|
42 |
// +------------------------------------------------------------------------------------------------------+
|
42 |
// +------------------------------------------------------------------------------------------------------+
|
43 |
*/
|
43 |
*/
|
Line 44... |
Line 44... |
44 |
|
44 |
|
45 |
// +------------------------------------------------------------------------------------------------------+
|
45 |
// +------------------------------------------------------------------------------------------------------+
|
46 |
// | ENTÊTE du PROGRAMME |
|
46 |
// | ENTÊTE du PROGRAMME |
|
Line 47... |
Line 47... |
47 |
// +------------------------------------------------------------------------------------------------------+
|
47 |
// +------------------------------------------------------------------------------------------------------+
|
48 |
|
- |
|
49 |
require_once 'papyrus/bibliotheque/fonctions/pap_menu.fonct.php';
|
48 |
|
- |
|
49 |
require_once 'papyrus/bibliotheque/fonctions/pap_menu.fonct.php';
|
50 |
|
50 |
$GLOBALS['_MENU_']['nom_fonction'] = 'afficherMenuNiveauMultiple';
|
Line 51... |
Line 51... |
51 |
$_GEN_commun['info_applette_nom_fonction'] = 'afficherMenuNiveauMultiple';
|
51 |
$_GEN_commun['info_applette_nom_fonction'] = $GLOBALS['_MENU_']['nom_fonction'];
|
52 |
$_GEN_commun['info_applette_balise'] = 'MENU_?(?:(|CLASSIQUE|COMMUN)_([0-9]+)_([0-9]+)(|_ID_([0-9]+))|(UNIQUE)_([0-9]+))';
|
52 |
$_GEN_commun['info_applette_balise'] = 'MENU_?(?:(|CLASSIQUE|COMMUN)_([0-9]+)_([0-9]+)(|_ID_([0-9]+))|(UNIQUE)_([0-9]+))';
|
53 |
|
53 |
|
Line 72... |
Line 72... |
72 |
function afficherMenuNiveauMultiple($tab_applette_arguments, $_GEN_commun)
|
72 |
function afficherMenuNiveauMultiple($tab_applette_arguments, $_GEN_commun)
|
73 |
{
|
73 |
{
|
74 |
// Initialisation de variable.
|
74 |
// Initialisation de variable.
|
75 |
$objet_pear_db = $_GEN_commun['pear_db'];
|
75 |
$objet_pear_db = $_GEN_commun['pear_db'];
|
76 |
$id_site = $_GEN_commun['info_site']->gs_id_site;
|
76 |
$id_site = $_GEN_commun['info_site']->gs_id_site;
|
77 |
$id_menu = $_GEN_commun['info_menu']->gm_id_menu;
|
77 |
$id_menu = $_GEN_commun['info_menu']->gm_id_menu;
|
- |
|
78 |
$num_menu = $GLOBALS['_PAPYRUS_']['applette']['comptage'][$GLOBALS['_MENU_']['nom_fonction']];
|
78 |
$id_langue = $_GEN_commun['i18n'];
|
79 |
$id_langue = $_GEN_commun['i18n'];
|
79 |
$i18n_url = '';// Evite d'écrire l'i18n dans l'url demandée.
|
80 |
$i18n_url = '';// Evite d'écrire l'i18n dans l'url demandée.
|
80 |
if (!empty($_GEN_commun['url_i18n'])) {
|
81 |
if (!empty($_GEN_commun['url_i18n'])) {
|
81 |
// L'écriture de l'i18n dans les urls des menus est demandée.
|
82 |
// L'écriture de l'i18n dans les urls des menus est demandée.
|
82 |
$i18n_url = $_GEN_commun['url_i18n'];
|
83 |
$i18n_url = $_GEN_commun['url_i18n'];
|
Line 121... |
Line 122... |
121 |
default:
|
122 |
default:
|
122 |
$menu_type = 'classique';
|
123 |
$menu_type = 'classique';
|
123 |
}
|
124 |
}
|
Line 124... |
Line 125... |
124 |
|
125 |
|
125 |
//Construction du menu
|
126 |
//Construction du menu
|
- |
|
127 |
$xhtml_menu = afficherListeNiveauMultiple( $objet_pear_db, $id_site, $id_langue, $i18n_url ,$niveau_depart,
|
- |
|
128 |
$profondeur, $menu_depart, 1, $menu_type, $indent_origine,
|
Line 126... |
Line 129... |
126 |
$xhtml_menu = afficherListeNiveauMultiple($objet_pear_db, $id_site, $id_langue, $i18n_url ,$niveau_depart, $profondeur, $menu_depart, 1, $menu_type, $indent_origine, $indent_pas, $_GEN_commun);
|
129 |
$indent_pas, $_GEN_commun, $num_menu);
|
127 |
|
130 |
|
128 |
//Si nous avons un
|
131 |
//Si nous avons un
|
129 |
if (! empty($xhtml_menu)) {
|
132 |
if (! empty($xhtml_menu)) {
|
Line 146... |
Line 149... |
146 |
* @param integer niveau de départ.
|
149 |
* @param integer niveau de départ.
|
147 |
* @param integer niveau d'arrivée (profondeur max demandée).
|
150 |
* @param integer niveau d'arrivée (profondeur max demandée).
|
148 |
* @param integer identifiant d'un menu pére.
|
151 |
* @param integer identifiant d'un menu pére.
|
149 |
* @return string les listes de menus au format XHTML.
|
152 |
* @return string les listes de menus au format XHTML.
|
150 |
*/
|
153 |
*/
|
151 |
function afficherListeNiveauMultiple($objet_pear_db, $id_site, $id_langue, $i18n_url, $niveau_depart, $profondeur, $id_pere_menu_a_deployer, $position, $menu_type, $indent_origine = 12, $indent_pas = 4, $_GEN_commun)
|
154 |
function afficherListeNiveauMultiple( $objet_pear_db, $id_site, $id_langue, $i18n_url, $niveau_depart, $profondeur,
|
- |
|
155 |
$id_pere_menu_a_deployer, $position, $menu_type, $indent_origine = 12,
|
- |
|
156 |
$indent_pas = 4, $_GEN_commun, $num_menu)
|
152 |
{
|
157 |
{
|
153 |
// Initialisation des variables
|
158 |
// Initialisation des variables
|
154 |
static $niveau_actuel = 1;
|
159 |
static $niveau_actuel = 1;
|
155 |
$retour = '';
|
160 |
$retour = '';
|
156 |
// Gestion des menus uniques
|
161 |
// Gestion des menus uniques
|
Line 166... |
Line 171... |
166 |
}
|
171 |
}
|
Line 167... |
Line 172... |
167 |
|
172 |
|
168 |
// Nous regardons si nous devons afficher un menu racine
|
173 |
// Nous regardons si nous devons afficher un menu racine
|
169 |
if ($id_pere_menu_a_deployer != 0 && $niveau_actuel == 1) {
|
174 |
if ($id_pere_menu_a_deployer != 0 && $niveau_actuel == 1) {
|
170 |
$retour .= str_repeat(' ', $indent_origine + ($indent_pas * $position)).
|
175 |
$retour .= str_repeat(' ', $indent_origine + ($indent_pas * $position)).
|
171 |
'<ul class="menu_commun_n'.($niveau_actuel - 1).'">'."\n";
|
176 |
'<ul class="groupe_menu_'.$num_menu.'_'.$id_pere_menu_a_deployer.'" class="menu_'.$menu_type.'_'.'n'.$niveau_actuel.'">'."\n";
|
172 |
$id_menu_selectionne = $GLOBALS['_GEN_commun']['info_menu']->gm_id_menu;
|
177 |
$id_menu_selectionne = $GLOBALS['_GEN_commun']['info_menu']->gm_id_menu;
|
173 |
if (!empty($id_menu_selectionne) && (GEN_etreAncetre($id_pere_menu_a_deployer, $id_menu_selectionne) || $id_pere_menu_a_deployer == $id_menu_selectionne) ) {
|
178 |
if (!empty($id_menu_selectionne) && (GEN_etreAncetre($id_pere_menu_a_deployer, $id_menu_selectionne) || $id_pere_menu_a_deployer == $id_menu_selectionne) ) {
|
174 |
$classe = 'menu_actif';
|
179 |
$classe = 'menu_actif';
|
175 |
} else {
|
180 |
} else {
|
176 |
$classe = 'menu_inactif';
|
181 |
$classe = 'menu_inactif';
|
177 |
}
|
182 |
}
|
178 |
// Pour un menu dont on spécifie l'identifiant du menu départ, on affiche ce menu.
|
183 |
// Pour un menu dont on spécifie l'identifiant du menu départ, on affiche ce menu.
|
179 |
$retour .= str_repeat(' ', $indent_origine + ($indent_pas * ($position + 1))).
|
184 |
$retour .= str_repeat(' ', $indent_origine + ($indent_pas * ($position + 1))).
|
180 |
'<li id="menu_'.$menu_type.'_'.$id_pere_menu_a_deployer.'" class="'.$classe.'">'."\n";
|
185 |
'<li id="menu_'.$num_menu.'_'.$id_pere_menu_a_deployer.'" class="'.$classe.'">'."\n";
|
181 |
$retour .= afficherEntreeListeMenu( $objet_pear_db, $id_pere_menu_a_deployer, $i18n_url,
|
186 |
$retour .= afficherEntreeListeMenu( $objet_pear_db, $id_pere_menu_a_deployer, $i18n_url,
|
182 |
$niveau_actuel, 1, $position, $menu_type, $indent_origine, $indent_pas, $_GEN_commun);
|
187 |
$niveau_actuel, 1, $position, $menu_type, $indent_origine, $indent_pas, $_GEN_commun);
|
Line 183... |
Line 188... |
183 |
}
|
188 |
}
|
184 |
|
189 |
|
185 |
if ($niveau_actuel >= $niveau_depart && $niveau_actuel <= $profondeur) {
|
190 |
if ($niveau_actuel >= $niveau_depart && $niveau_actuel <= $profondeur) {
|
186 |
$retour .= str_repeat(' ', $indent_origine + ($indent_pas * $position)).
|
191 |
$retour .= str_repeat(' ', $indent_origine + ($indent_pas * ($position + 1))).
|
Line 187... |
Line 192... |
187 |
'<ul id="groupe_menu_'.$menu_type.'_'.$id_pere_menu_a_deployer.'" class="menu_'.$menu_type.'_'.'n'.$niveau_actuel.'">'."\n";
|
192 |
'<ul id="groupe_menu_'.$num_menu.'_'.$id_pere_menu_a_deployer.'" class="menu_'.$menu_type.'_'.'n'.$niveau_actuel.'">'."\n";
|
188 |
}
|
193 |
}
|
189 |
|
194 |
|
Line 239... |
Line 244... |
239 |
} else {
|
244 |
} else {
|
240 |
$classe = 'menu_inactif';
|
245 |
$classe = 'menu_inactif';
|
241 |
}
|
246 |
}
|
Line 242... |
Line 247... |
242 |
|
247 |
|
243 |
// Affichage du menu
|
248 |
// Affichage du menu
|
244 |
$retour .= str_repeat(' ', $indent_origine + ($indent_pas * ($position + 1))).
|
249 |
$retour .= str_repeat(' ', $indent_origine + ($indent_pas * ($position + 2))).
|
245 |
'<li id="menu_'.$menu_type.'_'.$id_menu_inf.'" class="'.$classe.'">'."\n";
|
250 |
'<li id="menu_'.$num_menu.'_'.$id_menu_inf.'" class="'.$classe.'">'."\n";
|
246 |
$retour .= afficherEntreeListeMenu( $objet_pear_db, $id_menu_inf, $i18n_url, $niveau_actuel,
|
251 |
$retour .= afficherEntreeListeMenu( $objet_pear_db, $id_menu_inf, $i18n_url, $niveau_actuel,
|
247 |
$ligne->gmr_ordre, $position, $menu_type, $indent_origine, $indent_pas, $_GEN_commun);
|
252 |
$ligne->gmr_ordre, $position, $menu_type, $indent_origine, $indent_pas, $_GEN_commun);
|
248 |
}
|
253 |
}
|
249 |
// Pour chaque menu on regarde s'il y a des fils. Si oui, on les déploie.
|
254 |
// Pour chaque menu on regarde s'il y a des fils. Si oui, on les déploie.
|
Line 264... |
Line 269... |
264 |
: '';
|
269 |
: '';
|
Line 265... |
Line 270... |
265 |
|
270 |
|
266 |
if ($resultat_fils->numRows() != 0 && $ligne->gm_id_menu == $GLOBALS['_GEN_commun']['info_menu']->gm_id_menu
|
271 |
if ($resultat_fils->numRows() != 0 && $ligne->gm_id_menu == $GLOBALS['_GEN_commun']['info_menu']->gm_id_menu
|
267 |
|| GEN_etreAncetre($ligne->gm_id_menu, $GLOBALS['_GEN_commun']['info_menu']->gm_id_menu)) {
|
272 |
|| GEN_etreAncetre($ligne->gm_id_menu, $GLOBALS['_GEN_commun']['info_menu']->gm_id_menu)) {
|
268 |
$niveau_actuel++;
|
273 |
$niveau_actuel++;
|
- |
|
274 |
$retour .= afficherListeNiveauMultiple( $objet_pear_db, $id_site, $id_langue, $i18n_url, $niveau_depart,
|
- |
|
275 |
$profondeur, $ligne->gm_id_menu, ($position + 3), $menu_type,
|
269 |
$retour .= afficherListeNiveauMultiple($objet_pear_db, $id_site, $id_langue, $i18n_url, $niveau_depart, $profondeur, $ligne->gm_id_menu, ($position + 2), $menu_type, null, null, $_GEN_commun);
|
276 |
null, null, $_GEN_commun, $num_menu);
|
270 |
// On ramène $niveau_actuel un cran plus bas
|
277 |
// On ramène $niveau_actuel un cran plus bas
|
271 |
$niveau_actuel--;
|
- |
|
272 |
$retour .= str_repeat(' ', $indent_origine + ($indent_pas * ($position + 1))).'</li>'."\n";
|
278 |
$niveau_actuel--;
|
- |
|
279 |
}
|
- |
|
280 |
|
273 |
} else {
|
281 |
if ($niveau_actuel >= $niveau_depart && $niveau_actuel <= $profondeur) {
|
274 |
$retour .= str_repeat(' ', $indent_origine + ($indent_pas * ($position + 1))).'</li>'."\n";
|
282 |
$retour .= str_repeat(' ', $indent_origine + ($indent_pas * ($position + 2))).'</li>'."\n";
|
- |
|
283 |
}
|
275 |
}
|
284 |
|
276 |
$resultat_fils->free();
|
285 |
$resultat_fils->free();
|
277 |
}
|
286 |
}
|
Line 278... |
Line 287... |
278 |
$resultat->free();
|
287 |
$resultat->free();
|
279 |
|
288 |
|
280 |
if ($niveau_actuel >= $niveau_depart && $niveau_actuel <= $profondeur) {
|
289 |
if ($niveau_actuel >= $niveau_depart && $niveau_actuel <= $profondeur) {
|
Line 281... |
Line 290... |
281 |
$retour .= str_repeat(' ', $indent_origine + ($indent_pas * $position)).'</ul>'."\n";
|
290 |
$retour .= str_repeat(' ', $indent_origine + ($indent_pas * $position+ 1)).'</ul>'."\n";
|
282 |
}
|
291 |
}
|
283 |
|
292 |
|
Line 362... |
Line 371... |
362 |
|
371 |
|
363 |
|
372 |
|
364 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
373 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
- |
|
374 |
*
|
- |
|
375 |
* $Log: not supported by cvs2svn $
|
- |
|
376 |
* Revision 1.10 2004/11/15 17:40:02 jpm
|
365 |
*
|
377 |
* Changement nom balise.
|
366 |
* $Log: not supported by cvs2svn $
|
378 |
*
|
367 |
* Revision 1.9 2004/11/15 16:17:40 jpm
|
379 |
* Revision 1.9 2004/11/15 16:17:40 jpm
|
368 |
* Gestion des différents types de menus.
|
380 |
* Gestion des différents types de menus.
|
369 |
*
|
381 |
*
|