Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
345 jpm 1
<?php
2
 
3
class Text_Wiki_Render_Xhtml_Plan extends Text_Wiki_Render {
4
 
5
    /**
6
    *
7
    * Renders a token into text matching the requested format.
8
    *
9
    * @access public
10
    *
11
    * @param array $options The "options" portion of the token (second
12
    * element).
13
    *
14
    * @return string The text rendered from the token options.
15
    *
16
    */
17
 
18
    function token($options)
19
    {
20
        // Initialisation des variables
21
        $sortie = '';
22
        $sites = $options['site'];
23
        // Récupération de l'affichage ou pas des raccourcis
24
        if (isset($options['permalien'])) {
25
            $permalien = $options['permalien'];
26
        }
27
        $tab_site = array_map('trim', explode(',', $sites));
28
        $sortie .= '<ul class="plan_site_'.$site.'" >'."\n";
29
        foreach ($tab_site as $cle => $site) {
30
            $aso_menus = GEN_retournerTableauMenusSiteCodeAlpha($GLOBALS['_GEN_commun']['pear_db'], $site);
31
            $sortie .= $this->parserTableauMenus($aso_menus, $permalien);
32
        }
33
        $sortie .= '</ul>'."\n";
34
 
35
        return $sortie;
36
    }
37
 
38
    function parserTableauMenus($aso_menus, $permalien)
39
    {
40
        $sortie = '';
41
        // Création de l'url
42
        foreach ($aso_menus as $menu_id => $menu_valeur) {
43
            $sortie .= '<li>';
44
            // Création de l'url
45
            $une_url =& new Pap_URL();
46
            $une_url->setId($menu_id);
47
 
48
            // Construction de l'attribut title
49
            $title = '';
50
            if (!empty($menu_valeur['gm_titre'])) {
51
                $title = ' title="'.$menu_valeur['gm_titre'].'"';
52
            } elseif (!empty($menu_valeur['gm_titre_alternatif'])) {
53
                $title = ' title="'.$menu_valeur['gm_titre_alternatif'].'"';
54
            }
55
 
56
            // Construction du lien
57
            $sortie .= '<a href="'.$une_url->getURL().'"'.$title.'>'.$menu_valeur['gm_nom'].'</a>';
58
 
59
            // Nous affichons ou pas le permalien
60
            if ($permalien) {
61
                $une_url->setPermalien(true);
62
                $sortie .= ' <span class="plan_permalien">'.'('.$une_url->getURL().')'.'</span>';
63
                $une_url->setPermalien(false);
64
            }
65
 
66
            // Nous ajoutons les sous-menus s'il y en a.
67
            $retour = $this->parserTableauMenus($menu_valeur['sous_menus'], $permalien);
68
            if ($retour != '') {
69
                $sortie .= "\n".'<ul>'."\n".$retour."\n".'</ul>'."\n";
70
            }
71
 
72
            $sortie .= '</li>'."\n";
73
        }
74
        return $sortie;
75
    }
76
}
77
?>