mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-12 20:51:30 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
1c1d547e92
|
@ -205,7 +205,8 @@
|
||||||
- add filter function to notification service
|
- add filter function to notification service
|
||||||
- reindex document after it was edited
|
- reindex document after it was edited
|
||||||
- show preview images in drop folder menu after mouse over
|
- show preview images in drop folder menu after mouse over
|
||||||
- add support for indexing folders
|
- add support for indexing folders in fulltext search
|
||||||
|
- add support for start folder in fulltext search
|
||||||
- always call hook postAddSubFolder and postEditDocument
|
- always call hook postAddSubFolder and postEditDocument
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
|
@ -128,6 +128,7 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
|
||||||
if($comment = $document->getComment()) {
|
if($comment = $document->getComment()) {
|
||||||
$this->addField(Zend_Search_Lucene_Field::Text('comment', $comment, 'utf-8'));
|
$this->addField(Zend_Search_Lucene_Field::Text('comment', $comment, 'utf-8'));
|
||||||
}
|
}
|
||||||
|
$this->addField(Zend_Search_Lucene_Field::Keyword('path', $document->getFolderList()));
|
||||||
|
|
||||||
if($document->isType('document')) {
|
if($document->isType('document')) {
|
||||||
$this->addField(Zend_Search_Lucene_Field::Keyword('document_id', 'D'.$document->getID()));
|
$this->addField(Zend_Search_Lucene_Field::Keyword('document_id', 'D'.$document->getID()));
|
||||||
|
|
|
@ -110,6 +110,21 @@ class SeedDMS_Lucene_Search {
|
||||||
$querystr .= implode('" || users:"', $fields['user']);
|
$querystr .= implode('" || users:"', $fields['user']);
|
||||||
$querystr .= '")';
|
$querystr .= '")';
|
||||||
}
|
}
|
||||||
|
if(!empty($fields['rootFolder']) && $fields['rootFolder']->getFolderList()) {
|
||||||
|
if($querystr)
|
||||||
|
$querystr .= ' && ';
|
||||||
|
$querystr .= '(path:"';
|
||||||
|
$querystr .= $fields['rootFolder']->getFolderList().$fields['rootFolder']->getID().':';
|
||||||
|
$querystr .= '")';
|
||||||
|
}
|
||||||
|
if(!empty($fields['startFolder']) && $fields['startFolder']->getFolderList()) {
|
||||||
|
if($querystr)
|
||||||
|
$querystr .= ' && ';
|
||||||
|
$querystr .= '(path:"';
|
||||||
|
$querystr .= $fields['startFolder']->getFolderList().$fields['startFolder']->getID().':';
|
||||||
|
$querystr .= '")';
|
||||||
|
}
|
||||||
|
echo $querystr;
|
||||||
try {
|
try {
|
||||||
$query = Zend_Search_Lucene_Search_QueryParser::parse($querystr);
|
$query = Zend_Search_Lucene_Search_QueryParser::parse($querystr);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -119,6 +119,7 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
|
||||||
}
|
}
|
||||||
$owner = $document->getOwner();
|
$owner = $document->getOwner();
|
||||||
$this->addField('owner', $owner->getLogin());
|
$this->addField('owner', $owner->getLogin());
|
||||||
|
$this->addField('path', $document->getFolderList());
|
||||||
if($comment = $document->getComment()) {
|
if($comment = $document->getComment()) {
|
||||||
$this->addField('comment', $comment);
|
$this->addField('comment', $comment);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,9 +63,9 @@ class SeedDMS_SQLiteFTS_Indexer {
|
||||||
*/
|
*/
|
||||||
$version = SQLite3::version();
|
$version = SQLite3::version();
|
||||||
if($version['versionNumber'] >= 3008000)
|
if($version['versionNumber'] >= 3008000)
|
||||||
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(documentid, title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, status, notindexed=created, matchinfo=fts3)';
|
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(documentid, title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, status, path, notindexed=created, matchinfo=fts3)';
|
||||||
else
|
else
|
||||||
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(documentid, title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, status, matchinfo=fts3)';
|
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(documentid, title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, status, path, matchinfo=fts3)';
|
||||||
$res = $index->_conn->exec($sql);
|
$res = $index->_conn->exec($sql);
|
||||||
if($res === false) {
|
if($res === false) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -96,7 +96,7 @@ class SeedDMS_SQLiteFTS_Indexer {
|
||||||
if(!$this->_conn)
|
if(!$this->_conn)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$sql = "INSERT INTO docs (documentid, title, comment, keywords, category, owner, content, mimetype, origfilename, created, users, status) VALUES (".$this->_conn->quote($doc->getFieldValue('document_id')).", ".$this->_conn->quote($doc->getFieldValue('title')).", ".$this->_conn->quote($doc->getFieldValue('comment')).", ".$this->_conn->quote($doc->getFieldValue('keywords')).", ".$this->_conn->quote($doc->getFieldValue('category')).", ".$this->_conn->quote($doc->getFieldValue('owner')).", ".$this->_conn->quote($doc->getFieldValue('content')).", ".$this->_conn->quote($doc->getFieldValue('mimetype')).", ".$this->_conn->quote($doc->getFieldValue('origfilename')).", ".(int)$doc->getFieldValue('created').", ".$this->_conn->quote($doc->getFieldValue('users')).", ".$this->_conn->quote($doc->getFieldValue('status'))/*time()*/.")";
|
$sql = "INSERT INTO docs (documentid, title, comment, keywords, category, owner, content, mimetype, origfilename, created, users, status, path) VALUES (".$this->_conn->quote($doc->getFieldValue('document_id')).", ".$this->_conn->quote($doc->getFieldValue('title')).", ".$this->_conn->quote($doc->getFieldValue('comment')).", ".$this->_conn->quote($doc->getFieldValue('keywords')).", ".$this->_conn->quote($doc->getFieldValue('category')).", ".$this->_conn->quote($doc->getFieldValue('owner')).", ".$this->_conn->quote($doc->getFieldValue('content')).", ".$this->_conn->quote($doc->getFieldValue('mimetype')).", ".$this->_conn->quote($doc->getFieldValue('origfilename')).", ".(int)$doc->getFieldValue('created').", ".$this->_conn->quote($doc->getFieldValue('users')).", ".$this->_conn->quote($doc->getFieldValue('status')).", ".$this->_conn->quote($doc->getFieldValue('path'))/*time()*/.")";
|
||||||
$res = $this->_conn->exec($sql);
|
$res = $this->_conn->exec($sql);
|
||||||
if($res === false) {
|
if($res === false) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -204,7 +204,7 @@ class SeedDMS_SQLiteFTS_Indexer {
|
||||||
if(!$this->_conn)
|
if(!$this->_conn)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$sql = "SELECT docid, documentid, title, comment, owner, keywords, category, mimetype, origfilename, created, users, status FROM docs WHERE docid=".$id;
|
$sql = "SELECT docid, documentid, title, comment, owner, keywords, category, mimetype, origfilename, created, users, status, path FROM docs WHERE docid=".$id;
|
||||||
$res = $this->_conn->query($sql);
|
$res = $this->_conn->query($sql);
|
||||||
$doc = false;
|
$doc = false;
|
||||||
if($res) {
|
if($res) {
|
||||||
|
@ -222,6 +222,7 @@ class SeedDMS_SQLiteFTS_Indexer {
|
||||||
$doc->addField('created', $rec['created']);
|
$doc->addField('created', $rec['created']);
|
||||||
$doc->addField('users', $rec['users']);
|
$doc->addField('users', $rec['users']);
|
||||||
$doc->addField('status', $rec['status']);
|
$doc->addField('status', $rec['status']);
|
||||||
|
$doc->addField('path', $rec['path']);
|
||||||
}
|
}
|
||||||
return $doc;
|
return $doc;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -236,7 +237,7 @@ class SeedDMS_SQLiteFTS_Indexer {
|
||||||
if(!$this->_conn)
|
if(!$this->_conn)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$sql = "SELECT docid, documentid, title, comment, owner, keywords, category, mimetype, origfilename, created, users, status FROM docs WHERE documentid='F".$id."'";
|
$sql = "SELECT docid, documentid, title, comment, owner, keywords, category, mimetype, origfilename, created, users, status, path FROM docs WHERE documentid='F".$id."'";
|
||||||
$res = $this->_conn->query($sql);
|
$res = $this->_conn->query($sql);
|
||||||
$doc = false;
|
$doc = false;
|
||||||
if($res) {
|
if($res) {
|
||||||
|
@ -249,6 +250,7 @@ class SeedDMS_SQLiteFTS_Indexer {
|
||||||
$doc->addField('owner', $rec['owner']);
|
$doc->addField('owner', $rec['owner']);
|
||||||
$doc->addField('created', $rec['created']);
|
$doc->addField('created', $rec['created']);
|
||||||
$doc->addField('users', $rec['users']);
|
$doc->addField('users', $rec['users']);
|
||||||
|
$doc->addField('path', $rec['path']);
|
||||||
}
|
}
|
||||||
return $doc;
|
return $doc;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
|
@ -111,6 +111,20 @@ class SeedDMS_SQliteFTS_Search {
|
||||||
$querystr .= implode(' OR users:', $fields['user']);
|
$querystr .= implode(' OR users:', $fields['user']);
|
||||||
$querystr .= ')';
|
$querystr .= ')';
|
||||||
}
|
}
|
||||||
|
if(!empty($fields['rootFolder']) && $fields['rootFolder']->getFolderList()) {
|
||||||
|
if($querystr)
|
||||||
|
$querystr .= ' ';
|
||||||
|
$querystr .= '(path:';
|
||||||
|
$querystr .= $fields['rootFolder']->getFolderList().$fields['rootFolder']->getID().':';
|
||||||
|
$querystr .= ')';
|
||||||
|
}
|
||||||
|
if(!empty($fields['startFolder']) && $fields['startFolder']->getFolderList()) {
|
||||||
|
if($querystr)
|
||||||
|
$querystr .= ' ';
|
||||||
|
$querystr .= '(path:';
|
||||||
|
$querystr .= $fields['startFolder']->getFolderList().$fields['startFolder']->getID().':';
|
||||||
|
$querystr .= ')';
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
$result = $this->index->find($querystr, $limit);
|
$result = $this->index->find($querystr, $limit);
|
||||||
$recs = array();
|
$recs = array();
|
||||||
|
|
|
@ -166,6 +166,19 @@ if(((!isset($_GET["fullsearch"]) && $settings->_defaultSearchMethod == 'fulltext
|
||||||
$status[] = S_EXPIRED;
|
$status[] = S_EXPIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check to see if the search has been restricted to a particular sub-tree in
|
||||||
|
// the folder hierarchy.
|
||||||
|
$startFolder = null;
|
||||||
|
if (isset($_GET["targetid"]) && is_numeric($_GET["targetid"]) && $_GET["targetid"]>0) {
|
||||||
|
$targetid = $_GET["targetid"];
|
||||||
|
$startFolder = $dms->getFolder($targetid);
|
||||||
|
if (!is_object($startFolder)) {
|
||||||
|
UI::exitError(getMLText("search"),getMLText("invalid_folder_id"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$rootFolder = $dms->getFolder($settings->_rootFolderID);
|
||||||
|
|
||||||
$startTime = getTime();
|
$startTime = getTime();
|
||||||
if($settings->_fullSearchEngine == 'lucene') {
|
if($settings->_fullSearchEngine == 'lucene') {
|
||||||
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
|
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
|
||||||
|
@ -183,7 +196,7 @@ if(((!isset($_GET["fullsearch"]) && $settings->_defaultSearchMethod == 'fulltext
|
||||||
if($index) {
|
if($index) {
|
||||||
$limit = 20;
|
$limit = 20;
|
||||||
$lucenesearch = $fulltextservice->Search();
|
$lucenesearch = $fulltextservice->Search();
|
||||||
$searchresult = $lucenesearch->search($query, array('owner'=>$owner, 'status'=>$status, 'category'=>$categorynames, 'user'=>$user->isAdmin() ? [] : [$user->getLogin()], 'mimetype'=>$mimetype), ($pageNumber == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($pageNumber-1))));
|
$searchresult = $lucenesearch->search($query, array('owner'=>$owner, 'status'=>$status, 'category'=>$categorynames, 'user'=>$user->isAdmin() ? [] : [$user->getLogin()], 'mimetype'=>$mimetype, 'startFolder'=>$startFolder, 'rootFolder'=>$rootFolder), ($pageNumber == 'all' ? array() : array('limit'=>$limit, 'offset'=>$limit * ($pageNumber-1))));
|
||||||
if($searchresult === false) {
|
if($searchresult === false) {
|
||||||
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
|
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
|
||||||
$dcount = 0;
|
$dcount = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user