]> 91.132.146.200 Git - bibliotheca-php.git/commitdiff
advanced search
authorBanana <mail@bananas-playground.net>
Fri, 1 Jan 2021 00:04:15 +0000 (01:04 +0100)
committerBanana <mail@bananas-playground.net>
Fri, 1 Jan 2021 00:04:15 +0000 (01:04 +0100)
12 files changed:
TODO
documentation/fields.txt [new file with mode: 0644]
documentation/setup/bibliotheca.sql
webclient/config/path.php.default
webclient/lib/manageentry.class.php
webclient/lib/mancubus.class.php
webclient/lib/trite.class.php
webclient/view/default/advancedsearch/advancedsearch.html
webclient/view/default/advancedsearch/advancedsearch.php
webclient/view/default/collections/collections.php
webclient/view/default/entry/field-number.html [new file with mode: 0644]
webclient/view/default/manageentry/field-number.html [new file with mode: 0644]

diff --git a/TODO b/TODO
index 158d4ec8b6b31df15b0bd07cd57c85f366a9a4bd..3b080a407e2f4b3a58f592f712f5428e2f137e92 100644 (file)
--- a/TODO
+++ b/TODO
@@ -9,4 +9,4 @@
 * delete of a collection
 * sort by filter for collection display
 * responsive and breakpoints
