From: Banana Date: Sun, 4 Apr 2021 10:12:12 +0000 (+0200) Subject: adnvanced search has table view now X-Git-Tag: 1.1~12 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=2643b64172199609531ddbbffc2e1cbbcdbe5909;p=bibliotheca-php.git adnvanced search has table view now --- diff --git a/CHANGELOG b/CHANGELOG index e65a485..b062176 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -27,6 +27,8 @@ Upload fields are not supported yet. * Fixed bug #5 * Added feature #1. Collections overview has pagination at the bottom too. + * Advanced search has a table view option + Displayed fields are configured in collection management. See notes there. 1.0 - Castle 20210106 * First usable version diff --git a/TODO b/TODO index 3720f2c..45d2167 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,4 @@ +* Update install sql file * stats overview page. amount of entries. file / cache and db storage. Version info and where to find it. * User and groupmanagement: Check where a user or group is used! * Better error handling and display while adding / update and delete diff --git a/documentation/setup/bibliotheca.sql b/documentation/setup/bibliotheca.sql index 19f88b3..8d1e7b9 100644 --- a/documentation/setup/bibliotheca.sql +++ b/documentation/setup/bibliotheca.sql @@ -34,12 +34,14 @@ CREATE TABLE `#REPLACEME#_collection` ( `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `defaultSearchField` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `defaultSortField` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL, + `advancedSearchTableFields` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `modificationuser` int DEFAULT NULL, `owner` int NOT NULL, `group` int NOT NULL, - `rights` char(9) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL + `rights` char(9) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -------------------------------------------------------- @@ -87,7 +89,8 @@ CREATE TABLE `#REPLACEME#_menu` ( `group` int NOT NULL DEFAULT '0', `rights` char(9) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `position` int NOT NULL DEFAULT '0', - `category` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL + `category` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- @@ -106,9 +109,11 @@ INSERT INTO `#REPLACEME#_menu` (`id`, `text`, `action`, `icon`, `owner`, `group` (10, 'Collection fields', 'managecollectionfields', '', 1, 2, 'rw-rw----', 0, ''), (11, 'Entry', 'entry', '', 1, 1, 'rw-r--r--', 0, ''), (12, 'Search', 'search', '', 1, 1, 'rw-r--r--', 0, ''), -(14, 'Tool', 'tool', '', 1, 1, 'rw-------', 0, ''), -(15, 'Profile', 'profile', 'user', 1, 2, 'rw-rw----', 5, 'manage'), -(16, 'Groups', 'managegroups', 'users', 1, 1, 'rw-------', 6, 'manage'); +(14, 'Tool', 'tool', '', 1, 2, 'rw-rw----', 0, ''), +(15, 'Advanced search', 'advancedsearch', '', 1, 1, 'rw-r--r--', 0, ''), +(16, 'Profile', 'profile', 'user', 1, 2, 'rw-rw----', 6, 'manage'), +(17, 'Groups', 'managegroups', 'users', 1, 1, 'rw-------', 5, 'manage'), +(18, 'Bulkedit', 'bulkedit', '', 1, 2, 'rw-rw----', 0, ''); -- -------------------------------------------------------- @@ -348,7 +353,7 @@ ALTER TABLE `#REPLACEME#_group` -- AUTO_INCREMENT for table `#REPLACEME#_menu` -- ALTER TABLE `#REPLACEME#_menu` - MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17; + MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19; -- -- AUTO_INCREMENT for table `#REPLACEME#_sys_fields` diff --git a/documentation/upgrade.txt b/documentation/upgrade.txt index ecf4489..645bdfb 100644 --- a/documentation/upgrade.txt +++ b/documentation/upgrade.txt @@ -2,3 +2,5 @@ Each release has its own file in the upgrade folder. In this file there are the steps needed to make an upgrade. If you upgrade multiple versions make sure to read all the files in the correct order. + +Within the upgrade note files there is an order. Make sure to follow. diff --git a/upgrade/from-version-1.0.txt b/upgrade/from-version-1.0.txt index 70a927d..d71d0d3 100644 --- a/upgrade/from-version-1.0.txt +++ b/upgrade/from-version-1.0.txt @@ -1,20 +1,20 @@ -# Migration of the config files into one config file +#1 Migration of the config files into one config file Please copy the new config/config.php.default to config/config.php and adapt the settings which you have on the old config files. After that you can delete config/database|path|system files. -# Deletion of config definition +#2 Deletion of config definition The definition of USER_DEFAULT_RIGHTS_STRING can be removed from config file. -# New config file +#3 New 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 +#4 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. +#5 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; UPDATE `#REPLACEME#_menu` SET `group` = '2' WHERE `#REPLACEME#_menu`.`id` = 10; @@ -32,3 +32,8 @@ UPDATE `#REPLACEME#_sys_fields` SET `inputValidation` = 'allowSpace' WHERE `bib_ UPDATE `#REPLACEME#_sys_fields` SET `inputValidation` = 'allowSpace' WHERE `bib_sys_fields`.`id` = 8; UPDATE `#REPLACEME#_sys_fields` SET `inputValidation` = 'allowSpace' WHERE `bib_sys_fields`.`id` = 20; UPDATE `#REPLACEME#_sys_fields` SET `inputValidation` = 'allowSpace' WHERE `bib_sys_fields`.`id` = 26; +ALTER TABLE `#REPLACEME#_collection` ADD `advancedSearchTableFields` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL AFTER `defaultSortField`; +ALTER TABLE `#REPLACEME#_sys_fields` ADD UNIQUE (`identifier`); + +# 6 +Update your collection settings. There are new options which should be set. diff --git a/webclient/lib/managecollections.class.php b/webclient/lib/managecollections.class.php index 69e0267..5e0898d 100644 --- a/webclient/lib/managecollections.class.php +++ b/webclient/lib/managecollections.class.php @@ -214,7 +214,8 @@ class ManageCollections { `group` = '".$this->_DB->real_escape_string($data['group'])."', `rights` = '".$this->_DB->real_escape_string($data['rights'])."', `defaultSearchField` = '".$this->_DB->real_escape_string($data['defaultSearchField'])."', - `defaultSortField` = '".$this->_DB->real_escape_string($data['defaultSortField'])."'"; + `defaultSortField` = '".$this->_DB->real_escape_string($data['defaultSortField'])."', + `advancedSearchTableFields` = '".$this->_DB->real_escape_string($data['advancedSearchTableFields'])."'"; if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true)); $this->_DB->query($queryStr); $newId = $this->_DB->insert_id; @@ -281,7 +282,7 @@ class ManageCollections { 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`, + `c`.`defaultSortField`, `c`.`advancedSearchTableFields`, `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` @@ -295,6 +296,7 @@ class ManageCollections { $ret = $query->fetch_assoc(); $ret['rights'] = Summoner::prepareRightsArray($ret['rights']); $ret['tool'] = $this->getAvailableTools($id); + $ret['advancedSearchTableFields'] = $this->_loadAdvancedSearchTableFields($ret['advancedSearchTableFields']); } } catch (Exception $e) { @@ -328,7 +330,8 @@ class ManageCollections { `group` = '".$this->_DB->real_escape_string($data['group'])."', `rights` = '".$this->_DB->real_escape_string($data['rights'])."', `defaultSearchField` = '".$this->_DB->real_escape_string($data['defaultSearchField'])."', - `defaultSortField` = '".$this->_DB->real_escape_string($data['defaultSortField'])."' + `defaultSortField` = '".$this->_DB->real_escape_string($data['defaultSortField'])."', + `advancedSearchTableFields` = '".$this->_DB->real_escape_string($data['advancedSearchTableFields'])."' WHERE `id` = '".$this->_DB->real_escape_string($data['id'])."'"; if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true)); try { @@ -558,6 +561,14 @@ class ManageCollections { return $ret; } + /** + * Update the rights from the group to the entries in this collection + * + * @param string $collectionId + * @param string|bool $owner + * @param string|bool $group + * @param string|bool $rights + */ private function _updateEntryRights($collectionId, $owner=false, $group=false, $rights=false) { if(!empty($collectionId)) { $queryStr = "UPDATE `".DB_PREFIX."_collection_entry_".$collectionId."` SET"; @@ -582,4 +593,21 @@ class ManageCollections { } } } + + /** + * Make a key=>value array of a comma seperated string and use the value as key + * + * @param array $data + * @return array + */ + private function _loadAdvancedSearchTableFields($data) { + $ret = array(); + + $_t = explode(',',$data); + foreach($_t as $e) { + $ret[$e] = $e; + } + + return $ret; + } } diff --git a/webclient/lib/mancubus.class.php b/webclient/lib/mancubus.class.php index a9d65e6..61df841 100644 --- a/webclient/lib/mancubus.class.php +++ b/webclient/lib/mancubus.class.php @@ -206,7 +206,7 @@ class Mancubus { if(!empty($searchData)) { // this search supports fulltext search and number <> search. // also can search in the entry2lookup table. - // not perfect but works really well + // not perfect but it works foreach($searchData as $k=>$sd) { if(!isset($sd['colName']) || !isset($sd['colValue']) || empty($sd['colValue'])) continue; diff --git a/webclient/lib/summoner.class.php b/webclient/lib/summoner.class.php index 70b8489..86133f4 100644 --- a/webclient/lib/summoner.class.php +++ b/webclient/lib/summoner.class.php @@ -610,12 +610,26 @@ class Summoner { * * http://php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op * - * @param $array - * @param $key + * @param array $array + * @param array|string $key * @return bool|mixed */ static function ifset($array,$key) { - return isset($array[$key]) ? $array[$key] : false; + if(is_array($key)) { + $_t = $array; + $_c = 0; + foreach ($key as $k) { + if(isset($_t[$k])) { + $_t = $_t[$k]; + $_c++; + } + } + + return sizeof($key)==$_c ? $_t : false; + + } else { + return isset($array[$key]) ? $array[$key] : false; + } } /** @@ -679,4 +693,22 @@ class Summoner { return $ret; } + + /** + * Return given string with given $endChar with the max $length + * + * @param string $string + * @param int $length + * @param string $endChar + * @return string + */ + static function limitWithDots($string, $length, $endChar) { + $ret = $string; + + if(strlen($string.$endChar) > $length) { + $ret = substr($string,0, $length).$endChar; + } + + return $ret; + } } diff --git a/webclient/lib/trite.class.php b/webclient/lib/trite.class.php index 718a756..17eb17d 100644 --- a/webclient/lib/trite.class.php +++ b/webclient/lib/trite.class.php @@ -118,7 +118,7 @@ class Trite { $queryStr = "SELECT `c`.`id`, `c`.`name`, `c`.`description`, `c`.`created`, `c`.`owner`, `c`.`group`, `c`.`rights`, `c`.`defaultSearchField`, - `c`.`defaultSortField`, + `c`.`defaultSortField`,`c`.`advancedSearchTableFields`, `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` @@ -130,6 +130,7 @@ class Trite { $query = $this->_DB->query($queryStr); if ($query !== false && $query->num_rows > 0) { $this->_collectionData = $query->fetch_assoc(); + $this->_collectionData['advancedSearchTableFields'] = $this->_loadAdvancedSearchTableFields($this->_collectionData['advancedSearchTableFields']); $this->_id = $this->_collectionData['id']; } } catch (Exception $e) { @@ -340,4 +341,21 @@ class Trite { $options['sortDirection'] = false; $this->setQueryOptions($options); } + + /** + * Make a key=>value array of a comma seperated string and use the value as key + * + * @param array $data + * @return array + */ + private function _loadAdvancedSearchTableFields($data) { + $ret = array(); + + $_t = explode(',',$data); + foreach($_t as $e) { + $ret[$e] = $e; + } + + return $ret; + } } diff --git a/webclient/view/default/advancedsearch/advancedsearch.html b/webclient/view/default/advancedsearch/advancedsearch.html index 13ec271..a352fa0 100644 --- a/webclient/view/default/advancedsearch/advancedsearch.html +++ b/webclient/view/default/advancedsearch/advancedsearch.html @@ -5,28 +5,29 @@

