From 1b54c6488e6642dccdbd3319b7f5d392ffb7f4ff Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Mon, 22 Dec 2008 07:26:15 +0000 Subject: [PATCH] =?UTF-8?q?La=20fonction=20principale=20de=20l'agenda=20n'?= =?UTF-8?q?a=20pas=20=C3=A0=20consulter=20directement=20les=20variables=20?= =?UTF-8?q?d'URL,=20on=20d=C3=A9porte=20dans=20les=20appelants.=20Pour=20l?= =?UTF-8?q?'espace=20priv=C3=A9,=20c'est=20boucl=C3=A9.=20Pour=20l'espace?= =?UTF-8?q?=20public=20(les=20squelettes=20{{{agenda=5F}}}*{{{.html}}})=20?= =?UTF-8?q?c'est=20encore=20insuffisant:=20c'est=20le=20filtre=20{{{agenda?= =?UTF-8?q?=5Faffiche}}}=20qui=20consulte=20les=20variables=20d'URL,=20alo?= =?UTF-8?q?rs=20que=20les=20squelettes=20devraient=20les=20lui=20fournir.?= =?UTF-8?q?=20A=20finir,=20mais=20la=20signature=20de=20ce=20filtre=20devr?= =?UTF-8?q?a=20changer.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/exec/calendrier.php | 23 +++++++++++++---------- ecrire/exec/message.php | 3 +-- ecrire/inc/agenda.php | 28 ++++++++++++---------------- ecrire/inc/filtres.php | 35 +++++++++++++++++++---------------- 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/ecrire/exec/calendrier.php b/ecrire/exec/calendrier.php index 39fb338c7a..593a5340fd 100644 --- a/ecrire/exec/calendrier.php +++ b/ecrire/exec/calendrier.php @@ -33,21 +33,24 @@ function exec_calendrier_dist() else { $titre = _T('titre_page_calendrier', array('nom_mois' => nom_mois($date), 'annee' => annee($date))); - } + $type = 'mois'; + } $ancre = 'calendrier-1'; - - $r = http_calendrier_init('', $type, '','',generer_url_ecrire('calendrier', ($type ? "type=$type" : '')) . "#$ancre"); + $time = array(_request('jour'), _request('mois'), _request('annee')); + $r = generer_url_ecrire('calendrier', "type=$type") . "#$ancre"; + $r = http_calendrier_init($time, $type, _request('echelle'), _request('partie_cal'), $r); if (_AJAX) { ajax_retour($r); } else { - $commencer_page = charger_fonction('commencer_page', 'inc'); - echo $commencer_page($titre, "accueil", "calendrier"); - echo barre_onglets("calendrier", "calendrier"); // ne produit rien par defaut, mais est utilisee par le plugin agenda - echo debut_grand_cadre(true); - echo "\n<div> </div>\n<div id='", $ancre, "'>",$r,'</div>'; - echo fin_grand_cadre(true); - echo fin_page(); + $commencer_page = charger_fonction('commencer_page', 'inc'); + echo $commencer_page($titre, "accueil", "calendrier"); + // ne produit rien par defaut, mais est utilisee par le plugin agenda + echo barre_onglets("calendrier", "calendrier"); + echo debut_grand_cadre(true); + echo "\n<div> </div>\n<div id='", $ancre, "'>",$r,'</div>'; + echo fin_grand_cadre(true); + echo fin_page(); } } diff --git a/ecrire/exec/message.php b/ecrire/exec/message.php index 997ee13067..39f9035049 100644 --- a/ecrire/exec/message.php +++ b/ecrire/exec/message.php @@ -302,7 +302,6 @@ function http_affiche_message($id_message, $expediteur, $statut, $type, $texte, // http://doc.spip.org/@exec_affiche_message_dist function exec_affiche_message_dist($id_message, $cherche_auteur, $forcer_dest) { - global $echelle, $partie_cal; $row = sql_fetsel("*", "spip_messages", "id_message=$id_message"); if ($row) { $id_message = $row['id_message']; @@ -348,7 +347,7 @@ function exec_affiche_message_dist($id_message, $cherche_auteur, $forcer_dest) echo creer_colonne_droite('', true); echo http_calendrier_ics_titre($lannee,$lemois,$lejour,generer_url_ecrire('calendrier')); - echo http_calendrier_ics($lannee,$lemois, $lejour, $echelle, $partie_cal, 90, array($sh, $ah)); + echo http_calendrier_ics($lannee,$lemois, $lejour, '', '', 90, array($sh, $ah)); } echo debut_droite('', true); diff --git a/ecrire/inc/agenda.php b/ecrire/inc/agenda.php index 3f316d11b6..89ea69a867 100644 --- a/ecrire/inc/agenda.php +++ b/ecrire/inc/agenda.php @@ -171,28 +171,24 @@ function calendrier_height ($heure, $heurefin, $debut, $fin, $dimheure, $dimjour // // http://doc.spip.org/@http_calendrier_init -function http_calendrier_init($time='', $type='mois', $lechelle='', $lpartie_cal='', $script='', $evt=null) +function http_calendrier_init($time='', $type='mois', $echelle='', $partie_cal='', $script='', $evt=null) { - if (!$time) - { - $mindate = ($j=_request('jour')) + ($m=_request('mois')) + ($a=_request('annee')); - if ($mindate) - $time = mktime(0,0,0, $m, $j, $a); - else $time = time(); - } + if (is_array($time)) { + list($j,$m,$a) = $time; + if ($j+$m+$a) $time = @mktime(0,0,0, $m, $j, $a); + } + if (!is_numeric($time)) $time = time(); - if (!$type) $type ='mois'; // ca suffit pas, l'entete $jour = date("d",$time); $mois = date("m",$time); $annee = date("Y",$time); - if (!$lechelle) $lechelle = _request('echelle'); - - if (!$lpartie_cal) - if (!($lpartie_cal = _request('partie_cal'))) - $partie_cal = DEFAUT_PARTIE; + if (!$echelle = intval($echelle)) $echelle = DEFAUT_D_ECHELLE; + if (!is_string($type) OR !preg_match('/^\w+$/', $type)) $type ='mois'; + if (!is_string($partie_cal) OR !preg_match('/^\w+$/', $partie_cal)) + $partie_cal = DEFAUT_PARTIE; list($script, $ancre) = calendrier_retire_args_ancre($script); - if (is_null($evt)) { + if (is_null($evt)) { $g = 'quete_calendrier_' . $type; $evt = quete_calendrier_interval($g($annee,$mois, $jour)); quete_calendrier_interval_articles("'$annee-$mois-00'", "'$annee-$mois-1'", $evt[0]); @@ -201,7 +197,7 @@ function http_calendrier_init($time='', $type='mois', $lechelle='', $lpartie_cal } $f = 'http_calendrier_' . $type; if (!function_exists($f)) $f = 'http_calendrier_mois'; - return $f($annee, $mois, $jour, $lechelle, $lpartie_cal, $script, $ancre, $evt); + return $f($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt); } # affichage d'un calendrier de plusieurs semaines diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php index 4c5e22b0ff..346bb42a4e 100644 --- a/ecrire/inc/filtres.php +++ b/ecrire/inc/filtres.php @@ -1215,33 +1215,36 @@ function agenda_memo($date=0 , $descriptif='', $titre='', $url='', $cal='') // et affiche selon le type les elements indexes par N dans ce tableau. // Si le suite de noms est vide, tout le tableau est pris // Ces noms N sont aussi des classes CSS utilisees par http_calendrier_init +// Cette fonction recupere aussi par _request les parametres +// jour, mois, annee, echelle, partie_cal (a ameliorer) // http://doc.spip.org/@agenda_affiche function agenda_affiche($i) { include_spip('inc/agenda'); $args = func_get_args(); - $nb = array_shift($args); // nombre d'evenements (on pourrait l'afficher) - $sinon = array_shift($args); + // date ou nombre d'evenements (on pourrait l'afficher) + $nb = array_shift($args); + $evt = array_shift($args); $type = array_shift($args); - if (!$nb){ - return http_calendrier_init('', ($type != 'periode') ? $type : 'mois', '', '', self('&'), $sinon); - } - $agenda = agenda_memo(0); - $evt = array(); - foreach (($args ? $args : array_keys($agenda)) as $k) { - if (is_array($agenda[$k])) - foreach($agenda[$k] as $d => $v) { - $evt[$d] = $evt[$d] ? (array_merge($evt[$d], $v)) : $v; + spip_log("evt $nb"); + if (!$nb) { + $d = array(time()); + } else { + $agenda = agenda_memo(0); + $evt = array(); + foreach (($args ? $args : array_keys($agenda)) as $k) { + if (is_array($agenda[$k])) + foreach($agenda[$k] as $d => $v) { + $evt[$d] = $evt[$d] ? (array_merge($evt[$d], $v)) : $v; + } } + $d = array_keys($evt); } - $d = array_keys($evt); - if (count($d)){ $mindate = min($d); $start = strtotime($mindate); - } - else { + } else { $mindate = ($j=_request('jour')) * ($m=_request('mois')) * ($a=_request('annee')); if ($mindate) $start = mktime(0,0,0, $m, $j, $a); @@ -1256,7 +1259,7 @@ function agenda_affiche($i) $evt = array('', $evt, $min, $max); $type = 'mois'; } - return http_calendrier_init($start, $type, '', '', self('&'), $evt); + return http_calendrier_init($start, $type, _request('echelle'), _request('partie_cal'), self('&'), $evt); } // -- GitLab