Accéder au contenu.
Menu Sympa

devel - [Devel] r270 - branches/dui

Objet : devel-adl

Archives de la liste

[Devel] r270 - branches/dui


Chronologique Discussions 
  • From: svn AT agendadulibre.org
  • To: devel AT agendadulibre.org
  • Subject: [Devel] r270 - branches/dui
  • Date: Wed, 2 May 2007 23:14:12 +0200 (CEST)
  • List-archive: <http://lolut.utbm.info/pipermail/devel>
  • List-id: Developpement de l'Agenda du Libre <devel.agendadulibre.org>

Author: ldayot
Date: Wed May 2 23:14:10 2007
New Revision: 270

Log:
Correction d'un bug dans listevents depuis que les tags sont dans une
table.
Ajout d'un filtre sur les tags dans rsslist et icallist.



Modified:
branches/dui/funcs.inc.php
branches/dui/ical.php
branches/dui/icallist.php
branches/dui/listevents.php
branches/dui/rss.php
branches/dui/rsslist.php
branches/dui/showevent.php

Modified: branches/dui/funcs.inc.php
==============================================================================
--- branches/dui/funcs.inc.php (original)
+++ branches/dui/funcs.inc.php Wed May 2 23:14:10 2007
@@ -914,7 +914,7 @@
put_footer();
exit;
}
- $return = _("R�gion :") ." ";
+ $return = "<strong>". _("R�gion :") ."</strong> ";
$return .= "<select name='region'>";
$return .= " <option value='all' ". ($region=="all" ? "selected='selected'
" : ""). ">". _("Toutes les r�gions"). "</option>";
while ($row = $db->fetchObject($ret))
@@ -931,7 +931,7 @@
// output if HTML string select part of form
function selectDurationHTML($daylimit)
{
- $return = _("P�riode :") ." ";
+ $return = "<strong>". _("P�riode :") ."</strong> ";
$return .= "<select name='daylimit'>\n";
$aDurations = array("30"=>_("1 mois"), "91"=>_("3 mois"), "365"=>_("un
an"), "0"=>_("sans limite"),);
foreach ($aDurations as $value=>$label)
@@ -942,7 +942,50 @@
return $return;
}

-
+// Function to choose tags
+// $aTags is an array (category_id=>tag_name)
+// output if HTML string select part of form
+function selectTagsHTML($aTags)
+{
+ global $db;
+ // TODO Select only tags used twice or more.
+ // Or sort and class tags in alphabetical optgroup
+ $ret = $db->query ("SELECT tags.name AS tag, tags_categories.id AS
category_id, tags_categories.name AS category, tags_categories.description as
description FROM tags LEFT JOIN tags_categories ON
tags_categories.id=category_id GROUP BY category_id, tags.id ORDER BY
tags_categories.name, tags.name");
+ if ($ret == FALSE)
+ {
+ error ("Erreur lors de la recherche des tags");
+ put_footer();
+ exit;
+ }
+ $category_id=-1;
+ $return = "";
+ while ($row = $db->fetchObject($ret))
+ {
+ if ($category_id!=$row->category_id)
+ {
+ if ($category_id!=-1)
+ $return .= " ".($description!="" ? $description : "").
"</select>\n<br />\n";
+ if ($category_id==-1)
+ {
+ $category_id = 0;
+ $category="tag";
+ }
+ else
+ {
+ $category_id = $row->category_id;
+ $category = $row->category;
+ }
+ $return .= "<strong>{$category}". _(" :"). "</strong> ";
+ $description = $row->description;
+ $return .= "<select name='tags[{$category}]'>\n";
+ $return .= " <option value='' ". (!isset($aTags[$category]) ?
"selected='selected' " : ""). "></option>";
+ } // end if
+ $return .= " <option value='{$row->tag}' ". (isset($aTags[$category]) &&
$aTags[$category]==$row->tag ? "selected='selected' " : "").
">{$row->tag}</option>";
+ } // end while
+ $db->freeResult($ret);
+ $return .= " </select>\n<br />\n";
+ return $return;
+}

// Get tags name for one event
// Filter for one category, all if null

Modified: branches/dui/ical.php
==============================================================================
--- branches/dui/ical.php (original)
+++ branches/dui/ical.php Wed May 2 23:14:10 2007
@@ -78,14 +78,18 @@
{
$start = mktime() - (12 * 30 * 24 * 60 *60);

- $sql = "select * from events where " .
+ $sql = "select events.* from events ".
+ ($tag != "" ? "LEFT JOIN tags_events ON event_id=events.id LEFT JOIN
tags ON tags.id=tag_id ".
+ "WHERE (tags.name='{$tag}') AND " : "WHERE " ).
"(end_time >= '" . date_timestamp2mysql($start) . "') AND
(moderated=1)";

if ($region != "all")
$sql .= " AND ((region=" . $region . ") OR (locality=1))";

if ($tag != "")
- $sql .= " AND (tags like '%" . $tag . "%')";
+ $sql .= " GROUP BY events.id ";
+
+ $sql .= " ORDER BY start_time ASC";

return $db->query ($sql);
}

Modified: branches/dui/icallist.php
==============================================================================
--- branches/dui/icallist.php (original)
+++ branches/dui/icallist.php Wed May 2 23:14:10 2007
@@ -36,7 +36,15 @@
// Purpose url

echo "<fieldset><legend>". _("S�lection"). "</legend>";
-$url = calendar_absolute_url("ical.php?region=". (isset($_GET["region"]) ?
$_GET["region"] : "all"). (isset($_GET["daylimit"]) &&
$_GET["daylimit"]!="30" ? "&daylimit=". $_GET["daylimit"] : ""), "webcal");
+if (isset($_GET["tags"]) && is_array($_GET["tags"]))
+{
+ $urltags="";
+ foreach ($_GET["tags"] AS $category=>$tag)
+ {
+ $urltags .= "&$category=$tag";
+ }
+}
+$url = calendar_absolute_url("ical.php?region=". (isset($_GET["region"]) ?
$_GET["region"] : "all"). (isset($_GET["daylimit"]) &&
$_GET["daylimit"]!="30" ? "&daylimit=". $_GET["daylimit"] : "").
(isset($urltags) ? $urltags : ""), "webcal");
echo "<a href=\"$url\">$url</a>\n";
echo "</fieldset>\n";

@@ -49,6 +57,9 @@
// Select duration
echo selectDurationHTML(isset($_GET["daylimit"]) ? $_GET["daylimit"] :
"30"). "<br />\n";

+// Select tags
+echo selectTagsHTML(isset($_GET["tags"]) ? $_GET["tags"] : array());
+
echo " <input type=\"submit\" name=\"submit\" value=\"". _("Mettre � jour
la s�lection"). "\" /> <input type=\"reset\" name=\"reset\" value=\"".
_("R�initialise"). "\" />\n";
echo "</fieldset>";


Modified: branches/dui/listevents.php
==============================================================================
--- branches/dui/listevents.php (original)
+++ branches/dui/listevents.php Wed May 2 23:14:10 2007
@@ -52,7 +52,7 @@

$db = new db();

-if (! $_GET['tag'] || !ereg("^[a-z0-9\-]*$", $_GET['tag']))
+if (! isset($_GET['tag']) || !ereg("^[a-z0-9\-]*$", $_GET['tag']))
{
echo "<p><b>Aucun tag s�lectionn�, ou tag invalide.</b></p>";
put_footer();
@@ -95,8 +95,10 @@
list_events($events);
}

-$sql = "select id, title, city, start_time, end_time from events ".
- "where (tags like '%" . $_GET['tag'] . "%') and (start_time < NOW())
and (moderated=1) order by start_time desc";
+$sql = "SELECT events.id AS id, title, city, start_time, end_time FROM
events ".
+ "LEFT JOIN tags_events ON event_id=events.id LEFT JOIN tags ON
tags.id=tag_id ".
+ "WHERE (tags.name='{$_GET['tag']}') ".
+ "AND (start_time < NOW()) AND (moderated=1) GROUP BY events.id ORDER
BY start_time DESC";
$events = $db->query($sql);
if (! $events)
{

Modified: branches/dui/rss.php
==============================================================================
--- branches/dui/rss.php (original)
+++ branches/dui/rss.php Wed May 2 23:14:10 2007
@@ -49,7 +49,9 @@
$start = mktime();
$end = mktime() + ($daylimit * 24 * 60 * 60);

- $sql = "select * from events where " .
+ $sql = "select events.* from events ".
+ ($tag != "" ? "LEFT JOIN tags_events ON event_id=events.id LEFT JOIN
tags ON tags.id=tag_id ".
+ "WHERE (tags.name='{$tag}') AND " : "WHERE " ).
"(start_time <= '" . date_timestamp2mysql($end) . "') AND " .
"(end_time >= '" . date_timestamp2mysql($start) . "') AND
(moderated=1)";

@@ -57,7 +59,7 @@
$sql .= " AND ((region=" . $region . ") OR (locality=1))";

if ($tag != "")
- $sql .= " AND (tags like '%" . $tag . "%')";
+ $sql .= " GROUP BY events.id ";

$sql .= " ORDER BY start_time ASC";

@@ -73,7 +75,7 @@

$daylimit = get_safe_integer('daylimit', 30);

-if ($_GET['tag'] && ereg("^[a-z0-9\-]*$", $_GET['tag']))
+if (isset($_GET['tag']) && ereg("^[a-z0-9\-]*$", $_GET['tag']))
$tag = $_GET['tag'];
else
$tag = '';
@@ -149,7 +151,7 @@
$event->description, $event->city,
$event->region, $event->locality,
$event->url, $event->contact,
- $event->submitter,
$event->tags)));
+ $event->submitter,
eventTagsList($event->id))));

