-* change the search data. Maybe an extra search field in which all the searchable information of an entry will be
- saved.
+* Better error handling and display while adding / update and delete
+** Maybe some message "store"
* query optimization and default indexes on columns
* make documentation markdown to be nicer
* change multiple-attachment to a field which tells it is used for a image gallery
* i18n support
* Definition of fields in "card view"
* User and groupmanagement: Check where a user or group is used!
-* Better error handling and display while adding / update and delete
* Export of an entry, collection or everything. Stored on disk.
* Import of the export
* remove ifset and maybe ifsetvalue from summoner
-
* Field management: Web interface to configure or even create new ones.
(30, 'sysReq', 'System Requirements', 'text3', 'entryText', '`sysReq` varchar(255) NULL DEFAULT NULL, ADD FULLTEXT (`sysReq`)', '', NULL, 'string 255', '2021-04-25 21:21:54', '2021-04-25 21:21:54', 0, 1, 1, 'rw-r--r--'),
(31, 'artist', 'Artist', 'text', 'entrySingleText', '`artist` varchar(128) NULL DEFAULT NULL', '', NULL, 'string 128', '2021-07-09 08:30:11', '2021-07-09 08:38:33', NULL, 1, 1, 'rw-r--r--'),
(32, 'artists', 'Artists', 'lookupmultiple', 'tag', NULL, 'allowSpace', NULL, 'string 64', '2021-07-18 11:42:16', '2021-07-18 11:42:16', NULL, 1, 1, 'rw-r--r--'),
-(34, 'isbn', 'ISBN', 'text', 'entrySingleText', '`isbn` varchar(32) NULL, ADD INDEX (`isbn`)', '', NULL, 'varchar 32', '2022-10-08 10:47:01', '2023-04-08 08:53:55', NULL, 1, 1, 'rw-r--r--');
+(34, 'isbn', 'ISBN', 'text', 'entrySingleText', '`isbn` varchar(32) NULL, ADD INDEX (`isbn`)', '', NULL, 'varchar 32', '2022-10-08 10:47:01', '2023-04-08 08:53:55', NULL, 1, 1, 'rw-r--r--'),
+(35, 'combSearch', 'Combined Search', 'hidden', 'entryText', '`combSearch` text NULL DEFAULT NULL, ADD FULLTEXT (`combSearch`)', '', NULL, 'mysql text - Content will be auto generated from other entry fields', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, '1', '1', 'rw-r--r--');
-- --------------------------------------------------------
-- AUTO_INCREMENT for table `#REPLACEME#_sys_fields`
--
ALTER TABLE `#REPLACEME#_sys_fields`
- MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35;
+ MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36;
--
-- AUTO_INCREMENT for table `#REPLACEME#_tool`
# Added a new global search field
-As of version 1.6, the field 'Combined Search' provides a much better default search base.
-If you want to use it make sure you update its contents for all the existing entries in
-your collection. After that and for all new entries the data will be created automatically.
-The update and creation of the field is done by using the new option "Update combined search field data"
-in collection management. It needs to be done for each if your collections but only once.
+As of version 1.6, the field 'Combined Search' provides a much better search base.
+How to change and use new field: Run the following sql query. Replace #REPLACEME# with the used DB prefix.
+```
+INSERT INTO `#REPLACEME#_sys_fields` (`id`, `identifier`, `displayname`, `type`, `searchtype`, `createstring`, `inputValidation`, `value`, `apiinfo`, `created`, `modified`, `modificationuser`, `owner`, `group`, `rights`) VALUES (NULL, 'combSearch', 'Combined Search', 'hidden', 'entryText', '`combSearch` text NULL DEFAULT NULL, ADD FULLTEXT (`combSearch`)', '', NULL, 'mysql text - Content will be auto generated from other entry fields', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, '1', '1', 'rw-r--r--');
+```
+Add the new field 'Combined Search' to a collection.
+Change the 'Default gloabal seach field' to 'Combined search' and save.
+After that check the 'Update combined search field data' option to create the search data
+for the selected collection. Do this for every collection.
+For all new entries the data will be created automatically.
# Added new constants to config.php file.
Use config.php.default as a help. The new lines are:
// add systemfields
$def['created'] = array('identifier' => 'created', 'displayname' => 'Created', 'type' => 'systemfield');
$def['modified'] = array('identifier' => 'modified', 'displayname' => 'Modified', 'type' => 'systemfield');
- $def['search'] = array('identifier' => 'search', 'displayname' => 'Combined Search', 'type' => 'systemfield');
return $def + $ret;
}
`owner` int NOT NULL,
`group` int NOT NULL,
`rights` char(9) COLLATE utf8mb4_bin NOT NULL,
- `search` text COLLATE utf8mb4_unicode_ci NOT NULL,
- PRIMARY KEY (`id`),
- FULLTEXT KEY `search` (`search`)
+ PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryCollectionEntry));
$this->_DB->query($queryCollectionEntry);
// optimize does a recreation and the column collation
// is considered
$this->_DB->query("OPTIMIZE TABLE `".DB_PREFIX."_collection_entry_".$data['id']."`");
- } elseif($data['defaultSearchField'] === "search") {
- // Special case. 1.6 adds the search field. Needs to be checked if there
- // It is a new default column which is added at creation of a collection
- // but needs to be added manually for existing ones.
- // could be removed in future version...
- $queryStr = "ALTER TABLE `".DB_PREFIX."_collection_entry_".$data['id']."`
- ADD `search` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
- NOT NULL AFTER `rights`, ADD FULLTEXT (`search`)";
- if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
- $this->_DB->query($queryStr);
- }
+ }
} catch (Exception $e) {
if($e->getCode() == "1061") {
// duplicate key message if the index is already there.
// Name starts with entry. Here we want only the text fields
// Those fields are the data for the combined search field
$dataFields = array();
+ $_fieldAvailable = false;
if(!empty($searchFields)) {
foreach($searchFields as $k=>$v) {
+ if($v['identifier'] == "combSearch") {
+ $_fieldAvailable = true;
+ continue;
+ }
if(isset($v['searchtype']) && strpos($v['searchtype'],'Text') !== false) {
$dataFields[$k] = $v['identifier'];
}
}
}
+ // only if the combSearch field is available in the collection
+ if(!$_fieldAvailable) return $ret;
+
// get the search data for every entry in the collection
$entryData = array();
if(!empty($dataFields)) {
$searchData = implode(" ", Summoner::words($searchData));
$queryStr = "UPDATE `".DB_PREFIX."_collection_entry_".$collectionId."`
- SET `search` = '".$this->_DB->real_escape_string($searchData)."'
+ SET `combSearch` = '".$this->_DB->real_escape_string($searchData)."'
WHERE `id` = '".$entryid."'";
if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
try {
if(!empty($this->_collectionId)) {
$queryStr = "SELECT `cf`.`fk_field_id` AS id, `sf`.`type`, `sf`.`displayname`, `sf`.`identifier`,
- `sf`.`value`, `sf`.`inputValidation`
+ `sf`.`value`, `sf`.`inputValidation`, `sf`.`searchtype`
FROM `".DB_PREFIX."_collection_fields_".$this->_DB->real_escape_string($this->_collectionId)."` AS cf
LEFT JOIN `".DB_PREFIX."_sys_fields` AS sf ON `cf`.`fk_field_id` = `sf`.`id`
ORDER BY `cf`.`sort`";
if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." methodname: ".Summoner::cleanForLog($_methodName));
if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." methodnamespecial: ".Summoner::cleanForLog($_methodNameSpecial));
if(method_exists($this, $_methodNameSpecial)) {
- $queryData = $this->$_methodNameSpecial($d, $queryData);
+ $queryData = $this->$_methodNameSpecial($d, $queryData, $data);
}
elseif(method_exists($this, $_methodName)) {
$queryData = $this->$_methodName($d, $queryData);
return $this->_saveField_text($data, $queryData);
}
+ /**
+ * Create part of the insert statement for field type hidden
+ *
+ * @param array $data
+ * @param array $queryData
+ * @return array
+ */
+ private function _saveField_hidden(array $data, array $queryData): array {
+ return $this->_saveField_text($data, $queryData);
+ }
+
+ /**
+ * Create part of the insert statement for field type hidden and identifier combSearch
+ * Creates it contents of the other fields as a combined search field. Ignores any input
+ *
+ * @see ManageCollections->updateSearchData()
+ *
+ * @param array $data
+ * @param array $queryData
+ * @param array $allInputData All the POST data if needed
+ * @return array
+ */
+ private function _saveField_hidden__combSearch(array $data, array $queryData, array $allInputData): array {
+ $searchData = '';
+ foreach($allInputData as $f=>$_d) {
+ if(isset($_d['searchtype']) && strpos($_d['searchtype'],'Text') !== false) {
+ $searchData .= " ".$_d['valueToSave'];
+ }
+ }
+ $data['valueToSave'] = implode(" ", Summoner::words($searchData));
+ $queryData['init'][] = "`".$data['identifier']."` = '".$this->_DB->real_escape_string($data['valueToSave'])."'";
+ return $queryData;
+ }
+
/**
* Create part of the insert statement for field type year
* Uses some simple 4 digit patter to extract the year if the input is
*
* @param array $data
* @param array $queryData
+ * @param array $allInputData All the POST data if needed
* @return array
*/
- private function _saveField_upload__coverimage(array $data, array $queryData): array {
+ private function _saveField_upload__coverimage(array $data, array $queryData, array $allInputData): array {
$queryData = $this->_saveField_upload($data, $queryData);
if(!isset($queryData['after']['upload'])) {
/**
* Get entries for loaded collection by looking for the given value in given field
+ *
+ * @TODO: unused?
*
* @param string $fieldId Number ID of the field to search in
* @param string $fieldValue Value of the field
// add systemfields
$def['created'] = array('identifier' => 'created', 'displayname' => 'Created', 'type' => 'systemfield');
$def['modified'] = array('identifier' => 'modified', 'displayname' => 'Modified', 'type' => 'systemfield');
- $def['search'] = array('identifier' => 'search', 'displayname' => 'Combined Search', 'type' => 'systemfield');
- $ret = $def + $ret;
-
- return $ret;
+ return $def + $ret;
}
/**
(30, 'sysReq', 'System Requirements', 'text3', 'entryText', '`sysReq` varchar(255) NULL DEFAULT NULL, ADD FULLTEXT (`sysReq`)', '', NULL, 'string 255', '2021-04-25 21:21:54', '2021-04-25 21:21:54', 0, 1, 1, 'rw-r--r--'),
(31, 'artist', 'Artist', 'text', 'entrySingleText', '`artist` varchar(128) NULL DEFAULT NULL', '', NULL, 'string 128', '2021-07-09 08:30:11', '2021-07-09 08:38:33', NULL, 1, 1, 'rw-r--r--'),
(32, 'artists', 'Artists', 'lookupmultiple', 'tag', NULL, 'allowSpace', NULL, 'string 64', '2021-07-18 11:42:16', '2021-07-18 11:42:16', NULL, 1, 1, 'rw-r--r--'),
-(34, 'isbn', 'ISBN', 'text', 'entrySingleText', '`isbn` varchar(32) NULL, ADD INDEX (`isbn`)', '', NULL, 'varchar 32', '2022-10-08 10:47:01', '2023-04-08 08:53:55', NULL, 1, 1, 'rw-r--r--');
+(34, 'isbn', 'ISBN', 'text', 'entrySingleText', '`isbn` varchar(32) NULL, ADD INDEX (`isbn`)', '', NULL, 'varchar 32', '2022-10-08 10:47:01', '2023-04-08 08:53:55', NULL, 1, 1, 'rw-r--r--'),
+(35, 'combSearch', 'Combined Search', 'hidden', 'entryText', '`combSearch` text NULL DEFAULT NULL, ADD FULLTEXT (`combSearch`)', '', NULL, 'mysql text - Content will be auto generated from other entry fields', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, '1', '1', 'rw-r--r--');
-- --------------------------------------------------------
-- AUTO_INCREMENT for table `#REPLACEME#_sys_fields`
--
ALTER TABLE `#REPLACEME#_sys_fields`
- MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35;
+ MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36;
--
-- AUTO_INCREMENT for table `#REPLACEME#_tool`
<div class="window-body">
<p>
Display result for: <b><?php echo $TemplateData['search']; ?></b><br>
- <small>(Max. result of 60)</small>
+ (Max. result of 60)
</p>
</div>
</div>
<h3>Manage your collections</h3>
<h4>Add or modify a collection</h4>
<blockquote>
- Any default field or any option which needs a field get its content after the fields are configured.
+ Any default field or any option which needs a field, get its values after the fields are configured.
</blockquote>
<form method="post" class="maxSizeForm">
<div class="field-row-stacked">
<label>
The field is used in the global search. Altering the default search field results in
- a DB reindex. This could take some time, depending on the amount of data.
+ a DB reindex.<br />
+ This could take some time, depending on the amount of data.<br />
+ As of version 1.6, the field 'Combined Search' provides a much better default search base.<br />
+ Select the field and save. Use the option below to created or update the search data
+ for every entry in this collection.
</label>
</div>
+ <div class="field-row-stacked">
+ <input id="updateSearchData" type="checkbox" name="fdata[updateSearchData]" value="1">
+ <label for="updateSearchData">Update Combined Search field data</label>
+ This could take some time to complete, depending on the amount of data.<br />
+ Plase do this after you remove fields(text) from your collection.
+ </div>
<div class="field-row-stacked">
<label for="defaultSortField">Default sort field</label>
<select id="defaultSortField" name="fdata[defaultSortField]">
</select>
</div>
<div class="field-row-stacked">
- <label for="advancedSearchTableFields">Table advanced search view</label>
+ <label for="advancedSearchTableFields">Advanced search table fields</label>
<select id="advancedSearchTableFields" name="fdata[advancedSearchTableFields][]" multiple="multiple" size="5">
<?php foreach($TemplateData['existingFields'] as $k=>$v) { ?>
<option value="<?php echo $v['id']; ?>"
</select>
</div>
<div class="field-row-stacked">
- <label>Make sure that the default global search field is in this list. This does not limit the fields to search in.</label>
+ <label>
+ Make sure that the default global search field is in this list.
+ This does not limit the fields to search in.
+ </label>
</div>
<div class="field-row-stacked">
<label for="tool">Tools</label>
<?php if(Summoner::ifset($TemplateData['editData'], 'name')) { ?>
<div class="field-row-stacked">
<input id="doRightsForEntries" type="checkbox" name="fdata[doRightsForEntries]" value="1">
- <label for="doRightsForEntries">
- Overwrite existing rights<br />
+ <label for="doRightsForEntries">Overwrite existing rights</label>
Warning: This will overwrite existing entry rights (user, group, rights) with the ones from the collection!
</label>
</div>
<div class="field-row-stacked">
<input id="doDelete" type="checkbox" name="fdata[doDelete]" value="1">
- <label for="doDelete">
- Delete<br />
- Warning: This will delete ALL the data in this collection!
- </label>
+ <label for="doDelete">Delete</label>
+ Warning: This will delete ALL the data in this collection!
</div>
<?php } ?>
?>
<div class="field-row-stacked">
- <label>Rights *</label></td>
+ <label>Rights *</label>
<table>
<thead>
--- /dev/null
+<!-- hidden <?php echo $field['identifier']; ?> -->
<div class="uk-width-1-2">
<h4 class="uk-h4">Add or modify a collection</h4>
<p>
- <span uk-icon="icon: warning"></span> Any default field or any option which needs a field
- get its content after the fields are configured.
+ <span uk-icon="icon: warning"></span> Any default field or any option which needs a field,
+ get its values after the fields are configured.
</p>
<form class="uk-form-horizontal uk-margin-small" method="post">
<div class="uk-margin">
<small>
<span class="" uk-icon="icon: warning"></span> As of version 1.6, the field 'Combined Search'
provides a much better default search base.<br />
- If you want to use it make sure you update its contents (following option) for all the existing entries in
- your collection. After that and for all new entries the data will be created automatically.
+ Select the field and save. Use the option below to created or update the search data
+ for every entry in this collection.
</small>
</div>
</div>
<div class="uk-margin">
- <div class="uk-form-label">Update combined search field data</div>
+ <div class="uk-form-label">Update Combined Search field data</div>
<div class="uk-form-controls uk-form-controls-text">
<label>
<input class="uk-checkbox" type="checkbox" name="fdata[updateSearchData]" value="1">
><?php echo $v['displayname']; ?> (<?php echo $v['type']; ?>)</option>
<?php } ?>
</select>
- <small>Make sure that the default global search field is in this list.<br />
- This does not limit the fields to search in.</small>
+ <small>
+ Make sure that the default global search field is in this list.<br />
+ This does not limit the fields to search in.
+ </small>
</div>
</div>
<div class="uk-margin">
--- /dev/null
+<input type="hidden" id="<?php echo $field['identifier']; ?>" autocomplete="off"
+ name="fdata[<?php echo $field['identifier']; ?>]"
+ value="<?php echo Summoner::ifset($TemplateData['editData'], $field['identifier']); ?>"
+>