]> 91.132.146.200 Git - bibliotheca-php.git/commitdiff
adding sort
authorBanana <mail@bananas-playground.net>
Sun, 31 Jan 2021 20:27:44 +0000 (21:27 +0100)
committerBanana <mail@bananas-playground.net>
Sun, 31 Jan 2021 20:27:44 +0000 (21:27 +0100)
18 files changed:
CHANGELOG
TODO
documentation/fields.txt
upgrade/from-version-1.0.txt
webclient/index.php
webclient/lib/managecollectionfields.class.php
webclient/lib/managecollections.class.php
webclient/lib/mancubus.class.php
webclient/lib/summoner.class.php
webclient/lib/trite.class.php
webclient/view/default/collections/collections.html
webclient/view/default/collections/collections.php
webclient/view/default/main.php
webclient/view/default/managecolletions/managecolletions.html
webclient/view/default/managecolletions/managecolletions.php
webclient/view/default/system/pagination.html [deleted file]
webclient/view/default/system/pagination_after.php [deleted file]
webclient/view/default/system/pagination_before.php [deleted file]

index 7b38ab05fb2330d7b8dc434bd4fed11634f3bf6d..98d1d2843a7cf2a2464b0e4a49d2e5accd969a01 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,8 +3,10 @@
        * Missing changelog file
        * api has its own log file now.
        * User profile for editing own settings.
-       * Collection management has the option to update entry rights with the collection ones.
-       * Entry rights can now be managed. More info about user and rights can be found in documentation.
+       * Collection management has the option to update entry rights with the 
+               collection ones.
+       * Entry rights can now be managed. More info about user and rights can 
+               be found in documentation.
        * User management: Honor rights from current logged in user
        * Group management now available. But no relation check yet.
        * User management: Additional groups
        * Documentation for tools
        * Documentation for tool imdbweb grabber. Default config added.
        * Fixed bug #3
-       * Added feature #2. There is now a new definition which defines the default targets of the imdb grabber values.
-               See the config-imdbweb.php.default for more details
+       * Added feature #2. There is now a new definition which defines the default 
+               targets of the imdb grabber values. See the config-imdbweb.php.default 
+               for more details
+       * Added sort filter. Collection has a default sort field config now.
+               Sort fields are the simple fields. See fields documentation.
 
 1.0 - Castle 20210106
        * First usable version
diff --git a/TODO b/TODO
index ec8b20d0bdb109958dda7775b30caf2ccf8bbb2b..517e11c1189061986f3208fd8673bd436e11b7a6 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
-* sort by filter for collection display
 * Mass edit of entries
 * User and groupmanagement: Check where a user or group is used!
 * Better error handling and display while adding / update and delete
index 330211173a9da5a84c54e4d3174a4ddf5db8a7fc..d3279a019be6ab6fc4c29e0d7a762b1d51595a0d 100644 (file)
@@ -9,7 +9,7 @@ Each collection can have there own set of fields. But at least the title field s
 Fields can be managed after a collection has been created.
 
 
-# If you want to create new ones here is a explanation how they work
+# If you want to create new ones here is an explanation how they work
 A field is defined in the sys_fields table. It needs a _saveField and optinal _loadFieldValue method
 in manageentry.class and the _loadFieldValue also in mancubus.class
 HTML definitions are needed in view/UI_THEME/entry and view/UI_THEME/manageentry
@@ -32,6 +32,7 @@ A _saveField_TYPE method in manageentry.class for data saving.
 Modification on advancedsearch.php if search needs some special treatment for this field
 
 searchtype
+Every field with entry* is a simple search field and can be used in global search.
 - tag = releation to lookup2entry table
 - entryText = text col in entry table
 - entrySingleText = entry col in entry table. Single value