echo " </description>\n";
echo " <content:encoded>\n";
@@ -160,7 +162,7 @@
$event->description, $event->city,
$event->region, $event->locality,
$event->url, $event->contact,
- $event->submitter, $event->tags));
+ $event->submitter,
eventTagsList($event->id)));

echo " </content:encoded>\n";
echo " </item>\n\n";

Modified: branches/dui/rsslist.php
==============================================================================
--- branches/dui/rsslist.php (original)
+++ branches/dui/rsslist.php Wed May 2 23:14:10 2007
@@ -45,7 +45,16 @@
// Purpose url

echo "<fieldset><legend>". _("S�lection"). "</legend>";
-$url = calendar_absolute_url("rss.php?region=". (isset($_GET["region"]) ?
$_GET["region"] : "all"). (isset($_GET["daylimit"]) &&
$_GET["daylimit"]!="30" ? "&daylimit=". $_GET["daylimit"] : ""));
+
+if (isset($_GET["tags"]) && is_array($_GET["tags"]))
+{
+ $urltags="";
+ foreach ($_GET["tags"] AS $category=>$tag)
+ {
+ $urltags .= "&$category=$tag";
+ }
+}
+$url = calendar_absolute_url("rss.php?region=". (isset($_GET["region"]) ?
$_GET["region"] : "all"). (isset($_GET["daylimit"]) &&
$_GET["daylimit"]!="30" ? "&daylimit=". $_GET["daylimit"] : "").
(isset($urltags) ? $urltags : ""));
echo "<a href=\"$url\">$url</a>\n";
echo "</fieldset>\n";

@@ -58,6 +67,9 @@
// Select duration
echo selectDurationHTML(isset($_GET["daylimit"]) ? $_GET["daylimit"] :
"30"). "<br />\n";

+// Select tags
+echo selectTagsHTML(isset($_GET["tags"]) ? $_GET["tags"] : array());
+
echo " <input type=\"submit\" name=\"submit\" value=\"". _("Mettre � jour
la s�lection"). "\" /> <input type=\"reset\" name=\"reset\" value=\"".
_("R�initialise"). "\" />\n";
echo "</fieldset>";


Modified: branches/dui/showevent.php
==============================================================================
--- branches/dui/showevent.php (original)
+++ branches/dui/showevent.php Wed May 2 23:14:10 2007
@@ -63,6 +63,8 @@
echo " </ul>";
}

+ $event->tags = eventTagsList($event->id);
+
if (in_array("libre-en-fete-2007", split(" ", $event->tags)))
{
echo "<hr/>";




  • [Devel] r270 - branches/dui, svn, 02/05/2007

Archives gérées par MHonArc 2.6.16.

Haut de le page