* @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"); /** * Include class to preview documents */ require_once("SeedDMS/Preview.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_Bootstrap_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(); window.location.href = $(this).attr('href')+'&includecontent='+($('#includecontent').prop('checked') ? '1' : '0'); }); }); printFolderChooserJs("form1"); $this->printDeleteFolderButtonJs(); $this->printDeleteDocumentButtonJs(); /* Add js for catching click on document in one page mode */ $this->printClickDocumentJs(); $this->printClickFolderJs(); } /* }}} */ function export() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $entries = $this->params['searchhits']; 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')) { $extracols = $this->callHook('extraDownloadColumns', $entry); if(isset($_GET['includecontent']) && $_GET['includecontent'] && $rawcontent = $this->callHook('rawcontent', $entry->getLatestContent())) { $downmgr->addItem($entry->getLatestContent(), $extracols, $rawcontent); } else $downmgr->addItem($entry->getLatestContent(), $extracols); } } $filename = tempnam('/tmp', ''); if(isset($_GET['includecontent']) && $_GET['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') . ".xls\""); header("Content-Type: application/vnd.ms-excel"); header("Cache-Control: must-revalidate"); } readfile($filename); unlink($filename); } /* }}} */ function show() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $fullsearch = $this->params['fullsearch']; $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']; $owner = $this->params['owner']; $startfolder = $this->params['startfolder']; $startdate = $this->params['startdate']; $stopdate = $this->params['stopdate']; $expstartdate = $this->params['expstartdate']; $expstopdate = $this->params['expstopdate']; $creationdate = $this->params['creationdate']; $expirationdate = $this->params['expirationdate']; $status = $this->params['status']; $this->query = $this->params['query']; $orderby = $this->params['orderby']; $entries = $this->params['searchhits']; $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']; $timeout = $this->params['timeout']; $xsendfile = $this->params['xsendfile']; $reception = $this->params['reception']; $showsinglesearchhit = $this->params['showsinglesearchhit']; if($showsinglesearchhit && count($entries) == 1) { $entry = $entries[0]; if($entry->isType('document')) { header('Location: ../out/out.ViewDocument.php?documentid='.$entry->getID()); exit; } elseif($entry->isType('folder')) { header('Location: ../out/out.ViewFolder.php?folderid='.$entry->getID()); exit; } } // if ($pageNumber != 'all') // $entries = array_slice($entries, ($pageNumber-1)*$limit, $limit); $this->htmlAddHeader(''."\n", 'js'); $this->htmlStartPage(getMLText("search_results")); $this->globalNavigation(); $this->contentStart(); $this->pageNavigation(getMLText("search_results"), ""); echo "
\n"; echo "
\n"; //echo "
";print_r($_GET);echo "
"; ?>
contentContainerStart(); ?> getObjType() == SeedDMS_Core_AttributeDefinition::objtype_all) { ?>
:
:
:
:
: printFolderChooserHtml("form1", M_READ, -1, $startfolder);?>
:
">   ">
getName()); ?>: printAttributeEditField($attrdef, isset($attributes[$attrdef->getID()]) ? $attributes[$attrdef->getID()] : null, 'attributes', true) ?>
contentContainerEnd(); // }}} // 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) { $attricon = ''; if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_document || $attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_documentcontent) { if(!empty($attributes[$attrdef->getID()])) $openfilterdlg = true; } } } if($categories) $openfilterdlg = true; if($status) $openfilterdlg = true; if($expirationdate) $openfilterdlg = true; if($reception) $openfilterdlg = true; ?>
">
getObjType() == SeedDMS_Core_AttributeDefinition::objtype_document || $attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_documentcontent) { ?>
:
:
:
:
">   ">
getName()); ?>: printAttributeEditField($attrdef, isset($attributes[$attrdef->getID()]) ? $attributes[$attrdef->getID()] : null, 'attributes', true) ?>
getObjType() == SeedDMS_Core_AttributeDefinition::objtype_folder) { if(!empty($attributes[$attrdef->getID()])) $openfilterdlg = true; } } } ?>
">
getObjType() == SeedDMS_Core_AttributeDefinition::objtype_folder) { ?>
getName()); ?>: printAttributeEditField($attrdef, isset($attributes[$attrdef->getID()]) ? $attributes[$attrdef->getID()] : null, 'attributes', true) ?>
\n"; $this->contentContainerStart(); ?>
:
:
:
contentContainerEnd(); echo "
\n"; } // }}} ?>
\n"; echo "
\n"; // Search Result {{{ $foldercount = $doccount = 0; if($entries) { /* foreach ($entries as $entry) { if($entry->isType('document')) { $doccount++; } elseif($entry->isType('document')) { $foldercount++; } } */ print "
".getMLText("search_report", array("doccount" => $totaldocs, "foldercount" => $totalfolders, 'searchtime'=>$searchTime))."
"; $this->pageList($pageNumber, $totalpages, "../out/out.Search.php", $urlparams); // $this->contentContainerStart(); $txt = $this->callHook('searchListHeader'); if(is_string($txt)) echo $txt; else { parse_str($_SERVER['QUERY_STRING'], $tmp); $tmp['orderby'] = $orderby=="n"||$orderby=="na)"?"nd":"n"; print ""; print "\n\n"; print "\n"; print "\n"; //print "\n"; print "\n"; print "\n"; print "\n\n\n"; } $previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile); $previewer->setConverters($previewconverters); foreach ($entries as $entry) { if($entry->isType('document')) { $txt = $this->callHook('documentListItem', $entry, $previewer, false, 'search'); if(is_string($txt)) echo $txt; else { $document = $entry; $owner = $document->getOwner(); if($lc = $document->getLatestContent()) $previewer->createPreview($lc); if (in_array(3, $searchin)) $comment = $this->markQuery(htmlspecialchars($document->getComment())); else $comment = htmlspecialchars($document->getComment()); if (strlen($comment) > 150) $comment = substr($comment, 0, 147) . "..."; $belowtitle = "
".getMLText('in_folder').": /"; $folder = $document->getFolder(); $path = $folder->getPath(); for ($i = 1; $i < count($path); $i++) { $belowtitle .= htmlspecialchars($path[$i]->getName())."/"; } $belowtitle .= ""; $lcattributes = $lc ? $lc->getAttributes() : null; $attrstr = ''; if($lcattributes) { $attrstr .= "
".getMLText("name"); if(!$fullsearch) { print " ".($orderby=="n"||$orderby=="na"?' ':($orderby=="nd"?' ':' ')).""; $tmp['orderby'] = $orderby=="d"||$orderby=="da)"?"dd":"d"; print " ".($orderby=="d"||$orderby=="da"?' ':($orderby=="dd"?' ':' ')).""; } print "".getMLText("attributes")."".getMLText("status")."".getMLText("action")."
\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'] = $belowtitle; if($attrstr) $extracontent['bottom_title'] = '
'.$this->printPopupBox(''.getMLText('attributes').'', $attrstr, true); print $this->documentListRow($document, $previewer, false, 0, $extracontent); } } elseif($entry->isType('folder')) { $folder = $entry; $owner = $folder->getOwner(); if (in_array(2, $searchin)) { $folderName = $this->markQuery(htmlspecialchars($folder->getName()), "i"); } else { $folderName = htmlspecialchars($folder->getName()); } $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(); if($attrstr) $extracontent['bottom_title'] = '
'.$this->printPopupBox(''.getMLText('attributes').'', $attrstr, true); print $this->folderListRow($folder, false, $extracontent); } } print "\n"; // $this->contentContainerEnd(); $this->pageList($pageNumber, $totalpages, "../out/out.Search.php", $_GET); } else { $numResults = $totaldocs + $totalfolders; if ($numResults == 0) { print "
".getMLText("search_no_results")."
"; } } // }}} echo "
"; echo "
"; $this->contentEnd(); $this->htmlEndPage(); } /* }}} */ } ?>