summaryrefslogtreecommitdiff
path: root/timeline/timeline.php
blob: 4bc1d4e9ff601c053cad79acd7af70a5f8c361bf (plain)
    1 <?php
    2 // Useless comment
    3 require_once('DB.php');
    4 Markup("timeline", "directives", "/\\(:timeline(\\s+.*)?\\s*:\\)/e",
    5   "'<:block>'.GetEvents()");
    6 
    7 function GetEvents() {
    8 
    9 $days = 14;
   10 if (isset($_POST['days'])) {
   11 	$days = intval($_POST['days']);
   12 }
   13 
   14 $dsn = 'sqlite:////home/crux/public_html/local/timeline.db';
   15 $db =& DB::connect($dsn);
   16 if (DB::isError($db)) die("Cannot connect to database");
   17 $db->setFetchMode(DB_FETCHMODE_ASSOC);
   18 $from = time() - ($days * 24 * 60 * 60);
   19 $sql = "select distinct event_date, event_description, event_notes, event_type, event_time from events where event_tstamp >= $from order by event_tstamp desc";
   20 $res =& $db->Query($sql);
   21 if (DB::isError($res)) die("Query error");
   22 
   23 $timeline .= '<table cellspacing="0" border="0" cellpadding="0">'."\n";
   24 $currdate = "noway";
   25 while ($evt =& $res->fetchRow()) {
   26 	if ($evt['event_date'] != $currdate) {
   27 		$timeline .= '<tr><td class="timeline-head" colspan="3"><span class="timeline-date">'.$evt['event_date']."</span></td></tr>\n";
   28 	}
   29 	$event_description = $evt['event_description'];
   30 	if ($evt['event_notes'] != "") {
   31 		$event_description .= ": ".$evt['event_notes'];
   32 	}
   33 	$event_type = "";
   34 	if (substr($evt['event_type'], 0, 11) == "git_commit_") {
   35 		$event_type = "Changeset ".substr($evt['event_type'], 11, strlen($evt['event_type'])).".git ";
   36 	}
   37 	$img = '<img src="/images/'.$evt['event_type'].'.png">';
   38 	$timeline .= '<tr><td align="right" valign="top" width="60">'.$evt['event_time'].'</td><td align="center" valign="top" width="30">'.$img.'</td><td valign="top">'.$event_type.$event_description.'</td></tr>';
   39 	$timeline .= "\n";
   40 	$currdate = $evt['event_date'];
   41 }
   42 $timeline .= "</table>\n";
   43 $timeline .= '<br><form method="post" action="pmwiki.php?n=Main.Timeline">Show the latest <input size="4" type="text" name="days" value="'.$days.'"> days <input type="submit" value="Show"></form>'."\n";
   44 return $timeline;
   45 
   46 }
   47 ?>

Generated by cgit