1 | 1 | simandl | <?php |
2 | | | // WebSVN - Subversion repository viewing via the web using PHP |
3 | | | // Copyright (C) 2004-2006 Tim Armes |
4 | | | // |
5 | | | // This program is free software; you can redistribute it and/or modify |
6 | | | // it under the terms of the GNU General Public License as published by |
7 | | | // the Free Software Foundation; either version 2 of the License, or |
8 | | | // (at your option) any later version. |
9 | | | // |
10 | | | // This program is distributed in the hope that it will be useful, |
11 | | | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | | | // GNU General Public License for more details. |
14 | | | // |
15 | | | // You should have received a copy of the GNU General Public License |
16 | | | // along with this program; if not, write to the Free Software |
17 | | | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | | | // |
19 | | | // -- |
20 | | | // |
21 | | | // index.php |
22 | | | // |
23 | | | // Main page. Lists all the projects |
24 | | | |
25 | | | require_once("include/setup.php"); |
26 | | | require_once("include/svnlook.php"); |
27 | | | require_once("include/template.php"); |
28 | | | |
29 | | | $vars["action"] = $lang["PROJECTS"]; |
30 | | | $vars["repname"] = ""; |
31 | | | $vars["rev"] = 0; |
32 | | | $vars["path"] = ""; |
33 | | | |
34 | | | // Sort the repositories by group |
35 | | | $config->sortByGroup(); |
36 | | | |
37 | | | if ($config->flatIndex) { |
38 | | | // Create the flat view |
39 | | | |
40 | | | $projects = $config->getRepositories(); |
41 | | | $i = 0; |
42 | | | $listing = array(); |
43 | | | foreach ($projects as $project) { |
44 | | | if ($project->hasReadAccess("/", true)) { |
45 | | | $url = $config->getURL($project, "/", "dir"); |
46 | | | |
47 | | | $listing[$i]["rowparity"] = $i % 2; |
48 | | | $listing[$i]["projlink"] = "<a href=\"${url}\">".$project->getDisplayName()."</a>"; |
49 | | | $i++; |
50 | | | } |
51 | | | } |
52 | | | $vars["flatview"] = true; |
53 | | | $vars["treeview"] = false; |
54 | | | } else { |
55 | | | // Create the tree view |
56 | | | |
57 | | | $projects = $config->getRepositories(); |
58 | | | reset($projects); |
59 | | | $i = 0; |
60 | | | $listing = array(); |
61 | | | $curgroup = NULL; |
62 | | | $parity = 0; |
63 | | | foreach ($projects as $project) { |
64 | | | if ($project->hasReadAccess("/", true)) { |
65 | | | $listing[$i] = array(); |
66 | | | if ($curgroup != $project->group) { |
67 | | | // TODO: this should be de-soupified |
68 | | | if (!empty($curgroup)) { |
69 | | | // Close the switchcontent div |
70 | | | $listing[$i]["listitem"] = "</div>\n"; |
71 | | | } else { |
72 | | | $listing[$i]["listitem"] = ""; |
73 | | | } |
74 | | | |
75 | | | $listing[$i]["isprojlink"] = false; |
76 | | | $listing[$i]["isgrouphead"] = true; |
77 | | | |
78 | | | $curgroup = $project->group; |
79 | | | $id = strtr(base64_encode('grp'.$curgroup), array('+' => '-', '/' => '_', '=' => '')); |
80 | | | $listing[$i]["listitem"] .= "<div class=\"groupname\" onclick=\"expandcontent(this, '$id');\" style=\"cursor:hand; cursor:pointer\"><div class=\"a\"><span class=\"showstate\"></span>$curgroup</div></div>\n<div id=\"$id\" class=\"switchcontent\">"; |
81 | | | |
82 | | | $i++; |
83 | | | $listing[$i] = array(); |
84 | | | } |
85 | | | |
86 | | | $listing[$i]["isgrouphead"] = false; |
87 | | | $listing[$i]["isprojlink"] = true; |
88 | | | $url = $config->getURL($project, "/", "dir"); |
89 | | | $listing[$i]["listitem"] = "<a href=\"${url}\">".$project->name."</a>\n"; |
90 | | | |
91 | | | $listing[$i]["rowparity"] = $parity % 2; |
92 | | | $parity++; |
93 | | | |
94 | | | $i++; |
95 | | | } |
96 | | | } |
97 | | | |
98 | | | if (!empty($curgroup)) { |
99 | | | // Close the switchcontent div |
100 | | | $listing[$i]["isprojlink"] = false; |
101 | | | $listing[$i]["isgrouphead"] = false; |
102 | | | $listing[$i]["listitem"] = "</div>"; |
103 | | | } |
104 | | | |
105 | | | $vars["flatview"] = false; |
106 | | | $vars["treeview"] = true; |
107 | | | $vars["opentree"] = $config->openTree; |
108 | | | } |
109 | | | |
110 | | | $vars['indexurl'] = $config->getURL($rep, '', 'index'); |
111 | | | |
112 | | | $vars["version"] = $version; |
113 | | | parseTemplate($config->getTemplatePath()."header.tmpl", $vars, $listing); |
114 | | | parseTemplate($config->getTemplatePath()."index.tmpl", $vars, $listing); |
115 | | | parseTemplate($config->getTemplatePath()."footer.tmpl", $vars, $listing); |