#include <infodrom.style>
#include "calendar.inc"

<page func="Infodrom Oldenburg" title="Events">

<?

  $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
	       or die("Unable to connect to SQL server");

  pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");

  $query = "SELECT $event_cols FROM events WHERE "
          ."start <= 'now' AND start + delta + '23:59' >= 'now' ORDER BY start,name";

  $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");

  $year = 0;
  $color = $nowcolor;
  for ($i=0; $i < pg_NumRows ($sth); $i++) {
    $row = pg_fetch_array ($sth, $i);

    $date = explode (" ", $row['start']);
    $date = explode ("-", $date[0]);
    $end = explode (" ", $row[3]);
    $end = explode ("-", $end[0]);
    $thisyear = $date[0];

    $date = format_date ($date, $end);

    if ($thisyear != $year) {
      if ($year > 0) {
        echo ($event_table_end);
      }
      printf ("<h3 class=\"bar\">Upcoming events in %s</h3>", $thisyear);
      echo ($event_table_start);
      $year = $thisyear;
    }

    $row['name'] = str_replace (" ", "&nbsp;", $row['name']);
    $row['city'] = str_replace (" ", "&nbsp;", $row['city']);
    $row['country'] = str_replace (" ", "&nbsp;", $row['country']);

    printf ($event_row, $color, $row['oid'], $row['name'], $row['cancelled'] == 1?" *cancelled*":"",
	    $row['city'], $row['country'], $date);
  }

  $query = "SELECT $event_cols FROM events WHERE start > 'now' ORDER BY start,name";

  $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");

  $color = 0;
  for ($i=0; $i < pg_NumRows ($sth); $i++) {
    $row = pg_fetch_array ($sth, $i);

    $date = explode (" ", $row['start']);
    $date = explode ("-", $date[0]);
    $end = explode (" ", $row[3]);
    $end = explode ("-", $end[0]);
    $thisyear = $date[0];

    $date = format_date ($date, $end);

    if ($thisyear != $year) {
      if ($year > 0) {
        echo ($event_table_end);
      }
      $color = 0;
      printf ("<h3 class=\"bar\">Upcoming events in %s</h3>", $thisyear);
      echo ($event_table_start);
      $year = $thisyear;
    }

    $row['name'] = str_replace (" ", "&nbsp;", $row['name']);
    $row['city'] = str_replace (" ", "&nbsp;", $row['city']);
    $row['country'] = str_replace (" ", "&nbsp;", $row['country']);

    printf ($event_row, $color, $row['oid'], $row['name'], $row['cancelled'] == 1?" *cancelled*":"",
	    $row['city'], $row['country'], $date);
    $color = !$color;
  }
  echo ($event_table_end);
?>

<p><b>External resources:</b></p>
<ul>
<li><a href="http://www.usenix.org/events/">Usenix - Events Calendar</a>
<li><a href="http://www.guug.de/kalender/">GUUG - Kalender</a>
<li><a href="http://www.pl-forum.de/cgi-bin/plcal/index.cgi">Pro-Linux</a>
<li><a href="http://www.linuxcalendar.com/">LWN Community Calendar</a>
<li><a href="http://www.linuxwochen.at/">Linuxwochen Österreich</a>
</ul>

</page>

# Local variables:
# mode: text
# mode: auto-fill
# end:
