Bug 28764: (QA follow-up) Add comment, remove two defined's

If we no longer offer the sortfield with :asc actively, we should
probably write it somewhere too.
Replaced a few defined tests by empty test. No need to split empty
string or zero etc.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Marcel de Rooy 2021-08-09 13:41:45 +00:00 committed by Kyle M Hall
parent 0d2208b9f1
commit eed750ba95
1 changed files with 6 additions and 3 deletions

View File

@ -256,16 +256,19 @@ if ( $op eq 'view' ) {
if ( $shelf ) {
if ( $shelf->can_be_viewed( $loggedinuser ) ) {
$category = $shelf->category;
# Sortfield param may still include sort order with :asc or :desc, but direction overrides it
my( $sortfield, $direction );
if( defined( $query->param('sortfield') ) ){ # Passed in sorting overrides default sorting
if( $query->param('sortfield') ){
( $sortfield, $direction ) = split /:/, $query->param('sortfield');
} else {
$sortfield = $shelf->sortfield;
$direction = 'asc';
}
if( defined( $query->param('direction') ) ){ $direction = $query->param('direction'); }
$sortfield = 'title' if !$sortfield or !grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded );
$direction = $query->param('direction') if $query->param('direction');
$direction = 'asc' if !$direction or ( $direction ne 'asc' and $direction ne 'desc' );
$sortfield = 'title' if !$sortfield or !grep { $_ eq $sortfield } qw( title author copyrightdate itemcallnumber dateadded );
my ( $page, $rows );
unless ( $query->param('print') or $query->param('rss') ) {
$rows = C4::Context->preference('OPACnumSearchResults') || 20;