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