Display result for: (Max. result of 60)

- - - -
- - - +
+ + + + + + + + + - - +
-
@@ -35,6 +36,14 @@ placeholder="See search syntax for options">
+
+
Table view
+
+ +
+
+
+ +
+ + Make sure that the default global search field is in this list.
+ This does not limit the fields to search in.
+
+
diff --git a/webclient/view/default/managecolletions/managecolletions.php b/webclient/view/default/managecolletions/managecolletions.php index d9c1344..1dd057e 100644 --- a/webclient/view/default/managecolletions/managecolletions.php +++ b/webclient/view/default/managecolletions/managecolletions.php @@ -67,8 +67,8 @@ if(isset($_POST['submitForm'])) { $_saveData['owner'] = trim($fdata['owner']); $_saveData['group'] = trim($fdata['group']); $_saveData['rights'] = Summoner::prepareRightsString($fdata['rights']); - $_saveData['defaultSearchField'] = trim($fdata['defaultSearchField']); - $_saveData['defaultSortField'] = trim($fdata['defaultSortField']); + $_saveData['defaultSearchField'] = $fdata['defaultSearchField']; + $_saveData['defaultSortField'] = $fdata['defaultSortField']; $_saveData['id'] = $_id; $_saveData['tool'] = array(); @@ -81,6 +81,11 @@ if(isset($_POST['submitForm'])) { $_saveData['doRightsForEntries'] = true; } + $_saveData['advancedSearchTableFields'] = ''; + if(isset($fdata['advancedSearchTableFields'])) { + $_saveData['advancedSearchTableFields'] = implode(',',$fdata['advancedSearchTableFields']); + } + if(!empty($TemplateData['editData']['name'])) { // EDIT if(isset($fdata['doDelete'])) { $do = $ManangeCollections->deleteCollection($_id);