mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 00:45:34 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
337c0ed41f
|
@ -69,6 +69,7 @@ if (isset($_GET["removecategory"]) && is_numeric($_GET["removecategory"]) && $_G
|
|||
$terms = [];
|
||||
$limit = (isset($_GET["limit"]) && is_numeric($_GET["limit"])) ? (int) $_GET['limit'] : 20;
|
||||
$fullsearch = ((!isset($_GET["fullsearch"]) && $settings->_defaultSearchMethod == 'fulltext') || !empty($_GET["fullsearch"])) && $settings->_enableFullSearch;
|
||||
$facetsearch = !empty($_GET["facetsearch"]) && $settings->_enableFullSearch;
|
||||
if($fullsearch) {
|
||||
// Search in Fulltext {{{
|
||||
if (isset($_GET["query"]) && is_string($_GET["query"])) {
|
||||
|
@ -88,9 +89,13 @@ if($fullsearch) {
|
|||
$category = $_GET['category'];
|
||||
foreach($_GET['category'] as $catid) {
|
||||
if($catid) {
|
||||
if($cat = $dms->getDocumentCategory($catid)) {
|
||||
$categories[] = $cat;
|
||||
$categorynames[] = $cat->getName();
|
||||
if(is_numeric($catid)) {
|
||||
if($cat = $dms->getDocumentCategory($catid)) {
|
||||
$categories[] = $cat;
|
||||
$categorynames[] = $cat->getName();
|
||||
}
|
||||
} else {
|
||||
$categorynames[] = $catid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,17 +125,25 @@ if($fullsearch) {
|
|||
// document owner.
|
||||
$owner = [];
|
||||
$ownernames = [];
|
||||
if (isset($_GET["owner"])) {
|
||||
if(!empty($_GET["owner"])) {
|
||||
$owner = $_GET['owner'];
|
||||
if (!is_array($_GET['owner'])) {
|
||||
if(!empty($_GET['owner']) && $o = $dms->getUser($_GET['owner']))
|
||||
$ownernames[] = $o->getLogin();
|
||||
else
|
||||
UI::exitError(getMLText("search"),getMLText("unknown_owner"));
|
||||
if(is_numeric($_GET['owner'])) {
|
||||
if($o = $dms->getUser($_GET['owner']))
|
||||
$ownernames[] = $o->getLogin();
|
||||
} else {
|
||||
$ownernames[] = $_GET['owner'];
|
||||
}
|
||||
} else {
|
||||
foreach($_GET["owner"] as $l) {
|
||||
if($l && $o = $dms->getUser($l))
|
||||
$ownernames[] = $o->getLogin();
|
||||
if($l) {
|
||||
if(is_numeric($l)) {
|
||||
if($o = $dms->getUser($l))
|
||||
$ownernames[] = $o->getLogin();
|
||||
} else {
|
||||
$ownernames[] = $l;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +231,9 @@ if($fullsearch) {
|
|||
$index = $fulltextservice->Indexer();
|
||||
if($index) {
|
||||
if(!empty($settings->_suggestTerms) && !empty($_GET['query'])) {
|
||||
$terms = $index->terms($_GET['query'], $settings->_suggestTerms);
|
||||
$st = preg_split("/[\s,]+/", trim($_GET['query']));
|
||||
if($lastterm = end($st))
|
||||
$terms = $index->terms($lastterm, $settings->_suggestTerms);
|
||||
}
|
||||
$lucenesearch = $fulltextservice->Search();
|
||||
$searchresult = $lucenesearch->search($query, array('record_type'=>$record_type, 'owner'=>$ownernames, 'status'=>$status, 'category'=>$categorynames, 'user'=>$user->isAdmin() ? [] : [$user->getLogin()], 'mimetype'=>$mimetype, 'startFolder'=>$startFolder, 'rootFolder'=>$rootFolder, 'created_start'=>$createstartts, 'created_end'=>$createendts, 'attributes'=>$attributes), ($pageNumber == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($pageNumber-1))));
|
||||
|
@ -657,6 +672,7 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
|
|||
$view->setParam('totaldocs', $dcount /*resArr['totalDocs']*/);
|
||||
$view->setParam('totalfolders', $fcount /*resArr['totalFolders']*/);
|
||||
$view->setParam('fullsearch', $fullsearch);
|
||||
$view->setParam('facetsearch', $facetsearch);
|
||||
$view->setParam('mode', isset($mode) ? $mode : '');
|
||||
$view->setParam('orderby', isset($orderby) ? $orderby : '');
|
||||
$view->setParam('defaultsearchmethod', !empty($_GET["fullsearch"]) || $settings->_defaultSearchMethod);
|
||||
|
|
|
@ -680,13 +680,14 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
|
|||
foreach($menuitems as $menuitem) {
|
||||
$content .= " <li class=\"".(!empty($menuitem['active']) ? ' active' : '')."\">\n";
|
||||
$content .= ' <a';
|
||||
$content .= !empty($menuitem['link']) ? 'href="'.$menuitem['link'].'"' : '';
|
||||
$content .= !empty($menuitem['link']) ? ' href="'.$menuitem['link'].'"' : '';
|
||||
if(!empty($menuitem['attributes']))
|
||||
foreach($menuitem['attributes'] as $attr)
|
||||
$content .= ' '.$attr[0].'="'.$attr[1].'"';
|
||||
$content .= '>';
|
||||
$content .= $menuitem['label'];
|
||||
$content .= '<span class="badge'.($menuitem['badge'] > 0 ? ' badge-info' : '').' badge-right">'.$menuitem['badge']."</span>";
|
||||
if(!empty($menuitem['badge']))
|
||||
$content .= '<span class="badge'.($menuitem['badge'] > 0 ? ' badge-info' : '').' badge-right">'.$menuitem['badge']."</span>";
|
||||
$content .= ' </a>'."\n";
|
||||
$content .= " </li>\n";
|
||||
}
|
||||
|
|
|
@ -394,7 +394,9 @@ $(document).ready(function() {
|
|||
function show() { /* {{{ */
|
||||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
$request = $this->params['request'];
|
||||
$fullsearch = $this->params['fullsearch'];
|
||||
$facetsearch = $this->params['facetsearch'];
|
||||
$total = $this->params['total'];
|
||||
$totaldocs = $this->params['totaldocs'];
|
||||
$totalfolders = $this->params['totalfolders'];
|
||||
|
@ -406,6 +408,7 @@ $(document).ready(function() {
|
|||
$resultmode = $this->params['resultmode'];
|
||||
$workflowmode = $this->params['workflowmode'];
|
||||
$enablefullsearch = $this->params['enablefullsearch'];
|
||||
$enablefacetsearch = true;
|
||||
$enableclipboard = $this->params['enableclipboard'];
|
||||
$attributes = $this->params['attributes'];
|
||||
$categories = $this->params['categories'];
|
||||
|
@ -463,7 +466,12 @@ $(document).ready(function() {
|
|||
<?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" role="button"><?php printMLText('fullsearch'); ?></a></li>
|
||||
<li class="nav-item <?php echo ($fullsearch == true && $facetsearch == false) ? 'active' : ''; ?>"><a class="nav-link <?php echo ($fullsearch == true && $facetsearch == false) ? 'active' : ''; ?>" data-target="#fulltext" data-toggle="tab" role="button"><?php printMLText('fullsearch'); ?></a></li>
|
||||
<?php
|
||||
}
|
||||
if($enablefacetsearch) {
|
||||
?>
|
||||
<li class="nav-item <?php echo ($facetsearch == true && $facetsearch == true) ? 'active' : ''; ?>"><a class="nav-link <?php echo ($facetsearch == true && $facetsearch == true) ? 'active' : ''; ?>" data-target="#facetfulltext" data-toggle="tab" role="button"><?php printMLText('facetfullsearch'); ?></a></li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
@ -778,7 +786,7 @@ $(document).ready(function() {
|
|||
|
||||
// Fulltext search Form {{{
|
||||
if($enablefullsearch) {
|
||||
echo "<div class=\"tab-pane ".(($fullsearch == true) ? 'active' : '')."\" id=\"fulltext\">\n";
|
||||
echo "<div class=\"tab-pane ".(($fullsearch == true && $facetsearch == false) ? 'active' : '')."\" id=\"fulltext\">\n";
|
||||
?>
|
||||
<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" />
|
||||
|
@ -793,7 +801,7 @@ $(document).ready(function() {
|
|||
'value'=>htmlspecialchars($this->query)
|
||||
)
|
||||
);
|
||||
$this->formField(getMLText("under_folder"), $this->getFolderChooserHtml("form1", M_READ, -1, $startfolder, 'folderfullsearchid'));
|
||||
$this->formField(getMLText("under_folder"), $this->getFolderChooserHtml("form2", M_READ, -1, $startfolder, 'folderfullsearchid'));
|
||||
$this->formField(
|
||||
getMLText("creation_date")." (".getMLText('from').")",
|
||||
$this->getDateChooser($createstartdate, "createstart", $this->params['session']->getLanguage())
|
||||
|
@ -886,14 +894,12 @@ $(document).ready(function() {
|
|||
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.')'*/);
|
||||
$option = array($uu->getId(), $v);
|
||||
if(isset(${$facetname}) && in_array($uu->getId(), ${$facetname}))
|
||||
$option[] = true;
|
||||
else
|
||||
|
@ -906,7 +912,7 @@ $(document).ready(function() {
|
|||
foreach($values as $v=>$c) {
|
||||
$cat = $dms->getDocumentCategoryByName($v);
|
||||
if($cat) {
|
||||
$option = array($cat->getId(), $v/*.' ('.$c.')'*/);
|
||||
$option = array($cat->getId(), $v);
|
||||
if(isset(${$facetname}) && in_array($cat->getId(), ${$facetname}))
|
||||
$option[] = true;
|
||||
else
|
||||
|
@ -915,6 +921,7 @@ $(document).ready(function() {
|
|||
$options[] = $option;
|
||||
}
|
||||
}
|
||||
} elseif(substr($facetname, 0, 5) == 'attr_') {
|
||||
} elseif($facetname == 'status') {
|
||||
foreach($values as $v=>$c) {
|
||||
$option = array($v, getOverallStatusText($v)/*.' ('.$c.')'*/);
|
||||
|
@ -925,19 +932,9 @@ $(document).ready(function() {
|
|||
$option[] = array(array('data-subtitle', $c.' ×'));
|
||||
$options[] = $option;
|
||||
}
|
||||
} elseif(substr($facetname, 0, 5) == 'attr_') {
|
||||
foreach($values as $v=>$c) {
|
||||
$option = array($v, $v/*.' ('.$c.')'*/);
|
||||
if(isset($attributes[$facetname]) && in_array($v, $attributes[$facetname]))
|
||||
$option[] = true;
|
||||
else
|
||||
$option[] = false;
|
||||
$option[] = array(array('data-subtitle', $c.' ×'));
|
||||
$options[] = $option;
|
||||
}
|
||||
} else {
|
||||
foreach($values as $v=>$c) {
|
||||
$option = array($v, $v.' ('.$c.')');
|
||||
$option = array($v, $v);
|
||||
if(isset(${$facetname}) && in_array($v, ${$facetname}))
|
||||
$option[] = true;
|
||||
else
|
||||
|
@ -946,27 +943,7 @@ $(document).ready(function() {
|
|||
$options[] = $option;
|
||||
}
|
||||
}
|
||||
if(substr($facetname, 0, 5) == 'attr_') {
|
||||
if($options) {
|
||||
$tmp = explode('_', $facetname);
|
||||
if($attrdef = $dms->getAttributeDefinition($tmp[1]))
|
||||
$dispname = $attrdef->getName();
|
||||
else
|
||||
$dispname = getMLText($facetname);
|
||||
$this->formField(
|
||||
$dispname,
|
||||
array(
|
||||
'element'=>'select',
|
||||
'id'=>$facetname,
|
||||
'name'=>'attributes['.$facetname.'][]',
|
||||
'class'=>'chzn-select',
|
||||
'attributes'=>array(array('data-placeholder', $dispname), array('data-allow-clear', 'true')),
|
||||
'options'=>$options,
|
||||
'multiple'=>$multiple
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if(substr($facetname, 0, 5) != 'attr_') {
|
||||
$this->formField(
|
||||
getMLText($facetname),
|
||||
array(
|
||||
|
@ -981,11 +958,179 @@ $(document).ready(function() {
|
|||
);
|
||||
}
|
||||
}
|
||||
foreach($facets as $facetname=>$values) {
|
||||
if(substr($facetname, 0, 5) == 'attr_') {
|
||||
/* If the facet is empty, don't show the input field */
|
||||
if($values) {
|
||||
$tmp = explode('_', $facetname);
|
||||
if($attrdef = $dms->getAttributeDefinition($tmp[1])) {
|
||||
$dispname = $attrdef->getName();
|
||||
switch($attrdef->getType()) {
|
||||
case 556: //SeedDMS_Core_AttributeDefinition::type_int:
|
||||
$this->formField(
|
||||
$dispname.' ('.getMLText('from').')',
|
||||
array(
|
||||
'element'=>'input',
|
||||
'type'=>'number',
|
||||
'id'=>$facetname,
|
||||
'name'=>'attributes['.$facetname.'][from]',
|
||||
'placeholder'=>implode(' ', array_keys($values)),
|
||||
)
|
||||
);
|
||||
$this->formField(
|
||||
$dispname.' ('.getMLText('to').')',
|
||||
array(
|
||||
'element'=>'input',
|
||||
'type'=>'number',
|
||||
'id'=>$facetname,
|
||||
'name'=>'attributes['.$facetname.'][to]',
|
||||
'placeholder'=>implode(' ', array_keys($values)),
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$options = [];
|
||||
foreach($values as $v=>$c) {
|
||||
$option = array($v, $v);
|
||||
if(isset($attributes[$facetname]) && in_array($v, $attributes[$facetname]))
|
||||
$option[] = true;
|
||||
else
|
||||
$option[] = false;
|
||||
$option[] = array(array('data-subtitle', $c.' ×'));
|
||||
$options[] = $option;
|
||||
}
|
||||
|
||||
if($options) {
|
||||
$this->formField(
|
||||
$dispname,
|
||||
array(
|
||||
'element'=>'select',
|
||||
'id'=>$facetname,
|
||||
'name'=>'attributes['.$facetname.'][]',
|
||||
'class'=>'chzn-select',
|
||||
'attributes'=>array(array('data-placeholder', $dispname), 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";
|
||||
}
|
||||
// }}}
|
||||
|
||||
// Fulltext search with facets Form {{{
|
||||
if($enablefacetsearch) {
|
||||
echo "<div class=\"tab-pane ".(($fullsearch == true && $facetsearch == true) ? 'active' : '')."\" id=\"facetfulltext\">\n";
|
||||
?>
|
||||
<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" />
|
||||
<input type="hidden" name="facetsearch" value="1" />
|
||||
<?php
|
||||
$this->contentContainerStart();
|
||||
$this->formField(
|
||||
getMLText("search_query"),
|
||||
array(
|
||||
'element'=>'input',
|
||||
'type'=>'search',
|
||||
'name'=>'query',
|
||||
'value'=>htmlspecialchars($this->query),
|
||||
'placeholder'=>'Search in title, comments, keywords, content',
|
||||
)
|
||||
);
|
||||
$this->formField(getMLText("under_folder"), $this->getFolderChooserHtml("form3", M_READ, -1, $startfolder, 'folderfullsearchid'));
|
||||
|
||||
$this->contentContainerEnd();
|
||||
$this->formSubmit("<i class=\"fa fa-search\"></i> ".getMLText('search'));
|
||||
echo "<p></p>";
|
||||
|
||||
if($facets) {
|
||||
$menuitems = [];
|
||||
foreach($facets as $facetname=>$values) {
|
||||
if(substr($facetname, 0, 5) == 'attr_') {
|
||||
$tmp = explode('_', $facetname);
|
||||
if($attrdef = $dms->getAttributeDefinition($tmp[1])) {
|
||||
$dispname = $attrdef->getName();
|
||||
/* Create a link to remove the filter */
|
||||
$allparams = $request->query->all();
|
||||
if(isset($allparams['attributes'][$facetname])) {
|
||||
$oldvalue = is_array($allparams['attributes'][$facetname]) ? implode(',', $allparams['attributes'][$facetname]) : $allparams['attributes'][$facetname];
|
||||
unset($allparams['attributes'][$facetname]);
|
||||
$newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams);
|
||||
$menuitems[] = array('label'=>$dispname.' = '.$oldvalue, 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Create a link to remove the filter */
|
||||
$allparams = $request->query->all();
|
||||
if(isset($allparams[$facetname])) {
|
||||
$oldvalue = is_array($allparams[$facetname]) ? implode(',', $allparams[$facetname]) : $allparams[$facetname];
|
||||
unset($allparams[$facetname]);
|
||||
$newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams);
|
||||
$menuitems[] = array('label'=>getMLText($facetname).' = '.$oldvalue, 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x');
|
||||
}
|
||||
}
|
||||
}
|
||||
if($menuitems) {
|
||||
ob_start();
|
||||
self::showNavigationListWithBadges($menuitems);
|
||||
$content = ob_get_clean();
|
||||
$this->printAccordion(getMLText('current_filter'), $content, true);
|
||||
}
|
||||
|
||||
foreach($facets as $facetname=>$values) {
|
||||
if(substr($facetname, 0, 5) == 'attr_') {
|
||||
$tmp = explode('_', $facetname);
|
||||
if($attrdef = $dms->getAttributeDefinition($tmp[1])) {
|
||||
$dispname = $attrdef->getName();
|
||||
/* See below on an explaination for the if statement */
|
||||
if($values && (count($values) > 1 || reset($values) < $total)) {
|
||||
$menuitems = array();
|
||||
arsort($values);
|
||||
foreach($values as $v=>$c) {
|
||||
$menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$request->getRequestUri().'&attributes['.$facetname.'][]='.urlencode($v), 'badge'=>$c, 'attributes'=>array(array('data-href', $request->getRequestUri().'&'.$facetname.'='.$v), array('data-action', "printOpenTasksList")));
|
||||
}
|
||||
ob_start();
|
||||
self::showNavigationListWithBadges($menuitems);
|
||||
$content = ob_get_clean();
|
||||
$this->printAccordion($dispname, $content);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Further filter makes onle sense if the facet has mor than 1 value
|
||||
* or in case of 1 value that value has a count < $total. That second
|
||||
* case will reduce the result set on those objects which the field
|
||||
* actually set.
|
||||
*/
|
||||
if($values && (count($values) > 1 || reset($values) < $total)) {
|
||||
$menuitems = array();
|
||||
arsort($values);
|
||||
foreach($values as $v=>$c) {
|
||||
$menuitems[] = array('label'=>htmlspecialchars($v), 'link'=>$request->getRequestUri().'&'.$facetname.'[]='.urlencode($v), 'badge'=>$c, 'attributes'=>array(array('data-href', "#initlist"), array('data-action', "printOpenTasksList")));
|
||||
}
|
||||
ob_start();
|
||||
self::showNavigationListWithBadges($menuitems);
|
||||
$content = ob_get_clean();
|
||||
$this->printAccordion(getMLText($facetname), $content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// echo "<pre>";
|
||||
// print_r($facets);
|
||||
// echo "</pre>";
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
echo "</div>\n";
|
||||
}
|
||||
|
|
|
@ -607,14 +607,15 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
|
|||
foreach($menuitems as $menuitem) {
|
||||
$content .= " <li class=\"list-group-item d-flex justify-content-between align-items-center".(!empty($menuitem['active']) ? ' active' : '')."\">\n";
|
||||
$content .= ' <a';
|
||||
$content .= !empty($menuitem['link']) ? 'href="'.$menuitem['link'].'"' : '';
|
||||
$content .= !empty($menuitem['link']) ? ' href="'.$menuitem['link'].'"' : '';
|
||||
if(!empty($menuitem['attributes']))
|
||||
foreach($menuitem['attributes'] as $attr)
|
||||
$content .= ' '.$attr[0].'="'.$attr[1].'"';
|
||||
$content .= '>';
|
||||
$content .= $menuitem['label'];
|
||||
$content .= ' </a>'."\n";
|
||||
$content .= '<span class="badge'.($menuitem['badge'] > 0 ? ' badge-primary' : ' badge-secondary').' badge-pill">'.$menuitem['badge']."</span>";
|
||||
if(!empty($menuitem['badge']))
|
||||
$content .= '<span class="badge'.($menuitem['badge'] > 0 ? ' badge-primary' : ' badge-secondary').' badge-pill">'.$menuitem['badge']."</span>";
|
||||
$content .= " </li>\n";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user