Subversion Repositories Applications.papyrus

Rev

Rev 345 | Go to most recent revision | Details | Compare with Previous | 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
347 jpm 21
        $bdd =& $GLOBALS['_GEN_commun']['pear_db'];
345 jpm 22
        $sortie = '';
23
        $sites = $options['site'];
24
        // Récupération de l'affichage ou pas des raccourcis
25
        if (isset($options['permalien'])) {
26
            $permalien = $options['permalien'];
27
        }
28
        $tab_site = array_map('trim', explode(',', $sites));
347 jpm 29
 
345 jpm 30
        foreach ($tab_site as $cle => $site) {
347 jpm 31
            if (count($tab_site) > 1) {
32
                $aso_site = GEN_lireInfoSitePrincipalCodeAlpha($bdd, $site, DB_FETCHMODE_ASSOC);
33
                if (!empty($aso_site['gs_titre'])) {
34
                    $titre = $aso_site['gs_titre'];
35
                } else {
36
                    $titre = $aso_site['gs_nom'];
37
                }
38
                $sortie .= '<h2>'.$titre.'</h2>'."\n";
39
            }
40
            $sortie .= '<ul class="plan_site_'.$site.'" >'."\n";
41
            $aso_menus = GEN_retournerTableauMenusSiteCodeAlpha($bdd, $site);
345 jpm 42
            $sortie .= $this->parserTableauMenus($aso_menus, $permalien);
347 jpm 43
            $sortie .= '</ul>'."\n";
345 jpm 44
        }
45
 
46
        return $sortie;
47
    }
48
 
49
    function parserTableauMenus($aso_menus, $permalien)
50
    {
51
        $sortie = '';
52
        // Création de l'url
53
        foreach ($aso_menus as $menu_id => $menu_valeur) {
54
            $sortie .= '<li>';
55
            // Création de l'url
56
            $une_url =& new Pap_URL();
57
            $une_url->setId($menu_id);
58
 
59
            // Construction de l'attribut title
60
            $title = '';
61
            if (!empty($menu_valeur['gm_titre'])) {
62
                $title = ' title="'.$menu_valeur['gm_titre'].'"';
63
            } elseif (!empty($menu_valeur['gm_titre_alternatif'])) {
64
                $title = ' title="'.$menu_valeur['gm_titre_alternatif'].'"';
65
            }
66
 
67
            // Construction du lien
68
            $sortie .= '<a href="'.$une_url->getURL().'"'.$title.'>'.$menu_valeur['gm_nom'].'</a>';
69
 
70
            // Nous affichons ou pas le permalien
71
            if ($permalien) {
72
                $une_url->setPermalien(true);
73
                $sortie .= ' <span class="plan_permalien">'.'('.$une_url->getURL().')'.'</span>';
74
                $une_url->setPermalien(false);
75
            }
76
 
77
            // Nous ajoutons les sous-menus s'il y en a.
78
            $retour = $this->parserTableauMenus($menu_valeur['sous_menus'], $permalien);
79
            if ($retour != '') {
80
                $sortie .= "\n".'<ul>'."\n".$retour."\n".'</ul>'."\n";
81
            }
82
 
83
            $sortie .= '</li>'."\n";
84
        }
85
        return $sortie;
86
    }
87
}
88
?>