index 22b14f5a6f618ecf42623bbe2433f66f6e861ab6..86c6e132001e1c909788db899ee3caa0a6b859ed 100644 (file)
@@ -9,6 +9,11 @@ The definition of USER_DEFAULT_RIGHTS_STRING can be removed from config file.
 Copy config/config-imdbweb.php.default to config/config-imdbweb.php
 See too-imdbweb.txt documentation for more information.
 
+# following files can be removed
+view/default/system/pagination.html
+view/default/system/pagination_after.php
+view/default/system/pagination_before.php
+
 # DB changes. Run each line against your bibliotheca DB.
 # Replace #REPLACEME# with your table prefix. Default is bib
 UPDATE `#REPLACEME#_menu` SET `rights` = 'rw-rw----' WHERE `#REPLACEME#_menu`.`id` = 10;
@@ -18,3 +23,4 @@ DELETE FROM `#REPLACEME#_menu` WHERE `#REPLACEME#_menu`.`id` = 13;
 INSERT INTO `#REPLACEME#_menu` (`id`, `text`, `action`, `icon`, `owner`, `group`, `rights`, `position`, `category`) VALUES (NULL, 'Groups', 'managegroups', 'users', '1', '1', 'rw-------', '5', 'manage');
 UPDATE `#REPLACEME#_menu` SET `position` = '6' WHERE `#REPLACEME#_menu`.`id` = 16;
 UPDATE `#REPLACEME#_menu` SET `group` = '2', `rights` = 'rw-rw----' WHERE `#REPLACEME#_menu`.`id` = 14;
+ALTER TABLE `#REPLACEME#_collection` ADD `defaultSortField` VARCHAR(16) NOT NULL AFTER `defaultSearchField`;
index acfe2f6f34f7f2070ab91c05abcf3a6c721fafe6..beae986af22d579450c1fcd29b0b2f0e74a85895 100644 (file)
@@ -68,8 +68,6 @@ $ViewScript = Summoner::themefile('dashboard/dashboard.php', UI_THEME);
 $ViewMessage = Summoner::themefile('system/message.php',UI_THEME);
 # the menu
 $ViewMenu = Summoner::themefile('system/menu.php',UI_THEME);
-# the pagination
-$ViewPagination = Summoner::themefile('system/pagination.html',UI_THEME);
 
 ## DB connection
 $DB = new mysqli(DB_HOST, DB_USERNAME,DB_PASSWORD, DB_NAME);
index 640078c2950c957c2ef75b6f6a839e009b1bb357..510a4199e92831c1fa2c7b616185207b07387a98 100644 (file)
@@ -255,8 +255,10 @@ class ManageCollectionFields {
                        return $this->_cacheExistingSysFields;
                }
 
+               $this->_cacheExistingSysFields = array();
+
                $queryStr = "SELECT `cf`.`fk_field_id` AS id, `sf`.`type`, `sf`.`displayname`, `sf`.`identifier`,
