Subversion Repositories Applications.papyrus

Rev

Rev 375 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 375 Rev 1030
1
<?php
1
<?php
2
 
2
 
3
class Text_Wiki_Render_Xhtml_Plan extends Text_Wiki_Render {
3
class Text_Wiki_Render_Xhtml_Plan extends Text_Wiki_Render {
4
    
4
    
5
    /**
5
    /**
6
    * 
6
    * 
7
    * Renders a token into text matching the requested format.
7
    * Renders a token into text matching the requested format.
8
    * 
8
    * 
9
    * @access public
9
    * @access public
10
    * 
10
    * 
11
    * @param array $options The "options" portion of the token (second
11
    * @param array $options The "options" portion of the token (second
12
    * element).
12
    * element).
13
    * 
13
    * 
14
    * @return string The text rendered from the token options.
14
    * @return string The text rendered from the token options.
15
    * 
15
    * 
16
    */
16
    */
17
    
17
    
18
    function token($options)
18
    function token($options)
19
    {
19
    {
20
        // Initialisation des variables
20
        // Initialisation des variables
21
        $bdd =& $GLOBALS['_GEN_commun']['pear_db'];
21
        $bdd =& $GLOBALS['_GEN_commun']['pear_db'];
22
        $sortie = '';
22
        $sortie = '';
23
        $sites = $options['site'];
23
        $sites = $options['site'];
24
        // Récupération de l'affichage ou pas des raccourcis
24
        // Récupération de l'affichage ou pas des raccourcis
25
        if (isset($options['permalien'])) {
25
        if (isset($options['permalien'])) {
26
            $permalien = $options['permalien'];
26
            $permalien = $options['permalien'];
27
        }
27
        }
28
        $tab_site = array_map('trim', explode(',', $sites));
28
        $tab_site = array_map('trim', explode(',', $sites));
29
        
29
        
30
        foreach ($tab_site as $cle => $site) {
30
        foreach ($tab_site as $cle => $site) {
31
            if (count($tab_site) > 1) {
31
            if (count($tab_site) > 1) {
32
                $aso_site = GEN_lireInfoSitePrincipalCodeAlpha($bdd, $site, DB_FETCHMODE_ASSOC);
32
                $aso_site = GEN_lireInfoSitePrincipalCodeAlpha($bdd, $site, DB_FETCHMODE_ASSOC);
33
                if (!empty($aso_site['gs_titre'])) {
33
                if (!empty($aso_site['gs_titre'])) {
34
                    $titre = $aso_site['gs_titre'];
34
                    $titre = $aso_site['gs_titre'];
35
                } else {
35
                } else {
36
                    $titre = $aso_site['gs_nom'];
36
                    $titre = $aso_site['gs_nom'];
37
                }
37
                }
-
 
38
                $url_site =& new Pap_URL();
-
 
39
            	$url_site->setUrlType('SITE');
-
 
40
            	$url_site->setId($aso_site['gs_id_site']);
38
                $sortie .= '<h2>'.htmlentities($titre).'</h2>'."\n";
41
                $sortie .= '<h2><a href="'.$url_site->getUrl().'">'.htmlentities($titre).'</a></h2>'."\n";
39
            }
42
            }
40
            $sortie .= '<ul class="plan_site_'.$site.'" >'."\n";
43
            $sortie .= '<ul class="plan_site_'.$site.'" >'."\n";
41
            $aso_menus = GEN_retournerTableauMenusSiteCodeAlpha($bdd, $site);
44
            $aso_menus = GEN_retournerTableauMenusSiteCodeAlpha($bdd, $site);
42
            $sortie .= $this->parserTableauMenus($aso_menus, $permalien);
45
            $sortie .= $this->parserTableauMenus($aso_menus, $permalien);
43
            $sortie .= '</ul>'."\n";
46
            $sortie .= '</ul>'."\n";
44
        }
47
        }
45
        
48
        
46
        return $sortie;
49
        return $sortie;
47
    }
50
    }
48
    
51
    
49
    function parserTableauMenus($aso_menus, $permalien)
52
    function parserTableauMenus($aso_menus, $permalien)
50
    {
53
    {
51
        $sortie = '';
54
        $sortie = '';
52
        // Création de l'url
55
        // Création de l'url
53
        foreach ($aso_menus as $menu_id => $menu_valeur) {
56
        foreach ($aso_menus as $menu_id => $menu_valeur) {
54
            if (    $menu_valeur['gm_date_fin_validite'] == '' 
57
            if (    $menu_valeur['gm_date_fin_validite'] == '' 
55
                    || $menu_valeur['gm_date_fin_validite'] == '0000-00-00 00:00:00' 
58
                    || $menu_valeur['gm_date_fin_validite'] == '0000-00-00 00:00:00' 
56
                    || strtotime($menu_valeur['gm_date_fin_validite']) > time()) {
59
                    || strtotime($menu_valeur['gm_date_fin_validite']) > time()) {
57
                $sortie .= '<li>';
60
                $sortie .= '<li>';
58
                // Création de l'url
61
                // Création de l'url
59
                $une_url =& new Pap_URL('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
62
                $une_url =& new Pap_URL('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
60
                $une_url->setId($menu_id);
63
                $une_url->setId($menu_id);
61
                
64
                
62
                // Construction de l'attribut title
65
                // Construction de l'attribut title
63
                $title = '';
66
                $title = '';
64
                if (!empty($menu_valeur['gm_titre'])) {
67
                if (!empty($menu_valeur['gm_titre'])) {
65
                    $title = ' title="'.htmlentities($menu_valeur['gm_titre']).'"';
68
                    $title = ' title="'.htmlentities($menu_valeur['gm_titre']).'"';
66
                } elseif (!empty($menu_valeur['gm_titre_alternatif'])) {
69
                } elseif (!empty($menu_valeur['gm_titre_alternatif'])) {
67
                    $title = ' title="'.htmlentities($menu_valeur['gm_titre_alternatif']).'"';
70
                    $title = ' title="'.htmlentities($menu_valeur['gm_titre_alternatif']).'"';
68
                }
71
                }
69
                
72
                
70
                // Construction du lien
73
                // Construction du lien
71
                $sortie .= '<a href="'.$une_url->getURL().'"'.$title.'>'.htmlentities($menu_valeur['gm_nom']).'</a>';
74
                $sortie .= '<a href="'.$une_url->getURL().'"'.$title.'>'.htmlentities($menu_valeur['gm_nom']).'</a>';
72
                
75
                
73
                // Nous affichons ou pas le permalien
76
                // Nous affichons ou pas le permalien
74
                if ($permalien) {
77
                if ($permalien) {
75
                    $une_url->setPermalien(true);
78
                    $une_url->setPermalien(true);
76
                    $sortie .= ' <span class="plan_permalien">'.'('.$une_url->getURL().')'.'</span>';
79
                    $sortie .= ' <span class="plan_permalien">'.'('.$une_url->getURL().')'.'</span>';
77
                    $une_url->setPermalien(false);
80
                    $une_url->setPermalien(false);
78
                }
81
                }
79
                
82
                
80
                // Nous ajoutons les sous-menus s'il y en a.
83
                // Nous ajoutons les sous-menus s'il y en a.
81
                $retour = $this->parserTableauMenus($menu_valeur['sous_menus'], $permalien);
84
                $retour = $this->parserTableauMenus($menu_valeur['sous_menus'], $permalien);
82
                if ($retour != '') {
85
                if ($retour != '') {
83
                    $sortie .= "\n".'<ul>'."\n".$retour."\n".'</ul>'."\n";
86
                    $sortie .= "\n".'<ul>'."\n".$retour."\n".'</ul>'."\n";
84
                }
87
                }
85
                
88
                
86
                $sortie .= '</li>'."\n";
89
                $sortie .= '</li>'."\n";
87
            }
90
            }
88
        }
91
        }
89
        return $sortie;
92
        return $sortie;
90
    }
93
    }
91
}
94
}
92
?>
95
?>