1 <?php
2
3 // to obtain a list of wiki profiles:
4 // $ ls -1 /home/crux/public_html/wiki.d/Profiles.* | cut -d'.' -f3-
5 $profiles = array(
6 "AnttiNykanen",
7 "BrettGoulder",
8 "DanielMueller",
9 "DannyRawlins",
10 "FalkHamann",
11 "FredrikRinnestam",
12 "Frinnst",
13 "Jaeger",
14 "JamesMills",
15 "JasonThomasDolan",
16 "JohannesWinkelmann",
17 "JonathanAsghar",
18 "JoseBeneyto",
19 "JoseVBeneyto",
20 "JuergenDaubert",
21 "JukkaHeino",
22 "JustinRebelo",
23 "LucasHazel",
24 "MattHoush",
25 "NickSteeves",
26 "PerLiden",
27 "SimoneRota",
28 "ThomasPenteker",
29 "TillBiedermann",
30 "TilmanSauerbeck",
31 );
32
33 // DB class from php pear
34 require_once('DB.php');
35
36 Markup("timeline", "directives", "/\\(:timeline(\\s+.*)?\\s*:\\)/e", "'<:block>'.GetEvents()");
37
38 function GetEvents() {
39
40 global $profiles;
41
42 $days = 14;
43 if (isset($_POST['days'])) $days = intval($_POST['days']);
44
45 $dsn = 'sqlite:////home/crux/public_html/local/timeline.db';
46 $db =& DB::connect($dsn);
47 if (DB::isError($db)) die("Cannot connect to database");
48 $db->setFetchMode(DB_FETCHMODE_ASSOC);
49 $from = time() - ($days * 24 * 60 * 60);
50 $sql = "select distinct event_date, event_description, event_notes, event_type, event_time from events where event_tstamp >= $from order by event_tstamp desc";
51 $res =& $db->Query($sql);
52 if (DB::isError($res)) die("Query error");
53
54 $timeline .= '<table cellspacing="0" border="0" cellpadding="0">'."\n";
55 $currdate = "noway";
56
57 while ($evt =& $res->fetchRow()) {
58
59 // date header
60 if ($evt['event_date'] != $currdate) {
61 $timeline .= '<tr><td class="timeline-head" colspan="3"><span class="timeline-date">'.$evt['event_date']."</span></td></tr>\n";
62 }
63
64 // description
65 $event_description = "";
66 if (substr($evt['event_type'], 0, 5) == "task_") {
67 // flyspray events
68 $real_name = strstr($evt['event_description'], 'by');
69 $real_name = substr($real_name, 3, strlen($real_name));
70 $trim_name = str_replace(' ', '', $real_name);
71 if (in_array($trim_name, $profiles)) {
72 $event_description = str_replace($real_name, "[[~".$trim_name."]]", $evt['event_description']);
73 }
74 else {
75 $event_description = $evt['event_description'];
76 }
77 }
78 elseif (substr($evt['event_type'], 0, 5) == "wiki_") {
79 // wiki events
80 $event_description = $evt['event_description'];
81 }
82 elseif (substr($evt['event_type'], 0, 11) == "git_commit_") {
83 // git events
84 $event_description = "Changeset ".substr($evt['event_type'], 11, strlen($evt['event_type'])).".git ".$evt['event_description'];
85 }
86
87 // append notes
88 if ($evt['event_notes'] != "") $event_description .= ": ".$evt['event_notes'];
89
90 // image
91 $img = '<img src="/images/'.$evt['event_type'].'.png">';
92
93 // final string
94 $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_description.'</td></tr>'."\n";
95 $currdate = $evt['event_date'];
96 }
97
98 $timeline .= "</table>\n";
99 $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";
100
101 return $timeline;
102 }
103
104 ?>
|