[Devel] r306 - branches/dui

svn at agendadulibre.org svn at agendadulibre.org
Dim 21 Oct 17:33:45 CEST 2007


Author: ldayot
Date: Sun Oct 21 17:32:50 2007
New Revision: 306

Log:
Lorsqu'il y a plus de <x> evenements le meme jour, alors le calendrier 
mensuel s'etend beaucoup. Solution retenue ici : fixer un nombre maximum 
d'evenements à afficher dans une journee du calendrier et proposer un 
lien vers tous les évenements de cette journee la. Pour qu'il n'y ait 
pas de jaloux, les evenements affichez sont tires au hasard.




Modified:
   branches/dui/bd-private.inc.php.template
   branches/dui/funcs.inc.php

Modified: branches/dui/bd-private.inc.php.template
==============================================================================
--- branches/dui/bd-private.inc.php.template	(original)
+++ branches/dui/bd-private.inc.php.template	Sun Oct 21 17:32:50 2007
@@ -24,4 +24,7 @@
 /** Mailing-list of moderators */
 $moderatorlist = "moderators at your.domain.org";
 
+/** Max events displayed in calendar **/
+$maxEventsInCalendar = 2;
+
 ?>

Modified: branches/dui/funcs.inc.php
==============================================================================
--- branches/dui/funcs.inc.php	(original)
+++ branches/dui/funcs.inc.php	Sun Oct 21 17:32:50 2007
@@ -256,7 +256,7 @@
 	      'month'  => $next_month);
 }
 
-function show_day_events ($db, $day, $month, $year, $region)
+function show_day_events ($db, $day, $month, $year, $region, $maxEventsInCalendar=100)
 {
   /*
    * Compute timestamp of current day and next day. The next day is
@@ -270,37 +270,45 @@
                       ((end_time >= " . $db->quote_smart(date_timestamp2mysql($cur)) . ") AND
                       (start_time <= " . $db->quote_smart(date_timestamp2mysql($next)) . ") AND
                       (moderated = 1))
-                      order by city";
+                      order by rand()";
   else
     $sql = "select * from events where
                       ((end_time >= " . $db->quote_smart(date_timestamp2mysql($cur)) . ") AND
                       (start_time <= " . $db->quote_smart(date_timestamp2mysql($next)) . ") AND
                       (moderated = 1) AND
                       ((region = " . $db->quote_smart($region) . ") OR (locality>=1)) )
-                      order by city";
+                      order by rand()";
 
   $result = $db->query ($sql);
 
   if (! $result)
     {
-      echo "Rien";
+      echo "Erreur ". $sql;
       return;
     }
 
-  if ($db->numRows ($result) > 0)
+  if (($count = $db->numRows ($result)) > 0)
     {
       echo "  <ul>\n";
-
-      while ($ret = $db->fetchObject ($result))
+      $n=0;
+      while (($ret = $db->fetchObject ($result)) && ($n<$maxEventsInCalendar))
 	{
 	  echo "   <li><a href=\"showevent.php?id=" . $ret->id . "\">\n";
 	  echo "    <b>" . str_replace("-", " ", stripslashes($ret->city)) . "</b>: ";
 	  echo htmlentities(stripslashes($ret->title));
 	  echo "    </a></li>\n";
+          $n++;
 	}
+      if ($ret)
+        {
+          echo "<div style=\"text-align:right;text-decoration:bold;\"><a href=\"showoneday.php?date={$ret->start_time}\" title=\"". 
+            sprintf( _("Tous les %s événements du %s"), $count, onlyday_timestamp2humanreadable(date_mysql2timestamp($ret->start_time)) ). 
+            "\"><b>+ ". ($count-$n). " autre". ($count-$n>1 ? "s" : ""). "</b></a></div>\n";
+        }
 
       echo "  </ul>\n";
     }
+
 }
 
 // LD : seems ad hoc function. TODO : generalize or remove it.
@@ -316,6 +324,8 @@
 
 function calendar($db, $month, $year, $region)
 {
+global $maxEventsInCalendar;
+
   $prev = get_prev_month($month, $year);
   $prev_year  = $prev['year'];
   $prev_month = $prev['month'];
@@ -357,7 +367,7 @@
 	      calendar_custom_icon($year, $month, $day);
 	      echo $max_day_in_prev_month + $day;
 	      echo "</h1>\n";
-	      show_day_events ($db, $max_day_in_prev_month + $day, $prev_month, $prev_year, $region);
+	      show_day_events ($db, $max_day_in_prev_month + $day, $prev_month, $prev_year, $region, $maxEventsInCalendar);
 	      echo "  </td>\n";
 	    }
 	  /* Show days of the current month */
@@ -374,7 +384,7 @@
 	      calendar_custom_icon($year, $month, $day);
 	      echo $day;
 	      echo "</h1>\n";
-	      show_day_events ($db, $day, $month, $year, $region);
+	      show_day_events ($db, $day, $month, $year, $region, $maxEventsInCalendar);
 	      echo "</td>\n";
 	    }
 	  /* Show days after the current month (next month) */
@@ -384,7 +394,7 @@
 	      calendar_custom_icon($year, $month, $day);
 	      echo $day - $max_day_in_month;
 	      echo "</h1>\n";
-	      show_day_events ($db, $day - $max_day_in_month, $next_month, $next_year, $region);
+	      show_day_events ($db, $day - $max_day_in_month, $next_month, $next_year, $region, $maxEventsInCalendar);
 	      echo "</td>\n";
 	    }
 	  $day++;
@@ -682,7 +692,7 @@
       if ($cat != "-1")
         if ($cat_id==0)
         {
-          $last_line = "<p>". _("Tags"). " : ";
+          $last_line = "<p>". _("Mots-clés"). " : ";
           foreach ($result_tags as $tag)
             $last_line .= "<a href=\"listevents.php?tag=$tag\">$tag</a> ";
           $last_line .= "</p>";
@@ -704,7 +714,7 @@
   if ($cat != "-1")
     if ($cat_id==0)
     {
-      $last_line = "<p>". _("Tags"). " : ";
+      $last_line = "<p>". _("Mots-clés"). " : ";
       foreach ($result_tags as $tag)
         $last_line .= "<a href=\"listevents.php?tag=$tag\">$tag</a> ";
       $last_line .= "</p>";
@@ -753,7 +763,7 @@
     "URL         : " . $url . "\n".
     "Contact     : " . $contact . "\n" .
     "Soumetteur  : " . $submitter . "\n" .
-    "Tags        : " . $tags . "\n" .
+    "Mots-clés   : " . $tags . "\n" .
     "Description : \n " . preg_replace ("/\n/", "\n ", $description);
 
   return $str;


Plus d'informations sur la liste de diffusion Devel