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

This commit is contained in:
Uwe Steinmann 2022-08-24 08:29:36 +02:00
commit 0539945bf1
5 changed files with 150 additions and 60 deletions

View File

@ -595,6 +595,7 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
$view->setParam('accessobject', $accessop);
$view->setParam('query', $query);
$view->setParam('includecontent', $includecontent);
$view->setParam('marks', isset($_GET['marks']) ? $_GET['marks'] : array());
$view->setParam('newowner', $newowner);
$view->setParam('searchhits', $entries);
$view->setParam('totalpages', $totalPages);

View File

@ -1462,7 +1462,7 @@ function getOverallStatusIcon($status) { /* {{{ */
$icon = 'fa fa-question';
break;
}
return '<i class="fa '.$icon.'"'.($color ? ' style="color: '.$color.';"' : '').' title="'.getOverallStatusText($status).'"></i>';
return '<div style="display: inline-block; white-space: nowrap;"><i class="fa '.$icon.'"'.($color ? ' style="color: '.$color.';"' : '').' title="'.getOverallStatusText($status).'"></i> <span class="visible-desktop">'.getOverallStatusText($status).'</span></div>';
}
} /* }}} */

View File

@ -45,10 +45,10 @@ class SeedDMS_View_Search extends SeedDMS_Theme_Style {
*/
function markQuery($str, $tag = "b") { /* {{{ */
$querywords = preg_split("/ /", $this->query);
foreach ($querywords as $queryword)
$str = str_ireplace("($queryword)", "<" . $tag . ">\\1</" . $tag . ">", $str);
return $str;
} /* }}} */
@ -61,16 +61,39 @@ class SeedDMS_View_Search extends SeedDMS_Theme_Style {
$(document).ready( function() {
$('#export').on('click', function(e) {
e.preventDefault();
window.location.href = $(this).attr('href')+'&includecontent='+($('#includecontent').prop('checked') ? '1' : '0');
var url = "";
url = $(this).attr('href')+'&includecontent='+($('#includecontent').prop('checked') ? '1' : '0');
var inputs = $('input[name^=\"marks\"]');
var values = {};
inputs.each(function() {
console.log(this.name+'='+this.checked);
if(this.checked)
values[this.name] = 1;
});
url += '&'+$.param(values);
window.location.href = url;
});
$('#changeowner').on('click', function(e) {
e.preventDefault();
window.location.href = $(this).attr('href')+'&newowner='+($('#newowner').val());
var url = "";
url = $(this).attr('href')+'&newowner='+($('#newowner').val());
var inputs = $('input[name^=\"marks\"]');
var values = {};
inputs.each(function() {
console.log(this.name+'='+this.checked);
if(this.checked)
values[this.name] = 1;
});
url += '&'+$.param(values);
window.location.href = url;
});
});
<?php
// $this->printFolderChooserJs("form1");
$this->printDeleteFolderButtonJs();
$this->printMarkDocumentButtonJs();
$this->printDeleteDocumentButtonJs();
/* Add js for catching click on document in one page mode */
$this->printClickDocumentJs();
@ -83,11 +106,64 @@ $(document).ready(function() {
<?php
} /* }}} */
/**
* Print button with icon for marking a document
*
* @param object $document document to be marked
* @param boolean $return return html instead of printing it
* @return string html content if $return is true, otherwise an empty string
*/
function printMarkDocumentButton($document, $return=false){ /* {{{ */
$docid = $document->getID();
$content = '';
$content .= '<br /><span class="mark-btn document-unmarked" title="'.getMLText('mark_document').'" rel="D'.$docid.'"><i class="fa fa-square-o"></i></span><input type="checkbox" id="marks_D'.$docid.'" name="marks[D'.$docid.']" value="1" style="display: none;">';
if($return)
return $content;
else
echo $content;
return '';
} /* }}} */
/**
* Print button with icon for marking a folder
*
* @param object $folder folder to be marked
* @param boolean $return return html instead of printing it
* @return string html content if $return is true, otherwise an empty string
*/
function printMarkFolderButton($folder, $return=false){ /* {{{ */
$folderid = $folder->getID();
$content = '';
$content .= '<br /><span class="mark-btn folder-unmarked" title="'.getMLText('mark_folder').'" rel="F'.$folderid.'"><i class="fa fa-square-o"></i></span><input type="checkbox" id="marks_F'.$folderid.'" name="marks[F'.$folderid.']" value="1" style="display: none;">';
if($return)
return $content;
else
echo $content;
return '';
} /* }}} */
function printMarkDocumentButtonJs(){ /* {{{ */
$url = $this->html_url('Search', array_merge($_GET, array('action'=>null)));
echo "
// ".$url."
$(document).ready(function () {
$('body').on('click', 'span.mark-btn', function(ev){
ev.stopPropagation();
id = $(ev.currentTarget).attr('rel');
$('#marks_'+id).each(function () { this.checked = !this.checked; });
$(this).parents('tr').toggleClass('table-info');
$(this).find('i').toggleClass('fa-square-o fa-check-square-o')
});
});
";
} /* }}} */
function export() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$entries = $this->params['searchhits'];
$includecontent = $this->params['includecontent'];
$marks = $this->params['marks'];
include("../inc/inc.ClassDownloadMgr.php");
$downmgr = new SeedDMS_Download_Mgr();
@ -95,12 +171,14 @@ $(document).ready(function() {
$downmgr->addHeader($extraheader);
foreach($entries as $entry) {
if($entry->isType('document')) {
$extracols = $this->callHook('extraDownloadColumns', $entry);
$filename = $this->callHook('filenameDownloadItem', $entry->getLatestContent());
if($includecontent && $rawcontent = $this->callHook('rawcontent', $entry->getLatestContent())) {
$downmgr->addItem($entry->getLatestContent(), $extracols, $rawcontent, $filename);
} else
$downmgr->addItem($entry->getLatestContent(), $extracols, null, $filename);
if(empty($marks) || !empty($marks['D'.$entry->getId()])) {
$extracols = $this->callHook('extraDownloadColumns', $entry);
$filename = $this->callHook('filenameDownloadItem', $entry->getLatestContent());
if($includecontent && $rawcontent = $this->callHook('rawcontent', $entry->getLatestContent())) {
$downmgr->addItem($entry->getLatestContent(), $extracols, $rawcontent, $filename);
} else
$downmgr->addItem($entry->getLatestContent(), $extracols, null, $filename);
}
}
}
$filename = tempnam(sys_get_temp_dir(), '');
@ -129,16 +207,18 @@ $(document).ready(function() {
$user = $this->params['user'];
$entries = $this->params['searchhits'];
$newowner = $this->params['newowner'];
$marks = $this->params['marks'];
if($newowner && $user->isAdmin()) {
$j = $i = 0;
foreach($entries as $entry) {
// if($entry->isType('document')) {
$prefix = $entry->isType('document') ? 'D' : 'F';
if(empty($marks) || !empty($marks[$prefix.$entry->getId()])) {
if($entry->getOwner()->getId() != $newowner->getId()) {
$entry->setOwner($newowner);
$j++;
}
// }
}
}
$this->setParam('batchmsg', getMLText('batch_new_owner_msg', ['count'=>$j]));
} else {
@ -210,7 +290,7 @@ function typeahead() { /* {{{ */
$tmp['orderby'] = ($orderby=="d"||$orderby=="da") ? "dd" : "d";
$headcol .= " <a href=\"../out/out.Search.php?".http_build_query($tmp)."\" title=\"".getMLText("sort_by_date")."\">".($orderby=="d"||$orderby=="da"?' <i class="fa fa-sort-amount-asc selected"></i>':($orderby=="dd"?' <i class="fa fa-sort-amount-desc selected"></i>':' <i class="fa fa-sort-amount-asc"></i>'))."</a>";
}
return $headcol;
return $headcol;
} /* }}} */
function show() { /* {{{ */
@ -277,7 +357,7 @@ function typeahead() { /* {{{ */
//$this->contentHeading("<button class=\"btn btn-primary\" id=\"searchform-toggle\" data-toggle=\"collapse\" href=\"#searchform\"><i class=\"fa fa-exchange\"></i></button> ".getMLText('search'), true);
$this->contentHeading(getMLText('search'), true);
if($this->query) {
echo "<div id=\"searchform\" class=\"_collapse mb-sm-4\">";
echo "<div id=\"searchform\" class=\"_collapse mb-sm-4\">";
}
?>
<ul class="nav nav-pills" id="searchtab">
@ -583,53 +663,9 @@ function typeahead() { /* {{{ */
$this->formSubmit("<i class=\"fa fa-search\"></i> ".getMLText('search'));
?>
</form>
<?php
if($totaldocs) {
ob_start();
$this->formField(
getMLText("include_content"),
array(
'element'=>'input',
'type'=>'checkbox',
'name'=>'includecontent',
'id'=>'includecontent',
'value'=>1,
)
);
//$this->formSubmit("<i class=\"fa fa-download\"></i> ".getMLText('export'));
print $this->html_link('Search', array_merge($_GET, array('action'=>'export')), array('class'=>'btn btn-primary', 'id'=>'export'), "<i class=\"fa fa-download\"></i> ".getMLText("export"), false, true)."\n";
$content = ob_get_clean();
$this->printAccordion(getMLText('export'), $content);
}
if($total) {
ob_start();
$users = $dms->getAllUsers();
$options = array();
$options[] = array("-1", getMLText("choose_user"));
foreach ($users as $currUser) {
$options[] = array($currUser->getID(), htmlspecialchars($currUser->getLogin().' - '.$currUser->getFullName()), false, array(array('data-subtitle', htmlspecialchars($currUser->getEmail()))));
}
$this->formField(
null, //getMLText("selection"),
array(
'element'=>'select',
'id'=>'newowner',
'class'=>'chzn-select',
'options'=>$options,
'placeholder'=>getMLText('select_users'),
)
);
print $this->html_link('Search', array_merge($_GET, array('action'=>'changeowner')), array('class'=>'btn btn-primary', 'id'=>'changeowner'), "<i class=\"fa fa-user\"></i> ".getMLText("batch_change_owner"), false, true)."\n";
$content = ob_get_clean();
$this->printAccordion(getMLText('batch_change_owner'), $content);
}
?>
</div>
<?php
// }}}
// }}}
// Fulltext search Form {{{
if($enablefullsearch) {
@ -783,6 +819,54 @@ function typeahead() { /* {{{ */
if($this->query) {
echo "</div>\n";
}
/* Batch operations {{{ */
if($total)
$this->contentHeading(getMLText('batch_operation'));
if($totaldocs) {
ob_start();
$this->formField(
getMLText("include_content"),
array(
'element'=>'input',
'type'=>'checkbox',
'name'=>'includecontent',
'id'=>'includecontent',
'value'=>1,
)
);
//$this->formSubmit("<i class=\"fa fa-download\"></i> ".getMLText('export'));
print $this->html_link('Search', array_merge($_GET, array('action'=>'export')), array('class'=>'btn btn-primary', 'id'=>'export'), "<i class=\"fa fa-download\"></i> ".getMLText("export"), false, true)."\n";
$content = ob_get_clean();
$this->printAccordion(getMLText('export'), $content);
}
if($user->isAdmin() && $total) {
ob_start();
$users = $dms->getAllUsers();
$options = array();
$options[] = array("-1", getMLText("choose_user"));
foreach ($users as $currUser) {
$options[] = array($currUser->getID(), htmlspecialchars($currUser->getLogin().' - '.$currUser->getFullName()), false, array(array('data-subtitle', htmlspecialchars($currUser->getEmail()))));
}
$this->formField(
null, //getMLText("selection"),
array(
'element'=>'select',
'id'=>'newowner',
'class'=>'chzn-select',
'options'=>$options,
'placeholder'=>getMLText('select_users'),
)
);
print $this->html_link('Search', array_merge($_GET, array('action'=>'changeowner')), array('class'=>'btn btn-primary', 'id'=>'changeowner'), "<i class=\"fa fa-user\"></i> ".getMLText("batch_change_owner"), false, true)."\n";
$content = ob_get_clean();
$this->printAccordion(getMLText('batch_change_owner'), $content);
}
// }}}
?>
<?php
$this->columnEnd();
$this->columnStart(8);
if($batchmsg = $this->getParam('batchmsg')) {
@ -878,6 +962,7 @@ function typeahead() { /* {{{ */
$extracontent['below_title'] = $this->getListRowPath($document);
if($attrstr)
$extracontent['bottom_title'] = '<br />'.$this->printPopupBox('<span class="btn btn-mini btn-sm btn-secondary">'.getMLText('attributes').'</span>', $attrstr, true);
$extracontent['end_action_list'] = $this->printMarkDocumentButton($document, true);
$txt = $this->callHook('documentListItem', $entry, $previewer, false, 'search', $extracontent);
if(is_string($txt))
@ -907,6 +992,7 @@ function typeahead() { /* {{{ */
$extracontent['below_title'] = $this->getListRowPath($folder);
if($attrstr)
$extracontent['bottom_title'] = '<br />'.$this->printPopupBox('<span class="btn btn-mini btn-sm btn-secondary">'.getMLText('attributes').'</span>', $attrstr, true);
$extracontent['end_action_list'] = $this->printMarkFolderButton($folder, true);
print $this->folderListRow($folder, false, $extracontent);
}
}

View File

@ -434,6 +434,9 @@ ul.qq-upload-list li span {
width: 900px;
margin-left: -450px;
}
.modal-wide .modal-body {
max-height: 642px;
}
}
@media (max-width: 480px) {

View File

@ -1386,7 +1386,7 @@ function getOverallStatusIcon($status) { /* {{{ */
$icon = 'fa fa-question';
break;
}
return '<i class="fa '.$icon.'"'.($color ? ' style="color: '.$color.';"' : '').' title="'.getOverallStatusText($status).'"></i>';
return '<div style="display: inline-block; white-space: nowrap;"><i class="fa '.$icon.'"'.($color ? ' style="color: '.$color.';"' : '').' title="'.getOverallStatusText($status).'"></i> <span class="d-none d-md-inline-block">'.getOverallStatusText($status).'</span></div>';
}
} /* }}} */