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
+* 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
`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;
-- --------------------------------------------------------
`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;
--
(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, '');
-- --------------------------------------------------------
-- 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`
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.
-# 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;
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.
`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;
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`
$ret = $query->fetch_assoc();
$ret['rights'] = Summoner::prepareRightsArray($ret['rights']);
$ret['tool'] = $this->getAvailableTools($id);
+ $ret['advancedSearchTableFields'] = $this->_loadAdvancedSearchTableFields($ret['advancedSearchTableFields']);
}
}
catch (Exception $e) {
`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 {
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";
}
}
}
+
+ /**
+ * 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;
+ }
}
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;
*
* 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;
+ }
}
/**
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;
+ }
}
$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`
$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) {
$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;
+ }
}
<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 if(!empty($TemplateData['entries'])) { ?>
-<form method="post" action="index.php?p=bulkedit&collection=<?php echo $TemplateData['loadedCollection']['id']; ?>" class="uk-display-inline-block">
- <button type="submit" class="uk-button uk-button-default uk-button-small">Bulkedit these results</button>
- <?php foreach($TemplateData['entries']['ids'] as $f) { ?>
- <input type="hidden" name="bulkedit[]" value="<?php echo $f; ?>" />
+<div class="uk-padding-small uk-padding-remove-left">
+ <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 if(!empty($TemplateData['entries'])) { ?>
+ <form method="post" action="index.php?p=bulkedit&collection=<?php echo $TemplateData['loadedCollection']['id']; ?>" class="uk-display-inline-block">
+ <button type="submit" class="uk-button uk-button-default uk-button-small">Bulkedit these results</button>
+ <?php foreach($TemplateData['entries']['ids'] as $f) { ?>
+ <input type="hidden" name="bulkedit[]" value="<?php echo $f; ?>" />
+ <?php } ?>
+ </form>
<?php } ?>
-</form>
-<?php } ?>
+</div>
<?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">
<div class="uk-margin">
<label class="uk-form-label" for="search">Search for</label>
placeholder="See search syntax for options">
</div>
</div>
+ <div class="uk-margin">
+ <div class="uk-form-label">Table view</div>
+ <div class="uk-form-controls uk-form-controls-text">
+ <label>
+ <input class="uk-checkbox" type="checkbox" name="fdata[tableView]" value="1">
+ </label>
+ </div>
+ </div>
<div class="uk-margin">
<button class="uk-button uk-button-primary" type="submit" name="submitForm">
<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. Not every search operator does make sense with tag search fields.</p>
+ <p>
+ To search within the possible fields of a collection type the field identifier followed by : and then a space. Not every search operator does make sense with tag search fields.
+ If the search is within a field witch is not configured to be displayed in the table view, it will be added.
+ </p>
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">
</div>
<?php if(!empty($TemplateData['entries'])) { ?>
-<div class="uk-grid-small uk-grid-match" uk-grid>
+<div>
+ <?php if($TemplateData['searchResultStyle'] == "table") { ?>
+
+ <table class="uk-table uk-table-small uk-table-divider uk-table-justify">
+ <thead>
+ <tr>
+ <th class="">#</th>
+ <?php
+ foreach($TemplateData['collectionFields'] as $f) {
+ if(in_array($f['id'],$TemplateData['loadedCollection']['advancedSearchTableFields'])) {
+ echo '<th>'.$f['displayname'].'</th>';
+ }
+ }
+ ?>
+ </tr>
+ </thead>
+ <tbody>
+
<?php foreach($TemplateData['entries']['results'] as $entryK=>$entry) { ?>
+ <tr>
+ <td class="">
+ <a href="<?php echo $TemplateData['entryLinkPrefix']; ?>&id=<?php echo $entryK; ?>" target=_blank><span class="" uk-icon="icon: link"></span></a>
+ </td>
+
+ <?php
+ foreach($entry['fields'] as $f) {
+ if(in_array($f['id'],$TemplateData['loadedCollection']['advancedSearchTableFields'])) {
+ ?>
+ <td>
+ <?php
+ if(Summoner::ifset($f, 'value')) {
+ if(is_array($f['value'])) {
+ echo Summoner::limitWithDots(implode(', ',$f['value']),100,'...');
+ }
+ else {
+ echo Summoner::limitWithDots($f['value'],100,'...');
+ }
+ }
+ ?>
+ </td>
+ <?php
+ }
+ }
+ ?>
+ </tr>
+ <?php } ?>
+ </tbody>
+ </table>
+</div>
+ <?php
+ } else {
+ ?>
+<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')) { ?>
- <a href="<?php echo $TemplateData['entryLinkPrefix']; ?>&id=<?php echo $entryK; ?>">
+ <a href="<?php echo $TemplateData['entryLinkPrefix']; ?>&id=<?php echo $entryK; ?>" target=_blank>
<img src="<?php echo $TemplateData['storagePath'].'/'.$entryK.'/'.$entry['fields']['coverimage']['value']; ?>"
alt="<?php echo $entry['fields']['coverimage']['displayname']; ?>">
</a>
<?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>
+ <a href="<?php echo $TemplateData['entryLinkPrefix']; ?>&id=<?php echo $entryK; ?>" class="uk-button uk-button-text" target=_blank>View</a>
</div>
</div>
</div>
- <?php } ?>
+ <?php
+ }
+ }
+ ?>
</div>
<?php } ?>
$TemplateData['collections'] = array();
$TemplateData['collectionFields'] = array();
$TemplateData['search'] = false;
+$TemplateData['searchResultStyle'] = 'grid';
if(!empty($_collection)) {
$TemplateData['loadedCollection'] = $Trite->load($_collection);
if (!empty($fdata)) {
$_search = trim($fdata['search']);
+ if(isset($fdata['tableView'])) {
+ $TemplateData['searchResultStyle'] = 'table';
+ }
+
if (!empty($_search) && Summoner::validate($_search)) {
if (strstr($_search, ':')) { // field search
$_matches = array();
$_sData[$i]['colName'] = $_cn;
$_sData[$i]['colValue'] = trim(str_replace($_matches[1][$i],'',$_matches[0][$i]));
$_sData[$i]['fieldData'] = $TemplateData['collectionFields'][$_cn];
+
+ if(!isset($TemplateData['loadedCollection']['advancedSearchTableFields'][$_sData[$i]['fieldData']['id']])) {
+ $TemplateData['loadedCollection']['advancedSearchTableFields'][$_sData[$i]['fieldData']['id']] = $_sData[$i]['fieldData']['id'];
+ }
}
}
</select>
</div>
</div>
+ <div class="uk-margin">
+ <label class="uk-form-label" for="advancedSearchTableFields">Table advanced search view</label>
+ <div class="uk-form-controls">
+ <select class="uk-select" id="advancedSearchTableFields" name="fdata[advancedSearchTableFields][]" multiple="multiple" size="5">
+ <?php foreach($TemplateData['existingFields'] as $k=>$v) { ?>
+ <option value="<?php echo $v['id']; ?>"
+ <?php if(Summoner::ifset($TemplateData['editData']['advancedSearchTableFields'], $v['id'])) echo 'selected'; ?>
+ ><?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>
+ </div>
+ </div>
<div class="uk-margin">
<label class="uk-form-label" for="tool">Tools</label>
<div class="uk-form-controls">
$_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();
$_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);