seeddms-code/views/bootstrap/class.Search.php

740 lines
29 KiB
PHP
Raw Normal View History

2012-12-14 07:53:13 +00:00
<?php
/**
* Implementation of Search result view
*
* @category DMS
* @package SeedDMS
2012-12-14 07:53:13 +00:00
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2002-2005 Markus Westphal,
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
* 2010-2012 Uwe Steinmann
* @version Release: @package_version@
*/
/**
* Include parent class
*/
//require_once("class.Bootstrap.php");
2012-12-14 07:53:13 +00:00
/**
* Include class to preview documents
*/
require_once("SeedDMS/Preview.php");
2012-12-14 07:53:13 +00:00
/**
* Class which outputs the html page for Search result view
*
* @category DMS
* @package SeedDMS
2012-12-14 07:53:13 +00:00
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2002-2005 Markus Westphal,
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
* 2010-2012 Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_View_Search extends SeedDMS_Theme_Style {
2012-12-14 07:53:13 +00:00
/**
* Mark search query sting in a given string
*
* @param string $str mark this text
* @param string $tag wrap the marked text with this html tag
* @return string marked text
*/
function markQuery($str, $tag = "b") { /* {{{ */
$querywords = preg_split("/ /", $this->query);
foreach ($querywords as $queryword)
$str = str_ireplace("($queryword)", "<" . $tag . ">\\1</" . $tag . ">", $str);
return $str;
} /* }}} */
2015-12-14 08:53:42 +00:00
function js() { /* {{{ */
header('Content-Type: application/javascript; charset=UTF-8');
parent::jsTranslations(array('cancel', 'splash_move_document', 'confirm_move_document', 'move_document', 'confirm_transfer_link_document', 'transfer_content', 'link_document', 'splash_move_folder', 'confirm_move_folder', 'move_folder'));
2015-12-14 08:53:42 +00:00
// $this->printFolderChooserJs("form1");
2015-12-14 08:53:42 +00:00
$this->printDeleteFolderButtonJs();
$this->printDeleteDocumentButtonJs();
2020-02-28 08:48:43 +00:00
/* Add js for catching click on document in one page mode */
$this->printClickDocumentJs();
$this->printClickFolderJs();
2021-05-06 20:22:37 +00:00
?>
$(document).ready(function() {
$('body').on('submit', '#form1', function(ev){
});
});
<?php
2015-12-14 08:53:42 +00:00
} /* }}} */
function opensearchsuggestion() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$query = $this->params['query'];
$entries = $this->params['searchhits'];
$recs = array();
$content = "<?xml version=\"1.0\"?>\n";
$content .= "<SearchSuggestion version=\"2.0\" xmlns=\"http://opensearch.org/searchsuggest2\">\n";
$content .= "<Query xml:space=\"preserve\">".$query."</Query>";
if($entries) {
$content .= "<Section>\n";
foreach ($entries as $entry) {
$content .= "<Item>\n";
if($entry->isType('document')) {
$content .= "<Text xml:space=\"preserve\">".$entry->getName()."</Text>\n";
$content .= "<Url xml:space=\"preserve\">http:".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$entry->getId()."</Url>\n";
} elseif($entry->isType('folder')) {
$content .= "<Text xml:space=\"preserve\">".$entry->getName()."</Text>\n";
$content .= "<Url xml:space=\"preserve\">http:".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$entry->getId()."</Url>\n";
}
$content .= "</Item>\n";
}
$content .= "</Section>\n";
}
$content .= "</SearchSuggestion>";
header("Content-Disposition: attachment; filename=\"search.xml\"; filename*=UTF-8''search.xml");
header('Content-Type: application/x-suggestions+xml');
echo $content;
} /* }}} */
function typeahead() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$query = $this->params['query'];
$entries = $this->params['searchhits'];
$recs = array();
if($entries) {
foreach ($entries as $entry) {
if($entry->isType('document')) {
// $recs[] = 'D'.$entry->getName();
$recs[] = array('type'=>'D', 'id'=>$entry->getId(), 'name'=>$entry->getName());
} elseif($entry->isType('folder')) {
// $recs[] = 'F'.$entry->getName();
$recs[] = array('type'=>'F', 'id'=>$entry->getId(), 'name'=>$entry->getName());
}
}
}
array_unshift($recs, array('type'=>'S', 'name'=>$query));
header('Content-Type: application/json');
echo json_encode($recs);
} /* }}} */
public function folderListHeaderName() { /* {{{ */
$orderby = $this->params['orderby'];
$fullsearch = $this->params['fullsearch'];
parse_str($_SERVER['QUERY_STRING'], $tmp);
$tmp['orderby'] = ($orderby=="n"||$orderby=="na") ? "nd" : "n";
$headcol = getMLText("name");
if(!$fullsearch) {
$headcol .= $orderby." <a href=\"../out/out.Search.php?".http_build_query($tmp)."\" title=\"".getMLText("sort_by_name")."\">".($orderby=="n"||$orderby=="na"?' <i class="fa fa-sort-alpha-asc selected"></i>':($orderby=="nd"?' <i class="fa fa-sort-alpha-desc selected"></i>':' <i class="fa fa-sort-alpha-asc"></i>'))."</a>";
$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;
} /* }}} */
2012-12-14 07:53:13 +00:00
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$fullsearch = $this->params['fullsearch'];
$total = $this->params['total'];
$totaldocs = $this->params['totaldocs'];
$totalfolders = $this->params['totalfolders'];
$attrdefs = $this->params['attrdefs'];
$allCats = $this->params['allcategories'];
$allUsers = $this->params['allusers'];
$mode = $this->params['mode'];
2015-06-08 07:15:33 +00:00
$resultmode = $this->params['resultmode'];
$workflowmode = $this->params['workflowmode'];
$enablefullsearch = $this->params['enablefullsearch'];
$enableclipboard = $this->params['enableclipboard'];
$attributes = $this->params['attributes'];
$categories = $this->params['categories'];
$category = $this->params['category'];
$mimetype = $this->params['mimetype'];
$owner = $this->params['owner'];
$startfolder = $this->params['startfolder'];
2021-05-05 11:47:38 +00:00
$createstartdate = $this->params['createstartdate'];
$createenddate = $this->params['createenddate'];
$expstartdate = $this->params['expstartdate'];
2021-05-05 11:47:38 +00:00
$expenddate = $this->params['expenddate'];
$statusstartdate = $this->params['statusstartdate'];
2021-05-05 11:47:38 +00:00
$statusenddate = $this->params['statusenddate'];
$creationdate = $this->params['creationdate'];
$expirationdate = $this->params['expirationdate'];
$statusdate = $this->params['statusdate'];
$status = $this->params['status'];
$record_type = $this->params['recordtype'];
$this->query = $this->params['query'];
$orderby = $this->params['orderby'];
2012-12-14 07:53:13 +00:00
$entries = $this->params['searchhits'];
$facets = $this->params['facets'];
2012-12-14 07:53:13 +00:00
$totalpages = $this->params['totalpages'];
$pageNumber = $this->params['pagenumber'];
$searchTime = $this->params['searchtime'];
$urlparams = $this->params['urlparams'];
$searchin = $this->params['searchin'];
$cachedir = $this->params['cachedir'];
2014-04-10 19:38:33 +00:00
$previewwidth = $this->params['previewWidthList'];
2016-02-15 09:57:37 +00:00
$timeout = $this->params['timeout'];
2019-01-18 12:07:39 +00:00
$xsendfile = $this->params['xsendfile'];
2012-12-14 07:53:13 +00:00
$this->htmlStartPage(getMLText("search_results"));
2013-06-07 13:26:47 +00:00
$this->globalNavigation();
2012-12-14 07:53:13 +00:00
$this->contentStart();
$this->pageNavigation("", "");
2012-12-14 07:53:13 +00:00
$this->rowStart();
$this->columnStart(4);
//$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);
2021-05-06 20:22:37 +00:00
if($this->query) {
echo "<div id=\"searchform\" class=\"_collapse mb-sm-4\">";
2021-05-06 20:22:37 +00:00
}
?>
2021-05-05 11:47:38 +00:00
<ul class="nav nav-pills" id="searchtab">
<li class="nav-item <?php echo ($fullsearch == false) ? 'active' : ''; ?>"><a class="nav-link <?php echo ($fullsearch == false) ? 'active' : ''; ?>" data-target="#database" data-toggle="tab"><?php printMLText('databasesearch'); ?></a></li>
<?php
if($enablefullsearch) {
?>
<li class="nav-item <?php echo ($fullsearch == true) ? 'active' : ''; ?>"><a class="nav-link <?php echo ($fullsearch == true) ? 'active' : ''; ?>" data-target="#fulltext" data-toggle="tab"><?php printMLText('fullsearch'); ?></a></li>
<?php
}
?>
</ul>
<div class="tab-content">
<div class="tab-pane <?php echo ($fullsearch == false) ? 'active' : ''; ?>" id="database">
<form class="form-horizontal" action="<?= $this->params['settings']->_httpRoot ?>out/out.Search.php" name="form1">
<input type="hidden" name="fullsearch" value="0" />
<?php
// Database search Form {{{
$this->contentContainerStart();
2021-05-05 11:47:38 +00:00
$this->formField(
getMLText("search_query"),
array(
'element'=>'input',
'type'=>'text',
2021-05-05 11:47:38 +00:00
'name'=>'query',
'value'=>htmlspecialchars($this->query)
)
);
$options = array();
$options[] = array('1', getMLText('search_mode_and'), $mode=='AND');
$options[] = array('0', getMLText('search_mode_or'), $mode=='OR');
$this->formField(
getMLText("search_mode"),
array(
'element'=>'select',
'name'=>'mode',
'multiple'=>false,
'options'=>$options
)
);
$options = array();
$options[] = array('1', getMLText('keywords').' ('.getMLText('documents_only').')', in_array('1', $searchin));
$options[] = array('2', getMLText('name'), in_array('2', $searchin));
$options[] = array('3', getMLText('comment'), in_array('3', $searchin));
$options[] = array('4', getMLText('attributes'), in_array('4', $searchin));
$options[] = array('5', getMLText('id'), in_array('5', $searchin));
$this->formField(
getMLText("search_in"),
array(
'element'=>'select',
'name'=>'searchin[]',
'class'=>'chzn-select',
'multiple'=>true,
'options'=>$options
)
);
$options = array();
2021-11-08 11:25:34 +00:00
$options[] = array('', getMLText('orderby_unsorted'));
$options[] = array('dd', getMLText('orderby_date_desc'), 'dd'==$orderby);
$options[] = array('d', getMLText('orderby_date_asc'), 'd'==$orderby);
$options[] = array('nd', getMLText('orderby_name_desc'), 'nd'==$orderby);
$options[] = array('n', getMLText('orderby_name_asc'), 'n'==$orderby);
$options[] = array('id', getMLText('orderby_id_desc'), 'id'==$orderby);
$options[] = array('i', getMLText('orderby_id_asc'), 'i'==$orderby);
$this->formField(
getMLText("orderby"),
array(
'element'=>'select',
'name'=>'orderby',
'class'=>'chzn-select',
'multiple'=>false,
'options'=>$options
)
);
$options = array();
2021-05-05 11:47:38 +00:00
foreach ($allUsers as $currUser) {
2021-06-14 15:20:16 +00:00
if($user->isAdmin() || (!$currUser->isGuest() && (!$currUser->isHidden() || $currUser->getID() == $user->getID())))
2021-05-05 11:47:38 +00:00
$options[] = array($currUser->getID(), htmlspecialchars($currUser->getLogin()), in_array($currUser->getID(), $owner), array(array('data-subtitle', htmlspecialchars($currUser->getFullName()))));
}
$this->formField(
getMLText("owner"),
array(
'element'=>'select',
'name'=>'owner[]',
'class'=>'chzn-select',
'multiple'=>true,
'options'=>$options
)
);
$options = array();
$options[] = array('1', getMLText('search_mode_documents'), $resultmode==1);
$options[] = array('2', getMLText('search_mode_folders'), $resultmode==2);
$options[] = array('3', getMLText('search_resultmode_both'), $resultmode==3);
$this->formField(
getMLText("search_resultmode"),
array(
'element'=>'select',
'name'=>'resultmode',
'multiple'=>false,
'options'=>$options
)
);
$this->formField(getMLText("under_folder"), $this->getFolderChooserHtml("form1", M_READ, -1, $startfolder));
$this->formField(
getMLText("creation_date")." (".getMLText('from').")",
$this->getDateChooser($createstartdate, "createstart", $this->params['session']->getLanguage())
);
$this->formField(
getMLText("creation_date")." (".getMLText('to').")",
$this->getDateChooser($createenddate, "createend", $this->params['session']->getLanguage())
);
if($attrdefs) {
foreach($attrdefs as $attrdef) {
if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_all) {
2021-05-05 11:47:38 +00:00
if($attrdef->getType() == SeedDMS_Core_AttributeDefinition::type_date) {
$this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('from').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['from']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['from'])) : '', 'attributes', true, 'from'));
$this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('to').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['to']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['to'])) : '', 'attributes', true, 'to'));
} else
$this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, isset($attributes[$attrdef->getID()]) ? $attributes[$attrdef->getID()] : '', 'attributes', true));
}
}
}
2014-07-23 18:12:55 +00:00
$this->contentContainerEnd();
/* First check if any of the folder filters are set. If it is,
* open the accordion.
*/
$openfilterdlg = false;
if($attrdefs) {
foreach($attrdefs as $attrdef) {
if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_document || $attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_documentcontent) {
if(!empty($attributes[$attrdef->getID()]))
$openfilterdlg = true;
}
}
}
2021-05-05 11:47:38 +00:00
if($categories)
2014-07-23 18:12:55 +00:00
$openfilterdlg = true;
if($status)
$openfilterdlg = true;
if($expirationdate)
$openfilterdlg = true;
if($statusdate)
$openfilterdlg = true;
2021-05-05 11:47:38 +00:00
/* Start of fields only applicable to documents */
ob_start();
$tmpcatids = array();
foreach($categories as $tmpcat)
$tmpcatids[] = $tmpcat->getID();
2021-05-05 11:47:38 +00:00
$options = array();
$allcategories = $dms->getDocumentCategories();
foreach($allcategories as $acategory) {
$options[] = array($acategory->getID(), $acategory->getName(), in_array($acategory->getId(), $tmpcatids));
}
2021-05-05 11:47:38 +00:00
$this->formField(
getMLText("categories"),
array(
'element'=>'select',
'class'=>'chzn-select',
'name'=>'category[]',
'multiple'=>true,
'attributes'=>array(array('data-placeholder', getMLText('select_category'), array('data-no_results_text', getMLText('unknown_document_category')))),
'options'=>$options
)
);
$options = array();
if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') {
if($workflowmode == 'traditional') {
$options[] = array(S_DRAFT_REV, getOverallStatusText(S_DRAFT_REV), in_array(S_DRAFT_REV, $status));
}
} elseif($workflowmode == 'advanced') {
$options[] = array(S_IN_WORKFLOW, getOverallStatusText(S_IN_WORKFLOW), in_array(S_IN_WORKFLOW, $status));
}
$options[] = array(S_DRAFT_APP, getOverallStatusText(S_DRAFT_APP), in_array(S_DRAFT_APP, $status));
$options[] = array(S_RELEASED, getOverallStatusText(S_RELEASED), in_array(S_RELEASED, $status));
$options[] = array(S_REJECTED, getOverallStatusText(S_REJECTED), in_array(S_REJECTED, $status));
$options[] = array(S_EXPIRED, getOverallStatusText(S_EXPIRED), in_array(S_EXPIRED, $status));
$options[] = array(S_OBSOLETE, getOverallStatusText(S_OBSOLETE), in_array(S_OBSOLETE, $status));
$this->formField(
getMLText("status"),
array(
'element'=>'select',
'class'=>'chzn-select',
'name'=>'status[]',
'multiple'=>true,
'attributes'=>array(array('data-placeholder', getMLText('select_status')), array('data-no_results_text', getMLText('unknown_status'))),
'options'=>$options
)
);
$this->formField(
getMLText("expires")." (".getMLText('from').")",
$this->getDateChooser($expstartdate, "expirationstart", $this->params['session']->getLanguage())
);
$this->formField(
getMLText("expires")." (".getMLText('to').")",
$this->getDateChooser($expenddate, "expirationend", $this->params['session']->getLanguage())
);
$this->formField(
getMLText("status_change")." (".getMLText('from').")",
$this->getDateChooser($statusstartdate, "statusdatestart", $this->params['session']->getLanguage())
);
$this->formField(
getMLText("status_change")." (".getMLText('to').")",
$this->getDateChooser($statusenddate, "statusdateend", $this->params['session']->getLanguage())
);
2014-07-23 18:12:55 +00:00
if($attrdefs) {
foreach($attrdefs as $attrdef) {
if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_document || $attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_documentcontent) {
2021-05-05 11:47:38 +00:00
if($attrdef->getType() == SeedDMS_Core_AttributeDefinition::type_date) {
$this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('from').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['from']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['from'])) : '', 'attributes', true, 'from'));
$this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('to').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['to']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['to'])) : '', 'attributes', true, 'to'));
} else
$this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, isset($attributes[$attrdef->getID()]) ? $attributes[$attrdef->getID()] : '', 'attributes', true));
2014-07-23 18:12:55 +00:00
}
}
}
?>
<?php
2021-05-05 11:47:38 +00:00
$content = ob_get_clean();
$this->printAccordion(getMLText('filter_for_documents'), $content);
2014-07-23 18:12:55 +00:00
/* First check if any of the folder filters are set. If it is,
* open the accordion.
*/
$openfilterdlg = false;
if($attrdefs) {
foreach($attrdefs as $attrdef) {
if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_folder) {
if(!empty($attributes[$attrdef->getID()]))
$openfilterdlg = true;
}
}
}
2021-05-05 11:47:38 +00:00
ob_start();
2014-07-23 18:12:55 +00:00
if($attrdefs) {
foreach($attrdefs as $attrdef) {
if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_folder) {
2021-05-05 11:47:38 +00:00
if($attrdef->getType() == SeedDMS_Core_AttributeDefinition::type_date) {
$this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('from').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['from']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['from'])) : '', 'attributes', true, 'from'));
$this->formField(htmlspecialchars($attrdef->getName().' ('.getMLText('to').')'), $this->getAttributeEditField($attrdef, !empty($attributes[$attrdef->getID()]['to']) ? getReadableDate(makeTsFromDate($attributes[$attrdef->getID()]['to'])) : '', 'attributes', true, 'to'));
} else
$this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, isset($attributes[$attrdef->getID()]) ? $attributes[$attrdef->getID()] : '', 'attributes', true));
2014-07-23 18:12:55 +00:00
}
}
}
2021-05-05 11:47:38 +00:00
$content = ob_get_clean();
2021-12-03 09:49:27 +00:00
if($content)
$this->printAccordion(getMLText('filter_for_folders'), $content);
// }}}
2021-12-03 09:49:27 +00:00
$this->formSubmit("<i class=\"fa fa-search\"></i> ".getMLText('search'));
?>
2014-07-23 18:12:55 +00:00
</form>
</div>
<?php
if($enablefullsearch) {
echo "<div class=\"tab-pane ".(($fullsearch == true) ? 'active' : '')."\" id=\"fulltext\">\n";
?>
2021-12-03 09:49:27 +00:00
<form class="form-horizontal" action="<?= $this->params['settings']->_httpRoot ?>out/out.Search.php" name="form2" style="min-height: 330px;">
<input type="hidden" name="fullsearch" value="1" />
<?php
2021-05-05 11:47:38 +00:00
$this->contentContainerStart();
$this->formField(
getMLText("search_query"),
array(
'element'=>'input',
'type'=>'text',
2021-05-05 11:47:38 +00:00
'name'=>'query',
'value'=>htmlspecialchars($this->query)
)
);
$this->formField(getMLText("under_folder"), $this->getFolderChooserHtml("form1", M_READ, -1, $startfolder, 'folderfullsearchid'));
if(!isset($facets['owner'])) {
$options = array();
foreach ($allUsers as $currUser) {
if($user->isAdmin() || (!$currUser->isGuest() && (!$currUser->isHidden() || $currUser->getID() == $user->getID())))
$options[] = array($currUser->getID(), htmlspecialchars($currUser->getLogin()), in_array($currUser->getID(), $owner), array(array('data-subtitle', htmlspecialchars($currUser->getFullName()))));
}
$this->formField(
getMLText("owner"),
array(
'element'=>'select',
'name'=>'owner[]',
'class'=>'chzn-select',
'multiple'=>true,
'options'=>$options
)
);
}
if(!isset($facets['category'])) {
$tmpcatids = array();
foreach($categories as $tmpcat)
$tmpcatids[] = $tmpcat->getID();
$options = array();
$allcategories = $dms->getDocumentCategories();
foreach($allcategories as $acategory) {
$options[] = array($acategory->getID(), $acategory->getName(), in_array($acategory->getId(), $tmpcatids));
}
$this->formField(
getMLText("category_filter"),
array(
'element'=>'select',
'class'=>'chzn-select',
'name'=>'category[]',
'multiple'=>true,
'attributes'=>array(array('data-placeholder', getMLText('select_category'), array('data-no_results_text', getMLText('unknown_document_category')))),
'options'=>$options
)
);
2021-05-05 11:47:38 +00:00
}
if(!isset($facets['status'])) {
$options = array();
if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') {
if($workflowmode == 'traditional') {
$options[] = array(S_DRAFT_REV, getOverallStatusText(S_DRAFT_REV), in_array(S_DRAFT_REV, $status));
}
} elseif($workflowmode == 'advanced') {
$options[] = array(S_IN_WORKFLOW, getOverallStatusText(S_IN_WORKFLOW), in_array(S_IN_WORKFLOW, $status));
}
$options[] = array(S_DRAFT_APP, getOverallStatusText(S_DRAFT_APP), in_array(S_DRAFT_APP, $status));
$options[] = array(S_RELEASED, getOverallStatusText(S_RELEASED), in_array(S_RELEASED, $status));
$options[] = array(S_REJECTED, getOverallStatusText(S_REJECTED), in_array(S_REJECTED, $status));
$options[] = array(S_EXPIRED, getOverallStatusText(S_EXPIRED), in_array(S_EXPIRED, $status));
$options[] = array(S_OBSOLETE, getOverallStatusText(S_OBSOLETE), in_array(S_OBSOLETE, $status));
$this->formField(
getMLText("status"),
array(
'element'=>'select',
'class'=>'chzn-select',
'name'=>'status[]',
'multiple'=>true,
'attributes'=>array(array('data-placeholder', getMLText('select_status')), array('data-no_results_text', getMLText('unknown_status'))),
'options'=>$options
)
);
2021-05-05 11:47:38 +00:00
}
if($facets) {
foreach($facets as $facetname=>$values) {
$multiple = true;
// if(in_array($facetname, ['owner', 'status', 'mimetype']))
// $multiple = false;
$options = array();
if($facetname == 'owner') {
foreach($values as $v=>$c) {
$uu = $dms->getUserByLogin($v);
if($uu) {
$option = array($uu->getId(), $v.' ('.$c.')');
if(isset(${$facetname}) && in_array($uu->getId(), ${$facetname}))
$option[] = true;
$options[] = $option;
}
}
} elseif($facetname == 'category') {
foreach($values as $v=>$c) {
$cat = $dms->getDocumentCategoryByName($v);
if($cat) {
$option = array($cat->getId(), $v.' ('.$c.')');
if(isset(${$facetname}) && in_array($cat->getId(), ${$facetname}))
$option[] = true;
$options[] = $option;
}
}
} elseif($facetname == 'status') {
foreach($values as $v=>$c) {
$option = array($v, getOverallStatusText($v).' ('.$c.')');
if(isset(${$facetname}) && in_array($v, ${$facetname}))
$option[] = true;
$options[] = $option;
}
} else {
foreach($values as $v=>$c) {
$option = array($v, $v.' ('.$c.')');
if(isset(${$facetname}) && in_array($v, ${$facetname}))
$option[] = true;
$options[] = $option;
}
}
$this->formField(
getMLText($facetname),
array(
'element'=>'select',
'id'=>$facetname,
'name'=>$facetname."[]",
'class'=>'chzn-select',
'attributes'=>array(array('data-placeholder', getMLText('select_'.$facetname)), array('data-allow-clear', 'true')),
'options'=>$options,
'multiple'=>$multiple
)
);
}
}
$this->contentContainerEnd();
$this->formSubmit("<i class=\"fa fa-search\"></i> ".getMLText('search'));
?>
</form>
<?php
echo "</div>\n";
}
?>
</div>
<?php
2021-06-14 15:23:42 +00:00
if($this->query) {
echo "</div>\n";
}
$this->columnEnd();
$this->columnStart(8);
$this->contentHeading(getMLText('search_results'));
// Search Result {{{
$foldercount = $doccount = 0;
2012-12-14 07:53:13 +00:00
if($entries) {
/*
foreach ($entries as $entry) {
2019-08-08 07:16:06 +00:00
if($entry->isType('document')) {
$doccount++;
2019-08-08 07:16:06 +00:00
} elseif($entry->isType('document')) {
$foldercount++;
}
}
*/
echo $this->infoMsg(getMLText("search_report", array("count"=>$total, "doccount" => $totaldocs, "foldercount" => $totalfolders, 'searchtime'=>$searchTime)));
$this->pageList($pageNumber, $totalpages, "../out/out.Search.php", $urlparams);
2014-06-11 09:02:50 +00:00
// $this->contentContainerStart();
2012-12-14 07:53:13 +00:00
$txt = $this->callHook('searchListHeader', $orderby, 'asc');
if(is_string($txt)) {
2017-03-02 19:00:56 +00:00
echo $txt;
} elseif(is_array($txt)) {
2021-05-05 11:47:38 +00:00
print "<table class=\"table table-condensed table-sm table-hover\">";
2017-03-02 19:00:56 +00:00
print "<thead>\n<tr>\n";
foreach($txt as $headcol)
echo "<th>".$headcol."</th>\n";
print "</tr>\n</thead>\n";
} else {
echo $this->folderListHeader(null, 'search');
2017-03-02 19:00:56 +00:00
}
print "<tbody>\n";
2012-12-14 07:53:13 +00:00
2019-01-18 12:07:39 +00:00
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
2012-12-14 07:53:13 +00:00
foreach ($entries as $entry) {
2019-08-08 07:16:06 +00:00
if($entry->isType('document')) {
$document = $entry;
if($lc = $document->getLatestContent())
$previewer->createPreview($lc);
$lcattributes = $lc ? $lc->getAttributes() : null;
$attrstr = '';
if($lcattributes) {
$attrstr .= "<table class=\"table table-condensed table-sm\">\n";
$attrstr .= "<tr><th>".getMLText('name')."</th><th>".getMLText('attribute_value')."</th></tr>";
foreach($lcattributes as $lcattribute) {
$arr = $this->callHook('showDocumentContentAttribute', $lc, $lcattribute);
if(is_array($arr)) {
$attrstr .= "<tr>";
$attrstr .= "<td>".$arr[0].":</td>";
$attrstr .= "<td>".$arr[1]."</td>";
$attrstr .= "</tr>";
} elseif(is_string($arr)) {
$attrstr .= $arr;
} else {
$attrdef = $lcattribute->getAttributeDefinition();
$attrstr .= "<tr><td>".htmlspecialchars($attrdef->getName())."</td><td>".htmlspecialchars(implode(', ', $lcattribute->getValueAsArray()))."</td></tr>\n";
// TODO: better use printAttribute()
// $this->printAttribute($lcattribute);
}
}
$attrstr .= "</table>\n";
}
$docattributes = $document->getAttributes();
if($docattributes) {
$attrstr .= "<table class=\"table table-condensed table-sm\">\n";
$attrstr .= "<tr><th>".getMLText('name')."</th><th>".getMLText('attribute_value')."</th></tr>";
foreach($docattributes as $docattribute) {
$arr = $this->callHook('showDocumentAttribute', $document, $docattribute);
if(is_array($arr)) {
$attrstr .= "<tr>";
$attrstr .= "<td>".$arr[0].":</td>";
$attrstr .= "<td>".$arr[1]."</td>";
$attrstr .= "</tr>";
} elseif(is_string($arr)) {
$attrstr .= $arr;
} else {
$attrdef = $docattribute->getAttributeDefinition();
$attrstr .= "<tr><td>".htmlspecialchars($attrdef->getName())."</td><td>".htmlspecialchars(implode(', ', $docattribute->getValueAsArray()))."</td></tr>\n";
}
}
$attrstr .= "</table>\n";
}
$extracontent = array();
$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);
$txt = $this->callHook('documentListItem', $entry, $previewer, false, 'search', $extracontent);
if(is_string($txt))
echo $txt;
else {
print $this->documentListRow($document, $previewer, false, 0, $extracontent);
2013-07-31 19:44:46 +00:00
}
2019-08-08 07:16:06 +00:00
} elseif($entry->isType('folder')) {
2020-12-13 13:45:55 +00:00
$txt = $this->callHook('folderListItem', $entry, false, 'search');
if(is_string($txt))
echo $txt;
else {
2012-12-14 07:53:13 +00:00
$folder = $entry;
$attrstr = '';
$folderattributes = $folder->getAttributes();
if($folderattributes) {
2021-05-05 11:47:38 +00:00
$attrstr .= "<table class=\"table table-condensed table-sm\">\n";
$attrstr .= "<tr><th>".getMLText('name')."</th><th>".getMLText('attribute_value')."</th></tr>";
foreach($folderattributes as $folderattribute) {
$attrdef = $folderattribute->getAttributeDefinition();
$attrstr .= "<tr><td>".htmlspecialchars($attrdef->getName())."</td><td>".htmlspecialchars(implode(', ', $folderattribute->getValueAsArray()))."</td></tr>\n";
}
$attrstr .= "</table>";
}
$extracontent = array();
2021-04-22 07:59:37 +00:00
$extracontent['below_title'] = $this->getListRowPath($folder);
if($attrstr)
2021-05-05 11:47:38 +00:00
$extracontent['bottom_title'] = '<br />'.$this->printPopupBox('<span class="btn btn-mini btn-sm btn-secondary">'.getMLText('attributes').'</span>', $attrstr, true);
print $this->folderListRow($folder, false, $extracontent);
2020-12-13 13:45:55 +00:00
}
2012-12-14 07:53:13 +00:00
}
}
print "</tbody></table>\n";
2014-06-11 09:02:50 +00:00
// $this->contentContainerEnd();
$this->pageList($pageNumber, $totalpages, "../out/out.Search.php", $_GET);
2012-12-14 07:53:13 +00:00
} else {
$numResults = $totaldocs + $totalfolders;
2012-12-14 07:53:13 +00:00
if ($numResults == 0) {
2021-05-05 11:47:38 +00:00
echo $this->warningMsg(getMLText("search_no_results"));
2012-12-14 07:53:13 +00:00
}
}
// }}}
$this->columnEnd();
$this->rowEnd();
$this->contentEnd();
2012-12-14 07:53:13 +00:00
$this->htmlEndPage();
} /* }}} */
}
?>