Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2021-03-26 07:51:19 +01:00
commit 8fbb5fe24c
6 changed files with 32 additions and 8 deletions

View File

@ -215,6 +215,8 @@
- add searching for last date of a document status change
- fix a potential problem when remove a document with files attached to
previous versions
- search hits in typeahead search are now links to the folder/document.
Only the first item in the list still opens the search page.
--------------------------------------------------------------------------------
Changes in version 5.1.21

View File

@ -80,7 +80,11 @@ class SeedDMS_Preview_Base {
$pipes = array();
$timeout += time();
$process = proc_open($cmd, $descriptorspec, $pipes);
// Putting an 'exec' before the command will not fork the command
// and therefore not create any child process. proc_terminate will
// then reliably terminate the cmd and not just shell. See notes of
// https://www.php.net/manual/de/function.proc-terminate.php
$process = proc_open('exec '.$cmd, $descriptorspec, $pipes);
if (!is_resource($process)) {
throw new Exception("proc_open failed on: " . $cmd);
}

View File

@ -130,10 +130,22 @@ $(document).ready( function() {
/* updater is called when the item in the list is clicked. It is
* actually provided to update the input field, but here we use
* it to set the document location. The passed value is the string
* set in data-value of the list items. */
* set in data-value of the list items.
* This method relies on some changes in bootstrap-typeahead.js
* Originally, update was passed only the data-value of the li item
* which is set in the render fuction below,
* but the modified version passes all data fields. which also
* contain the 'id' and 'type' (also set in render function).
**/
updater: function (item) {
document.location = "../out/out.Search.php?query=" + encodeURIComponent(item);
return item;
if(item.id) {
if(item.type == 'D')
document.location = "../out/out.ViewDocument.php?documentid=" + item.id;
else
document.location = "../out/out.ViewFolder.php?folderid=" + item.id;
} else
document.location = "../out/out.Search.php?query=" + encodeURIComponent(item.value);
return item.value;
},
sorter: function(items) {
return items;
@ -144,6 +156,10 @@ $(document).ready( function() {
matcher : function (item) {
return true;
},
/* highlighter is for modifying the 'a' tag text. It places an icon
* in front of the name and replaces a '<' within the name with an
* entity.
**/
highlighter : function (item) {
if(item.type.charAt(0) == 'D')
return '<i class="fa fa-file"></i> ' + item.name.replace(/</g, '&lt;');
@ -164,7 +180,7 @@ $(document).ready( function() {
var that = this
items = $(items).map(function (i, item) {
i = $(that.options.item).attr('data-value', item.name)
i = $(that.options.item).attr('data-value', item.name).attr('data-id', item.id).attr('data-type', item.type);
i.find('a').html(that.highlighter(item))
return i[0]
})

View File

@ -46,7 +46,8 @@
constructor: Typeahead
, select: function () {
var val = this.$menu.find('.active').attr('data-value')
// var val = this.$menu.find('.active').attr('data-value')
var val = this.$menu.find('.active').data()
this.$element
.val(this.updater(val))
.change()

View File

@ -1220,6 +1220,7 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$icons["wav"] = "audio.svg";
$icons["mp3"] = "audio.svg";
$icons["m4a"] = "audio.svg";
$icons["ogg"] = "audio.svg";
$icons["opus"] = "audio.svg";
$icons["c"] = "text-x-preview.svg";
$icons["cpp"] = "text-x-preview.svg";

View File

@ -152,10 +152,10 @@ function typeahead() { /* {{{ */
foreach ($entries as $entry) {
if($entry->isType('document')) {
// $recs[] = 'D'.$entry->getName();
$recs[] = array('type'=>'D', 'name'=>$entry->getName());
$recs[] = array('type'=>'D', 'id'=>$entry->getId(), 'name'=>$entry->getName());
} elseif($entry->isType('folder')) {
// $recs[] = 'F'.$entry->getName();
$recs[] = array('type'=>'F', 'name'=>$entry->getName());
$recs[] = array('type'=>'F', 'id'=>$entry->getId(), 'name'=>$entry->getName());
}
}
}