function show_stupa_fak($row, &$pass) { extract($row); if ($_fakultaet) { print "<TR><TD>{$fakultaet}</TD>\n"; $pass = array(); } array_push($pass, $stimmen, $r, $g, $b); if ($fakultaet_) { print "<TD>\n"; ## Wenn Fakultät einen Slash enthält, ersetze durch Unterstrich $fakultaet = str_replace("/", "_", $fakultaet); barchart(200, 15, $pass, "stupa-fak-{$fakultaet}.png"); image("stupa-fak-{$fakultaet}.png"); print "</TD></TR>\n"; } }
print "<TR>" . colorTD($fakultaet, "left", 0.9, 0.9, 0.9) . "\n"; } print colorTD("<B>{$nummer}</B>" . (isset($stimmen) ? " ({$stimmen})" : " "), "left", $red, $green, $blue) . "\n"; if ($fakultaet_) { print "</TR>\n"; } } function set_chart($row, &$chart) { extract($row); array_push($chart, $sum, $red, $green, $blue); } function show_legende($row) { extract($row); print colorTD("{$name}", "center", $red, $green, $blue) . "\n"; } section("Status der Urnen"); print "<TABLE border=0 cellpadding=3>\n"; do_query("SELECT fakultaet, nummer, stimmen, " . "urne_status.name AS status_name, " . "red, green, blue FROM urne, urne_status " . "WHERE urne.status = urne_status.id " . "ORDER BY fakultaet, nummer", show_urnen); print "</TABLE><BR>\n"; section("Status der Stimmen"); $chart = array(); do_query_pass("SELECT sum(stimmen) AS sum, red, green, blue " . "FROM urne, urne_status " . "WHERE urne.status = urne_status.id " . "GROUP BY urne_status.id " . "ORDER BY urne_status.id ", set_chart, $chart); barchart(400, 20, $chart, "stimmenstatus.png"); image("stimmenstatus.png"); print "<BR><TABLE border=0 cellpadding=3><TR>\n"; print colorTD("Legende:", "left", 0.9, 0.9, 0.9) . "\n"; do_query("SELECT * FROM urne_status ORDER BY id", show_legende); print "</TR></TABLE><BR>\n"; foot();
/** * Show the time lines of the edits on each page as a graph * * @param unknown_type $subwiki the subwiki * @param unknown_type $cm * @param unknown_type $viewgroupid the user group to view */ function ouwiki_showtimelines($subwiki, $cm, $viewgroupid, $header, $csv) { // get the page versions edited in this subwiki by this user group $editpagetimes = ouwiki_get_editpagetimes($subwiki->id, $viewgroupid); // init arrays and min and max time $pagetimeline = array(); $timeline = array(); // record last page name $pagelast = "-1"; $mintime = '-1'; $maxtime = '-1'; // for each edited page version initialise its array and min/max dates foreach ($editpagetimes as $editpagetime) { // get the page title $page = $editpagetime->pagetitle; // get the edit time and make it into a date $date = userdate($editpagetime->date, get_string('strftimedate')); // if a different page if ($page !== $pagelast) { // init the timeline info $timeline[$page] = array(); // check for the earliest edit $mintime = $mintime == -1 ? $editpagetime->date : min($mintime, $editpagetime->date); } // check for the latest edit $maxtime = $maxtime == -1 ? $editpagetime->date : max($maxtime, $editpagetime->date); // save the title of the current page $pagelast = $page; } // number of seconds in a day $day = 60 * 60 * 24; // round the times to the beginning of the day $mintime -= $mintime % $day; $maxtime -= $maxtime % $day; // count the number of days $daycount = ceil(($maxtime - $mintime) / $day); // get the page titles $pages = array_keys($timeline); // for each page initialise every date to 0 edits foreach ($pages as $page) { // go from first edit date by user group on wiki to last edit date, a day at a time for ($time = $mintime; $time <= $maxtime; $time += $day) { // get the date $date = userdate($time, get_string('strftimedate')); // inititilise the data point to 0 edits $timeline[$page][$date] = 0; } } // init the maximum edits in a single day for scale $maxeditcount = 0; // for each edited page version count the number of edits for each page for each day foreach ($editpagetimes as $editpagetime) { // get the page title $page = $editpagetime->pagetitle; // get the edit date $date = userdate($editpagetime->date, get_string('strftimedate')); // increment the number of times the page has been edited on this date $timeline[$page][$date]++; // check for maximum edits in a single day $maxeditcount = max($maxeditcount, $timeline[$page][$date]); } // get min and max dates for edits by user group in wiki $mindate = userdate($mintime, get_string('strftimedate')); $maxdate = userdate($maxtime, get_string('strftimedate')); // Don't show it if there's nothing in it if (count($timeline) == 0) { return; } // print opening div and table tags as well as headers, the first header is the page name and link to the page // and the second contains the first and last date of editing if (!$csv) { print <<<EOF <div class="ouw_timelines_page"> <h3>{$header->timelinetitle}</h3> <table> <tr> <th scope="col">{$header->timelinepage}<div class='ouw_pagecolumn'></div></th> <th class="ouw_firstingroup" scope="col">{$mindate}</th><th class='ouw_rightcol ouw_lastdate' scope="col">{$maxdate}</th> \t </tr> EOF; } else { print $csv->line() . $csv->quote($header->timelinetitle) . $csv->line() . $csv->quote($header->timelinepage); $data = reset($timeline); foreach ($data as $date => $datum) { print $csv->sep() . $csv->quote($date); } } // Draw the graphs // for each timeline for each page $count = count($timeline); foreach ($timeline as $pagetitle => $data) { // if no title then must be start page of wiki, create link to this if ($pagetitle === '') { // get the parameters to view the subwiki pages $pageparams = ouwiki_display_wiki_parameters(null, $subwiki, $cm); // create a link to the page $pagelink = "<a href='view.php?" . $pageparams . "'>" . get_string('startpage', 'ouwiki') . "</a>"; } else { // get the page params to link to the page $pageparams = ouwiki_display_wiki_parameters($pagetitle, $subwiki, $cm); // create a link to the page $pagelink = "<a href='view.php?" . $pageparams . "'>" . htmlspecialchars($pagetitle) . "</a>"; } // print the title and link to the page $count--; if (!$csv) { print "\n \t<tr" . ($count == 0 ? " class='ouw_lastrow'" : "") . ">\n <td class='ouw_leftcol'>{$pagelink}</td>\n <td class='ouw_rightcol ouw_firstingroup' colspan='2'>"; // print the bar chart for the page timeline data, max edit count is for an even scale, // the numbers are the size of each graph => width, height barchart($data, 800, 20, $maxeditcount); // close the tags for the row print "\n \t\t<div class='clearer'></div></td>\n \t</tr>"; } else { if ($pagetitle === '') { $pagetitle = get_string('startpage', 'ouwiki'); } print $csv->line() . $csv->quote(htmlspecialchars($pagetitle)); foreach ($data as $date => $datum) { print $csv->sep() . $csv->quote($datum); } } } // close the table and div tags for the timeline data if (!$csv) { print ' </table> </div>'; } else { print $csv->line(); } }