diff --git a/op/op.Search.php b/op/op.Search.php
index 3434fddc2..09fcfc0a8 100644
--- a/op/op.Search.php
+++ b/op/op.Search.php
@@ -1,99 +1,106 @@
-_rootFolderID;
- }
- else {
- $folderid = $_GET["folderid"];
- }
- header("Location: ../out/out.SearchForm.php?folderid=".$folderid);
-}
-
-//
-// Supporting functions.
-//
-
-function makeTimeStamp($hour, $min, $sec, $year, $month, $day) {
- $thirtyone = array (1, 3, 5, 7, 8, 10, 12);
- $thirty = array (4, 6, 9, 11);
-
- // Very basic check that the terms are valid. Does not fail for illegal
- // dates such as 31 Feb.
- if (!is_numeric($hour) || !is_numeric($min) || !is_numeric($sec) || !is_numeric($year) || !is_numeric($month) || !is_numeric($day) || $month<1 || $month>12 || $day<1 || $day>31 || $hour<0 || $hour>23 || $min<0 || $min>59 || $sec<0 || $sec>59) {
- return false;
- }
- $year = (int) $year;
- $month = (int) $month;
- $day = (int) $day;
-
- if (array_search($month, $thirtyone)) {
- $max=31;
- }
- else if (array_search($month, $thirty)) {
- $max=30;
- }
- else {
- $max=(($year % 4 == 0) && ($year % 100 != 0 || $year % 400 == 0)) ? 29 : 28;
- }
-
- // If the date falls out of bounds, set it to the maximum for the given
- // month. Makes assumption about the user's intention, rather than failing
- // for absolutely everything.
- if ($day>$max) {
- $day=$max;
- }
-
- return mktime($hour, $min, $sec, $month, $day, $year);
-}
-
-function getTime() {
- if (function_exists('microtime')) {
- $tm = microtime();
- $tm = explode(' ', $tm);
- return (float) sprintf('%f', $tm[1] + $tm[0]);
- }
- return time();
-}
-
+include("../inc/inc.Language.php");
+include("../inc/inc.ClassUI.php");
+include("../inc/inc.Authentication.php");
+
+// Redirect to the search page if the navigation search button has been
+// selected without supplying any search terms.
+if (isset($_GET["navBar"])) {
+ if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) {
+ $folderid=$settings->_rootFolderID;
+ }
+ else {
+ $folderid = $_GET["folderid"];
+ }
+ if(strlen($_GET["query"])==0) {
+ header("Location: ../out/out.SearchForm.php?folderid=".$folderid);
+ } else {
+ if($_GET["fullsearch"]) {
+ header("Location: ../op/op.SearchFulltext.php?folderid=".$folderid."&query=".$_GET["query"]);
+ }
+ }
+}
+
+//
+// Supporting functions.
+//
+
+function makeTimeStamp($hour, $min, $sec, $year, $month, $day) {
+ $thirtyone = array (1, 3, 5, 7, 8, 10, 12);
+ $thirty = array (4, 6, 9, 11);
+
+ // Very basic check that the terms are valid. Does not fail for illegal
+ // dates such as 31 Feb.
+ if (!is_numeric($hour) || !is_numeric($min) || !is_numeric($sec) || !is_numeric($year) || !is_numeric($month) || !is_numeric($day) || $month<1 || $month>12 || $day<1 || $day>31 || $hour<0 || $hour>23 || $min<0 || $min>59 || $sec<0 || $sec>59) {
+ return false;
+ }
+ $year = (int) $year;
+ $month = (int) $month;
+ $day = (int) $day;
+
+ if (array_search($month, $thirtyone)) {
+ $max=31;
+ }
+ else if (array_search($month, $thirty)) {
+ $max=30;
+ }
+ else {
+ $max=(($year % 4 == 0) && ($year % 100 != 0 || $year % 400 == 0)) ? 29 : 28;
+ }
+
+ // If the date falls out of bounds, set it to the maximum for the given
+ // month. Makes assumption about the user's intention, rather than failing
+ // for absolutely everything.
+ if ($day>$max) {
+ $day=$max;
+ }
+
+ return mktime($hour, $min, $sec, $month, $day, $year);
+}
+
+function getTime() {
+ if (function_exists('microtime')) {
+ $tm = microtime();
+ $tm = explode(' ', $tm);
+ return (float) sprintf('%f', $tm[1] + $tm[0]);
+ }
+ return time();
+}
+
function markQuery($str, $tag = "b") {
-
- GLOBAL $query;
- $querywords = preg_split("/ /", $query);
-
- foreach ($querywords as $queryword)
- $str = str_ireplace("($queryword)", "<" . $tag . ">\\1" . $tag . ">", $str);
-
- return $str;
-}
-
-
+
+ GLOBAL $query;
+ $querywords = preg_split("/ /", $query);
+
+ foreach ($querywords as $queryword)
+ $str = str_ireplace("($queryword)", "<" . $tag . ">\\1" . $tag . ">", $str);
+
+ return $str;
+}
+
+
//
// Parse all of the parameters for the search
//
@@ -203,6 +210,15 @@ if (isset($_GET["obsolete"])){
if (isset($_GET["expired"])){
$status[] = S_EXPIRED;
}
+
+// category
+$categories = array();
+if(isset($_GET['categoryids']) && $_GET['categoryids']) {
+ foreach($_GET['categoryids'] as $catid) {
+ $categories[] = $dms->getDocumentCategory($catid);
+ }
+}
+
//
// Get the page number to display. If the result set contains more than
// 25 entries, it is displayed across multiple pages.
@@ -224,95 +240,95 @@ if (isset($_GET["pg"])) {
// ------------------------------------- Suche starten --------------------------------------------
$startTime = getTime();
-$resArr = $dms->search($query, 25, ($pageNumber-1)*25, $mode, $searchin, $startFolder, $owner, $status, $startdate, $stopdate);
-$searchTime = getTime() - $startTime;
-$searchTime = round($searchTime, 2);
-// ---------------------------------- Ausgabe der Ergebnisse --------------------------------------
-
-UI::contentContainerStart();
-?>
-
-
-
- $resArr['totalDocs']));
-}
-?>
- |
- $searchTime));?> |
-
-
-
-search($query, 25, ($pageNumber-1)*25, $mode, $searchin, $startFolder, $owner, $status, $startdate, $stopdate, $categories);
+$searchTime = getTime() - $startTime;
+$searchTime = round($searchTime, 2);
+// ---------------------------------- Ausgabe der Ergebnisse --------------------------------------
+
+UI::contentContainerStart();
+?>
+
+
+
+ $resArr['totalDocs']));
+}
+?>
+ |
+ $searchTime));?> |
+
+
+
+";
-print "\n\n";
-//print " | \n";
-print "".getMLText("name")." | \n";
-print "".getMLText("owner")." | \n";
-print "".getMLText("status")." | \n";
-print "".getMLText("version")." | \n";
-print "".getMLText("comment")." | \n";
-//print "".getMLText("reviewers")." | \n";
-//print "".getMLText("approvers")." | \n";
+
+print "";
+print "\n\n";
+//print " | \n";
+print "".getMLText("name")." | \n";
+print "".getMLText("owner")." | \n";
+print "".getMLText("status")." | \n";
+print "".getMLText("version")." | \n";
+print "".getMLText("comment")." | \n";
+//print "".getMLText("reviewers")." | \n";
+//print "".getMLText("approvers")." | \n";
print "
\n\n\n";
-
-$resultsFilteredByAccess = false;
+
+$resultsFilteredByAccess = false;
foreach ($resArr['docs'] as $document) {
- if ($document->getAccessMode($user) < M_READ) {
- $resultsFilteredByAccess = true;
- }
- else {
+ if ($document->getAccessMode($user) < M_READ) {
+ $resultsFilteredByAccess = true;
+ }
+ else {
$lc = $document->getLatestContent();
- print "";
- //print " | ";
- if (in_array(2, $searchin)) {
- $docName = markQuery($document->getName(), "i");
- }
- else {
- $docName = $document->getName();
- }
- print "getID()."\">/";
- $folder = $document->getFolder();
- $path = $folder->getPath();
- for ($i = 1; $i < count($path); $i++) {
- print $path[$i]->getName()."/";
+ print "";
+ //print " | ";
+ if (in_array(2, $searchin)) {
+ $docName = markQuery($document->getName(), "i");
}
- print $docName;
+ else {
+ $docName = $document->getName();
+ }
+ print "getID()."\">/";
+ $folder = $document->getFolder();
+ $path = $folder->getPath();
+ for ($i = 1; $i < count($path); $i++) {
+ print $path[$i]->getName()."/";
+ }
+ print $docName;
print " | ";
$owner = $document->getOwner();
- print "".$owner->getFullName()." | ";
- print "".getOverallStatusText($lc->getStatus()). " | ";
+ print "".$owner->getFullName()." | ";
+ print "".getOverallStatusText($lc->getStatus()). " | ";
print "".$lc->getVersion()." | ";
- if (in_array(3, $searchin)) $comment = markQuery($document->getComment());
- else $comment = $document->getComment();
- if (strlen($comment) > 50) $comment = substr($comment, 0, 47) . "...";
+ if (in_array(3, $searchin)) $comment = markQuery($document->getComment());
+ else $comment = $document->getComment();
+ if (strlen($comment) > 50) $comment = substr($comment, 0, 47) . "...";
print "".$comment." | ";
- print " \n";
- }
-}
-if ($resultsFilteredByAccess) {
- print "". getMLText("search_results_access_filtered") . " | ";
-}
-print " |
\n";
-
-UI::pageList($pageNumber, $resArr['totalPages'], "../op/op.Search.php", $_GET);
-
-UI::contentContainerEnd();
-UI::htmlEndPage();
-?>
+ print "
\n";
+ }
+}
+if ($resultsFilteredByAccess) {
+ print "". getMLText("search_results_access_filtered") . " |
";
+}
+print "\n";
+
+UI::pageList($pageNumber, $resArr['totalPages'], "../op/op.Search.php", $_GET);
+
+UI::contentContainerEnd();
+UI::htmlEndPage();
+?>
diff --git a/op/op.SearchFulltext.php b/op/op.SearchFulltext.php
new file mode 100644
index 000000000..838066618
--- /dev/null
+++ b/op/op.SearchFulltext.php
@@ -0,0 +1,229 @@
+_rootFolderID;
+} else {
+ $folderid = $_GET["folderid"];
+}
+
+$folder = $dms->getFolder($folderid);
+if (!is_object($folder)) {
+ UI::exitError(getMLText("search_results"),getMLText("invalid_folder_id"));
+}
+
+// Create the keyword search string. This search spans up to three columns
+// in the database: keywords, name and comment.
+
+if (isset($_GET["query"]) && is_string($_GET["query"])) {
+ $query = sanitizeString($_GET["query"]);
+}
+else {
+ $query = "";
+}
+
+// category
+$categories = array();
+if(isset($_GET['categoryids']) && $_GET['categoryids']) {
+ foreach($_GET['categoryids'] as $catid) {
+ if($catid > 0) {
+ $category = $dms->getDocumentCategory($catid);
+ $categories[] = $category->getName();
+ }
+ }
+}
+
+//
+// Get the page number to display. If the result set contains more than
+// 25 entries, it is displayed across multiple pages.
+//
+// This requires that a page number variable be used to track which page the
+// user is interested in, and an extra clause on the select statement.
+//
+// Default page to display is always one.
+$pageNumber=1;
+if (isset($_GET["pg"])) {
+ if (is_numeric($_GET["pg"]) && $_GET["pg"]>0) {
+ $pageNumber = (integer)$_GET["pg"];
+ }
+ else if (!strcasecmp($_GET["pg"], "all")) {
+ $pageNumber = "all";
+ }
+}
+
+
+// --------------- Suche starten --------------------------------------------
+
+$folderPathHTML = getFolderPathHTML($folder, true);
+UI::htmlStartPage(getMLText("search_results"));
+UI::globalNavigation($folder);
+UI::pageNavigation($folderPathHTML, "", $folder);
+UI::contentHeading(getMLText("search_results"));
+
+// Check to see if the search has been restricted to a particular
+// document owner.
+$owner = null;
+if (isset($_GET["ownerid"]) && is_numeric($_GET["ownerid"]) && $_GET["ownerid"]!=-1) {
+ $owner = $dms->getUser($_GET["ownerid"]);
+ if (!is_object($owner)) {
+ UI::contentContainer(getMLText("unknown_owner"));
+ UI::htmlEndPage();
+ exit;
+ }
+}
+
+$pageNumber=1;
+if (isset($_GET["pg"])) {
+ if (is_numeric($_GET["pg"]) && $_GET["pg"]>0) {
+ $pageNumber = (integer)$_GET["pg"];
+ }
+ else if (!strcasecmp($_GET["pg"], "all")) {
+ $pageNumber = "all";
+ }
+}
+
+$startTime = getTime();
+if($settings->_enableFullSearch) {
+ if(!empty($settings->_luceneDir))
+ require_once($settings->_luceneDir.'/Lucene.php');
+ else
+ require_once('LetoDMS/Lucene.php');
+}
+$index = Zend_Search_Lucene::open($settings->_indexPath);
+$lucenesearch = new LetoDMS_Lucene_Search($index);
+$hits = $lucenesearch->search($query, $owner ? $owner->getLogin() : '', '', $categories);
+$limit = 25;
+$resArr = array();
+if($pageNumber != 'all' && count($hits) > $limit) {
+ $resArr['totalPages'] = (int) (count($hits) / $limit);
+ if ((count($hits)%$limit) > 0)
+ $resArr['totalPages']++;
+ $hits = array_slice($hits, ($pageNumber-1)*$limit, $limit);
+} else {
+ $resArr['totalPages'] = 1;
+}
+
+$resArr['docs'] = array();
+$resArr['totalDocs'] = 0;
+if($hits) {
+ $resArr['totalDocs'] = count($hits);
+ foreach($hits as $hit) {
+ $resArr['docs'][] = $dms->getDocument($hit['document_id']);
+ }
+}
+$searchTime = getTime() - $startTime;
+$searchTime = round($searchTime, 2);
+
+UI::contentContainerStart();
+?>
+
+
+
+ $resArr['totalDocs']));
+}
+?>
+ |
+ $searchTime));?> |
+
+
+
+";
+print "\n\n";
+//print " | \n";
+print "".getMLText("name")." | \n";
+print "".getMLText("owner")." | \n";
+print "".getMLText("status")." | \n";
+print "".getMLText("version")." | \n";
+print "".getMLText("comment")." | \n";
+//print "".getMLText("reviewers")." | \n";
+//print "".getMLText("approvers")." | \n";
+print "
\n\n\n";
+
+$resultsFilteredByAccess = false;
+foreach ($resArr['docs'] as $document) {
+ if ($document->getAccessMode($user) < M_READ) {
+ $resultsFilteredByAccess = true;
+ }
+ else {
+ $lc = $document->getLatestContent();
+ print "";
+ $docName = $document->getName();
+ print "getID()."\">/";
+ $folder = $document->getFolder();
+ $path = $folder->getPath();
+ for ($i = 1; $i < count($path); $i++) {
+ print $path[$i]->getName()."/";
+ }
+ print $docName;
+ print " | ";
+
+ $owner = $document->getOwner();
+ print "".$owner->getFullName()." | ";
+ print "".getOverallStatusText($lc->getStatus()). " | ";
+
+ print "".$lc->getVersion()." | ";
+
+ $comment = $document->getComment();
+ if (strlen($comment) > 50) $comment = substr($comment, 0, 47) . "...";
+ print "".$comment." | ";
+ print "
\n";
+ }
+}
+if ($resultsFilteredByAccess) {
+ print "". getMLText("search_results_access_filtered") . " |
";
+}
+print "\n";
+
+UI::pageList($pageNumber, $resArr['totalPages'], "../op/op.Search.php", $_GET);
+
+UI::contentContainerEnd();
+UI::htmlEndPage();
+?>
diff --git a/out/out.IndexInfo.php b/out/out.IndexInfo.php
new file mode 100644
index 000000000..a4216c5de
--- /dev/null
+++ b/out/out.IndexInfo.php
@@ -0,0 +1,59 @@
+isAdmin()) {
+ UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
+}
+
+$v = new LetoDMS_Version;
+
+UI::htmlStartPage(getMLText('fulltext_info'));
+UI::globalNavigation();
+UI::pageNavigation(getMLText('fulltext_info'));
+UI::contentContainerStart();
+if($settings->_enableFullSearch) {
+ if(!empty($settings->_luceneDir))
+ require_once($settings->_luceneDir.'/Lucene.php');
+ else
+ require_once('LetoDMS/Lucene.php');
+
+ $index = Zend_Search_Lucene::open($settings->_indexPath);
+
+ $terms = $index->terms();
+ echo "".count($terms)." Terms
";
+ echo "";
+ foreach($terms as $term) {
+ echo $term->field.":".$term->text."\n";
+ }
+ echo "
";
+} else {
+ printMLText("fulltextsearch_disabled");
+}
+UI::contentContainerEnd();
+UI::htmlEndPage();
+?>
diff --git a/out/out.Indexer.php b/out/out.Indexer.php
new file mode 100644
index 000000000..9e982d9bf
--- /dev/null
+++ b/out/out.Indexer.php
@@ -0,0 +1,113 @@
+getName()."\n";
+ $subfolders = $folder->getSubFolders();
+ foreach($subfolders as $subfolder) {
+ tree($subfolder, $indent.' ');
+ }
+ $documents = $folder->getDocuments();
+ foreach($documents as $document) {
+ echo $indent." ".$document->getId().":".$document->getName()." ";
+ /* If the document wasn't indexed before then just add it */
+ if(!($hits = $index->find('document_id:'.$document->getId()))) {
+ $index->addDocument(new LetoDMS_Lucene_IndexedDocument($dms, $document));
+ echo "(document added)";
+ } else {
+ $hit = $hits[0];
+ $created = (int) $hit->getDocument()->getFieldValue('created');
+ $content = $document->getLatestContent();
+ if($created >= $content->getDate()) {
+ echo $indent."(document unchanged)";
+ } else {
+ if($index->delete($hit->id)) {
+ $index->addDocument(new LetoDMS_Lucene_IndexedDocument($dms, $document));
+ }
+ echo $indent."(document updated)";
+ }
+ }
+ echo "\n";
+ }
+} /* }}} */
+
+if (!$user->isAdmin()) {
+ UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
+}
+
+$v = new LetoDMS_Version;
+
+UI::htmlStartPage($v->banner());
+UI::globalNavigation();
+UI::pageNavigation($v->banner());
+UI::contentContainerStart();
+if($settings->_enableFullSearch) {
+ if(!empty($settings->_luceneDir))
+ require_once($settings->_luceneDir.'/Lucene.php');
+ else
+ require_once('LetoDMS/Lucene.php');
+
+ if(isset($_GET['create']) && $_GET['create'] == 1) {
+ if(isset($_GET['confirm']) && $_GET['confirm'] == 1) {
+ echo "Recreating index
";
+ $index = Zend_Search_Lucene::create($settings->_indexPath);
+ } else {
+ echo ''.getMLText('create_fulltext_index_warning').'
';
+ echo ''.getMLText('confirm_create_fulltext_index').'';
+ UI::contentContainerEnd();
+ UI::htmlEndPage();
+ exit;
+ }
+ } else {
+ echo "Updating index
";
+ $index = Zend_Search_Lucene::open($settings->_indexPath);
+ }
+
+ if($settings->_stopWordsFile && file_exists($settings->_stopWordsFile)) {
+ $stopWordsFilter = new Zend_Search_Lucene_Analysis_TokenFilter_StopWords();
+ $stopWordsFilter->loadFromFile($settings->_stopWordsFile);
+
+ $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive();
+ $analyzer->addFilter($stopWordsFilter);
+
+ Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
+ }
+
+ $folder = $dms->getFolder($settings->_rootFolderID);
+ echo "";
+ tree($folder);
+ echo "
";
+
+ $index->commit();
+} else {
+ printMLText("fulltextsearch_disabled");
+}
+UI::contentContainerEnd();
+UI::htmlEndPage();
+?>