Objet : devel-adl
Archives de la liste
- From: svn AT agendadulibre.org
- To: devel AT agendadulibre.org
- Subject: [Devel] r194 - trunk
- Date: Sun, 29 Oct 2006 20:07:26 +0100 (CET)
- List-archive: <http://lolut.utbm.info/pipermail/devel>
- List-id: Developpement de l'Agenda du Libre <devel.agendadulibre.org>
Author: thomas
Date: Sun Oct 29 20:07:26 2006
New Revision: 194
Modified:
trunk/funcs.inc.php
Log:
Ajout de fonctions has_event_in_past() et has_event_in_future() qi
permettent de savoir si, connaissant une date donnée, des évènements
ont lieu dans le passé ou dans le futur.
Cela permet d'afficher les flèches de navigation seulement si il y a
quelque chose à voir dans le passé ou dans le futur. Cela devrait donc
éviter à Google de scanner l'Agenda du Libre de l'année 2157.
Modified: trunk/funcs.inc.php
==============================================================================
--- trunk/funcs.inc.php (original)
+++ trunk/funcs.inc.php Sun Oct 29 20:07:26 2006
@@ -320,6 +320,28 @@
echo "</table>\n";
}
+function has_event_in_past($db, $month, $year, $region)
+{
+ $date = $year . "-" . $month . "-" . "01";
+ if ($region == "all")
+ $req = $db->query ("select id from events where start_time < '" . $date
. "'");
+ else
+ $req = $db->query ("select id from events where start_time < '" . $date
. "' and region=" . $region);
+
+ return (mysql_num_rows($req) != 0);
+}
+
+function has_event_in_future($db, $month, $year, $region)
+{
+ $date = $year . "-" . $month . "-" . "01";
+ if ($region == "all")
+ $req = $db->query ("select id from events where start_time >= '" . $date
. "'");
+ else
+ $req = $db->query ("select id from events where start_time >= '" . $date
. "' and region=" . $region);
+
+ return (mysql_num_rows($req) != 0);
+}
+
function one_month_calendar($db, $month, $year, $region)
{
/*
@@ -342,10 +364,12 @@
* 5. The region selector
*/
echo "<h2 class=\"calendar\">\n";
- echo " <a
href=\"?year=".$prev_year."&month=".$prev_month."&region=".$region."\">
<< </a>\n";
+ if (has_event_in_past($db, $month, $year, $region))
+ echo " <a
href=\"?year=".$prev_year."&month=".$prev_month."&region=".$region."\">
<< </a>\n";
echo " <span id=\"month_name\">".date_month2string($month)." ";
echo " <a
href=\"?year=".$year."&region=".$region."\">".$year."</a>"."</span>\n";
- echo " <a
href=\"?year=".$next_year."&month=".$next_month."&region=".$region."\">
>> </a>\n";
+ if (has_event_in_future($db, $next_month, $next_year, $region))
+ echo " <a
href=\"?year=".$next_year."&month=".$next_month."&region=".$region."\">
>> </a>\n";
echo "<form>\n";
echo "<select>\n";
@@ -401,9 +425,11 @@
$next_year = $year + 1;
$prev_year = $year - 1;
echo "<h2 class=\"calendar\">\n";
- echo " <a href=\"?year=".$prev_year."&region=".$region."\"> <<
</a>\n";
+ if (has_event_in_past($db, 1, $year, $region))
+ echo " <a href=\"?year=".$prev_year."&region=".$region."\"> <<
</a>\n";
echo " <span id=\"month_name\">".$year."</span>\n";
- echo " <a href=\"?year=".$next_year."&region=".$region."\"> >>
</a>\n";
+ if (has_event_in_future($db, 1, $next_year, $region))
+ echo " <a href=\"?year=".$next_year."&region=".$region."\"> >>
</a>\n";
echo "<form>";
echo "<select>\n";
- [Devel] r194 - trunk, svn, 29/10/2006
- Re: [Devel] r194 - trunk, David MENTRE, 29/10/2006
Archives gérées par MHonArc 2.6.16.