Rev 185 Rev 4988
Line 1... Line 1...
1 <?php 1 <?php
2 # vim:et:ts=3:sts=3:sw=3:fdm=marker: -  
3   -  
4 // WebSVN - Subversion repository viewing via the web using PHP 2 // WebSVN - Subversion repository viewing via the web using PHP
5 // Copyright © 2004-2006 Tim Armes, Matt Sicker 3 // Copyright (C) 2004-2006 Tim Armes
6 // 4 //
7 // This program is free software; you can redistribute it and/or modify 5 // 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 6 // 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 7 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version. 8 // (at your option) any later version.
11 // 9 //
12 // This program is distributed in the hope that it will be useful, 10 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details. 13 // GNU General Public License for more details.
16 // 14 //
17 // You should have received a copy of the GNU General Public License 15 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software 16 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // 18 //
21 // -- 19 // --
22 // 20 //
23 // index.php 21 // index.php
24 // 22 //
25 // Main page. Lists all the projects 23 // Main page which lists all configured repositories (optionally by groups).
26   24  
27 require_once("include/setup.inc"); 25 require_once 'include/setup.php';
28 require_once("include/svnlook.inc"); 26 require_once 'include/svnlook.php';
29 require_once("include/template.inc"); 27 require_once 'include/template.php';
30   28  
31 $vars["action"] = $lang["PROJECTS"]; 29 $vars['action'] = $lang['PROJECTS'];
32 $vars["repname"] = ""; 30 $vars['repname'] = '';
33 $vars["rev"] = 0; 31 $vars['rev'] = 0;
34 $vars["path"] = ""; 32 $vars['path'] = '';
-   33 $vars['safepath'] = escape('');
-   34 $vars['showlastmod'] = $config->showLastModInIndex();
35   35  
36 // Sort the repositories by group 36 // Sort the repositories by group
37 $config->sortByGroup(); 37 $config->sortByGroup();
-   38 $projects = $config->getRepositories();
-   39  
-   40 if (count($projects) == 1 && $projects[0]->hasReadAccess('/')) {
-   41 header('Location: '.str_replace('&amp;', '', $config->getURL($projects[0], '', 'dir')));
-   42 exit;
-   43 }
38   44  
-   45 $i = 0;
-   46 $parity = 0; // Alternates between every entry, whether it is a group or project
-   47 $groupparity = 0; // The first project (and first of any group) resets this to 0
39 if ($config->flatIndex) 48 $curgroup = null;
-   49 $groupcount = 0;
40 { 50  
-   51 // Create listing of all configured projects (includes groups if they are used).
41 // Create the flat view 52 foreach ($projects as $project) {
-   53 if (!$project->hasReadAccess('/'))
-   54 continue;
42 55  
-   56 $listvar = &$listing[$i];
-   57 // If this is the first project in a group, add an entry for the group.
43 $projects = $config->getRepositories(); 58 if ($curgroup != $project->group) {
-   59 $groupcount++;
44 $i = 0; 60 $groupparity = 0;
45 $listing = array (); 61 $listvar['notfirstgroup'] = !empty($curgroup);
46 foreach ($projects as $project) 62 $curgroup = $project->group;
-   63 $listvar['groupname'] = $curgroup; // Applies until next group is set.
-   64 $listvar['groupid'] = strtr(base64_encode('grp'.$curgroup), array('+' => '-', '/' => '_', '=' => ''));
47 { 65  
-   66 // setting to null because template.php won't unset them
-   67 $listvar['projectlink'] = null;
48 if ($project->hasReadAccess("/", true)) 68 $listvar['projectname'] = null;
-   69 $listvar['projecturl'] = null;
-   70 $i++; // Causes the subsequent lines to store data in the next array slot.
-   71 $listvar = &$listing[$i];
-   72 $listvar['groupid'] = null;
49 { 73 }
-   74 $listvar['clientrooturl'] = $project->clientRootURL;
-   75  
-   76 // Populate variables for latest modification to the current repository
-   77 if ($config->showLastModInIndex()) {
-   78 $svnrep = new SVNRepository($project);
50 $url = $config->getURL($project, "/", "dir"); 79 $log = $svnrep->getLog('/', '', '', true, 1);
51 80  
-   81 if (isset($log->entries[0])) {
-   82 $head = $log->entries[0];
52 $listing[$i]["rowparity"] = $i % 2; 83 $listvar['revision'] = $head->rev;
-   84 $listvar['date'] = $head->date;
53 $listing[$i++]["projlink"] = "<a href=\"${url}sc=0\">".$project->getDisplayName()."</a>"; 85 $listvar['age'] = datetimeFormatDuration(time() - strtotime($head->date));
-   86 $listvar['author'] = $head->author;
54 } 87 } else {
-   88 $listvar['revision'] = 0;
-   89 $listvar['date'] = '';
-   90 $listvar['age'] = '';
-   91 $listvar['author'] = '';
55 } 92 }
-   93 }
-   94  
-   95 // Create project (repository) listing
-   96 $url = str_replace('&amp;', '', $config->getURL($project, '', 'dir'));
-   97 $name = ($config->flatIndex) ? $project->getDisplayName() : $project->name;
-   98 $listvar['projectlink'] = '<a href="'.$url.'">'.escape($name).'</a>';
-   99 $listvar['projectname'] = escape($name);
56 $vars["flatview"] = true; 100 $listvar['projecturl'] = $url;
57 $vars["treeview"] = false; 101 $listvar['rowparity'] = $parity % 2;
-   102 $parity++;
-   103 $listvar['groupparity'] = $groupparity % 2;
-   104 $groupparity++;
-   105 $listvar['groupname'] = ($curgroup != null) ? $curgroup : '';
-   106 $i++;
58 } 107 }
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   108  
83 $listing[$i]["isprojlink"] = false; 109 if (empty($listing) && !empty($projects)) {
84 $listing[$i]["isgrouphead"] = true; -  
85 -  
86 $curgroup = $project->group; 110 $vars['error'] = $lang['NOACCESS'];
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\">"; 111 sendHeaderForbidden();
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 } 112 }
106   113  
107 $vars["version"] = $version; 114 $vars['flatview'] = $config->flatIndex;
108 parseTemplate($config->getTemplatePath()."header.tmpl", $vars, $listing); 115 $vars['treeview'] = !$config->flatIndex;
109 parseTemplate($config->getTemplatePath()."index.tmpl", $vars, $listing); 116 $vars['opentree'] = $config->openTree;
110 parseTemplate($config->getTemplatePath()."footer.tmpl", $vars, $listing); 117 $vars['groupcount'] = $groupcount; // Indicates whether any groups were present.
111   118  
112 ?> -  
-   119 renderTemplate('index');