Accéder au contenu.
Menu Sympa

devel - [Devel] r312 - trunk

Objet : devel-adl

Archives de la liste

[Devel] r312 - trunk


Chronologique Discussions 
  • From: svn AT agendadulibre.org
  • To: devel AT agendadulibre.org
  • Subject: [Devel] r312 - trunk
  • Date: Sun, 25 Nov 2007 17:30:06 +0100 (CET)
  • List-archive: <http://agendadulibre.org/pipermail/devel>
  • List-id: Developpement de l'Agenda du Libre <devel.agendadulibre.org>

Author: thomas
Date: Sun Nov 25 17:28:30 2007
New Revision: 312

Log:
Ajout d'un script permettant de récupérer la liste des évènements par
tag au format XML.



Added:
trunk/xmllistevents.php

Added: trunk/xmllistevents.php
==============================================================================
--- (empty file)
+++ trunk/xmllistevents.php Sun Nov 25 17:28:30 2007
@@ -0,0 +1,72 @@
+<?php
+
+/* Copyright 2007
+ * - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+include("bd.inc.php");
+include("funcs.inc.php");
+
+if (! $_GET['tag'] || !ereg("^[a-z0-9\-]*$", $_GET['tag']))
+{
+ echo "Aucun tag sélectionné, ou tag invalide.";
+ exit;
+}
+
+$db = new db();
+
+$sql = "select * from events where (tags like '%" . $_GET['tag'] . "%') " .
+ "and (moderated=1) order by start_time";
+$events = $db->query($sql);
+if (! $events)
+{
+ echo "Erreur lors de la requête SQL.";
+ exit;
+}
+
+$xml = new xmlWriter();
+$xml->openMemory();
+$xml->startDocument("1.0", "UTF-8");
+
+$xml->startElement("events");
+
+while($event = mysql_fetch_object($events))
+{
+ $xml->startElement("event");
+ $xml->writeElement("title", utf8_encode($event->title));
+ $xml->writeElement("start-time", $event->start_time);
+ $xml->writeElement("end-time", $event->end_time);
+ $xml->writeElement("city", utf8_encode($event->city));
+ $xml->writeElement("region", utf8_encode(region_find($db,
$event->region)));
+ $xml->writeElement("locality", $event->locality);
+ $xml->writeElement("url", $event->url);
+ $xml->writeElement("tags", $event->tags);
+ $xml->writeElement("contact", $event->contact);
+ $xml->startElement("description");
+ $xml->writeCData(utf8_encode($event->description));
+ $xml->endElement();
+ $xml->endElement();
+}
+
+$xml->EndElement();
+$xml->endDocument();
+
+header("Content-type: text/xml");
+echo $xml->outputMemory(true);
+
+?>
\ No newline at end of file




  • [Devel] r312 - trunk, svn, 25/11/2007

Archives gérées par MHonArc 2.6.16.

Haut de le page