From: Banana Date: Fri, 7 Apr 2023 12:59:14 +0000 (+0200) Subject: changed navsearch to $_GET to make sorting and pagination working X-Git-Tag: 1.5~33 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=2308c9d3d6d915fd1b3879e850bda34a334c44b6;p=bibliotheca-php.git changed navsearch to $_GET to make sorting and pagination working --- diff --git a/webclient/index.php b/webclient/index.php index f6ce4c1..a7d2e25 100644 --- a/webclient/index.php +++ b/webclient/index.php @@ -57,7 +57,7 @@ require_once 'lib/gorenest.class.php'; # and some defaults $TemplateData = array(); $TemplateData['pagination'] = array(); -$TemplateData['searchAction'] = 'index.php'; +$TemplateData['navSearchAction'] = array(); $TemplateData['pageTitle'] = 'Dashboard'; # the view $View = Summoner::themefile('dashboard/dashboard.html', UI_THEME); diff --git a/webclient/view/default/collections/collections.html b/webclient/view/default/collections/collections.html index 5f32bc9..9284efe 100644 --- a/webclient/view/default/collections/collections.html +++ b/webclient/view/default/collections/collections.html @@ -1,11 +1,12 @@ 1) { ?>
-
+
-
+
+
@@ -32,6 +33,7 @@
+
diff --git a/webclient/view/default/collections/collections.php b/webclient/view/default/collections/collections.php index defd065..d4e28e7 100644 --- a/webclient/view/default/collections/collections.php +++ b/webclient/view/default/collections/collections.php @@ -41,9 +41,11 @@ if(isset($_GET['fv']) && !empty($_GET['fv'])) { $_fv = Summoner::validate($_fv) ? $_fv : false; } +// nav search $_search = ''; -if(isset($_POST['navSearch'])) { - $_search = trim($_POST['navSearch']); +if(isset($_GET['navSearch'])) { + $_search = trim($_GET['navSearch']); + $_search = urldecode($_search); $_search = Summoner::validate($_search) ? $_search : ''; } @@ -85,7 +87,6 @@ $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); @@ -114,7 +115,7 @@ if(!empty($_collection)) { $TemplateData['storagePath'] = PATH_WEB_STORAGE . '/' . $Trite->param('id'); $TemplateData['entryLinkPrefix'] = "index.php?p=entry&collection=".$Trite->param('id'); - $TemplateData['searchAction'] = 'index.php?p=collections&collection='.$Trite->param('id'); + $TemplateData['navSearchAction'] = array('p' => 'collections', 'collection' => $Trite->param('id')); $_fd = $Trite->getCollectionFields(); @@ -136,12 +137,15 @@ if(!empty($_collection)) { 'colValue' => $_search, 'fieldData' =>$_fd[$Trite->param('defaultSearchField')] ); - $_doNotShowPagination = true; // fulltextsearch does not support order + if (!empty($_search)) { + $TemplateData['pagination']['hideSort'] = true; + } } $TemplateData['entries'] = $Mancubus->getEntries($_sdata); if (!empty($_search)) { $TemplateData['search'] = $_search; + $TemplateData['pagination']['currentGetParameters']['navSearch'] = urlencode($_search); } $TemplateData['pageTitle'] = $Trite->param('name'); @@ -157,33 +161,31 @@ else { } # pagination -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(!empty($TemplateData['entries']['amount'])) { + $TemplateData['pagination']['pages'] = (int)ceil($TemplateData['entries']['amount'] / RESULTS_PER_PAGE); + $TemplateData['pagination']['curPage'] = $_curPage; - 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); + $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) { + $TemplateData['pagination']['visibleRange'][] = $e; } - else { - $TemplateData['pagination']['visibleRange'] = range(1,$TemplateData['pagination']['pages']); + # 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); +} +else { + $TemplateData['pagination']['visibleRange'] = range(1,$TemplateData['pagination']['pages']); } # pagination end diff --git a/webclient/view/default/collections/collections_pagination.html b/webclient/view/default/collections/collections_pagination.html index fdfb8cc..633990c 100644 --- a/webclient/view/default/collections/collections_pagination.html +++ b/webclient/view/default/collections/collections_pagination.html @@ -8,6 +8,7 @@ $ellipsisShown = 0; for($i=1;$i<=$TemplateData['pagination']['pages'];$i++) { $active = ''; if($i == $TemplateData['pagination']['curPage']) $active = 'uk-active'; + if(in_array($i,$TemplateData['pagination']['visibleRange'])) { echo '
  • '.$i.'
  • '; diff --git a/webclient/view/default/dashboard/dashboard.html b/webclient/view/default/dashboard/dashboard.html index 10df022..d067fac 100644 --- a/webclient/view/default/dashboard/dashboard.html +++ b/webclient/view/default/dashboard/dashboard.html @@ -13,7 +13,7 @@
    $v) { ?>
    -
    +
    getLatest(5,5,$_search); diff --git a/webclient/view/default/entry/entry.php b/webclient/view/default/entry/entry.php index 89e180d..5a3c5b5 100644 --- a/webclient/view/default/entry/entry.php +++ b/webclient/view/default/entry/entry.php @@ -47,8 +47,8 @@ if(!empty($_collection) && !empty($_id)) { if(!empty($TemplateData['loadedCollection'])) { $Mancubus->setCollection($Trite->param('id')); $TemplateData['entry'] = $Mancubus->getEntry($_id); - $TemplateData['storagePath'] = PATH_WEB_STORAGE . '/' . $Trite->param('id') . '/' . $_id; - $TemplateData['searchAction'] = 'index.php?p=collections&collection=' . $Trite->param('id'); + $TemplateData['storagePath'] = PATH_WEB_STORAGE.'/'.$Trite->param('id').'/'.$_id; + $TemplateData['navSearchAction'] = array('p' => 'collections', 'collection' => $Trite->param('id')); $ManageEntry->setCollection($Trite->param('id')); $TemplateData['showEdit'] = $ManageEntry->canEditEntry($_id); diff --git a/webclient/view/default/system/menu.php b/webclient/view/default/system/menu.php index 20257cd..859b446 100644 --- a/webclient/view/default/system/menu.php +++ b/webclient/view/default/system/menu.php @@ -73,7 +73,14 @@ $_menuManage = $Gorenest->get('manage', false, $_contextActions);
    - diff --git a/webclient/view/default/tags/tags.php b/webclient/view/default/tags/tags.php index 1b63e40..334e6d2 100644 --- a/webclient/view/default/tags/tags.php +++ b/webclient/view/default/tags/tags.php @@ -39,8 +39,9 @@ $TemplateData['tags'] = array(); $TemplateData['search'] = array(); $_search = ''; -if(isset($_POST['navSearch'])) { - $_search = trim($_POST['navSearch']); +if(isset($_GET['navSearch'])) { + $_search = trim($_GET['navSearch']); + $_search = urldecode($_search); $_search = Summoner::validate($_search) ? $_search : ''; } @@ -48,7 +49,7 @@ if(isset($_POST['navSearch'])) { if(!empty($_collection)) { $TemplateData['loadedCollection'] = $Trite->load($_collection); if(!empty($TemplateData['loadedCollection'])) { - $TemplateData['searchAction'] = 'index.php?p=tags&collection='.$Trite->param('id'); + $TemplateData['navSearchAction'] = array('p' => 'tags', 'collection' => $Trite->param('id')); $Mancubus->setCollection($Trite->param('id')); //$TemplateData['tags'] = $Mancubus->getTags($_search); $TemplateData['tags'] = $Trite->getTags($_search);