36b310c7e8022fd74710c02a2f8497ba6cd5d953
[gwvp-mini.git] / gwvpmini / gwvpmini_view.php
1 <?php
2 global $HOME_PAGE_PROVIDERS;
3
4
5 $CALL_ME_FUNCTIONS["repoview"] = "gwvpmini_RepoViewCallMe";
6
7
8
9 function gwvpmini_RepoViewCallMe()
10 {
11         global $repo_view_call;
12         
13         error_log("in admin callme");\r
14         if(isset($_REQUEST["q"])) {\r
15                 $query = $_REQUEST["q"];\r
16                 $qspl = explode("/", $query);\r
17                 if(isset($qspl[0])) {\r
18                         if($qspl[0] == "view") {\r
19                                 if(isset($qspl[1])) {
20                                         $repo_view_call = $qspl[1];
21                                         return "gwvpmini_RepoViewPage";\r
22                                 } else return false;\r
23                         } else return false;\r
24                 }\r
25                 else return false;\r
26         }\r
27 \r
28         return false;\r
29         
30         
31 }
32
33 function gwvpmini_RepoViewPage()\r
34 {
35         global $repo_view_call, $MENU_ITEMS, $BASE_URL;\r
36         \r
37         $MENU_ITEMS["40thisrepo"]["text"] = "$repo_view_call";\r
38         $MENU_ITEMS["40thisrepo"]["link"] = "$BASE_URL/view/$repo_view_call";\r
39         \r
40         gwvpmini_goMainPage("gwvpmini_RepoViewPageBody");\r
41 }
42
43 function gwvpmini_RepoViewPageBody()
44 {
45         global $repo_view_call, $MENU_ITEMS, $BASE_URL;
46         
47         $repo_base = gwvpmini_getConfigVal("repodir");\r
48
49         if($_SERVER["SERVER_PORT"] == 443) $proto="https://";
50         else $proto = "http://";
51         $sname = $_SERVER["SERVER_NAME"];
52         
53         $owner = gwvpmini_GetRepoOwnerDetailsFromName($repo_view_call);
54         $desc = gwvpmini_GetRepoDescFromName($repo_view_call);
55         
56         $owner_name = $owner["username"];
57         
58         error_log("STUFF:".print_r($owner,true));
59         $cloneurl = "git clone $proto$sname$BASE_URL/git/$repo_view_call.git";
60         echo "<textarea rows=1 cols=".strlen($cloneurl).">$cloneurl</textarea><br>";\r
61         
62         echo "<h2>".get_gravatar($owner["email"], 30, 'mm', 'g', true)."$repo_view_call - $owner_name</h2>";
63         echo "<b>$desc</b><br>";
64         //echo "command: git log --git-dir=$repo_base/$repo_view_call.git --pretty=format:\"%H\" -10";
65         $rs = popen("git --git-dir=$repo_base/$repo_view_call.git log --pretty=format:\"%H\" -10", "r");
66         $commitids = array();
67         $i = 0;
68         if($rs) {
69                 while(!feof($rs)) {
70                         $flin = fgets($rs);
71                         if($flin !== false) {
72                                 $commitids[$i] = trim($flin);
73                                 $i++;
74                         }
75                 }
76                 fclose($rs);
77         } else {
78                 $commitids = false;
79         }
80         
81         if($commitids != false) {
82                 echo "<hr>Commits<br>";
83                 echo "<table border=\"1\">";
84                 echo "<tr><th>Committed By</th><th>Date</th><th>Commit Log Entry</th></tr>";
85                 foreach($commitids as $ids) {
86                         $rs = popen("git --git-dir=$repo_base/$repo_view_call.git log --pretty=format:\"%at%n%ce%n%an%n%s\" $ids -1", "r");
87                         if($rs) {
88                                 $flin1 = trim(fgets($rs));
89                                 $flin2 = trim(fgets($rs));
90                                 $flin3 = trim(fgets($rs));
91                                 while(!feof($rs)) {
92                                         $flin4 = fread($rs, 8192);
93                                 }
94                                 $flon =  gwvpmini_emailToUserLink($flin2);
95                                 if(!$flon) {
96                                         $flon = "$flin3 (external)";
97                                 }
98                         }
99                         echo "<tr><td>".get_gravatar($flin2, 18, 'mm', 'g', true)."$flon</td><td>$flin1</td><td>$flin4</td></tr>";
100                 }
101                 echo "</table>";
102         } else {
103                 echo "No commit information available yet<br>";
104         }
105 }
106 \r
107
108 ?>