From 2d665f3f24e8e2802b904df3b06a52ac3727ff43 Mon Sep 17 00:00:00 2001 From: Banana Date: Thu, 31 Dec 2020 12:53:03 +0100 Subject: [PATCH] init of advanced search --- .../lib/managecollectionfields.class.php | 2 +- webclient/lib/trite.class.php | 27 +++++++++ .../advancedsearch/advancedsearch.html | 56 +++++++++++++++++++ .../default/advancedsearch/advancedsearch.php | 44 +++++++++++++++ webclient/view/default/system/menu.php | 1 + 5 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 webclient/view/default/advancedsearch/advancedsearch.html create mode 100644 webclient/view/default/advancedsearch/advancedsearch.php diff --git a/webclient/lib/managecollectionfields.class.php b/webclient/lib/managecollectionfields.class.php index df2824b..c73aba1 100644 --- a/webclient/lib/managecollectionfields.class.php +++ b/webclient/lib/managecollectionfields.class.php @@ -52,7 +52,7 @@ class ManageCollectionFields { ); /** - * Store existing fileds info for runtime + * Store existing fields info for runtime * * @var array */ diff --git a/webclient/lib/trite.class.php b/webclient/lib/trite.class.php index 3b6bcbc..65cc390 100644 --- a/webclient/lib/trite.class.php +++ b/webclient/lib/trite.class.php @@ -176,6 +176,33 @@ class Trite { return $ret; } + /** + * Fields for the loaded collection. + * + * @return array + */ + public function getCollectionFields() { + $ret = array(); + + $queryStr = "SELECT `cf`.`fk_field_id` AS id, `sf`.`type`, `sf`.`displayname`, `sf`.`identifier` + FROM `".DB_PREFIX."_collection_fields_".$this->_id."` AS cf + LEFT JOIN `".DB_PREFIX."_sys_fields` AS sf ON `cf`.`fk_field_id` = `sf`.`id` + ORDER BY `cf`.`sort`"; + $query = $this->_DB->query($queryStr); + try { + if($query !== false && $query->num_rows > 0) { + while(($result = $query->fetch_assoc()) != false) { + $ret[$result['id']] = $result; + } + } + } catch (Exception $e) { + if(DEBUG) error_log("[DEBUG] ".__METHOD__." mysql query: ".$queryStr); + error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage()); + } + + return $ret; + } + /** * set some defaults by init of the class * diff --git a/webclient/view/default/advancedsearch/advancedsearch.html b/webclient/view/default/advancedsearch/advancedsearch.html new file mode 100644 index 0000000..4bf643e --- /dev/null +++ b/webclient/view/default/advancedsearch/advancedsearch.html @@ -0,0 +1,56 @@ + +
+
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+

Syntax

+

To search within the collection default search field, like the ordinary search, just type the search term and go.

+

To search within the possible fields of a collection type the field identifier followed by : and then a space.

+ eg.: title: starwars +

Available fields in are:

+
+		$v) {
+			echo $v['identifier']." ";
+		}
+		?>
+		
+

Possible search operators:

+

+ * = The asterisk serves as the truncation (or wildcard) operator. Unlike the other operators, + it is appended to the word to be affected. Words match if they begin with the word preceding the * operator. +

+

+ = A leading plus sign indicates that this word must be present in each row that is returned.

+

- = A leading minus sign indicates that this word must not be present in any of the rows that are returned.

+

" = A phrase that is enclosed within double quote (") characters matches only rows that contain the phrase literally, as it was typed.

+
+
+ +

Collection overview

+
+
+
+ $v) { ?> +
+
+ +
+
+
+ diff --git a/webclient/view/default/advancedsearch/advancedsearch.php b/webclient/view/default/advancedsearch/advancedsearch.php new file mode 100644 index 0000000..b3fbb4d --- /dev/null +++ b/webclient/view/default/advancedsearch/advancedsearch.php @@ -0,0 +1,44 @@ +load($_collection); + if(!empty($TemplateData['loadedCollection'])) { + $TemplateData['collectionFields'] = $Trite->getCollectionFields(); + } + else { + $TemplateData['message']['content'] = "Can not load given collection."; + $TemplateData['message']['status'] = "error"; + } +} +else { + $TemplateData['collections'] = $Trite->getCollections(); +} diff --git a/webclient/view/default/system/menu.php b/webclient/view/default/system/menu.php index b9f42cd..55f82d6 100644 --- a/webclient/view/default/system/menu.php +++ b/webclient/view/default/system/menu.php @@ -67,6 +67,7 @@ $_menuManage = $Gorenest->get('manage');
-- 2.39.5