]> 91.132.146.200 Git - bibliotheca-php.git/commitdiff
changed navsearch to $_GET to make sorting and pagination working
authorBanana <mail@bananas-playground.net>
Fri, 7 Apr 2023 12:59:14 +0000 (14:59 +0200)
committerBanana <mail@bananas-playground.net>
Fri, 7 Apr 2023 12:59:14 +0000 (14:59 +0200)
webclient/index.php
webclient/view/default/collections/collections.html
webclient/view/default/collections/collections.php
webclient/view/default/collections/collections_pagination.html
webclient/view/default/dashboard/dashboard.html
webclient/view/default/dashboard/dashboard.php
webclient/view/default/entry/entry.php
webclient/view/default/system/menu.php
webclient/view/default/tags/tags.php

index f6ce4c1a540a781d952734c5139d20c34c7c01be..a7d2e25049d84c2f65cae2c9b021b6490bc4d926 100644 (file)
@@ -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);
index 5f32bc9ddc8dd8a316b64aa4e80144256bbd735c..9284efebf009058ee3afbc218d22ee3fa20b63fc 100644 (file)
@@ -1,11 +1,12 @@
 <?php if(!empty($TemplateData['pagination']) && $TemplateData['pagination']['pages'] > 1) { ?>
 <div class="uk-grid-small uk-grid-match uk-grid">
-       <div class="uk-width-3-4">
+       <div class="uk-width-1-3">
                <ul class="uk-pagination" >
                        <?php require Summoner::themefile('collections/collections_pagination.html', UI_THEME); ?>
                </ul>
        </div>
-       <div class="uk-width-1-4">
+       <div class="uk-width-2-3">
+               <?php if(!isset($TemplateData['pagination']['hideSort'])) { ?>
                <div class="uk-inline">
                        <button class="uk-button uk-button-default uk-button-small" type="button">Sort</button>
                        <div uk-dropdown>
@@ -32,6 +33,7 @@
                                </ul>
                        </div>
                </div>
+               <?php } ?>
        </div>
 </div>
 <?php } ?>
index defd065d2e16cced73c258ab0d565f95d631c786..d4e28e70d70da54f784182055c307601aab61477 100644 (file)
@@ -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
index fdfb8cc7dffab7363cea260ed37ad8df583a68aa..633990cfded5c20e7f9f2955b7ee927a5338cc2c 100644 (file)
@@ -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 '<li class="'.$active.'"><a href="index.php?'.Summoner::createFromParameterLinkQuery($TemplateData['pagination']['currentGetParameters'],array('page'=>$i)).'"
                                                        title="Goto page '.$i.'">'.$i.'</a></li>';
index 10df0227ff6356696f929875d9191cc1df88eab8..d067fac5e5efce2d120e633003ff911648868477 100644 (file)
@@ -13,7 +13,7 @@
 <div class="uk-grid-divider uk-child-width-expand@s" uk-grid>
 <?php foreach($TemplateData['latest'] as $k=>$v) { ?>
        <div class="uk-width-1@s uk-width-1-2@m uk-width-1-3@l">
-               <a href="index.php?p=collections&collection=<?php echo $k; ?>"><?php echo $v['name']; ?></a><br  />
+               <a href="index.php?p=collections&collection=<?php echo $k; echo Summoner::ifset($TemplateData, 'navSearched'); ?>"><?php echo $v['name']; ?></a><br  />
                <?php echo $v['description']; ?>
 
                <?php
index cff4d5bf0ac5820f10ad8137483288706c412387..71823c9dfc970af1e66da199604a3a246f3a1442 100644 (file)
@@ -20,12 +20,13 @@ require_once 'lib/mancubus.class.php';
 $Mancubus = new Mancubus($DB,$Doomguy);
 
 $TemplateData['search'] = false;
-$TemplateData['searchAction'] = 'index.php';
 
 $_search = '';
-if(isset($_POST['navSearch'])) {
-       $_search = trim($_POST['navSearch']);
+if(isset($_GET['navSearch'])) {
+       $_search = trim($_GET['navSearch']);
+       $_search = urldecode($_search);
        $_search = Summoner::validate($_search,'text') ? $_search : '';
+       $TemplateData['navSearched'] = '&navSearch='.urlencode($_search);
 }
 
 $TemplateData['latest'] = $Mancubus->getLatest(5,5,$_search);
index 89e180d4441385ad285cd74dabd919961d4febf4..5a3c5b536f34334aa6293798b61645f08b24d369 100644 (file)
@@ -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);
index 20257cd8947eb01e7432eab3fc243a98c47ac0d9..859b4469f5c00beb918f9069bd048782cfb2b6ef 100644 (file)
@@ -73,7 +73,14 @@ $_menuManage = $Gorenest->get('manage', false, $_contextActions);
                <div>
                        <a class="uk-navbar-toggle" uk-search-icon href="#"></a>
                        <div class="uk-drop" uk-drop="mode: click; pos: left-center; offset: 0">
-                               <form class="uk-search uk-search-navbar uk-width-1-1" method="post" action="<?php echo $TemplateData['searchAction']; ?>">
+                               <form class="uk-search uk-search-navbar uk-width-1-1" method="get" action="index.php">
+                                       <?php
+                                               if(isset($TemplateData['navSearchAction'])) {
+                                                       foreach($TemplateData['navSearchAction'] as $param=>$pValue) {
+                                                               echo '<input type="hidden" name="'.$param.'" value="'.$pValue.'" />';
+                                                       }
+                                               }
+                                       ?>
                                        <input class="uk-search-input" type="search" placeholder="Search..." name="navSearch" autofocus>
                                        <small><a href="index.php?p=advancedsearch">Advanced</a></small>
                                </form>
index 1b63e4084d2614ab34e18478dcf8889c5d346a16..334e6d2663e9ac5b2339d3f2c26faaf25f412ae9 100644 (file)
@@ -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);