Commit c1ae6ad0bf60b37b44f3920d89b2d2001a85a53e

Authored by nbm
1 parent cd2bd652

Return proper sorting information for DateColumns and UserColumns.

Also, make sorting default to ascending when the column itself isn't
being sorted upon (otherwise swap to the opposite sorting to current).


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4952 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/browse/BrowseColumns.inc.php
@@ -33,7 +33,11 @@ class BrowseColumn { @@ -33,7 +33,11 @@ class BrowseColumn {
33 function renderHeader($sReturnURL) { 33 function renderHeader($sReturnURL) {
34 $text = _("Abstract") . ": " . $this->label; 34 $text = _("Abstract") . ": " . $this->label;
35 $href = $sReturnURL . "&sort_on=" . $this->name . "&sort_order="; 35 $href = $sReturnURL . "&sort_on=" . $this->name . "&sort_order=";
36 - $href .= $this->sort_direction == "asc" ? "desc" : "asc" ; 36 + if ($this->sort_on) {
  37 + $href .= $this->sort_direction == "asc" ? "desc" : "asc" ;
  38 + } else {
  39 + $href .= $this->sort_direction = "asc";
  40 + }
37 41
38 return '<a href="' . $href . '">'.$text.'</a>'; 42 return '<a href="' . $href . '">'.$text.'</a>';
39 43
@@ -63,7 +67,11 @@ class TitleColumn extends BrowseColumn { @@ -63,7 +67,11 @@ class TitleColumn extends BrowseColumn {
63 function renderHeader($sReturnURL) { 67 function renderHeader($sReturnURL) {
64 $text = _("Title"); 68 $text = _("Title");
65 $href = $sReturnURL . "&sort_on=" . $this->name . "&sort_order="; 69 $href = $sReturnURL . "&sort_on=" . $this->name . "&sort_order=";
66 - $href .= $this->sort_direction == "asc" ? "desc" : "asc" ; 70 + if ($this->sort_on) {
  71 + $href .= $this->sort_direction == "asc" ? "desc" : "asc" ;
  72 + } else {
  73 + $href .= $this->sort_direction = "asc";
  74 + }
67 75
68 return '<a href="' . $href . '">'.$text.'</a>'; 76 return '<a href="' . $href . '">'.$text.'</a>';
69 77
@@ -144,7 +152,11 @@ class DateColumn extends BrowseColumn { @@ -144,7 +152,11 @@ class DateColumn extends BrowseColumn {
144 function renderHeader($sReturnURL) { 152 function renderHeader($sReturnURL) {
145 $text = $this->label; 153 $text = $this->label;
146 $href = $sReturnURL . "&sort_on=" . $this->name . "&sort_order="; 154 $href = $sReturnURL . "&sort_on=" . $this->name . "&sort_order=";
147 - $href .= $this->sort_direction == "asc" ? "desc" : "asc" ; 155 + if ($this->sort_on) {
  156 + $href .= $this->sort_direction == "asc" ? "desc" : "asc" ;
  157 + } else {
  158 + $href .= $this->sort_direction = "asc";
  159 + }
148 160
149 return '<a href="' . $href . '">'.$text.'</a>'; 161 return '<a href="' . $href . '">'.$text.'</a>';
150 162
@@ -176,6 +188,13 @@ class DateColumn extends BrowseColumn { @@ -176,6 +188,13 @@ class DateColumn extends BrowseColumn {
176 return 'unspecified_type'; 188 return 'unspecified_type';
177 } 189 }
178 } 190 }
  191 +
  192 + function addToFolderQuery() {
  193 + return array(null, null, null);
  194 + }
  195 + function addToDocumentQuery() {
  196 + return array(null, null, $this->name);
  197 + }
179 } 198 }
180 199
181 200
@@ -192,7 +211,11 @@ class UserColumn extends BrowseColumn { @@ -192,7 +211,11 @@ class UserColumn extends BrowseColumn {
192 function renderHeader($sReturnURL) { 211 function renderHeader($sReturnURL) {
193 $text = $this->label; 212 $text = $this->label;
194 $href = $sReturnURL . "&sort_on=" . $this->name . "&sort_order="; 213 $href = $sReturnURL . "&sort_on=" . $this->name . "&sort_order=";
195 - $href .= $this->sort_direction == "asc" ? "desc" : "asc" ; 214 + if ($this->sort_on) {
  215 + $href .= $this->sort_direction == "asc" ? "desc" : "asc" ;
  216 + } else {
  217 + $href .= $this->sort_direction = "asc";
  218 + }
196 219
197 return '<a href="' . $href . '">'.$text.'</a>'; 220 return '<a href="' . $href . '">'.$text.'</a>';
198 221
@@ -220,6 +243,15 @@ class UserColumn extends BrowseColumn { @@ -220,6 +243,15 @@ class UserColumn extends BrowseColumn {
220 } 243 }
221 return $outStr; 244 return $outStr;
222 } 245 }
  246 +
  247 + function addToFolderQuery() {
  248 + return array(null, null, null);
  249 + }
  250 + function addToDocumentQuery() {
  251 + $sUsersTable = KTUtil::getTableName('users');
  252 + $sJoinSQL = "LEFT JOIN $sUsersTable AS users_order_join ON D.{$this->name} = users_order_join.id";
  253 + return array($sJoinSQL, null, "users_order_join.name");
  254 + }
223 } 255 }
224 256
225 // use the _name_ parameter + _f_ + id to create a non-clashing checkbox. 257 // use the _name_ parameter + _f_ + id to create a non-clashing checkbox.
@@ -272,7 +304,11 @@ class WorkflowColumn extends BrowseColumn { @@ -272,7 +304,11 @@ class WorkflowColumn extends BrowseColumn {
272 function renderHeader($sReturnURL) { 304 function renderHeader($sReturnURL) {
273 $text = $this->label; 305 $text = $this->label;
274 $href = $sReturnURL . "&sort_on=" . $this->name . "&sort_order="; 306 $href = $sReturnURL . "&sort_on=" . $this->name . "&sort_order=";
275 - $href .= $this->sort_direction == "asc" ? "desc" : "asc" ; 307 + if ($this->sort_on) {
  308 + $href .= $this->sort_direction == "asc" ? "desc" : "asc" ;
  309 + } else {
  310 + $href .= $this->sort_direction = "asc";
  311 + }
276 312
277 return '<a href="' . $href . '">'.$text.'</a>'; 313 return '<a href="' . $href . '">'.$text.'</a>';
278 } 314 }