* @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"); /** * Class which outputs the html page for Search result view * * @category DMS * @package SeedDMS * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann * @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 { /** * 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", $str); return $str; } /* }}} */ 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')); ?> $(document).ready( function() { $('#export').on('click', function(e) { e.preventDefault(); var url = ""; url = $(this).attr('href')+'&includecontent='+($('#includecontent').prop('checked') ? '1' : '0'); var inputs = $('input[name^=\"marks\"]'); var values = {}; inputs.each(function() { if(this.checked) values[this.name] = 1; }); url += '&'+$.param(values); window.location.href = url; }); $('#changecategory').on('click', function(e) { e.preventDefault(); var url = ""; url = $(this).attr('href')+'&changecategory='+$('#batchcategory').val()+'&removecategory='+($('#removecategory').prop('checked') ? '1' : '0'); var inputs = $('input[name^=\"marks\"]'); var values = {}; inputs.each(function() { if(this.checked) values[this.name] = 1; }); url += '&'+$.param(values); window.location.href = url; }); getParam('theme') !== 'bootstrap4'): ?> $('body').on('click', 'a.change-owner-btn', function(ev){ ev.preventDefault(); ev.stopPropagation(); confirmmsg = $(ev.currentTarget).attr('confirmmsg'); href = $(ev.currentTarget).attr('href'); bootbox.dialog(confirmmsg, [{ "label" : " ", "class" : "btn-danger", "callback": function() { var url = ""; url = href+'&newowner='+($('#newowner').val()); var inputs = $('input[name^=\"marks\"]'); var values = {}; inputs.each(function() { if(this.checked) values[this.name] = 1; }); url += '&'+$.param(values); window.location.href = url; } }, { "label" : "", "class" : "btn-cancel", "callback": function() { } }]); }); $('body').on('click', 'a.change-owner-btn', function(ev){ ev.preventDefault(); ev.stopPropagation(); confirmmsg = $(ev.currentTarget).attr('confirmmsg'); href = $(ev.currentTarget).attr('href'); bootbox.confirm({ "message": confirmmsg, "buttons": { "confirm": { "label" : " ", "className" : "btn-danger", }, "cancel": { "label" : " ", "className" : "btn-secondary", } }, "callback": function(result) { if(result) { var url = ""; url = href+'&newowner='+($('#newowner').val()); var inputs = $('input[name^=\"marks\"]'); var values = {}; inputs.each(function() { if(this.checked) values[this.name] = 1; }); url += '&'+$.param(values); window.location.href = url; } } }); }); }); printFolderChooserJs("form1"); $this->printDeleteFolderButtonJs(); $this->printMarkDocumentButtonJs(); $this->printDeleteDocumentButtonJs(); /* Add js for catching click on document in one page mode */ $this->printClickDocumentJs(); $this->printClickFolderJs(); ?> $(document).ready(function() { $('body').on('submit', '#form1', function(ev){ }); }); getID(); $content = ''; $content .= '
'; 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 .= '
'; 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(); if($extraheader = $this->callHook('extraDownloadHeader')) $downmgr->addHeader($extraheader); foreach($entries as $entry) { if($entry->isType('document')) { 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(), ''); if($includecontent) { $downmgr->createArchive($filename); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . filesize($filename)); header("Content-Disposition: attachment; filename=\"export-" .date('Y-m-d') . ".zip\""); header("Content-Type: application/zip"); header("Cache-Control: must-revalidate"); } else { $downmgr->createToc($filename); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . filesize($filename)); header("Content-Disposition: attachment; filename=\"export-" .date('Y-m-d') . ".xlsx\""); header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); header("Cache-Control: must-revalidate"); } readfile($filename); unlink($filename); } /* }}} */ function changeowner() { /* {{{ */ $dms = $this->params['dms']; $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) { $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 { } return self::show(); } /* }}} */ function changecategory() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $entries = $this->params['searchhits']; $changecategory = $this->params['changecategory']; $removecategory = $this->params['removecategory']; $marks = $this->params['marks']; if($changecategory && $user->isAdmin()) { $j = $i = 0; foreach($entries as $entry) { if($entry->isType('document')) { if(empty($marks) || !empty($marks['D'.$entry->getId()])) { if(!$removecategory) { if(!$entry->hasCategory($changecategory)) { $entry->addCategories([$changecategory]); $j++; } } else { if($entry->hasCategory($changecategory)) { $entry->removeCategories([$changecategory]); $j++; } } } } } if($removecategory) { $this->setParam('batchmsg', getMLText('batch_remove_category_msg', ['count'=>$j, 'catname'=>$changecategory->getName()])); } else { $this->setParam('batchmsg', getMLText('batch_add_category_msg', ['count'=>$j, 'catname'=>$changecategory->getName()])); } } else { } return self::show(); } /* }}} */ function opensearchsuggestion() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $query = $this->params['query']; $entries = $this->params['searchhits']; $recs = array(); $content = "\n"; $content .= "\n"; $content .= "".$query.""; if($entries) { $content .= "
\n"; foreach ($entries as $entry) { $content .= "\n"; if($entry->isType('document')) { $content .= "".$entry->getName()."\n"; $content .= "http:".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$entry->getId()."\n"; } elseif($entry->isType('folder')) { $content .= "".$entry->getName()."\n"; $content .= "http:".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$entry->getId()."\n"; } $content .= "\n"; } $content .= "
\n"; } $content .= "
"; 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']; $terms = $this->params['terms']; $recs = array(); $recs[] = array('type'=>'S', 'name'=>$query, 'occurences'=>''); if($terms) { foreach($terms as $term) $recs[] = array('type'=>'S', 'name'=>$term->text, 'occurences'=>$term->_occurrence); } if($entries) { foreach ($entries as $entry) { if($entry->isType('document')) { $recs[] = array('type'=>'D', 'id'=>$entry->getId(), 'name'=>htmlspecialchars($entry->getName()), 'path'=>htmlspecialchars($entry->getParent()->getFolderPathPlain(true, '/'))); } elseif($entry->isType('folder')) { $recs[] = array('type'=>'F', 'id'=>$entry->getId(), 'name'=>htmlspecialchars($entry->getName()), 'path'=>htmlspecialchars($entry->getParent()->getFolderPathPlain(true, '/'))); } } } 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." ".($orderby=="n"||$orderby=="na"?' ':($orderby=="nd"?' ':' ')).""; $tmp['orderby'] = ($orderby=="d"||$orderby=="da") ? "dd" : "d"; $headcol .= " ".($orderby=="d"||$orderby=="da"?' ':($orderby=="dd"?' ':' ')).""; } return $headcol; } /* }}} */ 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']; $limit = $this->params['limit']; $attrdefs = $this->params['attrdefs']; $allCats = $this->params['allcategories']; $allUsers = $this->params['allusers']; $mode = $this->params['mode']; $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']; $createstartdate = $this->params['createstartdate']; $createenddate = $this->params['createenddate']; $expstartdate = $this->params['expstartdate']; $expenddate = $this->params['expenddate']; $statusstartdate = $this->params['statusstartdate']; $statusenddate = $this->params['statusenddate']; $revisionstartdate = $this->params['revisionstartdate']; $revisionenddate = $this->params['revisionenddate']; $creationdate = $this->params['creationdate']; $expirationdate = $this->params['expirationdate']; $statusdate = $this->params['statusdate']; $revisiondate = $this->params['revisiondate']; $status = $this->params['status']; $record_type = $this->params['recordtype']; $this->query = $this->params['query']; $orderby = $this->params['orderby']; $entries = $this->params['searchhits']; $facets = $this->params['facets']; $totalpages = $this->params['totalpages']; $pageNumber = $this->params['pagenumber']; $searchTime = $this->params['searchtime']; $urlparams = $this->params['urlparams']; $searchin = $this->params['searchin']; $cachedir = $this->params['cachedir']; $previewwidth = $this->params['previewWidthList']; $previewconverters = $this->params['previewConverters']; $conversionmgr = $this->params['conversionmgr']; $timeout = $this->params['timeout']; $xsendfile = $this->params['xsendfile']; $reception = $this->params['reception']; $showsinglesearchhit = $this->params['showsinglesearchhit']; $this->htmlStartPage(getMLText("search_results")); $this->globalNavigation(); $this->contentStart(); $this->pageNavigation("", ""); $this->rowStart(); $this->columnStart(4); //$this->contentHeading(" ".getMLText('search'), true); $this->contentHeading(getMLText('search'), true); if($this->query) { echo "
"; } ?>
contentContainerStart(); $this->formField( getMLText("search_query"), array( 'element'=>'input', 'type'=>'search', '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(); $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(); 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 ) ); $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()) ); $this->contentContainerEnd(); // Seach options for documents and folders {{{ /* First check if any of the folder/document filters are set. If it is, * open the accordion. */ $openfilterdlg = false; $hasattrs = false; if($attrdefs) { foreach($attrdefs as $attrdef) { if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_all) { /* Do not check dates because they always have 'from' and 'to' element * even if it is empty. FIXME should be also checked. */ $hasattrs = true; if($attrdef->getType() != SeedDMS_Core_AttributeDefinition::type_date) if(!empty($attributes[$attrdef->getID()])) $openfilterdlg = true; } } } if($hasattrs) { ob_start(); if($attrdefs) { foreach($attrdefs as $attrdef) { if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_all) { 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)); } } } $content = ob_get_clean(); $this->printAccordion(getMLText('filter_for_documents_and_folders'), $content, $openfilterdlg); } // }}} // Seach options for documents {{{ /* 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) { /* Do not check dates because they always have 'from' and 'to' element * even if it is empty. FIXME should be also checked. */ if($attrdef->getType() != SeedDMS_Core_AttributeDefinition::type_date) if(!empty($attributes[$attrdef->getID()])) $openfilterdlg = true; } } } if($categories) $openfilterdlg = true; if($status) $openfilterdlg = true; if($expirationdate) $openfilterdlg = true; if($revisiondate) $openfilterdlg = true; if($reception) $openfilterdlg = true; if($statusdate) $openfilterdlg = true; /* Start of fields only applicable to documents */ ob_start(); $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("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_IN_REVISION, getOverallStatusText(S_IN_REVISION), in_array(S_IN_REVISION, $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)); $options[] = array(S_NEEDS_CORRECTION, getOverallStatusText(S_NEEDS_CORRECTION), in_array(S_NEEDS_CORRECTION, $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("revision")." (".getMLText('from').")", $this->getDateChooser($revisionstartdate, "revisiondatestart", $this->params['session']->getLanguage()) ); $this->formField( getMLText("revision")." (".getMLText('to').")", $this->getDateChooser($revisionenddate, "revisiondateend", $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()) ); if($attrdefs) { foreach($attrdefs as $attrdef) { if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_document || $attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_documentcontent) { 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, '', true)); } } } $content = ob_get_clean(); $this->printAccordion(getMLText('filter_for_documents'), $content, $openfilterdlg); // }}} // Seach options for folders {{{ /* First check if any of the folder filters are set. If it is, * open the accordion. */ $openfilterdlg = false; $hasattrs = false; if($attrdefs) { foreach($attrdefs as $attrdef) { if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_folder) { $hasattrs = true; if($attrdef->getType() != SeedDMS_Core_AttributeDefinition::type_date) if(!empty($attributes[$attrdef->getID()])) $openfilterdlg = true; } } } if($hasattrs) { ob_start(); if($attrdefs) { foreach($attrdefs as $attrdef) { if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_folder) { 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, '', true)); } } } $content = ob_get_clean(); $this->printAccordion(getMLText('filter_for_folders'), $content, $openfilterdlg); } // }}} $this->formSubmit(" ".getMLText('search')); ?>
\n"; ?>
contentContainerStart(); $this->formField( getMLText("search_query"), array( 'element'=>'input', 'type'=>'search', '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['record_type'])) { $options = array(); $options[] = array('document', getMLText('document'), $record_type && in_array('document', $record_type)); $options[] = array('folder', getMLText('folder'), $record_type && in_array('folder', $record_type)); $this->formField( getMLText("record_type"), array( 'element'=>'select', 'class'=>'chzn-select', 'name'=>'record_type[]', 'multiple'=>true, 'attributes'=>array(array('data-placeholder', getMLText('select_record_type'))), '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 ) ); } 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 ) ); } 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(" ".getMLText('search')); ?>
\n"; } // }}} ?>
query) { echo "
\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(" ".getMLText('export')); print $this->html_link('Search', array_merge($_GET, array('action'=>'export')), array('class'=>'btn btn-primary', 'id'=>'export'), " ".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'), 'attributes'=>array(array('style', 'width: 100%;')) ) ); // print $this->html_link('Search', array_merge($_GET, array('action'=>'changeowner')), array('class'=>'btn btn-primary', 'id'=>'changeowner'), " ".getMLText("batch_change_owner"), false, true)."\n"; print $this->html_link('Search', array_merge($_GET, array('action'=>'changeowner')), array('class'=>'btn btn-primary change-owner-btn mt-4', 'confirmmsg'=>htmlspecialchars(getMLText("confirm_change_owner", array ()), ENT_QUOTES)), " ".getMLText("batch_change_owner"), false, true)."\n"; $content = ob_get_clean(); $this->printAccordion(getMLText('batch_change_owner'), $content); ob_start(); $cats = $dms->getDocumentCategories(); if($cats) { $options = array(); $options[] = array("-1", getMLText("choose_category")); foreach ($cats as $currcat) { $options[] = array($currcat->getID(), htmlspecialchars($currcat->getName()), false); } $this->formField( null, array( 'element'=>'select', 'id'=>'batchcategory', 'class'=>'chzn-select', 'options'=>$options, 'multiple'=>false, 'placeholder'=>getMLText('select_category'), 'attributes'=>array(array('style', 'width: 100%;')) ) ); $this->formField( getMLText("batch_remove_category"), array( 'element'=>'input', 'type'=>'checkbox', 'id'=>'removecategory', 'value'=>'1', ) ); print $this->html_link('Search', array_merge($_GET, array('action'=>'changecategory')), array('class'=>'btn btn-primary change-category-btn mt-4', 'id'=>'changecategory'), " ".getMLText("batch_change_category"), false, true)."\n"; $content = ob_get_clean(); $this->printAccordion(getMLText('batch_change_category'), $content); } } // }}} ?> columnEnd(); $this->columnStart(8); if($batchmsg = $this->getParam('batchmsg')) { $this->contentHeading(getMLText('batch_operation_result')); echo $this->infoMsg($batchmsg); } $this->contentHeading(getMLText('search_results')); // Search Result {{{ $foldercount = $doccount = 0; if($entries) { /* foreach ($entries as $entry) { if($entry->isType('document')) { $doccount++; } elseif($entry->isType('document')) { $foldercount++; } } */ echo $this->infoMsg(getMLText("search_report", array("count"=>$total, "doccount" => $totaldocs, "foldercount" => $totalfolders, 'searchtime'=>$searchTime))); $this->pageList((int) $pageNumber, $totalpages, "../out/out.Search.php", $urlparams); // $this->contentContainerStart(); $txt = $this->callHook('searchListHeader', $orderby, 'asc'); if(is_string($txt)) { echo $txt; } elseif(is_array($txt)) { print ""; print "\n\n"; foreach($txt as $headcol) echo "\n"; print "\n\n"; } else { echo $this->folderListHeader(null, 'search'); } print "\n"; $previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile); if($conversionmgr) $previewer->setConversionMgr($conversionmgr); else $previewer->setConverters($previewconverters); foreach ($entries as $entry) { if($entry->isType('document')) { $document = $entry; if($lc = $document->getLatestContent()) $previewer->createPreview($lc); $lcattributes = $lc ? $lc->getAttributes() : null; $attrstr = ''; if($lcattributes) { $attrstr .= "
".$headcol."
\n"; $attrstr .= ""; foreach($lcattributes as $lcattribute) { $arr = $this->callHook('showDocumentContentAttribute', $lc, $lcattribute); if(is_array($arr)) { $attrstr .= ""; $attrstr .= ""; $attrstr .= ""; $attrstr .= ""; } elseif(is_string($arr)) { $attrstr .= $arr; } else { $attrdef = $lcattribute->getAttributeDefinition(); $attrstr .= "\n"; // TODO: better use printAttribute() // $this->printAttribute($lcattribute); } } $attrstr .= "
".getMLText('name')."".getMLText('attribute_value')."
".$arr[0].":".$arr[1]."
".htmlspecialchars($attrdef->getName())."".htmlspecialchars(implode(', ', $lcattribute->getValueAsArray()))."
\n"; } $docattributes = $document->getAttributes(); if($docattributes) { $attrstr .= "\n"; $attrstr .= ""; foreach($docattributes as $docattribute) { $arr = $this->callHook('showDocumentAttribute', $document, $docattribute); if(is_array($arr)) { $attrstr .= ""; $attrstr .= ""; $attrstr .= ""; $attrstr .= ""; } elseif(is_string($arr)) { $attrstr .= $arr; } else { $attrdef = $docattribute->getAttributeDefinition(); $attrstr .= "\n"; } } $attrstr .= "
".getMLText('name')."".getMLText('attribute_value')."
".$arr[0].":".$arr[1]."
".htmlspecialchars($attrdef->getName())."".htmlspecialchars(implode(', ', $docattribute->getValueAsArray()))."
\n"; } $extracontent = array(); $extracontent['below_title'] = $this->getListRowPath($document); if($attrstr) $extracontent['bottom_title'] = '
'.$this->printPopupBox(''.getMLText('attributes').'', $attrstr, true); $extracontent['end_action_list'] = $this->printMarkDocumentButton($document, 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); } } elseif($entry->isType('folder')) { $txt = $this->callHook('folderListItem', $entry, false, 'search'); if(is_string($txt)) echo $txt; else { $folder = $entry; $attrstr = ''; $folderattributes = $folder->getAttributes(); if($folderattributes) { $attrstr .= "\n"; $attrstr .= ""; foreach($folderattributes as $folderattribute) { $attrdef = $folderattribute->getAttributeDefinition(); $attrstr .= "\n"; } $attrstr .= "
".getMLText('name')."".getMLText('attribute_value')."
".htmlspecialchars($attrdef->getName())."".htmlspecialchars(implode(', ', $folderattribute->getValueAsArray()))."
"; } $extracontent = array(); $extracontent['below_title'] = $this->getListRowPath($folder); if($attrstr) $extracontent['bottom_title'] = '
'.$this->printPopupBox(''.getMLText('attributes').'', $attrstr, true); $extracontent['end_action_list'] = $this->printMarkFolderButton($folder, true); print $this->folderListRow($folder, false, $extracontent); } } } print "\n"; // $this->contentContainerEnd(); $this->pageList((int) $pageNumber, $totalpages, "../out/out.Search.php", $_GET); } else { $numResults = $totaldocs + $totalfolders; if ($numResults == 0) { echo $this->warningMsg(getMLText("search_no_results")); } } // }}} $this->columnEnd(); $this->rowEnd(); $this->contentEnd(); $this->htmlEndPage(); } /* }}} */ } ?>