);
/**
- * Store existing fileds info for runtime
+ * Store existing fields info for runtime
*
* @var array
*/
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
*
--- /dev/null
+<?php if(!empty($TemplateData['loadedCollection'])) { ?>
+<div class="uk-grid-small uk-grid-row-small uk-grid-row-small" uk-grid>
+ <div class="uk-width-1-2">
+
+ <form class="uk-form-horizontal uk-margin-small" method="post">
+ <div class="uk-margin">
+ <label class="uk-form-label" for="search">Search for</label>
+ <div class="uk-form-controls">
+ <input class="uk-input" id="search" type="text" autocomplete="off" name="fdata[search]"
+ placeholder="See search syntax for options">
+ </div>
+ </div>
+
+ <div class="uk-margin">
+ <button class="uk-button uk-button-primary" type="submit" name="submitForm">
+ Search
+ </button>
+ </div>
+ </form>
+ </div>
+ <div class="uk-width-1-2">
+ <h4>Syntax</h4>
+ <p>To search within the collection default search field, like the ordinary search, just type the search term and go.</p>
+ <p>To search within the possible fields of a collection type the field identifier followed by : and then a space.</p>
+ eg.: <code>title: starwars</code>
+ <p>Available fields in <b><?php echo Summoner::ifset($TemplateData['loadedCollection'], 'name'); ?></b> are:</p>
+ <pre style="white-space: normal">
+ <?php
+ foreach($TemplateData['collectionFields'] as $k=>$v) {
+ echo $v['identifier']." ";
+ }
+ ?>
+ </pre>
+ <p>Possible search operators:</p>
+ <p>
+ * = 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.
+ </p>
+ <p>+ = A leading plus sign indicates that this word must be present in each row that is returned.</p>
+ <p>- = A leading minus sign indicates that this word must not be present in any of the rows that are returned.</p>
+ <p>" = A phrase that is enclosed within double quote (") characters matches only rows that contain the phrase literally, as it was typed.</p>
+ </div>
+</div>
+<?php } else { ?>
+<h3 class="uk-h3">Collection overview</h3>
+<div class="uk-grid-small uk-grid-row-small uk-grid-row-small" uk-grid>
+ <div class="uk-width-2-3@m uk-width-1-2@xl">
+ <dl class="uk-description-list uk-description-list-divider">
+ <?php foreach($TemplateData['collections'] as $k=>$v) { ?>
+ <dt><a href="index.php?p=advancedsearch&collection=<?php echo $k; ?>"><?php echo $v['name']; ?></a></dt>
+ <dd><?php echo $v['description']; ?></dd>
+ <?php } ?>
+ </dl>
+ </div>
+</div>
+<?php } ?>
--- /dev/null
+<?php
+/**
+ * Bibliotheca webclient
+ *
+ * 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.
+ * 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.
+ */
+
+require_once 'lib/trite.class.php';
+$Trite = new Trite($DB,$Doomguy);
+
+$_collection = false;
+if(isset($_GET['collection']) && !empty($_GET['collection'])) {
+ $_collection = trim($_GET['collection']);
+ $_collection = Summoner::validate($_collection,'digit') ? $_collection : false;
+}
+
+$TemplateData['loadedCollection'] = array();
+$TemplateData['collections'] = array();
+$TemplateData['collectionFields'] = array();
+
+if(!empty($_collection)) {
+ $TemplateData['loadedCollection'] = $Trite->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();
+}
<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']; ?>">
<input class="uk-search-input" type="search" placeholder="Search..." name="navSearch" autofocus>
+ <small><a href="index.php?p=advancedsearch">Advanced</a></small>
</form>
</div>
</div>