Subversion Repositories Applications.papyrus

Rev

Rev 408 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
335 jpm 1
<?php
2
 
3
class Text_Wiki_Render_Xhtml_Motcles 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
        if (isset($options['mots'])) {
23
            $mots = $options['mots'];
24
        } else {
25
            return '<p>'.' Aucun mot-clés passé en paramêtre! '.'</p>';
26
        }
395 jpm 27
        $condition = 'OR';
28
        if (isset($options['condition'])) {
29
            $condition = $options['condition'];
30
        }
408 alexandre_ 31
        $condition2 = 'OR';
32
        if (isset($options['condition2'])) {
33
            $condition2 = $options['condition2'];
34
        }
395 jpm 35
        $ordre = 'ASC';
36
        if (isset($options['ordre'])) {
37
            $ordre = $options['ordre'];
38
        }
408 alexandre_ 39
        if (isset($options['categorie'])) {
40
        	$categorie = $options['categorie'] ;
41
        }
42
        // Récupération des infos sur les mots
335 jpm 43
        $tab_mots = explode(',', $mots);
44
        for ($i = 0; $i < count($tab_mots); $i++) {
45
            // Suppression des espaces, tabulations... en début et fin de chaine
46
            $tab_mots[$i] = trim($tab_mots[$i]);
47
        }
48
 
408 alexandre_ 49
        // Récupération des infos sur les catégories
50
        $tab_cat = explode(',', $categorie) ;
51
        for ($i = 0; $i < count($tab_cat); $i++) {
52
            // Suppression des espaces, tabulations... en début et fin de chaine
53
            $tab_cat[$i] = trim($tab_cat[$i]);
54
        }
55
 
56
        $aso_info_menu = GEN_lireInfoMenuMeta($GLOBALS['_GEN_commun']['pear_db'], $tab_mots, $tab_cat, $condition, $condition2, $ordre);
57
 
335 jpm 58
        // Formatage des infos en XHTML
59
        $sortie .= '<ul class="page_liste">'."\n";
60
        foreach ($aso_info_menu as $id_menu => $un_menu) {
61
            // Création de l'url
62
            $une_url =& new Pap_URL();
63
            $une_url->setId($id_menu);
64
 
65
            $sortie .= '<li>'."\n";
66
 
67
            // Affichage de l'auteur(s)
68
            $sortie .= '<span class="page_auteur"> '.$un_menu->gm_auteur.'</span>'."\n";
69
            $sortie .= '<span class="page_separateur_auteur"> - </span>'."\n";
70
 
71
            // Affichage du titre
72
            $sortie .= '<a href="'.$une_url->getURL().'">';
73
            $sortie .= '<span class="page_titre"> '.$un_menu->gm_titre.'</span>';
74
            $sortie .= '</a>'."\n";
75
            $sortie .= '<span class="page_separateur_titre"> - </span>'."\n";
76
 
77
            // Affichage de l'horaire de la création de la page
78
            if (($heure = date('G', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
79
                $sortie .= '<span class="page_creation_heure">'.$heure.'</span>';
80
                $sortie .= '<span class="page_separateur_heure">:</span>';
81
                $minute = date('i', strtotime($un_menu->gm_date_creation));
82
                $sortie .= '<span class="page_creation_minute">'.$minute.'</span>';
83
                if (($seconde = date('s', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
84
                    $sortie .= '<span class="page_separateur_heure">:</span>';
85
                    $sortie .= '<span class="page_creation_seconde">'.$seconde.'</span>';
86
                }
87
            }
88
            $sortie .= "\n".'<span class="page_separateur_date_heure"> - </span>'."\n";
89
 
90
            // Affichage de la date de la création de la page
91
            if (($jour = date('d', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
92
                $sortie .= '<span class="page_creation_jour"> '.$jour.'</span>'."\n";
93
            }
94
            if (($mois = $this->_traduireMois(date('m', strtotime($un_menu->gm_date_creation))) ) != '' ) {
95
                $sortie .= '<span class="page_creation_mois"> '.$mois.'</span>'."\n";
96
            }
97
            if (($annee = date('Y', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
98
                $sortie .= '<span class="page_creation_annee"> '.$annee.'</span>'."\n";
99
            }
100
            $sortie .= '</li>'."\n";
101
        }
102
        $sortie .= '</ul>'."\n";
103
        return $sortie;
104
    }
105
 
106
    function _traduireMois($mois_numerique)
107
    {
108
        switch ($mois_numerique) {
109
            case '01' :
110
                return 'janvier';
111
            case '02' :
112
                return 'février';
113
            case '03' :
114
                return 'mars';
115
            case '04' :
116
                return 'avril';
117
            case '05' :
118
                return 'mai';
119
            case '06' :
120
                return 'juin';
121
            case '07' :
122
                return 'juillet';
123
            case '08' :
124
                return 'août';
125
            case '09' :
126
                return 'septembre';
127
            case '10' :
128
                return 'octobre';
129
            case '11' :
130
                return 'novembre';
131
            case '12' :
132
                return 'décembre';
133
            default:
134
                return '';
135
        }
136
    }
137
}
138
?>