diff --git a/op/op.Search.php b/op/op.Search.php index 878b2a38f..afd3d21c3 100644 --- a/op/op.Search.php +++ b/op/op.Search.php @@ -23,6 +23,7 @@ include("../inc/inc.Utils.php"); include("../inc/inc.DBInit.php"); include("../inc/inc.Language.php"); include("../inc/inc.ClassUI.php"); +include("../inc/inc.ClassAccessOperation.php"); include("../inc/inc.Authentication.php"); /** @@ -58,18 +59,6 @@ function getTime() { return time(); } -function markQuery($str, $tag = "b") { - - GLOBAL $query; - $querywords = preg_split("/ /", $query); - - foreach ($querywords as $queryword) - $str = str_ireplace("($queryword)", "<" . $tag . ">\\1", $str); - - return $str; -} - - // // Parse all of the parameters for the search // @@ -106,7 +95,7 @@ if (isset($_GET['searchin']) && is_array($_GET["searchin"])) { } // if none is checkd search all -if (count($searchin)==0) $searchin=array( 0, 1, 2, 3, 4); +if (count($searchin)==0) $searchin=array(1, 2, 3, 4); // Check to see if the search has been restricted to a particular sub-tree in // the folder hierarchy. @@ -271,129 +260,21 @@ if($resArr['docs']) { } // -------------- Output results -------------------------------------------- -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'folder'=>$startFolder, 'searchhits'=>$entries, 'totalpages'=>$resArr['totalPages'], 'pagenumber'=>$pageNumber, 'searchtime'=>$searchTime, 'urlparams'=>$_GET, 'searchin'=>$searchin, 'cachedir'=>$settings->_cacheDir)); -if($view) { - $view->show(); - exit; -} - -// Now that the target folder has been identified, it is possible to create -// the full navigation bar. -UI::htmlStartPage(getMLText("search_results")); -UI::globalNavigation($startFolder); -UI::pageNavigation(getFolderPathHTML($startFolder, true), "", $startFolder); -UI::contentHeading(getMLText("search_results")); - -UI::contentContainerStart(); -UI::pageList($pageNumber, $resArr['totalPages'], "../op/op.Search.php", $_GET); - -print ""; -print "\n\n"; -print "\n"; -print "\n"; -print "\n"; -print "\n"; -print "\n"; -print "\n"; -print "\n"; -//print "\n"; -//print "\n"; -print "\n\n\n"; - -$resultsFilteredByAccess = false; -$foldercount = $doccount = 0; -foreach ($entries as $entry) { +if(count($entries) == 1) { + $entry = $entries[0]; if(get_class($entry) == 'LetoDMS_Core_Document') { - $document = $entry; - $doccount++; - $lc = $document->getLatestContent(); - print ""; - //print ""; - if (in_array(2, $searchin)) { - $docName = markQuery(htmlspecialchars($document->getName()), "i"); - } else { - $docName = htmlspecialchars($document->getName()); - } - print ""; - print ""; - - $attributes = $lc->getAttributes(); - print ""; - - $owner = $document->getOwner(); - print ""; - $display_status=$lc->getStatus(); - print ""; - - print ""; - - if (in_array(3, $searchin)) $comment = markQuery(htmlspecialchars($document->getComment())); - else $comment = htmlspecialchars($document->getComment()); - if (strlen($comment) > 50) $comment = substr($comment, 0, 47) . "..."; - print ""; - print "\n"; + header('Location: ../out/out.ViewDocument.php?documentid='.$entry->getID()); + exit; } elseif(get_class($entry) == 'LetoDMS_Core_Folder') { - $folder = $entry; - $foldercount++; - if (in_array(2, $searchin)) { - $folderName = markQuery(htmlspecialchars($folder->getName()), "i"); - } else { - $folderName = htmlspecialchars($folder->getName()); - } - print ""; - print ""; - print ""; - - $owner = $folder->getOwner(); - print ""; - print ""; - print ""; - if (in_array(3, $searchin)) $comment = markQuery(htmlspecialchars($folder->getComment())); - else $comment = htmlspecialchars($folder->getComment()); - if (strlen($comment) > 50) $comment = substr($comment, 0, 47) . "..."; - print ""; - print "\n"; + header('Location: ../out/out.ViewFolder.php?folderid='.$entry->getID()); + exit; + } +} else { + $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); + $view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'folder'=>$startFolder, 'query'=>$query, 'searchhits'=>$entries, 'totalpages'=>$resArr['totalPages'], 'pagenumber'=>$pageNumber, 'searchtime'=>$searchTime, 'urlparams'=>$_GET, 'searchin'=>$searchin, 'cachedir'=>$settings->_cacheDir)); + if($view) { + $view->show(); + exit; } } -if (0 && $resultsFilteredByAccess) { - print ""; -} - -print "
".getMLText("name")."".getMLText("attributes")."".getMLText("owner")."".getMLText("status")."".getMLText("version")."".getMLText("comment")."".getMLText("reviewers")."".getMLText("approvers")."
getID()."\">getFileType())."\" title=\"".$lc->getMimeType()."\">getID()."\">/"; - $folder = $document->getFolder(); - $path = $folder->getPath(); - for ($i = 1; $i < count($path); $i++) { - print htmlspecialchars($path[$i]->getName())."/"; - } - print $docName; - print ""; - print "
    \n"; - $attributes = $lc->getAttributes(); - if($attributes) { - foreach($attributes as $attribute) { - $attrdef = $attribute->getAttributeDefinition(); - print "
  • ".htmlspecialchars($attrdef->getName()).": ".htmlspecialchars($attribute->getValue())."
  • \n"; - } - } - print "
\n"; - print "
".htmlspecialchars($owner->getFullName())."".getOverallStatusText($display_status["status"]). "".$lc->getVersion()."".$comment."
getID()."\">getID()."\">"; - $path = $folder->getPath(); - print "/"; - for ($i = 1; $i < count($path)-1; $i++) { - print htmlspecialchars($path[$i]->getName())."/"; - } - print $folderName; - print "".htmlspecialchars($owner->getFullName())."".$comment."
". getMLText("search_results_access_filtered") . "
\n"; -$numResults = $doccount + $foldercount; -if ($numResults == 0) { - print "

".getMLText("search_no_results")."

"; -} else { -// print "

".getMLText("search_report", array("doccount" => $doccount, "foldercount" => $foldercount, 'searchtime'=>$searchTime))."

"; -} - -UI::pageList($pageNumber, $resArr['totalPages'], "../op/op.Search.php", $_GET); - -UI::contentContainerEnd(); -UI::htmlEndPage(); ?>