-* Advanced search. More options and searchable fields
+* DB query log and optimization
diff --git a/documentation/fields.txt b/documentation/fields.txt
new file mode 100644 (file)
index 0000000..3302111
--- /dev/null
@@ -0,0 +1,47 @@
+TBD
+
+Bibliotheca provides a set of fields which can be used to define which data an entry in your collection
+can be saved.
+Those field definitions are stored in the DB itself and can currently only managed there. But only of
+you know how.
+
+Each collection can have there own set of fields. But at least the title field should be available.
+Fields can be managed after a collection has been created.
+
+
+# If you want to create new ones here is a 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
+
+# Fields on sys_fields table
+Have a look into the table. Special ones are described here.
+
+identifier
+Unique string within the how sys_fields table.
+
+displayname
+Text which will be displayed for this field.
+
+type
+Specifies the type which then lets the code "know" what to do with this field.
+Needs a html definition in view/UI_THEME/entry and view/UI_THEME/manageentry.
+A _loadFieldValue_TYPE method in manageentry.class and mancubus.class if it needs special data process reading
+A _saveField_TYPE method in manageentry.class for data saving.
+Modification on advancedsearch.php if search needs some special treatment for this field
+
+searchtype
+- tag = releation to lookup2entry table
+- entryText = text col in entry table
+- entrySingleText = entry col in entry table. Single value
+- entrySingleNum = entry col in entry table. Number. Single value. Can be searched by with ><
+
+createstring
+The SQL create string which is run as you add it to your collection. Not everyone needs one!
+
+value
+The value which is displayed as a selection for the user. Needed for a selection type field
+
+apiinfo
+Text description what type of data the api expects if you want to fill this field.
index 23b61aaa9d8be012607b19993067ca27d3f55625..2194ab3a638dd7b2afd0f430fd12912a4eee6c97 100644 (file)
@@ -134,18 +134,17 @@ CREATE TABLE `#REPLACEME#_sys_fields` (
 --
 
 INSERT INTO `#REPLACEME#_sys_fields` (`id`, `identifier`, `displayname`, `type`, `searchtype`, `createstring`, `value`, `apiinfo`, `created`, `modificationuser`, `owner`, `group`, `rights`) VALUES
-(1, 'title', 'Title', 'text', 'text', '`title` varchar(128) NOT NULL', NULL, 'string 128', '2019-09-01 18:26:33', 0, 1, 1, 'rw-r--r--'),
-(2, 'description', 'Description', 'text3', 'text', '`description` varchar(255) NULL DEFAULT NULL', NULL, 'string 64', '2019-09-01 18:28:35', 0, 1, 1, 'rw-r--r--'),
-(3, 'content', 'Main content', 'textarea', 'text', 'content` text NULL DEFAULT NULL,', NULL, 'mysql text', '2019-09-01 18:28:35', 0, 1, 1, 'rw-r--r--'),
-(4, 'releasedate', 'Release date', 'date', 'text', '`releasedate` timestamp NULL DEFAULT NULL', NULL, 'mysql timestamp', '2019-09-01 19:01:39', 0, 1, 1, 'rw-r--r--'),
+(1, 'title', 'Title', 'text', 'entryText', '`title` varchar(128) NOT NULL, ADD FULLTEXT (`title`)', NULL, 'string 128', '2019-09-01 18:26:33', 0, 1, 1, 'rw-r--r--'),
+(2, 'description', 'Description', 'text3', 'entryText', '`description` varchar(255) NULL DEFAULT NULL, ADD FULLTEXT (`description`)', NULL, 'string 255', '2019-09-01 18:28:35', 0, 1, 1, 'rw-r--r--'),
+(3, 'content', 'Main content', 'textarea', 'entryText', '`content` text NULL DEFAULT NULL, ADD FULLTEXT (`content`)', NULL, 'mysql text', '2019-09-01 18:28:35', 0, 1, 1, 'rw-r--r--'),
 (5, 'tag', 'Tag', 'lookupmultiple', 'tag', NULL, NULL, 'string 64', '2019-09-01 19:11:18', 0, 1, 1, 'rw-r--r--'),
 (6, 'category', 'Category', 'lookupmultiple', 'tag', NULL, NULL, 'string 64', '2019-09-01 19:11:18', 0, 1, 1, 'rw-r--r--'),
 (7, 'publisher', 'Publisher', 'lookupmultiple', 'tag', NULL, NULL, 'string 64', '2019-09-01 19:17:51', 0, 1, 1, 'rw-r--r--'),
 (8, 'developer', 'Developer', 'lookupmultiple', 'tag', NULL, NULL, 'string 64', '2019-09-01 19:17:51', 0, 1, 1, 'rw-r--r--'),
 (9, 'platform', 'Platform', 'selection', 'tag', '`platform` varchar(32) NULL DEFAULT NULL', 'PC,Xbox,Playstation,Nintendo,Nintendo Switch', 'One of PC,Xbox,Playstation,Nintendo,Nintendo Switch', '2019-09-01 19:18:33', 0, 1, 1, 'rw-r--r--'),
 (10, 'storage', 'Storage', 'lookupmultiple', 'tag', NULL, NULL, 'string 64', '2019-09-01 19:18:33', 0, 1, 1, 'rw-r--r--'),
-(13, 'rating', 'Rating', 'selection', 'tag', '`rating` varchar(16) NULL DEFAULT NULL', '0/10,2/10,3/10,4/10,5/10,6/10,7/10,8/10,9/10,10/10', 'One of 0/10,2/10,3/10,4/10,5/10,6/10,7/10,8/10,9/10,10/10', '2019-09-01 19:25:35', 0, 1, 1, 'rw-r--r--'),
-(14, 'year', 'Year', 'year', 'tag', '`year` year NULL DEFAULT NULL', NULL, 'mysql year', '2019-09-01 19:30:11', 0, 1, 1, 'rw-r--r--'),
+(13, 'rating', 'Rating', 'selection', 'entrySingleText', '`rating` varchar(16) NULL DEFAULT NULL', '0/10,2/10,3/10,4/10,5/10,6/10,7/10,8/10,9/10,10/10', 'One of 0/10,2/10,3/10,4/10,5/10,6/10,7/10,8/10,9/10,10/10', '2019-09-01 19:25:35', 0, 1, 1, 'rw-r--r--'),
+(14, 'year', 'Year', 'year', 'entrySingleText', '`year` year NULL DEFAULT NULL', NULL, 'mysql year', '2019-09-01 19:30:11', 0, 1, 1, 'rw-r--r--'),
 (15, 'coverimage', 'Cover image', 'upload', NULL, NULL, NULL, 'One file in $_FILES[uploads] of post', '2019-09-01 19:48:44', 0, 1, 1, 'rw-r--r--'),
 (16, 'attachment', 'Attachments', 'upload_multiple', NULL, NULL, NULL, 'Multiple in $_FILES[uploads] of post', '2019-09-01 19:48:44', 0, 1, 1, 'rw-r--r--'),
 (17, 'os', 'Operating system and version', 'selection', 'tag', '`os` varchar(32) NULL DEFAULT NULL', 'Windows 10,Windows 95, Windows 99,Windows XP, Windows ME, Windows 2000,Windows Vista,Windows 8', 'One of Windows 10,Windows 95, Windows 99,Windows XP, Windows ME, Windows 2000,Windows Vista,Windows 8', '2019-09-01 19:55:13', 0, 1, 1, 'rw-r--r--'),
@@ -154,9 +153,9 @@ INSERT INTO `#REPLACEME#_sys_fields` (`id`, `identifier`, `displayname`, `type`,
 (20, 'directors', 'Directors', 'lookupmultiple', 'tag', NULL, NULL, 'string 64', '2020-07-26 07:17:59', NULL, 1, 1, 'rw-r--r--'),
 (21, 'genres', 'Genres', 'lookupmultiple', 'tag', NULL, NULL, 'string 64', '2020-07-26 07:18:55', NULL, 1, 1, 'rw-r--r--'),
 (22, 'languages', 'Languages', 'lookupmultiple', 'tag', NULL, NULL, 'string 64', '2020-07-26 07:20:45', NULL, 1, 1, 'rw-r--r--'),
-(23, 'runtime', 'Runtime', 'text', 'text', '`runtime` varchar(128) NULL DEFAULT NULL', NULL, 'string 128', '2020-07-26 07:22:24', NULL, 1, 1, 'rw-r--r--'),
-(24, 'imdbrating', 'IMDB Rating', 'text', 'text', '`imdbrating` varchar(128) NULL DEFAULT NULL', NULL, 'string 128', '2020-12-27 10:00:33', 0, 1, 1, 'rw-r--r--'),
-(25, 'viewcount', 'View counter', 'text', 'text', '`viewcount` varchar(128) NULL DEFAULT NULL', NULL, 'string 128', '2020-12-27 10:41:10', 0, 1, 1, 'rw-r--r--');
+(23, 'runtime', 'Runtime (min)', 'number', 'entrySingleNum', '`runtime` int(10) NULL, ADD INDEX (`runtime`)', NULL, 'int 10', '2020-07-26 07:22:24', NULL, 1, 1, 'rw-r--r--'),
+(24, 'imdbrating', 'IMDB Rating', 'text', 'entrySingleText', '`imdbrating` varchar(128) NULL DEFAULT NULL', NULL, 'string 128', '2020-12-27 10:00:33', 0, 1, 1, 'rw-r--r--'),
+(25, 'viewcount', 'View counter', 'number', 'entrySingleNum', '`viewcount` int(10) NULL, ADD INDEX (`viewcount`)', NULL, 'int 10', '2020-12-27 10:41:10', 0, 1, 1, 'rw-r--r--');
 
 -- --------------------------------------------------------
 
index cd41577898d846a5165c9aa9f68ddfbe6868e0f5..d07a694257c958cb861864062e1f6239e42c382a 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 # path settings
-define('PATH_ABSOLUTE','/home/banana/code/bibliotheca/webclient');
+define('PATH_ABSOLUTE','/home/some/path/bibliotheca/webclient');
 define('PATH_SYSTEMOUT',PATH_ABSOLUTE.'/systemout');
 define('PATH_STORAGE',PATH_ABSOLUTE.'/storage');
 define('PATH_WEB_STORAGE','storage');
index 3e4956eb0bc9628ca18f1631b63cf286801af1cf..6f72d984bc1e30bc2c7d69f263bacdc282dd2538 100644 (file)
@@ -519,6 +519,17 @@ class Manageentry {
                return $this->_saveField_text($data, $queryData);
        }
 
+       /**
+        * Create part of the insert statement for field type number
+        * @param array $data
+        * @param array $queryData
+        * @return mixed
+        */
+       private function _saveField_number($data, $queryData) {
+               $queryData['init'][] = "`".$data['identifier']."` = ".$this->_DB->real_escape_string($data['valueToSave'])."";
+               return $queryData;
+       }
+
        /**
         * Create part of the insert statement for field type lookupmultiple
         *
index faf8c99a97285393392ff6655800b953b3987934..224f6045c8f9e55a81e49682af1ec37fdcce984c 100644 (file)
@@ -129,8 +129,17 @@ class Mancubus {
                                        require_once 'lib/trite.class.php';
                                        $_colObj = new Trite($this->_DB,$this->_User);
                                        $_colObj->load($result['id']);
-
-                                       $result['entries'] = $_mObj->getEntries($_colObj->param('defaultSearchField'),$search,true);
+                                       $_fd = $_colObj->getCollectionFields();
+
+                                       $result['entries'] = $_mObj->getEntries(
+                                               array(
+                                                       0 => array(
+                                                               'colName' => $_colObj->param('defaultSearchField'),
+                                                               'colValue' => $search,
+                                                               'fieldData' => $_fd[$_colObj->param('defaultSearchField')]
+                                                       )
+                                               )
+                                       );
                                }
                                else {
                                        $result['entries'] = $_mObj->getEntries();
@@ -144,45 +153,76 @@ class Mancubus {
        }
 
        /**
-        * Get entries for loaded collection limited by search in
-        * given colName and colValue
+        * Get entries for loaded collection limited by search
+        * and already set query options
+        *
+        * array[0] => array(
+        *              'colName' => 'column name to search in',
+        *              'colValue' => 'Value to search for',
+        *              'fieldData' => field data from Trite->getCollectionFields()
+        * )
         *
-        * @param string $colName Table col to search
-        * @param string $colValue Value to search in col
-        * @param bool $fulltext If col has a fulltext index use it.
+        * @param array $searchData
         * @return array
         */
-       public function getEntries($colName='', $colValue='',$fulltext=false) {
+       public function getEntries($searchData=array()) {
                $ret = array();
 
                if(!empty($this->_collectionId)) {
                        // split since part of it is used later
                        $querySelect = "SELECT *";
                        $queryFrom = " FROM `".DB_PREFIX."_collection_entry_".$this->_DB->real_escape_string($this->_collectionId)."` AS t";
+                       $queryJoin = '';
                        $queryWhere = " WHERE ".$this->_User->getSQLRightsString("read", "t")."";
 
-                       if(!empty($colName) && !empty($colValue)) {
-                               if($fulltext === true) {
-                                       $queryWhere .= " AND MATCH (`t`.`".$this->_DB->real_escape_string($colName)."`) 
-                                               AGAINST ('".$this->_DB->real_escape_string($colValue)."' IN BOOLEAN MODE)";
-                               }
-                               else {
-                                       $queryWhere .= " AND `t`.`" . $this->_DB->real_escape_string($colName) . "` = '" . $this->_DB->real_escape_string($colValue) . "'";
+                       $_isFulltext = false;
+                       if(!empty($searchData)) {
+                               // this search supports fulltext search and number <> search.
+                               // also can search in the entry2lookup table.
+                               // not perfect but works really well
+                               foreach($searchData as $k=>$sd) {
+                                       if(!isset($sd['colName']) || !isset($sd['colValue']) || empty($sd['colValue'])) continue;
+
+                                       if($sd['fieldData']['searchtype'] == "tag") {
+                                               $_isFulltext = true;
+
+                                               $queryJoin = " LEFT JOIN `".DB_PREFIX."_collection_entry2lookup_".$this->_DB->real_escape_string($this->_collectionId)."` AS e2l ON e2l.fk_entry=t.id";
+
+                                               $queryWhere .= " AND e2l.fk_field = '".$this->_DB->real_escape_string($sd['fieldData']['id'])."'";
+                                               $queryWhere .= " AND MATCH (e2l.value) AGAINST ('".$this->_DB->real_escape_string($sd['colValue'])."' IN BOOLEAN MODE)";
+                                       }
+                                       elseif ($sd['fieldData']['searchtype'] == "entrySingleNum" && strstr($sd['colValue'],'<')) {
+                                               $_s = str_replace('<','',$sd['colValue']);
+                                               $queryWhere .= " AND `t`.`".$this->_DB->real_escape_string($sd['colName'])."` < ".(int)$_s."";
+                                       }
+                                       elseif ($sd['fieldData']['searchtype'] == "entrySingleNum" && strstr($sd['colValue'],'>')) {
+                                               $_s = str_replace('>','',$sd['colValue']);
+                                               $queryWhere .= " AND `t`.`".$this->_DB->real_escape_string($sd['colName'])."` > ".(int)$_s."";
+                                       }
+                                       elseif($sd['fieldData']['searchtype'] == "entryText") {
+                                               $_isFulltext = true;
+                                               $queryWhere .= " AND MATCH (`t`.`".$this->_DB->real_escape_string($sd['colName'])."`) 
+                                                                                       AGAINST ('".$this->_DB->real_escape_string($sd['colValue'])."' IN BOOLEAN MODE)";
+                                       }
+                                       else {
+                                               $queryWhere .= " AND `t`.`".$this->_DB->real_escape_string($sd['colName'])."` = '".$this->_DB->real_escape_string($sd['colValue'])."'";
+                                       }
                                }
                        }
 
-                       $queryOrder = " ORDER BY";
-                       if(!empty($this->_queryOptions['sort'])) {
-                               $queryOrder .= ' t.'.$this->_queryOptions['sort'];
-                       }
-                       else {
-                               $queryOrder .= " t.created";
-                       }
-                       if(!empty($this->_queryOptions['sortDirection'])) {
-                               $queryOrder .= ' '.$this->_queryOptions['sortDirection'];
-                       }
-                       else {
-                               $queryOrder .= " DESC";
+                       $queryOrder = '';
+                       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'];
+                               } else {
+                                       $queryOrder .= " t.created";
+                               }
+                               if (!empty($this->_queryOptions['sortDirection'])) {
+                                       $queryOrder .= ' ' . $this->_queryOptions['sortDirection'];
+                               } else {
+                                       $queryOrder .= " DESC";
+                               }
                        }
 
                        $queryLimit = '';
@@ -194,9 +234,9 @@ class Mancubus {
                                }
                        }
 
-                       if(DEBUG) error_log("[DEBUG] ".__METHOD__."  data: ".$querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit);
+                       if(DEBUG) error_log("[DEBUG] ".__METHOD__." data: ".$querySelect.$queryFrom.$queryJoin.$queryWhere.$queryOrder.$queryLimit);
 
-                       $query = $this->_DB->query($querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit);
+                       $query = $this->_DB->query($querySelect.$queryFrom.$queryJoin.$queryWhere.$queryOrder.$queryLimit);
 
                        if($query !== false && $query->num_rows > 0) {
                                $_entryFields = $this->_getEntryFields();
@@ -207,7 +247,7 @@ class Mancubus {
                                        $ret['results'][$result['id']] = $result;
                                }
 
-                               $query = $this->_DB->query("SELECT COUNT(t.id) AS amount ".$queryFrom.$queryWhere);
+                               $query = $this->_DB->query("SELECT COUNT(t.id) AS amount ".$queryFrom.$queryJoin.$queryWhere);
                                $result = $query->fetch_assoc();
                                $ret['amount'] = $result['amount'];
                        }
@@ -227,7 +267,7 @@ class Mancubus {
                if(!empty($this->_collectionId) && !empty($entryId)) {
                        $queryStr = "SELECT * 
                                                FROM `".DB_PREFIX."_collection_entry_".$this->_DB->real_escape_string($this->_collectionId)."` 
-                                               WHERE ".$this->_User->getSQLRightsString("read")."
+                                               WHERE ".$this->_User->getSQLRightsString()."
                                                AND `id` = '".$this->_DB->real_escape_string($entryId)."'";
                        $query = $this->_DB->query($queryStr);
 
@@ -254,7 +294,7 @@ class Mancubus {
                $ret = array();
 
                $fieldData = array();
-               $queryStr = "SELECT `identifier`, `type` FROM `".DB_PREFIX."_sys_fields`
+               $queryStr = "SELECT `identifier`, `type`, `id`, `searchtype` FROM `".DB_PREFIX."_sys_fields`
                                                WHERE `id` = '".$this->_DB->real_escape_string($fieldId)."'";
                $query = $this->_DB->query($queryStr);
                if($query !== false && $query->num_rows > 0) {
@@ -266,7 +306,16 @@ class Mancubus {
                if(empty($fieldData)) return $ret;
 
                if($fieldData['type'] !== "lookupmultiple") {
-                       return $this->getEntries($fieldData['identifier'], $fieldValue);
+                       return $this->getEntries(
+                               array(
+                                       0 => array(
+                                               'colName' => $fieldData['identifier'],
+                                               'colValue' => $fieldValue,
+                                               'fieldData' => $fieldData
+                                       )
+                               )
+                       );
+
                }
 
                $querySelect = "SELECT `fk_entry`";
index 65cc39089f3d84f1fb28bdee14cf283a46fbd9dd..3edfd7d2557792adca69c3825c6a584e124b5948 100644 (file)
@@ -184,7 +184,8 @@ class Trite {
        public function getCollectionFields() {
                $ret = array();
 
-               $queryStr = "SELECT `cf`.`fk_field_id` AS id, `sf`.`type`, `sf`.`displayname`, `sf`.`identifier`
+               $queryStr = "SELECT `cf`.`fk_field_id` AS id, `sf`.`type`, `sf`.`displayname`, `sf`.`identifier`,
+                                               `sf`.`searchtype`
                                                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`";
@@ -192,7 +193,7 @@ class Trite {
                try {
                        if($query !== false && $query->num_rows > 0) {
                                while(($result = $query->fetch_assoc()) != false) {
-                                       $ret[$result['id']] = $result;
+                                       $ret[$result['identifier']] = $result;
                                }
                        }
                } catch (Exception $e) {
index 4bf643e72d26a991a4769af7997075638a4a5ac3..c89c0469115295769155a8bed08d9e7c23e895f6 100644 (file)
@@ -1,5 +1,21 @@
 <?php if(!empty($TemplateData['loadedCollection'])) { ?>
-<div class="uk-grid-small uk-grid-row-small uk-grid-row-small" uk-grid>
+
+<?php if(!empty($TemplateData['search'])) { ?>
+<div uk-alert id="searchNotice">
+       <button class="uk-alert-close" type="button" uk-close></button>
+       <p>Display result for: <b><?php echo $TemplateData['search']; ?></b> (Max. result of 60)</p>
+</div>
+<script type="text/javascript">
+       UIkit.util.on('#searchNotice', 'hide', function () {
+               window.location.href="index.php?p=advancedsearch&collection=<?php echo $TemplateData['loadedCollection']['id']; ?>";
+       });
+</script>
+<button class="uk-button uk-button-default uk-button-small"
+        type="button" uk-toggle="target: #searchFrame; animation: uk-animation-scale-down; cls: uk-hidden">Toggle search</button>
+<?php } ?>
+
+<div class="uk-grid-small uk-grid-row-small uk-grid-row-small <?php if(!empty($TemplateData['search'])) { ?>uk-hidden<?php } ?>"
+       uk-grid id="searchFrame">
        <div class="uk-width-1-2">
 
                <form class="uk-form-horizontal uk-margin-small" method="post">
@@ -22,7 +38,7 @@
                <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>
+               eg.: <code>title: bourne</code>
                <p>Available fields in <b><?php echo Summoner::ifset($TemplateData['loadedCollection'], 'name'); ?></b> are:</p>
                <pre style="white-space: normal">
                <?php
                <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>
+               <p>&gt; = A leading greater than sign indicates that rows greater than the number will be returned.</p>
+               <p>&lt; = A leading less than sign indicates that rows smaller than the number will be returned.</p>
        </div>
 </div>
+
+<?php if(!empty($TemplateData['entries'])) { ?>
+<div class="uk-grid-small uk-grid-match" uk-grid>
+       <?php foreach($TemplateData['entries']['results'] as $entryK=>$entry) { ?>
+       <div class="uk-width-1-4@s uk-width-1-6@l">
+               <div class="uk-card uk-card-default uk-card-small">
+                       <div class="uk-card-media-top">
+                               <?php if(Summoner::ifset($entry['fields'], 'coverimage')) { ?>
+                               <img src="<?php echo $TemplateData['storagePath'].'/'.$entryK.'/'.$entry['fields']['coverimage']['value']; ?>"
+                                    alt="<?php echo $entry['fields']['coverimage']['displayname']; ?>">
+
+                               <?php } ?>
+                       </div>
+                       <div class="uk-card-body uk-visible@l">
+                               <?php if(Summoner::ifset($entry['fields'], 'title')) { ?>
+                               <h3 class="uk-card-title"><?php echo $entry['fields']['title']['value']; ?></h3>
+                               <?php } ?>
+
+                               <?php if(Summoner::ifset($entry['fields'], 'description')) { ?>
+                               <p><?php echo $entry['fields']['description']['value']; ?></p>
+                               <?php } ?>
+                       </div>
+                       <div class="uk-card-footer">
+                               <a href="<?php echo $TemplateData['entryLinkPrefix']; ?>&id=<?php echo $entryK; ?>" class="uk-button uk-button-text">View</a>
+                       </div>
+               </div>
+       </div>
+       <?php } ?>
+</div>
+<?php } ?>
+
 <?php } else { ?>
 <h3 class="uk-h3">Collection overview</h3>
 <div class="uk-grid-small uk-grid-row-small uk-grid-row-small" uk-grid>
index b3fbb4d028ab14aa5ab5b693a482693ef7b8ecee..baefff02f815fd45a50ce96d3a897e4efc779089 100644 (file)
@@ -18,6 +18,8 @@
 
 require_once 'lib/trite.class.php';
 $Trite = new Trite($DB,$Doomguy);
+require_once 'lib/mancubus.class.php';
+$Mancubus = new Mancubus($DB,$Doomguy);
 
 $_collection = false;
 if(isset($_GET['collection']) && !empty($_GET['collection'])) {
@@ -28,11 +30,64 @@ if(isset($_GET['collection']) && !empty($_GET['collection'])) {
 $TemplateData['loadedCollection'] = array();
 $TemplateData['collections'] = array();
 $TemplateData['collectionFields'] = array();
+$TemplateData['search'] = false;
+
+//
 
 if(!empty($_collection)) {
        $TemplateData['loadedCollection'] = $Trite->load($_collection);
        if(!empty($TemplateData['loadedCollection'])) {
                $TemplateData['collectionFields'] = $Trite->getCollectionFields();
+               $Mancubus->setCollection($Trite->param('id'));
+               $Mancubus->setQueryOptions(array('limit' => 60));
+
+               $TemplateData['storagePath'] = PATH_WEB_STORAGE . '/' . $Trite->param('id');
+               $TemplateData['entryLinkPrefix'] = "index.php?p=entry&collection=".$Trite->param('id');
+
+               if(isset($_POST['submitForm'])) {
+                       $fdata = $_POST['fdata'];
+                       if (!empty($fdata)) {
+                               $_search = trim($fdata['search']);
+
+                               if (!empty($_search) && Summoner::validate($_search)) {
+                                       if (strstr($_search, ':')) { // field search
+                                               $_matches = array();
+                                               if(preg_match_all("/(\p{L}+:)(?(?!\p{L}+:).)*/u",$_search, $_matches) !== false && !empty($_matches[0])) {
+                                                       // $matches[0] has the identifier: and text
+                                                       // $matches[1] has only the identifier:
+                                                       // $matches[0][0] belongs to $matches[1][0] and so on
+
+                                                       $_sData = array();
+                                                       $_ms = count($_matches[0]);
+                                                       for($i=0;$i<$_ms;$i++) {
+                                                               $_cn = trim(str_replace(':','',$_matches[1][$i]));
+                                                               $_sData[$i]['colName'] = $_cn;
+                                                               $_sData[$i]['colValue'] = trim(str_replace($_matches[1][$i],'',$_matches[0][$i]));
+                                                               $_sData[$i]['fieldData'] = $TemplateData['collectionFields'][$_cn];
+                                                       }
+
+                                                       $TemplateData['entries'] = $Mancubus->getEntries($_sData);
+                                                       $TemplateData['search'] = $_search;
+                                               }
+                                               else {
+                                                       $TemplateData['message']['content'] = "Wrong input format.";
+                                                       $TemplateData['message']['status'] = "error";
+                                               }
+                                       } else { // ordinary search within default field
+                                               $TemplateData['entries'] = $Mancubus->getEntries(
+                                                       array(
+                                                               0 => array(
+                                                                       'colName' => $Trite->param('defaultSearchField'),
+                                                                       'colValue' => $_search,
+                                                                       'fieldData' => $TemplateData['collectionFields'][$Trite->param('defaultSearchField')]
+                                                               )
+                                                       )
+                                               );
+                                               $TemplateData['search'] = $_search;
+                                       }
+                               }
+                       }
+               }
        }
        else {
                $TemplateData['message']['content'] = "Can not load given collection.";
index 6d363909e9798b7b789cbaef42e4e087c235d82b..dd10b1c18f56332ec3ada6a1da9d40ddc3e91691 100644 (file)
@@ -63,9 +63,9 @@ if(!empty($_collection)) {
        if(!empty($TemplateData['loadedCollection'])) {
                $Mancubus->setCollection($Trite->param('id'));
                $Mancubus->setQueryOptions($_queryOptions); // this comes from pagination_before!
-               $TemplateData['storagePath'] = PATH_WEB_STORAGE . '/' . $_collection;
-               $TemplateData['entryLinkPrefix'] = "index.php?p=entry&collection=".$_collection;
-               $TemplateData['searchAction'] = 'index.php?p=collections&collection='.$_collection;
+               $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');
 
                if (!empty($_fv) && !empty($_fid)) {
                        $TemplateData['entries'] = $Mancubus->getEntriesByFieldValue($_fid, $_fv);
@@ -74,7 +74,16 @@ if(!empty($_collection)) {
                        $TemplateData['pagination']['currentGetParameters']['fid'] = $_fid;
                        $TemplateData['pagination']['currentGetParameters']['fv'] = $_fv;
                } else {
-                       $TemplateData['entries'] = $Mancubus->getEntries($Trite->param('defaultSearchField'),$_search,true);
+                       $_fd = $Trite->getCollectionFields();
+                       $TemplateData['entries'] = $Mancubus->getEntries(
+                               array(
+                                       0 => array(
+                                               'colName' => $Trite->param('defaultSearchField'),
+                                               'colValue' => $_search,
+                                               'fieldData' =>$_fd[$Trite->param('defaultSearchField')]
+                                       )
+                               )
+                       );
                        if (!empty($_search)) {
                                $TemplateData['search'] = $_search;
                        }
diff --git a/webclient/view/default/entry/field-number.html b/webclient/view/default/entry/field-number.html
new file mode 100644 (file)
index 0000000..951b94e
--- /dev/null
@@ -0,0 +1,4 @@
+<p data-field-name="number" data-field-id="<?php echo $field['identifier']; ?>">
+       <span class="uk-text-muted"><?php echo $field['displayname']; ?>:</span>
+       <a href="index.php?p=collections&collection=<?php echo $TemplateData['loadedCollection']['id']; ?>&fid=<?php echo $field['id']; ?>&fv=<?php echo urlencode(Summoner::ifset($field, 'value')); ?>"><?php echo Summoner::ifset($field, 'value'); ?></a>
+</p>
diff --git a/webclient/view/default/manageentry/field-number.html b/webclient/view/default/manageentry/field-number.html
new file mode 100644 (file)
index 0000000..fca6035
--- /dev/null
@@ -0,0 +1,9 @@
+<div class="uk-margin">
+       <label class="uk-form-label" for="<?php echo $field['identifier']; ?>"><?php echo $field['displayname']; ?></label>
+       <div class="uk-form-controls">
+               <input class="uk-input" id="<?php echo $field['identifier']; ?>" type="number" autocomplete="off"
+                      name="fdata[<?php echo $field['identifier']; ?>]"
+                      value="<?php echo Summoner::ifset($TemplateData['editData'], $field['identifier']); ?>"
+               >
+       </div>
+</div>