import
[web.mtrack] / web / log.php
1 <?php # vim:ts=2:sw=2:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
3
4 include '../inc/common.php';
5 MTrackACL::requireAllRights('Browser', 'read');
6
7 $pi = mtrack_get_pathinfo(true);
8 $crumbs = MTrackSCM::makeBreadcrumbs($pi);
9 if (!strlen($pi) || $pi == '/') {
10   $pi = '/';
11   $repo = null;
12 } else {
13   $repo = MTrackSCM::factory($pi);
14 }
15
16 if ($repo === null) {
17   throw new Exception("Cannot determine what to log from $pi");
18 }
19
20 MTrackACL::requireAllRights("repo:$repo->repoid", 'read');
21 mtrack_head("Log $pi");
22
23 /* Render a bread-crumb enabled location indicator */
24 echo "<div class='browselocation'>Location: ";
25 $location = null;
26 if (isset($_GET['jump'])) {
27   $jump = '?jump=' . urlencode($_GET['jump']);
28   list($object, $ident) = explode(':', $_GET['jump'], 2);
29 } else {
30   $_GET['jump'] = '';
31   $jump = '';
32   $object = null;
33   $ident = null;
34 }
35 $last = array_pop($crumbs);
36 foreach ($crumbs as $path) {
37   if (!strlen($path)) {
38     $path = '[root]';
39     echo "<a href='{$ABSWEB}browse.php$jump'>$path</a> / ";
40   } else {
41     $location .= '/' . htmlentities(urlencode($path), ENT_QUOTES, 'utf-8');
42     echo "<a href='{$ABSWEB}log.php$location$jump'>$path</a> / ";
43   }
44 }
45
46 echo "$last";
47 $branches = $repo->getBranches();
48 $tags = $repo->getTags();
49 if (count($branches) + count($tags)) {
50   $jumps = array("" => "- Select Branch / Tag - ");
51   if (is_array($branches)) {
52     foreach ($branches as $name => $notcare) {
53       $jumps["branch:$name"] = "Branch: $name";
54     }
55   }
56   if (is_array($tags)) {
57     foreach ($tags as $name => $notcare) {
58       $jumps["tag:$name"] = "Tag: $name";
59     }
60   }
61   echo "<form>";
62   echo mtrack_select_box("jump", $jumps, $_GET['jump']);
63   echo "<button type='submit'>Choose</button></form>\n";
64 }
65 echo "</div>";
66
67 $last_day = null;
68 $even = 1;
69 $hist = $repo->history($pi, null, $object, $ident);
70 if (!count($hist)) {
71   echo "<em>No history for the requested path</em>";
72 } else {
73   echo "<div class='changesets'>\n";
74   foreach ($hist as $ent) {
75     $class = ($even++ % 2) ? '' : 'odd';
76
77     $ts = strtotime($ent->ctime);
78     $day = date('D, M d Y', $ts);
79     $time = date('H:m', $ts);
80
81     if ($day !== $last_day) {
82       echo "<div class='changesetday'>$day</div>\n";
83       $last_day = $day;
84     }
85     echo "<div class='changeset$class'>\n<div class='changelog'>";
86     echo MTrackWiki::format_to_html($ent->changelog);
87     echo "</div>\n";
88
89     echo "<div class='changeinfo'>\n";
90     echo mtrack_username($ent->changeby, array(
91           'no_name' => true,
92           'size' => 32
93           ));
94
95     echo mtrack_changeset($ent->rev, $repo);
96     foreach ($ent->branches as $b) {
97       echo " " . mtrack_branch($b);
98     }
99     foreach ($ent->tags as $t) {
100       echo " " . mtrack_tag($t);
101     }
102     echo "<br>\n";
103     echo mtrack_username($ent->changeby, array('no_image' => true)) . "<br>\n";
104     echo "$time <span class='time'>" . mtrack_date($ent->ctime) . "</span>\n";
105     echo "</div></div>\n";
106   }
107   echo "</div>\n";
108 }
109
110
111 mtrack_foot();
112