-                                                       `sf`.`createstring`
+                                                       `sf`.`createstring`, `sf`.`searchtype`
                                                FROM `".DB_PREFIX."_collection_fields_".$this->_collectionId."` AS cf
                                                LEFT JOIN `".DB_PREFIX."_sys_fields` AS sf ON `cf`.`fk_field_id` = `sf`.`id`";
                if($sortAZ === true) {
@@ -281,6 +283,28 @@ class ManageCollectionFields {
                return $this->_cacheExistingSysFields;
        }
 
+       /**
+        * return the simple search fields for loaded collection
+        * Every field witch has a column in the entry table is a simple search field.
+        * Name starts with entry
+        *
+        * @return array
+        */
+       public function getSimpleSearchFields(): array {
+               $ret = array();
+
+               $fields = $this->getExistingFields();
+               if(!empty($fields)) {
+                       foreach($fields as $k=>$v) {
+                               if(isset($v['searchtype']) && strpos($v['searchtype'],'entry') !== false) {
+                                       $ret[$k] = $v;
+                               }
+                       }
+               }
+
+               return $ret;
+       }
+
        /**
         * Get the column names from current collection entry table
         *
index 11d737fa9766daa45077f11df00961217c7bdaf0..69e02672b838272953f88ba32df2a4795d97b056 100644 (file)
@@ -197,7 +197,7 @@ class ManageCollections {
         * @param array $data
         * @return bool
         */
-       public function createCollection($data) {
+       public function createCollection(array $data): bool {
                $ret = false;
 
                if(!empty($data['name']) === true
@@ -213,7 +213,8 @@ class ManageCollections {
                                                                `owner` = '".$this->_DB->real_escape_string($data['owner'])."',
                                                                `group` = '".$this->_DB->real_escape_string($data['group'])."',
                                                                `rights` = '".$this->_DB->real_escape_string($data['rights'])."',
-                                                               `defaultSearchField` = '".$this->_DB->real_escape_string($data['defaultSearchField'])."'";
+                                                               `defaultSearchField` = '".$this->_DB->real_escape_string($data['defaultSearchField'])."',
+                                                               `defaultSortField` = '".$this->_DB->real_escape_string($data['defaultSortField'])."'";
                                if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
                                $this->_DB->query($queryStr);
                                $newId = $this->_DB->insert_id;
@@ -274,12 +275,13 @@ class ManageCollections {
         * @param string $id Number
         * @return array
         */
-       public function getEditData($id) {
+       public function getEditData(string $id): array {
                $ret = array();
 
                if (Summoner::validate($id, 'digit')) {
                        $queryStr = "SELECT `c`.`id`, `c`.`name`, `c`.`description`, `c`.`created`,
                                        `c`.`owner`, `c`.`group`, `c`.`rights`, `c`.`defaultSearchField`,
+                                       `c`.`defaultSortField`,
                                        `u`.`name` AS username, `g`.`name` AS groupname
                                        FROM `".DB_PREFIX."_collection` AS c
                                        LEFT JOIN `".DB_PREFIX."_user` AS u ON `c`.`owner` = `u`.`id`
@@ -310,7 +312,7 @@ class ManageCollections {
         * @param array $data
         * @return bool
         */
-       public function updateCollection($data) {
+       public function updateCollection(array $data): bool {
                $ret = false;
 
                if(DEBUG) error_log("[DEBUG] ".__METHOD__."  data: ".var_export($data,true));
@@ -325,7 +327,8 @@ class ManageCollections {
                                                        `owner` = '".$this->_DB->real_escape_string($data['owner'])."',
                                                        `group` = '".$this->_DB->real_escape_string($data['group'])."',
                                                        `rights` = '".$this->_DB->real_escape_string($data['rights'])."',
-                                                       `defaultSearchField` = '".$this->_DB->real_escape_string($data['defaultSearchField'])."'
+                                                       `defaultSearchField` = '".$this->_DB->real_escape_string($data['defaultSearchField'])."',
+                                                       `defaultSortField` = '".$this->_DB->real_escape_string($data['defaultSortField'])."'
                                                WHERE `id` = '".$this->_DB->real_escape_string($data['id'])."'";
                        if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
                        try {
index 696779ba5fee6838a712e97041cb35e62a0061c1..db754df27ed1e182ce56fea8437ead3a0f8554fa 100644 (file)
@@ -241,13 +241,13 @@ class Mancubus {
                        if(!$_isFulltext) { // fulltext do not order. Which results in ordering be relevance of the match
                                $queryOrder = " ORDER BY";
                                if (!empty($this->_queryOptions['sort'])) {
-                                       $queryOrder .= ' t.' . $this->_queryOptions['sort'];
+                                       $queryOrder .= ' t.'.$this->_queryOptions['sort'];
                                }
                                else {
                                        $queryOrder .= " t.created";
                                }
                                if (!empty($this->_queryOptions['sortDirection'])) {
-                                       $queryOrder .= ' ' . $this->_queryOptions['sortDirection'];
+                                       $queryOrder .= ' '.$this->_queryOptions['sortDirection'];
                                }
                                else {
                                        $queryOrder .= " DESC";
index 5a285d05d3d4c39b3767694cc45c01f48c61957f..70b8489d83d747a1ca1d0bf90a634a90e26b8144 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Bibliotheca
  *
- * Copyright 2018-2020 Johannes Keßler
+ * Copyright 2018-2021 Johannes Keßler
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -659,7 +659,7 @@ class Summoner {
         * @param array $modify
         * @return string
         */
-       static function createFromParameterLinkQuery($array,$modify=array()) {
+       static function createFromParameterLinkQuery(array $array, $modify=array()): string {
                $ret = '';
 
                if(!empty($modify)) {
index b323a36d1f04343bc9437dbee2981a2233dd7d7e..3d1c98863a26cc79073db754ff2f9fc811bd88a7 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Bibliotheca
  *
- * Copyright 2018-2020 Johannes Keßler
+ * Copyright 2018-2021 Johannes Keßler
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -63,6 +63,13 @@ class Trite {
         */
        private $_queryOptions;
 
+       /**
+        * Cache for already loaded collection fields
+        *
+        * @var array
+        */
+       private $_cacheExistingCollectionFields = array();
+
        /**
         * Trite constructor.
         *
@@ -100,17 +107,18 @@ class Trite {
         * Get information to display for current collection
         * based on current user and given rights
         *
-        * @param int $id The collection ID to load
+        * @param string $id The collection ID to load
         * @param string $right The rights mode. read, write or delete
         * @return array
         */
-       public function load($id,$right="read") {
+       public function load(string $id,$right="read"): array {
                $this->_collectionData = array();
 
                if(!empty($id) && Summoner::validate($id, 'digit')) {
 
                        $queryStr = "SELECT `c`.`id`, `c`.`name`, `c`.`description`, `c`.`created`,
                                        `c`.`owner`, `c`.`group`, `c`.`rights`, `c`.`defaultSearchField`,
+                                       `c`.`defaultSortField`,
                                        `u`.`name` AS username, `g`.`name` AS groupname
                                        FROM `".DB_PREFIX."_collection` AS c
                                        LEFT JOIN `".DB_PREFIX."_user` AS u ON `c`.`owner` = `u`.`id`
@@ -189,8 +197,11 @@ class Trite {
         *
         * @return array
         */
-       public function getCollectionFields() {
-               $ret = array();
+       public function getCollectionFields(): array {
+               if(!empty($this->_cacheExistingCollectionFields)) {
+                       return $this->_cacheExistingCollectionFields;
+               }
+               $this->_cacheExistingCollectionFields = array();
 
                $queryStr = "SELECT `cf`.`fk_field_id` AS id, `sf`.`type`, `sf`.`displayname`, `sf`.`identifier`,
                                                `sf`.`searchtype`
@@ -202,13 +213,35 @@ class Trite {
                try {
                        if($query !== false && $query->num_rows > 0) {
                                while(($result = $query->fetch_assoc()) != false) {
-                                       $ret[$result['identifier']] = $result;
+                                       $this->_cacheExistingCollectionFields[$result['identifier']] = $result;
                                }
                        }
                } catch (Exception $e) {
                        error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
                }
 
+               return $this->_cacheExistingCollectionFields;
+       }
+
+       /**
+        * return the simple search fields for loaded collection
+        * Every field witch has a column in the entry table is a simple search field.
+        * Name starts with entry
+        *
+        * @return array
+        */
+       public function getSimpleSearchFields(): array {
+               $ret = array();
+
+               $fields = $this->getCollectionFields();
+               if(!empty($fields)) {
+                       foreach($fields as $k=>$v) {
+                               if(isset($v['searchtype']) && strpos($v['searchtype'],'entry') !== false) {
+                                       $ret[$k] = $v;
+                               }
+                       }
+               }
+
                return $ret;
        }
 
index 23a16bc74569d14ab1962b7a85942b0e178b7a23..1f4d5a6733e137009de92243a7e894d82bb5393b 100644 (file)
@@ -1,3 +1,72 @@
+<?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">
+               <ul class="uk-pagination" >
+                       <?php
+                       if($TemplateData['pagination']['curPage'] > 1) {
+                       echo '<li><a href="index.php?'.Summoner::createFromParameterLinkQuery($TemplateData['pagination']['currentGetParameters'],array('page'=>($TemplateData['pagination']['curPage']-1))).'">
+                       <span uk-pagination-previous></span></a></li>';
+                       }
+
+                       $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>';
+                       }
+                       else {
+                       if($i < $TemplateData['pagination']['currentRangeStart'] && $ellipsisShown == 0) {
+                       echo '<li class="uk-disabled"><span>&hellip;</span></li>';
+                       $ellipsisShown = 1;
+                       }
+                       if($i > $TemplateData['pagination']['currentRangeEnd'] && ($ellipsisShown == 0 || $ellipsisShown == 1)) {
+                       echo '<li class="uk-disabled"><span>&hellip;</span></li>';
+                       $ellipsisShown = 2;
+                       }
+                       }
+                       }
+
+                       if($TemplateData['pagination']['curPage'] < $TemplateData['pagination']['pages']) {
+                       echo '<li><a href="index.php?'.Summoner::createFromParameterLinkQuery($TemplateData['pagination']['currentGetParameters'],array('page'=>($TemplateData['pagination']['curPage']+1))).'">
+                       <span uk-pagination-next></span></a></li>';
+                       }
+                       ?>
+               </ul>
+       </div>
+       <div class="uk-width-1-4">
+               <div class="uk-inline">
+                       <button class="uk-button uk-button-default uk-button-small" type="button">Sort</button>
+                       <div uk-dropdown>
+                               <ul class="uk-nav uk-dropdown-nav">
+                                       <?php if(!empty($TemplateData['defaultSortField'])) { ?>
+                                       <li><a href="index.php?<?php echo Summoner::createFromParameterLinkQuery($TemplateData['pagination']['currentGetParameters'],array('s'=>$TemplateData['defaultSortField'],'sd'=>'DESC')); ?>">Default</a></li>
+                                       <?php } else { ?>
+                                       <li><a href="index.php?<?php echo Summoner::createFromParameterLinkQuery($TemplateData['pagination']['currentGetParameters'],array('s'=>'','sd'=>'DESC')); ?>">Latest</a></li>
+                                       <?php } ?>
+
+                                       <?php
+                                       if(!empty($TemplateData['simpleSearchFields'])) {
+                                               foreach($TemplateData['simpleSearchFields'] as $k=>$v) {
+                                       ?>
+                                       <li><a href="index.php?<?php echo Summoner::createFromParameterLinkQuery($TemplateData['pagination']['currentGetParameters'],array('s'=>$k,'sd'=>'DESC')); ?>"><?php echo $v['displayname']; ?></a></li>
+                                       <?php
+                                               }
+                                       }
+                                       ?>
+
+                                       <li class="uk-nav-divider"></li>
+                                       <li><a href="index.php?<?php echo Summoner::createFromParameterLinkQuery($TemplateData['pagination']['currentGetParameters'],array('sd'=>'DESC')); ?>"><span class="uk-icon uk-margin-small-right" uk-icon="icon: chevron-down"></span></a></li>
+                                       <li><a href="index.php?<?php echo Summoner::createFromParameterLinkQuery($TemplateData['pagination']['currentGetParameters'],array('sd'=>'ASC')); ?>"><span class="uk-icon uk-margin-small-right" uk-icon="icon: chevron-up"></span></a></li>
+                               </ul>
+                       </div>
+               </div>
+       </div>
+</div>
+<?php } ?>
+
 <h3 class="uk-h3"><?php echo Summoner::ifset($TemplateData['loadedCollection'], 'name'); ?></h3>
 
 <?php if(!empty($TemplateData['search'])) { ?>
index 32530691738beca4188bc7e16b482bca4596f60f..2b2082a072174d106796c48cb7b8e6945a7db43b 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Bibliotheca
  *
- * Copyright 2018-2020 Johannes Keßler
+ * Copyright 2018-2021 Johannes Keßler
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,7 +47,34 @@ if(isset($_POST['navSearch'])) {
        $_search = Summoner::validate($_search) ? $_search :  false;
 }
 
-require_once(Summoner::themefile('system/pagination_before.php',UI_THEME));
+## pagination
+$TemplateData['pagination'] = array('pages' => 0);
+
+$_curPage = 1;
+if(isset($_GET['page']) && !empty($_GET['page'])) {
+       $_curPage = trim($_GET['page']);
+       $_curPage = Summoner::validate($_curPage,'digit') ? $_curPage : 1;
+}
+
+$_sort = false;
+if(isset($_GET['s']) && !empty($_GET['s'])) {
+       $_sort = trim($_GET['s']);
+       $_sort = Summoner::validate($_sort,'nospace') ? $_sort : false;
+}
+
+$_sortDirection = false;
+if(isset($_GET['sd']) && !empty($_GET['sd'])) {
+       $_sortDirection = trim($_GET['sd']);
+       $_sortDirection = Summoner::validate($_sortDirection,'nospace') ? $_sortDirection : false;
+}
+
+$_queryOptions = array(
+       'limit' => RESULTS_PER_PAGE,
+       'offset' => (RESULTS_PER_PAGE * ($_curPage-1)),
+       'sort' => $_sort,
+       'sortDirection' => $_sortDirection
+);
+## pagination end
 
 $TemplateData['pageTitle'] = "Collection overview";
 $TemplateData['loadedCollection'] = array();
@@ -63,7 +90,17 @@ if(!empty($_collection)) {
        $TemplateData['loadedCollection'] = $Trite->load($_collection);
        if(!empty($TemplateData['loadedCollection'])) {
                $Mancubus->setCollection($Trite->param('id'));
-               $Mancubus->setQueryOptions($_queryOptions); // this comes from pagination_before!
+
+               $TemplateData['defaultSortField'] = $defaultSortField = $Trite->param('defaultSortField');
+               $TemplateData['simpleSearchFields'] = $Trite->getSimpleSearchFields();
+               if(!empty($TemplateData['defaultSortField'])) {
+                       unset($TemplateData['simpleSearchFields'][$TemplateData['defaultSortField']]);
+                       if(empty($_queryOptions['sort'])) {
+                               $_queryOptions['sort'] = $TemplateData['defaultSortField'];
+                       }
+               }
+               $Mancubus->setQueryOptions($_queryOptions);
+
                $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');
@@ -107,4 +144,32 @@ else {
        $TemplateData['collections'] = $Trite->getCollections();
 }
 
-require_once(Summoner::themefile('system/pagination_after.php',UI_THEME));
+# 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($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);
+       }
+       # 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);
+       }
+       $TemplateData['pagination']['currentRangeStart'] = array_shift($cRange);
+       $TemplateData['pagination']['currentRangeEnd'] = array_pop($cRange);
+}
+else {
+       $TemplateData['pagination']['visibleRange'] = range(1,$TemplateData['pagination']['pages']);
+}
+# pagination end
index 203f0d4a86c36b79a5af64eaea9fea67be0c555f..7ecfb9b503261521007b9f906bee1991b7186c97 100644 (file)
@@ -20,7 +20,6 @@
        <main>
                <div class="uk-container uk-container-expand uk-margin-top">
                        <?php require_once $ViewMessage; ?>
-                       <?php require_once $ViewPagination; ?>
                        <?php require_once $View; ?>
                </div>
        </main>
index 197095e5767c3bfe21ef124ed0dc4eb1341640ef..a0eeee1a3a53efafd0e3a66ced793b48b790b557 100644 (file)
@@ -24,7 +24,7 @@
                                <div class="uk-form-controls">
                                        <select class="uk-select" id="defaultSearchField" name="fdata[defaultSearchField]">
                                                <option value="">Please select</option>
-                                               <?php foreach($TemplateData['existingFields'] as $k=>$v) { ?>
+                                               <?php foreach($TemplateData['simpleSearchFields'] as $k=>$v) { ?>
                                                <option value="<?php echo $v['identifier']; ?>"
                                                <?php if(Summoner::ifsetValue($TemplateData['editData'], 'defaultSearchField', $v['identifier'])) echo 'selected'; ?>
                                                ><?php echo $v['displayname']; ?> (<?php echo $v['type']; ?>)</option>
                                                a DB reindex. This could take some time, depending on the amount of data.</small>
                                </div>
                        </div>
+                       <div class="uk-margin">
+                               <label class="uk-form-label" for="defaultSortField">Default sort field</label>
+                               <div class="uk-form-controls">
+                                       <select class="uk-select" id="defaultSortField" name="fdata[defaultSortField]">
+                                               <option value="">Please select</option>
+                                               <?php foreach($TemplateData['simpleSearchFields'] as $k=>$v) { ?>
+                                               <option value="<?php echo $v['identifier']; ?>"
+                                               <?php if(Summoner::ifsetValue($TemplateData['editData'], 'defaultSortField', $v['identifier'])) echo 'selected'; ?>
+                                               ><?php echo $v['displayname']; ?> (<?php echo $v['type']; ?>)</option>
+                                               <?php } ?>
+                                       </select>
+                               </div>
+                       </div>
                        <div class="uk-margin">
                                <label class="uk-form-label" for="tool">Tools</label>
                                <div class="uk-form-controls">
index 21111637d90bd317bc271665ce6ef8a402b80b91..d9c134457e8b8719eb54e88eb0dd55a34222e349 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Bibliotheca
  *
- * Copyright 2018-2020 Johannes Keßler
+ * Copyright 2018-2021 Johannes Keßler
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ $TemplateData['editData']['rights'] = Summoner::prepareRightsArray('rwxr--r--');
 // tool needs to be preset
 $TemplateData['editData']['tool'] = array();
 $TemplateData['existingFields'] = array();
+$TemplateData['simpleSearchFields'] = array();
 
 $TemplateData['pageTitle'] = 'Manage collection';
 
@@ -51,6 +52,7 @@ if($_editMode === true && !empty($_id)) {
        $TemplateData['editData'] = $ManangeCollections->getEditData($_id);
        $ManangeCollectionFields->setCollection($_id);
        $TemplateData['existingFields'] = $ManangeCollectionFields->getExistingFields();
+       $TemplateData['simpleSearchFields'] = $ManangeCollectionFields->getSimpleSearchFields();
        if(!isset($TemplateData['editData']['name'])) {
                $TemplateData['refresh'] = 'index.php?p=managecolletions';
        }
@@ -66,6 +68,7 @@ if(isset($_POST['submitForm'])) {
                $_saveData['group'] = trim($fdata['group']);
                $_saveData['rights'] = Summoner::prepareRightsString($fdata['rights']);
                $_saveData['defaultSearchField'] = trim($fdata['defaultSearchField']);
+               $_saveData['defaultSortField'] = trim($fdata['defaultSortField']);
                $_saveData['id'] = $_id;
 
                $_saveData['tool'] = array();
diff --git a/webclient/view/default/system/pagination.html b/webclient/view/default/system/pagination.html
deleted file mode 100644 (file)
index 08f49ba..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php if(!empty($TemplateData['pagination']) && $TemplateData['pagination']['pages'] > 1) { ?>
-<ul class="uk-pagination" uk-margin>
-       <?php
-       if($TemplateData['pagination']['curPage'] > 1) {
-       echo '<li><a href="index.php?'.Summoner::createFromParameterLinkQuery($TemplateData['pagination']['currentGetParameters'],array('page'=>($TemplateData['pagination']['curPage']-1))).'">
-               <span uk-pagination-previous></span></a></li>';
-       }
-
-       $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>';
-               }
-               else {
-                       if($i < $TemplateData['pagination']['currentRangeStart'] && $ellipsisShown == 0) {
-                               echo '<li class="uk-disabled"><span>&hellip;</span></li>';
-                               $ellipsisShown = 1;
-                       }
-                       if($i > $TemplateData['pagination']['currentRangeEnd'] && ($ellipsisShown == 0 || $ellipsisShown == 1)) {
-                               echo '<li class="uk-disabled"><span>&hellip;</span></li>';
-                               $ellipsisShown = 2;
-                       }
-               }
-       }
-
-       if($TemplateData['pagination']['curPage'] < $TemplateData['pagination']['pages']) {
-       echo '<li><a href="index.php?'.Summoner::createFromParameterLinkQuery($TemplateData['pagination']['currentGetParameters'],array('page'=>($TemplateData['pagination']['curPage']+1))).'">
-               <span uk-pagination-next></span></a></li>';
-       }
-       ?>
-</ul>
-<?php } ?>
diff --git a/webclient/view/default/system/pagination_after.php b/webclient/view/default/system/pagination_after.php
deleted file mode 100644 (file)
index fd5b0bf..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/**
- * Bibliotheca
- *
- * Copyright 2018-2020 Johannes Keßler
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * split pagination building in two parts to make it includeable
- * - pagination_before
- *   this one sets the defaults and checks for requestparams
- * - pagination_after
- *   this one gets the results from the queries and builds the required infos for the pagination view
- */
-
-// this is comes from pagination_before
-// $TemplateData['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;
-}
-
-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);
-       }
-       # 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);
-       }
-       $TemplateData['pagination']['currentRangeStart'] = array_shift($cRange);
-       $TemplateData['pagination']['currentRangeEnd'] = array_pop($cRange);
-}
-else {
-       $TemplateData['pagination']['visibleRange'] = range(1,$TemplateData['pagination']['pages']);
-}
diff --git a/webclient/view/default/system/pagination_before.php b/webclient/view/default/system/pagination_before.php
deleted file mode 100644 (file)
index 27cdc3c..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-/**
- * Bibliotheca
- *
- * Copyright 2018-2020 Johannes Keßler
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * split pagination building in two parts to make it includeable
- * - pagination_before
- *   this one sets the defaults and checks for requestparams
- * - pagination_after
- *   this one gets the results from the queries and builds the required infos for the pagination view
- */
-
-$TemplateData['pagination'] = array('pages' => 0);
-
-$_curPage = 1;
-if(isset($_GET['page']) && !empty($_GET['page'])) {
-       $_curPage = trim($_GET['page']);
-       $_curPage = Summoner::validate($_curPage,'digit') ? $_curPage : 1;
-}
-$_sort = false;
-if(isset($_GET['s']) && !empty($_GET['s'])) {
-       $_sort = trim($_GET['s']);
-       $_sort = Summoner::validate($_sort,'nospace') ? $_sort : false;
-}
-
-$_sortDirection = false;
-if(isset($_GET['sd']) && !empty($_GET['sd'])) {
-       $_sortDirection = trim($_GET['sd']);
-       $_sortDirection = Summoner::validate($_sortDirection,'nospace') ? $_sortDirection : false;
-}
-
-$_queryOptions = array(
-       'limit' => RESULTS_PER_PAGE,
-       'offset' => (RESULTS_PER_PAGE * ($_curPage-1)),
-       'orderby' => $_sort,
-       'sortDirection' => $_sortDirection
-);