* 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
-* 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
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
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
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;
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`;
$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);
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) {
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
*
* @param array $data
* @return bool
*/
- public function createCollection($data) {
+ public function createCollection(array $data): bool {
$ret = false;
if(!empty($data['name']) === true
`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;
* @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`
* @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));
`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 {
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";
/**
* 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.
* @param array $modify
* @return string
*/
- static function createFromParameterLinkQuery($array,$modify=array()) {
+ static function createFromParameterLinkQuery(array $array, $modify=array()): string {
$ret = '';
if(!empty($modify)) {
/**
* 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.
*/
private $_queryOptions;
+ /**
+ * Cache for already loaded collection fields
+ *
+ * @var array
+ */
+ private $_cacheExistingCollectionFields = array();
+
/**
* Trite constructor.
*
* 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`
*
* @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`
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;
}
+<?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>…</span></li>';
+ $ellipsisShown = 1;
+ }
+ if($i > $TemplateData['pagination']['currentRangeEnd'] && ($ellipsisShown == 0 || $ellipsisShown == 1)) {
+ echo '<li class="uk-disabled"><span>…</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'])) { ?>
/**
* 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.
$_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();
$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');
$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
<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>
<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">
/**
* 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.
// tool needs to be preset
$TemplateData['editData']['tool'] = array();
$TemplateData['existingFields'] = array();
+$TemplateData['simpleSearchFields'] = array();
$TemplateData['pageTitle'] = 'Manage collection';
$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';
}
$_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();
+++ /dev/null
-<?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>…</span></li>';
- $ellipsisShown = 1;
- }
- if($i > $TemplateData['pagination']['currentRangeEnd'] && ($ellipsisShown == 0 || $ellipsisShown == 1)) {
- echo '<li class="uk-disabled"><span>…</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 } ?>
+++ /dev/null
-<?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']);
-}
+++ /dev/null
-<?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
-);