Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions include/configclass.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,8 @@ class WebSvnConfig {
var $flatIndex = true;
var $openTree = false;
var $alphabetic = false;
var $sortByField = 'filename';
var $validSortByFields = array( 'filename', 'date' );
var $showLastModInIndex = true;
var $showLastModInListing = true;
var $showAgeInsteadOfDate = true;
Expand Down Expand Up @@ -1613,6 +1615,19 @@ function isAlphabeticOrder() {
return $this->alphabetic;
}

function setSortByField($sortByField) {
if (in_array($sortByField, $this->validSortByFields)) {
$this->sortByField = $sortByField;
} else {
echo 'Setting default sort by field to an invalid value "'.$sortByField.'"';
exit;
}
}

function sortByField() {
return $this->sortByField;
}

function showLastModInIndex() {
return $this->showLastModInIndex;
}
Expand Down
6 changes: 6 additions & 0 deletions include/distconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@

// $config->setAlphabeticOrder(true);

// By default, WebSVN entries are alphabetically sorted, you may choose to sort
// by commit date.

// $config->setSortByField('filename');
// $config->setSortByField('date');

// By default, WebSVN loads parent path directories and then on user click other,
// This options loads the entire directory in one go and allows to browse without delay.
// By default all will be collapsed to root directory and can be expanded.
Expand Down
10 changes: 9 additions & 1 deletion include/svnlook.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ function _listSort($e1, $e2) {

$file1 = $e1->file;
$file2 = $e2->file;
$committime1 = $e1->committime;
$committime2 = $e2->committime;
$isDir1 = ($file1[strlen($file1) - 1] == '/');
$isDir2 = ($file2[strlen($file2) - 1] == '/');

Expand All @@ -491,7 +493,13 @@ function _listSort($e1, $e2) {
if ($isDir1) $file1 = substr($file1, 0, -1);
if ($isDir2) $file2 = substr($file2, 0, -1);

return strnatcasecmp($file1, $file2);
switch($config->sortByField()) {
case 'filename':
return strnatcasecmp($file1, $file2);
case 'date':
if ($committime1 == $committime2) return 0;
return ($committime1 < $committime2) ? -1 : 1;
}
}

// }}}
Expand Down