source: trunk/spip/esqueleto-redcta/plugins/agenda/1_9_1/balise/calendrier_mini.php @ 30

Last change on this file since 30 was 30, checked in by sebas, 17 years ago

nueva importacion del codigo del esqueleto de redcta con los plugins

File size: 3.4 KB
Line 
1<?php
2
3if (!defined("_ECRIRE_INC_VERSION")) return;    #securite
4
5// Pas besoin de contexte de compilation
6global $balise_CALENDRIER_MINI_collecte;
7$balise_CALENDRIER_MINI_collecte = array('id_rubrique','id_article','id_mot');
8
9function balise_CALENDRIER_MINI ($p) {
10        return calculer_balise_dynamique($p,'CALENDRIER_MINI', array('id_rubrique','id_article', 'id_mot'));
11}
12
13function balise_CALENDRIER_MINI_stat($args, $filtres) {
14        return $args;
15}
16 
17function balise_CALENDRIER_MINI_dyn($id_rubrique=0, $id_article = 0, $id_mot = 0,$date, $var_date = 'date', $url = '') {
18        if(!$url)
19                $url = self();
20        // nettoyer l'url qui est passee par htmlentities pour raison de securités
21        $url = str_replace("&amp;","&",$url);
22
23        return array('formulaires/calendrier_mini', 0, 
24                array(
25                        'date' => $date,
26                        'id_rubrique' => $id_rubrique,
27                        'id_article' => $id_article,
28                        'id_mot' => $id_mot,
29                        'var_date' => $var_date,
30                        'self' => $url,
31                ));
32}
33
34function agenda_mini($i) {
35  $args = func_get_args();
36  $une_date = array_shift($args); // une date comme balise
37  $sinon = array_shift($args);
38  if (!$une_date) return $sinon;
39  $type = 'mini';
40  $agenda = Agenda_memo_full(0);
41  $evt = array();
42  foreach (($args ? $args : array_keys($agenda)) as $k) { 
43      if (is_array($agenda[$k]))
44                foreach($agenda[$k] as $d => $v) { 
45                  $evt[$d] = $evt[$d] ? (array_merge($evt[$d], $v)) : $v;
46                }
47    }
48        $la_date = mktime(0, 0, 0, mois($une_date), 1, annee($une_date));
49    include_spip('inc/agenda');
50    return http_calendrier_init($la_date, $type, '', '', '', array('', $evt));
51}
52
53function http_calendrier_mini($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt) {
54        list($sansduree, $evenements, $premier_jour, $dernier_jour) = $evt;
55
56        if ($sansduree)
57                foreach($sansduree as $d => $r) {
58                        $evenements[$d] = !$evenements[$d] ? $r : 
59                                 array_merge($evenements[$d], $r);
60                         }
61
62        if (!$premier_jour) $premier_jour = '01';
63        if (!$dernier_jour) {
64                $dernier_jour = 31;
65                while (!(checkdate($mois,$dernier_jour,$annee))) $dernier_jour--;
66        }
67
68        // affichage du debut de semaine hors periode
69        $ligne = '';
70        $debut = date("w",mktime(1,1,1,$mois,$premier_jour,$annee));
71        for ($i=$debut ? $debut : 7;$i>1;$i--) {
72                $mois_precedent = mktime(1,1,1,$mois-1,1,$annee);
73                $jour_mois_precedent = date('t', $mois_precedent)+2-$i;
74                $ligne .= "\n\t<td class=\"horsperiode\">$jour_mois_precedent</td>";
75        }
76
77        $total = '';
78        for ($j=$premier_jour; $j<=$dernier_jour; $j++) {
79                $nom = mktime(1,1,1,$mois,$j,$annee);
80                $jour = date("d",$nom);
81                $jour_semaine = date("w",$nom);
82                $mois_en_cours = date("m",$nom);
83                $annee_en_cours = date("Y",$nom);
84                $amj = date("Y",$nom) . $mois_en_cours . $jour;
85
86                if ($jour_semaine==1) { 
87                        $total .= "\n<tr>$ligne\n</tr>";
88                        $ligne = '';
89                }
90
91                $evts = $evenements[$amj];
92                $class="";
93                if ($evts) {
94                        $evts = "<a href='".parametre_url($evts[0]['URL'],'date',"$annee_en_cours-$mois_en_cours-$jour")."' title='".$evts[0]['SUMMARY'].
95                        "'>".intval($jour)."</a>";
96                        $class='occupe';
97                }
98                else {
99                        $evts = intval($jour);
100                        $class='libre';
101                }
102                $ligne .= "\n\t<td  class='$class".($amj == date("Ymd")?' today':'')."'>" . $evts . "\n\t</td>";
103        }
104        $jour_mois_suivant=1;
105        // affichage de la fin de semaine hors periode
106        for($j=$jour_semaine ? $jour_semaine : 7; $j<7; $j++) {
107                $ligne .= "\n\t<td class=\"horsperiode\">".$jour_mois_suivant++."</td>";                       
108        }
109
110        return $total . ($ligne ? "\n<tr>$ligne\n</tr>" : '');
111}
112
113?>
Note: See TracBrowser for help on using the repository browser.