]> 91.132.146.200 Git - bibliotheca-php.git/commitdiff
do not show sort when there is no sort available
authorBanana <mail@bananas-playground.net>
Fri, 16 Dec 2022 19:29:25 +0000 (20:29 +0100)
committerBanana <mail@bananas-playground.net>
Fri, 16 Dec 2022 19:29:25 +0000 (20:29 +0100)
CHANGELOG
webclient/view/default/advancedsearch/advancedsearch.html
webclient/view/default/collections/collections.php

index a3f4cb94e5501c25cc161b181fd1b7d284e1d026..8c970f1d6cc842b0aa9d4ace9b62aa8e68937dfb 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,7 +10,7 @@
        * Stats info page
        * Some more PHP 8 syntax and support
        * Needs PHP 8 as of this version
-       * Tow new fields to choose from. ISBN and Artists
+       * Two new fields to choose from. ISBN and Artists
 
 1.2 - NyLeve's Falls 2021-07-17
        * Updated requirements information
index a352fa07f0b8ec10c0acba64df1830fc820403c0..b3bb80893d4d903f56fca62774ea0e83de2250cd 100644 (file)
@@ -3,7 +3,9 @@
 <?php if(!empty($TemplateData['search'])) { ?>
 <div uk-alert id="searchNotice">
        <button class="uk-alert-close" type="button" uk-close></button>
-       <p>Display result for: <b><?php echo $TemplateData['search']; ?></b> (Max. result of 60)</p>
+       <p>Display result for: <b><?php echo $TemplateData['search']; ?></b><br />
+               <small>(Max. result of 60)</small>
+       </p>
 </div>
 <div class="uk-padding-small uk-padding-remove-left">
        <script type="text/javascript">
index 7b61328a885e79167c1746f6709ad71e07082ecc..defd065d2e16cced73c258ab0d565f95d631c786 100644 (file)
@@ -21,17 +21,17 @@ $Mancubus = new Mancubus($DB,$Doomguy);
 require_once 'lib/trite.class.php';
 $Trite = new Trite($DB,$Doomguy);
 
-$_collection = false;
+$_collection = '';
 if(isset($_GET['collection']) && !empty($_GET['collection'])) {
        $_collection = trim($_GET['collection']);
-       $_collection = Summoner::validate($_collection,'digit') ? $_collection : false;
+       $_collection = Summoner::validate($_collection,'digit') ? $_collection : '';
 }
 
 // field identifier to search within
-$_fid = false;
+$_fid = '';
 if(isset($_GET['fid']) && !empty($_GET['fid'])) {
        $_fid = trim($_GET['fid']);
-       $_fid = Summoner::validate($_fid,'nospace') ? $_fid : false;
+       $_fid = Summoner::validate($_fid,'nospace') ? $_fid : '';
 }
 
 // field value to look up
@@ -41,10 +41,10 @@ if(isset($_GET['fv']) && !empty($_GET['fv'])) {
        $_fv = Summoner::validate($_fv) ? $_fv : false;
 }
 
-$_search = false;
+$_search = '';
 if(isset($_POST['navSearch'])) {
        $_search = trim($_POST['navSearch']);
-       $_search = Summoner::validate($_search) ? $_search :  false;
+       $_search = Summoner::validate($_search) ? $_search : '';
 }
 
 ## pagination
@@ -56,16 +56,16 @@ if(isset($_GET['page']) && !empty($_GET['page'])) {
        $_curPage = Summoner::validate($_curPage,'digit') ? $_curPage : 1;
 }
 
-$_sort = false;
+$_sort = '';
 if(isset($_GET['s']) && !empty($_GET['s'])) {
        $_sort = trim($_GET['s']);
-       $_sort = Summoner::validate($_sort,'nospace') ? $_sort : false;
+       $_sort = Summoner::validate($_sort,'nospace') ? $_sort : '';
 }
 
 $_sortDirection = '';
 if(isset($_GET['sd']) && !empty($_GET['sd'])) {
        $_sortDirection = trim($_GET['sd']);
-       $_sortDirection = Summoner::validate($_sortDirection,'nospace') ? $_sortDirection : false;
+       $_sortDirection = Summoner::validate($_sortDirection,'nospace') ? $_sortDirection : '';
 }
 
 $_queryOptions = array(
@@ -81,10 +81,11 @@ $TemplateData['loadedCollection'] = array();
 $TemplateData['storagePath'] = '';
 $TemplateData['entries'] = array();
 $TemplateData['collections'] = array();
-$TemplateData['search'] = false;
+$TemplateData['search'] = '';
 // needed for pagination link building
 $TemplateData['pagination']['currentGetParameters']['p'] = 'collections';
 $TemplateData['pagination']['currentGetParameters']['collection'] = $_collection;
+$_doNotShowPagination = false;
 
 if(!empty($_collection)) {
        $TemplateData['loadedCollection'] = $Trite->load($_collection);
@@ -135,6 +136,7 @@ if(!empty($_collection)) {
                                'colValue' => $_search,
                                'fieldData' =>$_fd[$Trite->param('defaultSearchField')]
                        );
+                       $_doNotShowPagination = true; // fulltextsearch does not support order
                }
 
                $TemplateData['entries'] = $Mancubus->getEntries($_sdata);
@@ -155,31 +157,33 @@ else {
 }
 
 # pagination
-if(!empty($TemplateData['entries']['amount'])) {
-       $TemplateData['pagination']['pages'] = ceil($TemplateData['entries']['amount'] / RESULTS_PER_PAGE);
-       $TemplateData['pagination']['curPage'] = $_curPage;
-
-       $TemplateData['pagination']['currentGetParameters']['page'] = $_curPage;
-       $TemplateData['pagination']['currentGetParameters']['s'] = $_sort;
-       $TemplateData['pagination']['currentGetParameters']['sd'] = $_sortDirection;
-}
+if(!$_doNotShowPagination) {
+       if(!empty($TemplateData['entries']['amount'])) {
+               $TemplateData['pagination']['pages'] = ceil($TemplateData['entries']['amount'] / RESULTS_PER_PAGE);
+               $TemplateData['pagination']['curPage'] = $_curPage;
+
+               $TemplateData['pagination']['currentGetParameters']['page'] = $_curPage;
+               $TemplateData['pagination']['currentGetParameters']['s'] = $_sort;
+               $TemplateData['pagination']['currentGetParameters']['sd'] = $_sortDirection;
+       }
 
-if($TemplateData['pagination']['pages'] > 11) {
-       # first pages
-       $TemplateData['pagination']['visibleRange'] = range(1,3);
-       # last pages
-       foreach(range($TemplateData['pagination']['pages']-2, $TemplateData['pagination']['pages']) as $e) {
-               array_push($TemplateData['pagination']['visibleRange'], $e);
+       if($TemplateData['pagination']['pages'] > 11) {
+               # first pages
+               $TemplateData['pagination']['visibleRange'] = array(range(1,3));
+               # last pages
+               foreach(range($TemplateData['pagination']['pages']-2, $TemplateData['pagination']['pages']) as $e) {
+                       $TemplateData['pagination']['visibleRange'][] = $e;
+               }
+               # pages before and after current page
+               $cRange = range($TemplateData['pagination']['curPage']-1, $TemplateData['pagination']['curPage']+1);
+               foreach($cRange as $e) {
+                       $TemplateData['pagination']['visibleRange'][] = $e;
+               }
+               $TemplateData['pagination']['currentRangeStart'] = array_shift($cRange);
+               $TemplateData['pagination']['currentRangeEnd'] = array_pop($cRange);
        }
-       # pages before and after current page
-       $cRange = range($TemplateData['pagination']['curPage']-1, $TemplateData['pagination']['curPage']+1);
-       foreach($cRange as $e) {
-               array_push($TemplateData['pagination']['visibleRange'], $e);
+       else {
+               $TemplateData['pagination']['visibleRange'] = range(1,$TemplateData['pagination']['pages']);
        }
-       $TemplateData['pagination']['currentRangeStart'] = array_shift($cRange);
-       $TemplateData['pagination']['currentRangeEnd'] = array_pop($cRange);
-}
-else {
-       $TemplateData['pagination']['visibleRange'] = range(1,$TemplateData['pagination']['pages']);
 }
 # pagination end