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 22... Line 20...
22 // 20 //
23 // log.php 21 // log.php
24 // 22 //
25 // Show the logs for the given path 23 // Show the logs for the given path
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/utils.inc"); 27 require_once 'include/utils.php';
30 require_once("include/template.inc"); 28 require_once 'include/template.php';
31 require_once("include/bugtraq.inc"); 29 require_once 'include/bugtraq.php';
32   30  
33 $page = (int)@$_REQUEST["page"]; 31 $page = (int)@$_REQUEST['page'];
34 $all = (@$_REQUEST["all"] == 1)?1:0; 32 $all = @$_REQUEST['all'] == 1;
35 $isDir = (@$_REQUEST["isdir"] == 1)?1:0; 33 $isDir = @$_REQUEST['isdir'] == 1 || $path == '' || $path == '/';
-   34  
-   35 // Make sure that we have a repository
-   36 if (!$rep)
-   37 {
-   38 renderTemplate404('log','NOREP');
-   39 }
-   40  
-   41 if (isset($_REQUEST['showchanges']))
-   42 {
36 $dosearch = (@$_REQUEST["logsearch"] == 1)?1:0; 43 $showchanges = @$_REQUEST['showchanges'] == 1;
-   44 }
-   45 else
-   46 {
-   47 $showchanges = $rep->logsShowChanges();
-   48 }
-   49  
37 $search = trim(@$_REQUEST["search"]); 50 $search = trim((string) @$_REQUEST['search']);
-   51 $dosearch = strlen($search) > 0;
-   52  
38 $words = preg_split('#\s+#', $search); 53 $words = preg_split('#\s+#', $search);
39 $fromRev = (int)@$_REQUEST["fr"]; 54 $fromRev = (int)@$_REQUEST['fr'];
40 $startrev = strtoupper(trim(@$_REQUEST["sr"])); 55 $startrev = strtoupper(trim((string) @$_REQUEST['sr']));
41 $endrev = strtoupper(trim(@$_REQUEST["er"])); 56 $endrev = strtoupper(trim((string) @$_REQUEST['er']));
42 $max = @$_REQUEST["max"]; 57 $max = isset($_REQUEST['max']) ? (int)$_REQUEST['max'] : false;
43   58  
44 // Max number of results to find at a time 59 // Max number of results to find at a time
45 $numSearchResults = 15; 60 $numSearchResults = 20;
46   61  
47 if ($search == "") 62 if ($search == '')
-   63 {
48 $dosearch = false; 64 $dosearch = false;
-   65 }
49   66  
50 // removeAccents 67 // removeAccents
51 // 68 //
52 // Remove all the accents from a string. This function doesn't seem 69 // Remove all the accents from a string. This function doesn't seem
53 // ideal, but expecting everyone to install 'unac' seems a little 70 // ideal, but expecting everyone to install 'unac' seems a little
54 // excessive as well... 71 // excessive as well...
55   72  
56 function removeAccents($string) 73 function removeAccents($string)
57 { 74 {
58 return strtr($string, 75 $string = htmlentities($string, ENT_QUOTES, 'ISO-8859-1');
59 "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ", 76 $string = preg_replace('/&([A-Za-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron);/', '$1', $string);
60 "AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn"); 77 return $string;
61 } 78 }
62   79  
63 // Normalise the search words 80 // Normalise the search words
64 foreach ($words as $index => $word) 81 foreach ($words as $index => $word)
65 { 82 {
Line 68... Line 85...
68 // Remove empty string introduced by multiple spaces 85 // Remove empty string introduced by multiple spaces
69 if (empty($words[$index])) 86 if (empty($words[$index]))
70 unset($words[$index]); 87 unset($words[$index]);
71 } 88 }
72   89  
73 if (empty($page)) $page = 1; 90 if (empty($page))
-   91 {
-   92 $page = 1;
-   93 }
74   94  
75 // If searching, display all the results 95 // If searching, display all the results
76 $all = (bool) $dosearch; 96 if ($dosearch)
-   97 {
-   98 $all = true;
-   99 }
77   100  
78 $maxperpage = 20; 101 $maxperpage = 20;
79   102  
80 // Make sure that we have a repository 103 $svnrep = new SVNRepository($rep);
-   104  
-   105 $history = $svnrep->getLog($path, 'HEAD', '', false, 1, ($path == '/') ? '' : $peg);
-   106  
81 if (!isset($rep)) 107 if (!$history)
-   108 {
-   109 unset($vars['error']);
-   110 $history = $svnrep->getLog($path, '', '', false, 1, ($path == '/') ? '' : $peg);
-   111  
-   112 if (!$history)
82 { 113 {
83 echo $lang["NOREP"]; 114 renderTemplate404('log','NOPATH');
84 exit; 115 }
85 } 116 }
86   117  
87 $svnrep = new SVNRepository($rep); 118 $youngest = ($history && isset($history->entries[0])) ? $history->entries[0]->rev : 0;
88   119  
-   120 if (empty($startrev))
-   121 {
-   122 //$startrev = ($rev) ? $rev : 'HEAD';
89 $passrev = $rev; 123 $startrev = $rev;
-   124 }
-   125 else if ($startrev != 'HEAD' && $startrev != 'BASE' && $startrev != 'PREV' && $startrev != 'COMMITTED')
-   126 {
-   127 $startrev = (int)$startrev;
-   128 }
90   129  
91 // If there's no revision info, go to the lastest revision for this path 130 if (empty($endrev))
-   131 {
-   132 $endrev = 1;
-   133 }
92 $history = $svnrep->getLog($path, "", "", true); 134 else if ($endrev != 'HEAD' && $endrev != 'BASE' && $endrev != 'PREV' && $endrev != 'COMMITTED')
-   135 {
93 $youngest = $history->entries[0]->rev; 136 $endrev = (int)$endrev;
-   137 }
94   138  
95 if (empty($rev)) 139 if (empty($rev))
-   140 {
96 $rev = $youngest; 141 $rev = $youngest;
-   142 }
-   143  
-   144 if (empty($startrev))
-   145 {
-   146 $startrev = $rev;
-   147 }
97   148  
98 // make sure path is prefixed by a / 149 // make sure path is prefixed by a /
99 $ppath = $path; 150 $ppath = $path;
100 if ($path == "" || $path{0} != "/") -  
101 $ppath = "/".$path; -  
102   151  
103 $vars["action"] = $lang["LOG"]; 152 if ($path == '' || $path[0] != '/')
104 $vars["repname"] = $rep->getDisplayName(); -  
105 $vars["rev"] = $rev; 153 {
106 $vars["path"] = $ppath; 154 $ppath = '/'.$path;
-   155 }
107   156  
-   157 $vars['action'] = $lang['LOG'];
-   158 $vars['rev'] = $rev;
-   159 $vars['peg'] = $peg;
108 createDirLinks($rep, $ppath, $passrev, $showchanged); 160 $vars['path'] = str_replace('%2F', '/', rawurlencode($ppath));
-   161 $vars['safepath'] = escape($ppath);
109   162  
-   163 if ($history && isset($history->entries[0]))
-   164 {
110 $logurl = $config->getURL($rep, $path, "log"); 165 $vars['log'] = xml_entities($history->entries[0]->msg);
-   166 $vars['date'] = $history->entries[0]->date;
-   167 $vars['age'] = datetimeFormatDuration(time() - strtotime($history->entries[0]->date));
-   168 $vars['author'] = $history->entries[0]->author;
-   169 }
111   170  
112 if ($rev != $youngest) 171 if ($max === false)
-   172 {
-   173 $max = ($dosearch) ? 0 : 40;
-   174 }
-   175 else if ($max < 0)
-   176 {
-   177 $max = 40;
-   178 }
-   179  
-   180 // TODO: If the rev is less than the head, get the path (may have been renamed!)
113 $vars["goyoungestlink"] = "<a href=\"${logurl}sc=1\">${lang["GOYOUNGEST"]}</a>"; 181 // Will probably need to call `svn info`, parse XML output, and substring a path
-   182  
-   183 createPathLinks($rep, $ppath, $passrev, $peg);
-   184 $passRevString = createRevAndPegString($rev, $peg);
-   185 $isDirString = ($isDir) ? 'isdir=1&amp;' : '';
-   186  
-   187 unset($queryParams['repname']);
-   188 unset($queryParams['path']);
-   189  
-   190 // Toggle 'showchanges' param for link to switch from the current behavior
-   191 if ($showchanges == $rep->logsShowChanges())
-   192 {
-   193 $queryParams['showchanges'] = (int)!$showchanges;
-   194 }
114 else 195 else
-   196 {
115 $vars["goyoungestlink"] = ""; 197 unset($queryParams['showchanges']);
-   198 }
116   199  
-   200 $vars['changesurl'] = $config->getURL($rep, $path, 'log').buildQuery($queryParams);
-   201 $vars['changeslink'] = '<a href="'.$vars['changesurl'].'">'.$lang[($showchanges ? 'HIDECHANGED' : 'SHOWCHANGED')].'</a>';
-   202 $vars['showchanges'] = $showchanges;
-   203  
117 // We get the bugtraq variable just once based on the HEAD 204 // Revert 'showchanges' param to propagate the current behavior
-   205 if ($showchanges == $rep->logsShowChanges())
-   206 {
-   207 unset($queryParams['showchanges']);
-   208 }
-   209 else
-   210 {
118 $bugtraq = new Bugtraq($rep, $svnrep, $ppath); 211 $queryParams['showchanges'] = (int)$showchanges;
-   212 }
119   213  
120 if ($startrev != "HEAD") $startrev = (int)$startrev; 214 $vars['revurl'] = $config->getURL($rep, $path, 'revision').$isDirString.$passRevString;
121 if (empty($startrev)) $startrev = $rev; -  
122 if (empty($endrev)) $endrev = 1; -  
123   215  
124 if (empty($_REQUEST["max"])) 216 if ($isDir)
125 { 217 {
-   218 $vars['directoryurl'] = $config->getURL($rep, $path, 'dir').$passRevString.'#'.anchorForPath($path);
126 if (empty($_REQUEST["logsearch"])) 219 $vars['directorylink'] = '<a href="'.$vars['directoryurl'].'">'.$lang['LISTING'].'</a>';
127 $max = 30; 220 }
128 else 221 else
-   222 {
-   223 $vars['filedetailurl'] = $config->getURL($rep, $path, 'file').$passRevString;
-   224 $vars['filedetaillink'] = '<a href="'.$vars['filedetailurl'].'">'.$lang['FILEDETAIL'].'</a>';
-   225  
-   226 $vars['blameurl'] = $config->getURL($rep, $path, 'blame').$passRevString;
-   227 $vars['blamelink'] = '<a href="'.$vars['blameurl'].'">'.$lang['BLAME'].'</a>';
-   228  
-   229 $vars['diffurl'] = $config->getURL($rep, $path, 'diff').$passRevString;
-   230 $vars['difflink'] = '<a href="'.$vars['diffurl'].'">'.$lang['DIFFPREV'].'</a>';
-   231 }
-   232  
-   233 if ($rep->isRssEnabled())
-   234 {
-   235 $vars['rssurl'] = $config->getURL($rep, $path, 'rss').$isDirString.createRevAndPegString('', $peg);
-   236 $vars['rsslink'] = '<a href="'.$vars['rssurl'].'">'.$lang['RSSFEED'].'</a>';
-   237 }
-   238  
-   239 if ($rev != $youngest)
-   240 {
129 $max = 0; 241 if ($path == '/')
-   242 {
-   243 $vars['goyoungesturl'] = $config->getURL($rep, '', 'log').$isDirString;
130 } 244 }
131 else 245 else
132 { 246 {
133 $max = (int)$max; -  
134 if ($max < 0) $max = 30; 247 $vars['goyoungesturl'] = $config->getURL($rep, $path, 'log').$isDirString.'peg='.($peg ? $peg : $rev);
-   248 }
-   249  
-   250 $vars['goyoungestlink'] = '<a href="'.$vars['goyoungesturl'].'"'.($youngest ? ' title="'.$lang['REV'].' '.$youngest.'"' : '').'>'.$lang['GOYOUNGEST'].'</a>';
135 } 251 }
136   252  
-   253 // We get the bugtraq variable just once based on the HEAD
137 $history = $svnrep->getLog($path, $startrev, $endrev, true, $max); 254 $bugtraq = new Bugtraq($rep, $svnrep, $ppath);
-   255  
138 $vars["logsearch_moreresultslink"] = ""; 256 $vars['logsearch_moreresultslink'] = '';
139 $vars["pagelinks"] = ""; 257 $vars['pagelinks'] = '';
140 $vars["showalllink"] = ""; 258 $vars['showalllink'] = '';
-   259  
-   260 if ($history)
-   261 {
-   262 $history = $svnrep->getLog($path, $startrev, $endrev, true, $max, $peg);
-   263  
-   264 if (empty($history))
-   265 {
141 $listing = array(); 266 unset($vars['error']);
-   267 $vars['warning'] = 'Revision '.$startrev.' of this resource does not exist.';
-   268 }
-   269 }
142   270  
143 if (!empty($history)) 271 if (!empty($history))
144 { 272 {
145 // Get the number of separate revisions 273 // Get the number of separate revisions
146 $revisions = count($history->entries); 274 $revisions = count($history->entries);
Line 157... Line 285...
157 $pages = floor($revisions / $maxperpage); 285 $pages = floor($revisions / $maxperpage);
158 if (($revisions % $maxperpage) > 0) $pages++; 286 if (($revisions % $maxperpage) > 0) $pages++;
159 287  
160 if ($page > $pages) $page = $pages; 288 if ($page > $pages) $page = $pages;
161 289  
162 // Word out where to start and stop 290 // Work out where to start and stop
163 $firstrevindex = ($page - 1) * $maxperpage; 291 $firstrevindex = ($page - 1) * $maxperpage;
164 $lastrevindex = $firstrevindex + $maxperpage - 1; 292 $lastrevindex = min($firstrevindex + $maxperpage - 1, $revisions - 1);
165 if ($lastrevindex > $revisions - 1) $lastrevindex = $revisions - 1; -  
166 } 293 }
167 294  
-   295 $frev = isset($history->entries[0]) ? $history->entries[0]->rev : false;
168 $history = $svnrep->getLog($path, $history->entries[$firstrevindex ]->rev, $history->entries[$lastrevindex]->rev, false, 0); 296 $brev = isset($history->entries[$firstrevindex]) ? $history->entries[$firstrevindex]->rev : false;
-   297 $erev = isset($history->entries[$lastrevindex]) ? $history->entries[$lastrevindex]->rev : false;
-   298  
-   299 $entries = array();
-   300  
-   301 if ($brev && $erev)
-   302 {
-   303 $history = $svnrep->getLog($path, $brev, $erev, false, 0, $peg, true);
-   304 if ($history)
-   305 {
-   306 $entries = $history->entries;
-   307 }
-   308 }
169 309  
170 $row = 0; 310 $row = 0;
171 $index = 0; 311 $index = 0;
172 $listing = array(); -  
173 $found = false; 312 $found = false;
174 313  
175 foreach ($history->entries as $r) 314 foreach ($entries as $revision)
176 { 315 {
177 // Assume a good match 316 // Assume a good match
178 $match = true; 317 $match = true;
179 $thisrev = $r->rev; 318 $thisrev = $revision->rev;
180 319  
181 // Check the log for the search words, if searching 320 // Check the log for the search words, if searching
182 if ($dosearch) 321 if ($dosearch)
183 { 322 {
184 if ((empty($fromRev) || $fromRev > $thisrev)) 323 if ((empty($fromRev) || $fromRev > $thisrev))
Line 186... Line 325...
186 // Turn all the HTML entities into real characters. 325 // Turn all the HTML entities into real characters.
187 326  
188 // Make sure that each word in the search in also in the log 327 // Make sure that each word in the search in also in the log
189 foreach($words as $word) 328 foreach ($words as $word)
190 { 329 {
191 if (strpos(strtolower(removeAccents($r->msg)), $word) === false) 330 if (strpos(strtolower(removeAccents($revision->msg)), $word) === false && strpos(strtolower(removeAccents($revision->author)), $word) === false)
192 { 331 {
193 $match = false; 332 $match = false;
194 break; 333 break;
195 } 334 }
196 } 335 }
Line 200... Line 339...
200 $numSearchResults--; 339 $numSearchResults--;
201 $found = true; 340 $found = true;
202 } 341 }
203 } 342 }
204 else 343 else
-   344 {
205 $match = false; 345 $match = false;
206 } 346 }
-   347 }
-   348  
-   349 $thisRevString = createRevAndPegString($thisrev, ($peg ? $peg : $thisrev));
207 350  
208 if ($match) 351 if ($match)
209 { 352 {
210 // Add the trailing slash if we need to (svnlook history doesn't return trailing slashes!) 353 // Add the trailing slash if we need to (svnlook history doesn't return trailing slashes!)
211 $rpath = $r->path; 354 $rpath = $revision->path;
212 355  
213 if (empty($rpath)) 356 if (empty($rpath))
-   357 {
214 $rpath = "/"; 358 $rpath = '/';
-   359 }
215 else if ($isDir && $rpath{strlen($rpath) - 1} != "/") 360 else if ($isDir && $rpath[strlen($rpath) - 1] != '/')
-   361 {
216 $rpath .= "/"; 362 $rpath .= '/';
-   363 }
-   364  
-   365 $precisePath = $revision->precisePath;
-   366 if (empty($precisePath))
-   367 {
-   368 $precisePath = '/';
-   369 }
-   370 else if ($isDir && $precisePath[strlen($precisePath) - 1] != '/')
-   371 {
-   372 $precisePath .= '/';
-   373 }
217 374  
218 // Find the parent path (or the whole path if it's already a directory) 375 // Find the parent path (or the whole path if it's already a directory)
219 $pos = strrpos($rpath, "/"); 376 $pos = strrpos($rpath, '/');
220 $parent = substr($rpath, 0, $pos + 1); 377 $parent = substr($rpath, 0, $pos + 1);
221 378  
222 $url = $config->getURL($rep, $parent, "dir"); 379 $compareValue = (($isDir) ? $parent : $rpath).'@'.$thisrev;
223 $listing[$index]["revlink"] = "<a href=\"${url}rev=$thisrev&amp;sc=1\">$thisrev</a>"; -  
224 380  
-   381 $listvar = &$listing[$index];
-   382 $listvar['compare_box'] = '<input type="checkbox" name="compare[]" value="'.$compareValue.'" onclick="enforceOnlyTwoChecked(this)" />';
-   383 $url = $config->getURL($rep, $rpath, 'revision').$thisRevString;
-   384 $listvar['revlink'] = '<a href="'.$url.'">'.$thisrev.'</a>';
-   385  
-   386 $url = $config->getURL($rep, $precisePath, ($isDir ? 'dir' : 'file')).$thisRevString;
-   387  
-   388 $listvar['revpathlink'] = '<a href="'.$url.'">'.escape($precisePath).'</a>';
-   389 $listvar['revpath'] = escape($precisePath);
-   390 $listvar['revauthor'] = $revision->author;
-   391 $listvar['revdate'] = $revision->date;
-   392 $listvar['revage'] = $revision->age;
-   393 $listvar['revlog'] = nl2br($bugtraq->replaceIDs(create_anchors(xml_entities($revision->msg))));
-   394 $listvar['rowparity'] = $row;
-   395 $listvar['compareurl'] = $config->getURL($rep, '', 'comp').'compare[]='.urlencode($rpath).'@'.($thisrev - 1).'&amp;compare[]='.urlencode($rpath).'@'.$thisrev;
-   396  
225 if ($isDir) 397 if ($showchanges)
226 { 398 {
227 $listing[$index]["compare_box"] = "<input type=\"checkbox\" name=\"compare[]\" value=\"$parent@$thisrev\" onclick=\"checkCB(this)\" />"; 399 // Aggregate added/deleted/modified paths for display in table
-   400 $modpaths = array();
-   401  
228 $url = $config->getURL($rep, $rpath, "dir"); 402 foreach ($revision->mods as $mod)
-   403 {
229 $listing[$index]["revpathlink"] = "<a href=\"${url}rev=$thisrev&amp;sc=$showchanged\">$rpath</a>"; 404 $modpaths[$mod->action][] = $mod->path;
230 } 405 }
-   406  
231 else 407 ksort($modpaths);
-   408  
-   409 foreach ($modpaths as $action => $paths)
232 { 410 {
233 $listing[$index]["compare_box"] = "<input type=\"checkbox\" name=\"compare[]\" value=\"$rpath@$thisrev\" onclick=\"checkCB(this)\" />"; -  
234 $url = $config->getURL($rep, $rpath, "file"); 411 sort($paths);
235 $listing[$index]["revpathlink"] = "<a href=\"${url}rev=$thisrev&amp;sc=$showchanged\">$rpath</a>"; 412 $modpaths[$action] = $paths;
236 } 413 }
237 414  
238 $listing[$index]["revauthor"] = $r->author; 415 $listvar['revadded'] = (isset($modpaths['A'])) ? implode('<br/>', escape($modpaths['A'])) : '';
239 $listing[$index]["revage"] = $r->age; -  
240 $listing[$index]["revlog"] = nl2br($bugtraq->replaceIDs(create_anchors($r->msg))); 416 $listvar['revdeleted'] = (isset($modpaths['D'])) ? implode('<br/>', escape($modpaths['D'])) : '';
241 $listing[$index]["rowparity"] = "$row"; 417 $listvar['revmodified'] = (isset($modpaths['M'])) ? implode('<br/>', escape($modpaths['M'])) : '';
-   418 }
242 419  
243 $row = 1 - $row; 420 $row = 1 - $row;
244 $index++; 421 $index++;
245 } 422 }
246 423  
247 // If we've reached the search limit, stop here... 424 // If we've reached the search limit, stop here...
248 if (!$numSearchResults) 425 if (!$numSearchResults)
249 { 426 {
250 $url = $config->getURL($rep, $path, "log"); 427 $url = $config->getURL($rep, $path, 'log').$isDirString.$thisRevString;
251 $vars["logsearch_moreresultslink"] = "<a href=\"${url}rev=$rev&amp;sc=$showchanged&amp;isdir=$isDir&amp;logsearch=1&amp;search=$search&amp;fr=$thisrev\">${lang["MORERESULTS"]}</a>"; 428 $vars['logsearch_moreresultslink'] = '<a href="'.$url.'&amp;search='.$search.'&amp;fr='.$thisrev.'">'.$lang['MORERESULTS'].'</a>';
252 break; 429 break;
253 } 430 }
254 } 431 }
255 432  
256 $vars["logsearch_resultsfound"] = true; 433 $vars['logsearch_resultsfound'] = true;
257 434  
258 if ($dosearch && !$found) 435 if ($dosearch && !$found)
259 { 436 {
260 if ($fromRev == 0) 437 if ($fromRev == 0)
261 { 438 {
262 $vars["logsearch_nomatches"] = true; 439 $vars['logsearch_nomatches'] = true;
263 $vars["logsearch_resultsfound"] = false; 440 $vars['logsearch_resultsfound'] = false;
264 } 441 }
265 else 442 else
-   443 {
266 $vars["logsearch_nomorematches"] = true; 444 $vars['logsearch_nomorematches'] = true;
-   445 }
267 } 446 }
268 else if ($dosearch && $numSearchResults > 0) 447 else if ($dosearch && $numSearchResults > 0)
269 { 448 {
270 $vars["logsearch_nomorematches"] = true; 449 $vars['logsearch_nomorematches'] = true;
271 } 450 }
272 451  
273 // Work out the paging options 452 // Work out the paging options, create links to pages of results
274 -  
275 if ($pages > 1) 453 if ($pages > 1)
276 { 454 {
277 $prev = $page - 1; 455 $prev = $page - 1;
278 $next = $page + 1; 456 $next = $page + 1;
279 echo "<p><center>"; -  
280 457  
-   458 unset($queryParams['page']);
-   459 $logurl = $config->getURL($rep, $path, 'log').buildQuery($queryParams);
-   460  
-   461 if ($page > 1)
-   462 {
281 if ($page > 1) $vars["pagelinks"] .= "<a href=\"${logurl}rev=$rev&amp;sr=$startrev&amp;er=$endrev&amp;sc=$showchanged&amp;max=$max&amp;page=$prev\"><&nbsp;${lang["PREV"]}</a> "; 463 $vars['pagelinks'] .= '<a href="'.$logurl.(!$peg && $frev && $prev != 1 ? '&amp;peg='.$frev : '').'&amp;page='.$prev.'">&larr;'.$lang['PREV'].'</a>';
-   464 }
-   465 else
-   466 {
-   467 $vars['pagelinks'] .= '<span>&larr;'.$lang['PREV'].'</span>';
-   468 }
-   469  
282 for ($p = 1; $p <= $pages; $p++) 470 for ($p = 1; $p <= $pages; $p++)
283 { 471 {
284 if ($p != $page) 472 if ($p != $page)
-   473 {
285 $vars["pagelinks"].= "<a href=\"${logurl}rev=$rev&amp;sr=$startrev&amp;er=$endrev&amp;sc=$showchanged&amp;max=$max&amp;page=$p\">$p</a> "; 474 $vars['pagelinks'] .= '<a href="'.$logurl.(!$peg && $frev && $p != 1 ? '&amp;peg='.$frev : '').'&amp;page='.$p.'">'.$p.'</a>';
-   475 }
-   476 else
-   477 {
-   478 $vars['pagelinks'] .= '<span id="curpage">'.$p.'</span>';
-   479 }
-   480 }
-   481  
-   482 if ($page < $pages)
-   483 {
-   484 $vars['pagelinks'] .= '<a href="'.$logurl.(!$peg && $frev ? '&amp;peg='.$frev : '').'&amp;page='.$next.'">'.$lang['NEXT'].'&rarr;</a>';
-   485 }
286 else 486 else
-   487 {
287 $vars["pagelinks"] .= "<b>$p </b>"; 488 $vars['pagelinks'] .= '<span>'.$lang['NEXT'].'&rarr;</span>';
288 } 489 }
289 if ($page < $pages) $vars["pagelinks"] .=" <a href=\"${logurl}rev=$rev&amp;sr=$startrev&amp;er=$endrev&amp;sc=$showchanged&amp;max=$max&amp;page=$next\">${lang["NEXT"]}&nbsp;></a>"; -  
290 490  
291 $vars["showalllink"] = "<a href=\"${logurl}rev=$rev&amp;sr=$startrev&amp;er=$endrev&amp;sc=$showchanged&amp;all=1&amp;max=$max\">${lang["SHOWALL"]}</a>"; 491 $vars['showalllink'] = '<a href="'.$logurl.'&amp;all=1">'.$lang['SHOWALL'].'</a>';
-   492 }
-   493 }
-   494  
-   495 // Create form elements for filtering and searching log messages
292 echo "</center>"; 496 if ($config->multiViews)
-   497 {
-   498 $hidden = '<input type="hidden" name="op" value="log" />';
293 } 499 }
-   500 else
-   501 {
-   502 $hidden = '<input type="hidden" name="repname" value="'.$repname.'" />';
-   503 $hidden .= '<input type="hidden" name="path" value="'.$path.'" />';
-   504 }
-   505  
-   506 if ($isDir)
-   507 {
-   508 $hidden .= '<input type="hidden" name="isdir" value="'.$isDir.'" />';
294 } 509 }
295   510  
-   511 if ($peg)
-   512 {
296 // Create the project change combo box 513 $hidden .= '<input type="hidden" name="peg" value="'.$peg.'" />';
-   514 }
297 515  
298 $url = $config->getURL($rep, $path, "log"); 516 if ($showchanges != $rep->logsShowChanges())
299 # XXX: forms don't have the name attribute, but _everything_ has the id attribute, -  
300 # so what you're trying to do (if anything?) should be done via that ~J -  
-   517 {
301 $vars["logsearch_form"] = "<form action=\"$url\" method=\"post\" name=\"logsearchform\">"; 518 $hidden .= '<input type="hidden" name="showchanges" value="'.$showchanges.'" />';
-   519 }
302   520  
-   521 $vars['logsearch_form'] = '<form method="get" action="'.$config->getURL($rep, $path, 'log').'" id="search">'.$hidden;
303 $vars["logsearch_startbox"] = "<input name=\"sr\" size=\"5\" value=\"$startrev\" />"; 522 $vars['logsearch_startbox'] = '<input name="sr" size="5" value="'.$startrev.'" />';
304 $vars["logsearch_endbox" ] = "<input name=\"er\" size=\"5\" value=\"$endrev\" />"; 523 $vars['logsearch_endbox'] = '<input name="er" size="5" value="'.$endrev.'" />';
305 $vars["logsearch_maxbox" ] = "<input name=\"max\" size=\"5\" value=\"".($max==0?"":$max)."\" />"; 524 $vars['logsearch_maxbox'] = '<input name="max" size="5" value="'.($max == 0 ? 40 : $max).'" />';
306 $vars["logsearch_inputbox"] = "<input name=\"search\" value=\"$search\" />"; 525 $vars['logsearch_inputbox'] = '<input name="search" value="'.escape($search).'" />';
-   526 $vars['logsearch_showall'] = '<input type="checkbox" name="all" value="1"'.($all ? ' checked="checked"' : '').' />';
-   527 $vars['logsearch_submit'] = '<input type="submit" value="'.$lang['GO'].'" />';
-   528 $vars['logsearch_endform'] = '</form>';
307   529  
308 $vars["logsearch_submit"] = "<input type=\"submit\" value=\"${lang["GO"]}\" />"; -  
309 $vars["logsearch_endform"] = "<input type=\"hidden\" name=\"logsearch\" value=\"1\" />". -  
310 "<input type=\"hidden\" name=\"op\" value=\"log\" />". 530 // If a filter is in place, produce a link to clear all filter parameters
311 "<input type=\"hidden\" name=\"rev\" value=\"$rev\" />". 531 if ($page !== 1 || $all || $dosearch || $fromRev || $startrev !== $rev || $endrev !== 1 || $max !== 40)
-   532 {
312 "<input type=\"hidden\" name=\"sc\" value=\"$showchanged\" />". 533 $url = $config->getURL($rep, $path, 'log').$isDirString.$passRevString;
313 "<input type=\"hidden\" name=\"isdir\" value=\"$isDir\" />". 534 $vars['logsearch_clearloglink'] = '<a href="'.$url.'">'.$lang['CLEARLOG'].'</a>';
314 "</form>"; -  
-   535 }
315   536  
316 $url = $config->getURL($rep, $path, "log"); 537 // Create form elements for comparing selected revisions
317 $vars["logsearch_clearloglink"] = "<a href=\"${url}rev=$rev&amp;sc=$showchanged&amp;isdir=$isDir\">${lang["CLEARLOG"]}</a>"; 538 $vars['compare_form'] = '<form method="get" action="'.$config->getURL($rep, '', 'comp').'" id="compare">';
318   539  
319 $url = $config->getURL($rep, "/", "comp"); 540 if ($config->multiViews)
-   541 {
320 $vars["compare_form"] = "<form action=\"$url\" method=\"post\" name=\"compareform\">"; 542 $vars['compare_form'] .= '<input type="hidden" name="op" value="comp" />';
-   543 }
-   544 else
-   545 {
321 $vars["compare_submit"] = "<input name=\"comparesubmit\" type=\"submit\" value=\"${lang["COMPAREREVS"]}\" />"; 546 $vars['compare_form'] .= '<input type="hidden" name="repname" value="'.$repname.'" />';
322 $vars["compare_endform"] = "<input type=\"hidden\" name=\"op\" value=\"comp\" /><input type=\"hidden\" name=\"sc\" value=\"$showchanged\" /></form>"; -  
-   547 }
323   548  
-   549 $vars['compare_submit'] = '<input type="submit" value="'.$lang['COMPAREREVS'].'" />';
324 $vars["version"] = $version; 550 $vars['compare_endform'] = '</form>';
325   551  
326 if (!$rep->hasReadAccess($path, false)) 552 if (!$rep->hasReadAccess($path, false))
327 $vars["noaccess"] = true; -  
328   553 {
329 parseTemplate($rep->getTemplatePath()."header.tmpl", $vars, $listing); 554 $vars['error'] = $lang['NOACCESS'];
330 parseTemplate($rep->getTemplatePath()."log.tmpl", $vars, $listing); 555 sendHeaderForbidden();
331 parseTemplate($rep->getTemplatePath()."footer.tmpl", $vars, $listing); -  
-   556 }
332   557  
333 ?> 558 renderTemplate('log');