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.
Line 20... Line 18...
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   -  
39 if ($config->flatIndex) -  
40 { -  
41 // Create the flat view -  
42 -  
43 $projects = $config->getRepositories(); 38 $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   39  
83 $listing[$i]["isprojlink"] = false; 40 if (count($projects) == 1 && $projects[0]->hasReadAccess('/')) {
84 $listing[$i]["isgrouphead"] = true; 41 header('Location: '.str_replace('&amp;', '', $config->getURL($projects[0], '', 'dir')));
-   42 exit;
-   43 }
85 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
-   48 $curgroup = null;
-   49 $groupcount = 0;
-   50  
-   51 // Create listing of all configured projects (includes groups if they are used).
-   52 foreach ($projects as $project) {
-   53 if (!$project->hasReadAccess('/'))
-   54 continue;
-   55  
-   56 $listvar = &$listing[$i];
-   57 // If this is the first project in a group, add an entry for the group.
-   58 if ($curgroup != $project->group) {
-   59 $groupcount++;
-   60 $groupparity = 0;
-   61 $listvar['notfirstgroup'] = !empty($curgroup);
86 $curgroup = $project->group; 62 $curgroup = $project->group;
-   63 $listvar['groupname'] = $curgroup; // Applies until next group is set.
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\">"; 64 $listvar['groupid'] = strtr(base64_encode('grp'.$curgroup), array('+' => '-', '/' => '_', '=' => ''));
88 } -  
89   65  
-   66 // setting to null because template.php won't unset them
-   67 $listvar['projectlink'] = null;
-   68 $listvar['projectname'] = null;
90 $parity++; 69 $listvar['projecturl'] = null;
-   70 $i++; // Causes the subsequent lines to store data in the next array slot.
-   71 $listvar = &$listing[$i];
91 $listing[$i]["isgrouphead"] = false; 72 $listvar['groupid'] = null;
-   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);
-   79 $log = $svnrep->getLog('/', '', '', true, 1);
-   80  
-   81 if (isset($log->entries[0])) {
-   82 $head = $log->entries[0];
92 $listing[$i]["isprojlink"] = true; 83 $listvar['revision'] = $head->rev;
-   84 $listvar['date'] = $head->date;
93 $listing[$i++]["listitem"] = "<a href=\"${url}sc=0\">".$project->name."</a>\n"; 85 $listvar['age'] = datetimeFormatDuration(time() - strtotime($head->date));
-   86 $listvar['author'] = $head->author;
-   87 } else {
-   88 $listvar['revision'] = 0;
-   89 $listvar['date'] = '';
-   90 $listvar['age'] = '';
-   91 $listvar['author'] = '';
94 } 92 }
95 } 93 }
96   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);
97 if (!empty($curgroup)) 100 $listvar['projecturl'] = $url;
98 $listing[$i]["isprojlink"] = false; 101 $listvar['rowparity'] = $parity % 2;
-   102 $parity++;
99 $listing[$i]["isgrouphead"] = false; 103 $listvar['groupparity'] = $groupparity % 2;
-   104 $groupparity++;
100 $listing[$i]["listitem"] = "</div>"; // Close the switchcontent div 105 $listvar['groupname'] = ($curgroup != null) ? $curgroup : '';
-   106 $i++;
-   107 }
101   108  
102 $vars["flatview"] = false; 109 if (empty($listing) && !empty($projects)) {
103 $vars["treeview"] = true; 110 $vars['error'] = $lang['NOACCESS'];
104 $vars["opentree"] = $config->openTree; 111 sendHeaderForbidden();
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');