Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2020-09-29 17:02:26 +02:00
commit b8652ec951
32 changed files with 573 additions and 426 deletions

View File

@ -179,6 +179,7 @@
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Changes in version 5.1.21 Changes in version 5.1.21
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
- new api to fulltext search
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Changes in version 5.1.20 Changes in version 5.1.20

View File

@ -168,6 +168,10 @@ 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'));
} }
if($version) {
$status = $version->getStatus();
$this->addField(Zend_Search_Lucene_Field::Keyword('status', $status['status'], 'utf-8'));
}
if($version && !$nocontent) { if($version && !$nocontent) {
$path = $dms->contentDir . $version->getPath(); $path = $dms->contentDir . $version->getPath();
if(file_exists($path)) { if(file_exists($path)) {

View File

@ -29,18 +29,22 @@ class SeedDMS_Lucene_Indexer {
*/ */
protected $indexname; protected $indexname;
static function open($luceneDir) { /* {{{ */ static function open($conf) { /* {{{ */
try { try {
$index = Zend_Search_Lucene::open($luceneDir); $index = Zend_Search_Lucene::open($conf['indexdir']);
return($index); return($index);
} catch (Exception $e) { } catch (Exception $e) {
return null; return null;
} }
} /* }}} */ } /* }}} */
static function create($luceneDir) { /* {{{ */ static function create($conf) { /* {{{ */
$index = Zend_Search_Lucene::create($luceneDir); try {
return($index); $index = Zend_Search_Lucene::create($conf['indexdir']);
return($index);
} catch (Exception $e) {
return null;
}
} /* }}} */ } /* }}} */
/** /**

View File

@ -59,30 +59,42 @@ class SeedDMS_Lucene_Search {
* @param object $index lucene index * @param object $index lucene index
* @return object instance of SeedDMS_Lucene_Search * @return object instance of SeedDMS_Lucene_Search
*/ */
function search($term, $owner, $status='', $categories=array(), $fields=array(), $users=array()) { /* {{{ */ function search($term, $fields=array(), $limit=array()) { /* {{{ */
$querystr = ''; $querystr = '';
if($fields) { if($term)
} else { $querystr .= trim($term);
if($term) if(!empty($fields['owner'])) {
$querystr .= trim($term); if(is_string($owner)) {
if($querystr)
$querystr .= ' && ';
$querystr .= 'owner:'.$owner;
} elseif(is_array($fields['owner'])) {
if($querystr)
$querystr .= ' && ';
$querystr .= '(owner:"';
$querystr .= implode('" || owner:"', $fields['owner']);
$querystr .= '")';
}
} }
if($owner) { if(!empty($fields['category'])) {
if($querystr)
$querystr .= ' && ';
$querystr .= 'owner:'.$owner;
}
if($categories) {
if($querystr) if($querystr)
$querystr .= ' && '; $querystr .= ' && ';
$querystr .= '(category:"'; $querystr .= '(category:"';
$querystr .= implode('" || category:"', $categories); $querystr .= implode('" || category:"', $fields['category']);
$querystr .= '")'; $querystr .= '")';
} }
if($users) { if(!empty($fields['status'])) {
if($querystr)
$querystr .= ' && ';
$querystr .= '(status:"';
$querystr .= implode('" || status:"', $fields['status']);
$querystr .= '")';
}
if(!empty($fields['user'])) {
if($querystr) if($querystr)
$querystr .= ' && '; $querystr .= ' && ';
$querystr .= '(users:"'; $querystr .= '(users:"';
$querystr .= implode('" || users:"', $users); $querystr .= implode('" || users:"', $fields['user']);
$querystr .= '")'; $querystr .= '")';
} }
try { try {
@ -90,10 +102,13 @@ class SeedDMS_Lucene_Search {
try { try {
$hits = $this->index->find($query); $hits = $this->index->find($query);
$recs = array(); $recs = array();
$c = 0;
foreach($hits as $hit) { foreach($hits as $hit) {
$recs[] = array('id'=>$hit->id, 'document_id'=>$hit->document_id); if($c >= $limit['offset'] && ($c-$limit['offset'] < $limit))
$recs[] = array('id'=>$hit->id, 'document_id'=>$hit->document_id);
$c++;
} }
return $recs; return array('count'=>count($hits), 'hits'=>$recs, 'facets'=>array());
} catch (Zend_Search_Lucene_Exception $e) { } catch (Zend_Search_Lucene_Exception $e) {
return false; return false;
} }

View File

@ -11,11 +11,11 @@
<email>uwe@steinmann.cx</email> <email>uwe@steinmann.cx</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2020-09-02</date> <date>2020-09-10</date>
<time>08:55:43</time> <time>08:55:43</time>
<version> <version>
<release>1.1.14</release> <release>1.1.15</release>
<api>1.1.14</api> <api>1.1.15</api>
</version> </version>
<stability> <stability>
<release>stable</release> <release>stable</release>
@ -23,7 +23,12 @@
</stability> </stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license> <license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes> <notes>
Index users with at least read access on the document - add searching for document status
- better error handling if opening index fails
- parameters for SeedDMS_Lucene_Search::search() has changed
- SeedDMS_Lucene_Search::search() returns array of hits, count and facets
- pass config array instead of index directory to SeedDMS_Lucene_Indexer::create()
and SeedDMS_Lucene_Indexer::open()
</notes> </notes>
<contents> <contents>
<dir baseinstalldir="SeedDMS" name="/"> <dir baseinstalldir="SeedDMS" name="/">
@ -315,5 +320,21 @@ execWithTimeout() reads data from stderr and saves it into error msg
IndexedDocument() remembers cmd and mimetype IndexedDocument() remembers cmd and mimetype
</notes> </notes>
</release> </release>
<release>
<date>2020-09-02</date>
<time>08:55:43</time>
<version>
<release>1.1.14</release>
<api>1.1.14</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
Index users with at least read access on the document
</notes>
</release>
</changelog> </changelog>
</package> </package>

View File

@ -162,6 +162,10 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
$this->addField('groups', implode(' ', $allg)); $this->addField('groups', implode(' ', $allg));
*/ */
} }
if($version) {
$status = $version->getStatus();
$this->addField('status', $status['status']+10);
}
if($version && !$nocontent) { if($version && !$nocontent) {
$path = $dms->contentDir . $version->getPath(); $path = $dms->contentDir . $version->getPath();
if(file_exists($path)) { if(file_exists($path)) {

View File

@ -42,30 +42,30 @@ class SeedDMS_SQLiteFTS_Indexer {
* *
* @param string $indexerDir directory on disk containing the index * @param string $indexerDir directory on disk containing the index
*/ */
static function open($indexerDir) { /* {{{ */ static function open($conf) { /* {{{ */
if(file_exists($indexerDir.'/index.db')) { if(file_exists($conf['indexdir'].'/index.db')) {
return new SeedDMS_SQLiteFTS_Indexer($indexerDir); return new SeedDMS_SQLiteFTS_Indexer($conf['indexdir']);
} else } else
return self::create($indexerDir); return self::create($conf['indexdir']);
} /* }}} */ } /* }}} */
/** /**
* Create a new index * Create a new index
* *
* @param string $indexerDir directory on disk containing the index * @param array $conf $conf['indexdir'] is the directory on disk containing the index
*/ */
static function create($indexerDir) { /* {{{ */ static function create($conf) { /* {{{ */
if(file_exists($indexerDir.'/index.db')) if(file_exists($conf['indexdir'].'/index.db'))
unlink($indexerDir.'/index.db'); unlink($conf['indexdir'].'/index.db');
$index = new SeedDMS_SQLiteFTS_Indexer($indexerDir); $index = new SeedDMS_SQLiteFTS_Indexer($conf['indexdir']);
/* Make sure the sequence of fields is identical to the field list /* Make sure the sequence of fields is identical to the field list
* in SeedDMS_SQLiteFTS_Term * in SeedDMS_SQLiteFTS_Term
*/ */
$version = SQLite3::version(); $version = SQLite3::version();
if($version['versionNumber'] >= 3008000) if($version['versionNumber'] >= 3008000)
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, notindexed=created, matchinfo=fts3)'; $sql = 'CREATE VIRTUAL TABLE docs USING fts4(title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, status, notindexed=created, matchinfo=fts3)';
else else
$sql = 'CREATE VIRTUAL TABLE docs USING fts4(title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, matchinfo=fts3)'; $sql = 'CREATE VIRTUAL TABLE docs USING fts4(title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, status, 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 (docid, title, comment, keywords, category, owner, content, mimetype, origfilename, created, users) VALUES(".$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')).", ".$doc->getFieldValue('created').", ".$this->_conn->quote($doc->getFieldValue('users'))/*time()*/.")"; $sql = "INSERT INTO docs (docid, title, comment, keywords, category, owner, content, mimetype, origfilename, created, users, status) VALUES(".$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()*/.")";
$res = $this->_conn->exec($sql); $res = $this->_conn->exec($sql);
if($res === false) { if($res === false) {
return false; return false;
@ -135,15 +135,29 @@ class SeedDMS_SQLiteFTS_Indexer {
/** /**
* Find documents in index * Find documents in index
* *
* @param object $doc indexed document of class * @param string $query
* SeedDMS_SQLiteFTS_IndexedDocument * @param array $limit array with elements 'limit' and 'offset'
* @return boolean false in case of an error, otherwise true * @return boolean false in case of an error, otherwise array with elements
* 'count', 'hits', 'facets'
*/ */
public function find($query) { /* {{{ */ public function find($query, $limit=array()) { /* {{{ */
if(!$this->_conn) if(!$this->_conn)
return false; return false;
$sql = "SELECT docid FROM docs WHERE docs MATCH ".$this->_conn->quote($query); $sql = "SELECT count(*) AS `c` FROM `docs`";
if($query)
$sql .= " WHERE docs MATCH ".$this->_conn->quote($query);
$res = $this->_conn->query($sql);
$row = $res->fetch();
$sql = "SELECT docid FROM docs";
if($query)
$sql .= " WHERE docs MATCH ".$this->_conn->quote($query);
$res = $this->_conn->query($sql);
if(!empty($limit['limit']))
$sql .= " LIMIT ".(int) $limit['limit'];
if(!empty($limit['offset']))
$sql .= " OFFSET ".(int) $limit['offset'];
$res = $this->_conn->query($sql); $res = $this->_conn->query($sql);
$hits = array(); $hits = array();
if($res) { if($res) {
@ -153,7 +167,7 @@ class SeedDMS_SQLiteFTS_Indexer {
$hits[] = $hit; $hits[] = $hit;
} }
} }
return $hits; return array('count'=>$row['c'], 'hits'=>$hits);
} /* }}} */ } /* }}} */
/** /**
@ -189,7 +203,7 @@ class SeedDMS_SQLiteFTS_Indexer {
if(!$this->_conn) if(!$this->_conn)
return false; return false;
$sql = "SELECT title, comment, owner, keywords, category, mimetype, origfilename, created, users FROM docs WHERE docid=".(int) $id; $sql = "SELECT title, comment, owner, keywords, category, mimetype, origfilename, created, users, status FROM docs WHERE docid=".(int) $id;
$res = $this->_conn->query($sql); $res = $this->_conn->query($sql);
$doc = false; $doc = false;
if($res) { if($res) {
@ -204,6 +218,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('status', $rec['status']);
} }
return $doc; return $doc;
} /* }}} */ } /* }}} */

View File

@ -59,43 +59,52 @@ class SeedDMS_SQliteFTS_Search {
* @param object $index SQlite FTS index * @param object $index SQlite FTS index
* @return object instance of SeedDMS_Lucene_Search * @return object instance of SeedDMS_Lucene_Search
*/ */
function search($term, $owner, $status='', $categories=array(), $fields=array(), $users=array()) { /* {{{ */ function search($term, $fields=array(), $limit=array()) { /* {{{ */
$querystr = ''; $querystr = '';
if($fields) { if($term)
} else { $querystr .= trim($term);
if($term) if(!empty($fields['owner'])) {
$querystr .= trim($term); if(is_string($fields['owner'])) {
if($querystr)
$querystr .= ' ';
$querystr .= 'owner:'.$fields['owner'];
} elseif(is_array($fields['owner'])) {
if($querystr)
$querystr .= ' ';
$querystr .= '(owner:';
$querystr .= implode(' OR owner:', $fields['owner']);
$querystr .= ')';
}
} }
if($owner) { if(!empty($fields['category'])) {
if($querystr) if($querystr)
$querystr .= ' '; $querystr .= ' ';
//$querystr .= ' AND '; $querystr .= '(category:';
$querystr .= 'owner:'.$owner; $querystr .= implode(' OR category:', $fields['category']);
//$querystr .= $owner; $querystr .= ')';
} }
if($categories) { if(!empty($fields['status'])) {
if($querystr) if($querystr)
$querystr .= ' '; $querystr .= ' ';
//$querystr .= ' AND '; $status = array_map(function($v){return $v+10;}, $fields['status']);
$querystr .= 'category:'; $querystr .= '(status:';
$querystr .= implode(' OR category:', $categories); $querystr .= implode(' OR status:', $status);
$querystr .= ''; $querystr .= ')';
} }
if($users) { if(!empty($fields['user'])) {
if($querystr) if($querystr)
$querystr .= ' '; $querystr .= ' ';
//$querystr .= ' AND '; $querystr .= '(users:';
$querystr .= 'users:'; $querystr .= implode(' OR users:', $fields['user']);
$querystr .= implode(' OR users:', $users); $querystr .= ')';
$querystr .= '';
} }
try { try {
$hits = $this->index->find($querystr); $result = $this->index->find($querystr, $limit);
$recs = array(); $recs = array();
foreach($hits as $hit) { foreach($result["hits"] as $hit) {
$recs[] = array('id'=>$hit->id, 'document_id'=>$hit->id); $recs[] = array('id'=>$hit->id, 'document_id'=>$hit->id);
} }
return $recs; return array('count'=>$result['count'], 'hits'=>$recs, 'facets'=>array());
} catch (Exception $e) { } catch (Exception $e) {
return false; return false;
} }

View File

@ -57,7 +57,8 @@ class SeedDMS_SQLiteFTS_Term {
6 => 'owner', 6 => 'owner',
7 => 'content', 7 => 'content',
8 => 'created', 8 => 'created',
9 => 'user' 9 => 'user',
10 => 'status'
); );
$this->field = $fields[$col]; $this->field = $fields[$col];
$this->_occurrence = $occurrence; $this->_occurrence = $occurrence;

View File

@ -11,11 +11,11 @@
<email>uwe@steinmann.cx</email> <email>uwe@steinmann.cx</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2020-09-02</date> <date>2020-09-11</date>
<time>08:57:44</time> <time>08:57:44</time>
<version> <version>
<release>1.0.13</release> <release>1.0.14</release>
<api>1.0.13</api> <api>1.0.14</api>
</version> </version>
<stability> <stability>
<release>stable</release> <release>stable</release>
@ -23,7 +23,12 @@
</stability> </stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license> <license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes> <notes>
add user to list of terms - add searching for document status
- search even if query is empty (will find all documents)
- parameters for SeedDMS_SQLiteFTS_Search::search() has changed
- SeedDMS_Lucene_Search::search() returns array of hits, count and facets
- pass config array instead of index directory to SeedDMS_Lucene_Indexer::create()
and SeedDMS_Lucene_Indexer::open()
</notes> </notes>
<contents> <contents>
<dir baseinstalldir="SeedDMS" name="/"> <dir baseinstalldir="SeedDMS" name="/">
@ -275,5 +280,21 @@ timestamp)
Index users with at least read access on a document Index users with at least read access on a document
</notes> </notes>
</release> </release>
<release>
<date>2020-09-02</date>
<time>08:57:44</time>
<version>
<release>1.0.13</release>
<api>1.0.13</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
add user to list of terms
</notes>
</release>
</changelog> </changelog>
</package> </package>

View File

@ -26,8 +26,7 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common {
$dms = $this->params['dms']; $dms = $this->params['dms'];
$user = $this->params['user']; $user = $this->params['user'];
$settings = $this->params['settings']; $settings = $this->params['settings'];
$index = $this->params['index']; $fulltextservice = $this->params['fulltextservice'];
$indexconf = $this->params['indexconf'];
$folder = $this->params['folder']; $folder = $this->params['folder'];
/* Call preAddDocument early, because it might need to modify some /* Call preAddDocument early, because it might need to modify some
@ -167,8 +166,8 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common {
return false; return false;
} }
if($index && $document) { if($fulltextservice && ($index = $fulltextservice->Indexer()) && $document) {
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, !($filesize < $settings->_maxSizeForFullText)); $idoc = $fulltextservice->IndexedDocument($document);
if(false !== $this->callHook('preIndexDocument', $document, $idoc)) { if(false !== $this->callHook('preIndexDocument', $document, $idoc)) {
$index->addDocument($idoc); $index->addDocument($idoc);
$index->commit(); $index->commit();

View File

@ -27,8 +27,7 @@ class SeedDMS_Controller_RemoveDocument extends SeedDMS_Controller_Common {
$user = $this->params['user']; $user = $this->params['user'];
$settings = $this->params['settings']; $settings = $this->params['settings'];
$document = $this->params['document']; $document = $this->params['document'];
$index = $this->params['index']; $fulltextservice = $this->params['fulltextservice'];
$indexconf = $this->params['indexconf'];
$folder = $document->getFolder(); $folder = $document->getFolder();
@ -58,8 +57,8 @@ class SeedDMS_Controller_RemoveDocument extends SeedDMS_Controller_Common {
} }
/* Remove the document from the fulltext index */ /* Remove the document from the fulltext index */
if($index) { if($fulltextservice && ($index = $fulltextservice->Indexer())) {
$lucenesearch = new $indexconf['Search']($index); $lucenesearch = $fulltextservice->Search();
if($hit = $lucenesearch->getDocument($documentid)) { if($hit = $lucenesearch->getDocument($documentid)) {
$index->delete($hit->id); $index->delete($hit->id);
$index->commit(); $index->commit();

View File

@ -27,8 +27,7 @@ class SeedDMS_Controller_RemoveFolder extends SeedDMS_Controller_Common {
$user = $this->params['user']; $user = $this->params['user'];
$settings = $this->params['settings']; $settings = $this->params['settings'];
$folder = $this->params['folder']; $folder = $this->params['folder'];
$index = $this->params['index']; $fulltextservice = $this->params['fulltextservice'];
$indexconf = $this->params['indexconf'];
/* Get the document id and name before removing the document */ /* Get the document id and name before removing the document */
$foldername = $folder->getName(); $foldername = $folder->getName();
@ -45,18 +44,17 @@ class SeedDMS_Controller_RemoveFolder extends SeedDMS_Controller_Common {
/* Register a callback which removes each document from the fulltext index /* Register a callback which removes each document from the fulltext index
* The callback must return null other the removal will be canceled. * The callback must return null other the removal will be canceled.
*/ */
function removeFromIndex($arr, $document) { function removeFromIndex($fulltextservice, $document) {
$index = $arr[0]; $lucenesearch = $fulltextservice->Search();
$indexconf = $arr[1];
$lucenesearch = new $indexconf['Search']($index);
if($hit = $lucenesearch->getDocument($document->getID())) { if($hit = $lucenesearch->getDocument($document->getID())) {
$index = $fulltextservice->Indexer();
$index->delete($hit->id); $index->delete($hit->id);
$index->commit(); $index->commit();
} }
return null; return null;
} }
if($index) if($fulltextservice && ($index = $fulltextservice->Indexer()))
$dms->setCallback('onPreRemoveDocument', 'removeFromIndex', array($index, $indexconf)); $dms->setCallback('onPreRemoveDocument', 'removeFromIndex', array($fulltextservice));
function removePreviews($arr, $document) { function removePreviews($arr, $document) {
$previewer = $arr[0]; $previewer = $arr[0];

View File

@ -40,8 +40,7 @@ class SeedDMS_Controller_UpdateDocument extends SeedDMS_Controller_Common {
$user = $this->params['user']; $user = $this->params['user'];
$document = $this->params['document']; $document = $this->params['document'];
$settings = $this->params['settings']; $settings = $this->params['settings'];
$index = $this->params['index']; $fulltextservice = $this->params['fulltextservice'];
$indexconf = $this->params['indexconf'];
$folder = $this->params['folder']; $folder = $this->params['folder'];
$userfiletmp = $this->getParam('userfiletmp'); $userfiletmp = $this->getParam('userfiletmp');
$userfilename = $this->getParam('userfilename'); $userfilename = $this->getParam('userfilename');
@ -94,12 +93,12 @@ class SeedDMS_Controller_UpdateDocument extends SeedDMS_Controller_Common {
return false; return false;
} }
if($index && $content) { if($fulltextservice && ($index = $fulltextservice->Indexer()) && $content) {
$lucenesearch = new $indexconf['Search']($index); $lucenesearch = $fulltextservice->Search();
if($hit = $lucenesearch->getDocument((int) $document->getId())) { if($hit = $lucenesearch->getDocument((int) $document->getId())) {
$index->delete($hit->id); $index->delete($hit->id);
} }
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, !($filesize < $settings->_maxSizeForFullText)); $idoc = $fulltextservice->IndexedDocument($document);
if(false !== $this->callHook('preIndexDocument', $document, $idoc)) { if(false !== $this->callHook('preIndexDocument', $document, $idoc)) {
$index->addDocument($idoc); $index->addDocument($idoc);
$index->commit(); $index->commit();

View File

@ -0,0 +1,107 @@
<?php
/**
* Implementation of fulltext service
*
* @category DMS
* @package SeedDMS
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2016 Uwe Steinmann
* @version Release: @package_version@
*/
/**
* Implementation of fulltext service
*
* @category DMS
* @package SeedDMS
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2016 Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_FulltextService {
/**
* List of services for searching fulltext
*/
protected $services;
/**
* List of converters
*/
protected $converters;
/**
* Max file size for imediate indexing
*/
protected $maxsize;
private $index;
private $search;
public function __construct() {
$this->services = array();
$this->converters = array();
$this->maxsize = 0;
$this->index = null;
$this->search = null;
$this->cmdtimeout = 5;
}
public function addService($name, $service) {
$this->services[] = $service;
}
public function setConverters($converters) {
$this->converters = $converters;
}
public function setMaxSize($maxsize) {
$this->maxsize = $maxsize;
}
public function setCmdTimeout($timeout) {
$this->cmdtimeout = $timeout;
}
public function IndexedDocument($document, $forceupdate=false) {
$nocontent = ($document->getLatestContent()->getFileSize() > $this->maxsize) && !$forceupdate;
return new $this->services[0]['IndexedDocument']($document->getDMS(), $document, $this->converters, $nocontent, $this->cmdtimeout);
}
/**
* Returns an instance of the indexer
*
* The indexer provides access to fulltext index. It allows to add and
* get documents.
*
* @return object instance of class specified in 'Indexer'
*/
public function Indexer($recreate=false) {
if($this->index)
return $this->index;
if($this->services[0]) {
if($recreate)
$this->index = $this->services[0]['Indexer']::create($this->services[0]['Conf']);
else
$this->index = $this->services[0]['Indexer']::open($this->services[0]['Conf']);
return $this->index;
} else
return null;
}
public function Search() {
if($this->search)
return $this->search;
if($this->services[0]) {
$this->search = new $this->services[0]['Search']($this->index);
return $this->search;
} else {
return null;
}
}
}

View File

@ -67,3 +67,4 @@ if(isset($GLOBALS['SEEDDMS_HOOKS']['initDMS'])) {
} }
require_once('inc/inc.Tasks.php'); require_once('inc/inc.Tasks.php');
require_once('inc.FulltextInit.php');

View File

@ -52,31 +52,6 @@ if (get_magic_quotes_gpc()) {
unset($process); unset($process);
} }
$indexconf = null;
if($settings->_enableFullSearch) {
if($settings->_fullSearchEngine == 'sqlitefts') {
$indexconf = array(
'Indexer' => 'SeedDMS_SQLiteFTS_Indexer',
'Search' => 'SeedDMS_SQLiteFTS_Search',
'IndexedDocument' => 'SeedDMS_SQLiteFTS_IndexedDocument'
);
require_once('SeedDMS/SQLiteFTS.php');
} else {
$indexconf = array(
'Indexer' => 'SeedDMS_Lucene_Indexer',
'Search' => 'SeedDMS_Lucene_Search',
'IndexedDocument' => 'SeedDMS_Lucene_IndexedDocument'
);
if(!empty($settings->_luceneClassDir))
require_once($settings->_luceneClassDir.'/Lucene.php');
else
require_once('SeedDMS/Lucene.php');
}
}
$settings->_indexconf = $indexconf;
/* Add root Dir. Needed because the view classes are included /* Add root Dir. Needed because the view classes are included
* relative to it. * relative to it.
*/ */

View File

@ -380,13 +380,6 @@ if($settings->_libraryFolder) {
} }
} }
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
$indexconf['Indexer']::init($settings->_stopWordsFile);
} else {
$index = null;
}
/* Check if additional notification shall be added */ /* Check if additional notification shall be added */
$notusers = array(); $notusers = array();
if(!empty($_POST['notification_users'])) { if(!empty($_POST['notification_users'])) {
@ -448,8 +441,7 @@ for ($file_num=0;$file_num<count($_FILES["userfile"]["tmp_name"]);$file_num++){
$controller->setParam('documentsource', $docsource); $controller->setParam('documentsource', $docsource);
$controller->setParam('folder', $folder); $controller->setParam('folder', $folder);
$controller->setParam('index', $index); $controller->setParam('fulltextservice', $fulltextservice);
$controller->setParam('indexconf', $indexconf);
$controller->setParam('name', $name); $controller->setParam('name', $name);
$controller->setParam('comment', $comment); $controller->setParam('comment', $comment);
$controller->setParam('expires', $expires); $controller->setParam('expires', $expires);

View File

@ -519,18 +519,9 @@ switch($command) {
); );
$docname = $document->getName(); $docname = $document->getName();
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
$indexconf['Indexer']::init($settings->_stopWordsFile);
} else {
$index = null;
$indexconf = null;
}
$controller = Controller::factory('RemoveDocument', array('dms'=>$dms, 'user'=>$user)); $controller = Controller::factory('RemoveDocument', array('dms'=>$dms, 'user'=>$user));
$controller->setParam('document', $document); $controller->setParam('document', $document);
$controller->setParam('index', $index); $controller->setParam('fulltextservice', $fulltextservice);
$controller->setParam('indexconf', $indexconf);
if($controller->run()) { if($controller->run()) {
if ($notifier){ if ($notifier){
$subject = "document_deleted_email_subject"; $subject = "document_deleted_email_subject";
@ -785,19 +776,10 @@ switch($command) {
$cats = array(); $cats = array();
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
$indexconf['Indexer']::init($settings->_stopWordsFile);
} else {
$index = null;
$indexconf = null;
}
$controller = Controller::factory('AddDocument', array('dms'=>$dms, 'user'=>$user)); $controller = Controller::factory('AddDocument', array('dms'=>$dms, 'user'=>$user));
$controller->setParam('documentsource', 'upload'); $controller->setParam('documentsource', 'upload');
$controller->setParam('folder', $folder); $controller->setParam('folder', $folder);
$controller->setParam('index', $index); $controller->setParam('fulltextservice', $fulltextservice);
$controller->setParam('indexconf', $indexconf);
$controller->setParam('name', $name); $controller->setParam('name', $name);
$controller->setParam('comment', ''); $controller->setParam('comment', '');
$controller->setParam('expires', $expires); $controller->setParam('expires', $expires);
@ -1009,13 +991,11 @@ switch($command) {
case 'indexdocument': /* {{{ */ case 'indexdocument': /* {{{ */
if($user && $user->isAdmin()) { if($user && $user->isAdmin()) {
if($settings->_enableFullSearch) { if($fulltextservice) {
$document = $dms->getDocument($_REQUEST['id']); $document = $dms->getDocument($_REQUEST['id']);
if($document) { if($document) {
$index = $indexconf['Indexer']::open($settings->_luceneDir); if($index = $fulltextservice->Indexer()) {
if($index) { $idoc = $fulltextservice->IndexedDocument($document, true);
$indexconf['Indexer']::init($settings->_stopWordsFile);
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout);
$error = $idoc->getErrorMsg(); $error = $idoc->getErrorMsg();
if(!$error) { if(!$error) {
$ires = null; $ires = null;

View File

@ -60,14 +60,6 @@ if($document->isLocked()) {
} }
} }
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
$indexconf['Indexer']::init($settings->_stopWordsFile);
} else {
$index = null;
$indexconf = null;
}
$folder = $document->getFolder(); $folder = $document->getFolder();
/* Remove all preview images. */ /* Remove all preview images. */
@ -87,8 +79,7 @@ $nl = array(
$docname = $document->getName(); $docname = $document->getName();
$controller->setParam('document', $document); $controller->setParam('document', $document);
$controller->setParam('index', $index); $controller->setParam('fulltextservice', $fulltextservice);
$controller->setParam('indexconf', $indexconf);
if(!$controller->run()) { if(!$controller->run()) {
if ($controller->getErrorMsg() != '') if ($controller->getErrorMsg() != '')
$errormsg = $controller->getErrorMsg(); $errormsg = $controller->getErrorMsg();

View File

@ -54,13 +54,6 @@ if ($folder->getAccessMode($user, 'removeFolder') < M_ALL) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied")); UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
} }
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
$indexconf['Indexer']::init($settings->_stopWordsFile);
} else {
$index = null;
}
/* /*
function removePreviews($arr, $document) { function removePreviews($arr, $document) {
$previewer = $arr[0]; $previewer = $arr[0];
@ -86,8 +79,7 @@ $nl = array(
); );
$controller->setParam('folder', $folder); $controller->setParam('folder', $folder);
$controller->setParam('index', $index); $controller->setParam('fulltextservice', $fulltextservice);
$controller->setParam('indexconf', $indexconf);
if(!$controller->run()) { if(!$controller->run()) {
UI::exitError(getMLText("folder_title", array("foldername" => htmlspecialchars($foldername))),getMLText("error_remove_folder")); UI::exitError(getMLText("folder_title", array("foldername" => htmlspecialchars($foldername))),getMLText("error_remove_folder"));
} }

View File

@ -74,14 +74,11 @@ if (count($document->getContent())==1) {
} else { } else {
$nexturl = "../out/out.ViewFolder.php?folderid=".$folder->getId(); $nexturl = "../out/out.ViewFolder.php?folderid=".$folder->getId();
/* Remove the document from the fulltext index */ /* Remove the document from the fulltext index */
if($settings->_enableFullSearch) { if($fulltextservice && ($index = $fulltextservice->Index())) {
$index = $indexconf['Indexer']::open($settings->_luceneDir); $lucenesearch = $fulltextservice->Search();
if($index) { if($hit = $lucenesearch->getDocument($documentid)) {
$lucenesearch = new $indexconf['Search']($index); $index->delete($hit->id);
if($hit = $lucenesearch->getDocument($documentid)) { $index->commit();
$index->delete($hit->id);
$index->commit();
}
} }
} }
@ -142,18 +139,14 @@ else {
else else
$nexturl = "../out/out.ViewDocument.php?documentid=".$documentid."&currenttab=previous"; $nexturl = "../out/out.ViewDocument.php?documentid=".$documentid."&currenttab=previous";
/* Remove the document from the fulltext index and reindex latest version */ /* Remove the document from the fulltext index and reindex latest version */
if($settings->_enableFullSearch) { if($fulltextservice && ($index = $fulltextservice->Indexer())) {
$index = $indexconf['Indexer']::open($settings->_luceneDir); $lucenesearch = $fulltextservice->Search();
if($index) { if($hit = $lucenesearch->getDocument($document->getID())) {
$lucenesearch = new $indexconf['Search']($index); $index->delete($hit->id);
if($hit = $lucenesearch->getDocument($document->getID())) {
$index->delete($hit->id);
}
$version = $document->getLatestContent();
$indexconf['Indexer']::init($settings->_stopWordsFile);
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, !($version->getFileSize() < $settings->_maxSizeForFullText)));
$index->commit();
} }
$version = $document->getLatestContent();
$index->addDocument($fulltextservice->IndexedDocument($document));
$index->commit();
} }
// Notify affected users. // Notify affected users.

View File

@ -133,13 +133,6 @@ if (isset($_FILES['userfile']) && $_FILES['userfile']['error'] == 0) {
$fileType = ".".pathinfo($userfilename, PATHINFO_EXTENSION); $fileType = ".".pathinfo($userfilename, PATHINFO_EXTENSION);
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
$indexconf['Indexer']::init($settings->_stopWordsFile);
} else {
$index = null;
}
if(isset($_POST["comment"])) if(isset($_POST["comment"]))
$comment = $_POST["comment"]; $comment = $_POST["comment"];
else else
@ -349,8 +342,7 @@ default:
$controller->setParam('folder', $folder); $controller->setParam('folder', $folder);
$controller->setParam('document', $document); $controller->setParam('document', $document);
$controller->setParam('index', $index); $controller->setParam('fulltextservice', $fulltextservice);
$controller->setParam('indexconf', $indexconf);
$controller->setParam('comment', $comment); $controller->setParam('comment', $comment);
if($oldexpires != $expires) if($oldexpires != $expires)
$controller->setParam('expires', $expires); $controller->setParam('expires', $expires);

View File

@ -159,15 +159,13 @@ if( move_uploaded_file( $source_file_path, $target_file_path ) ) {
if (is_bool($contentResult) && !$contentResult) { if (is_bool($contentResult) && !$contentResult) {
echo getMLText("error_occured"); echo getMLText("error_occured");
} else { } else {
if($settings->_enableFullSearch) { if($fulltextservice && ($index = $fulltextservice->Indexer())) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
if($index) { if($index) {
$lucenesearch = new $indexconf['Search']($index); $lucenesearch = $fulltextservice->Search();
if($hit = $lucenesearch->getDocument((int) $document->getId())) { if($hit = $lucenesearch->getDocument((int) $document->getId())) {
$index->delete($hit->id); $index->delete($hit->id);
} }
$indexconf['Indexer']::init($settings->_stopWordsFile); $index->addDocument($fulltextservice->IndexedDocument($document));
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, !($filesize < $settings->_maxSizeForFullText)));
$index->commit(); $index->commit();
} }
} }

View File

@ -41,14 +41,12 @@ if(!$settings->_enableFullSearch) {
UI::exitError(getMLText("admin_tools"),getMLText("fulltextsearch_disabled")); UI::exitError(getMLText("admin_tools"),getMLText("fulltextsearch_disabled"));
} }
$index = $indexconf['Indexer']::open($settings->_luceneDir); $index = $fulltextservice->Indexer();
if(!$index) { if(!$index) {
UI::exitError(getMLText("admin_tools"),getMLText("no_fulltextindex")); UI::exitError(getMLText("admin_tools"),getMLText("no_fulltextindex"));
} }
if($view) { if($view) {
$view->setParam('luceneclassdir', $settings->_luceneClassDir);
$view->setParam('lucenedir', $settings->_luceneDir);
$view->setParam('index', $index); $view->setParam('index', $index);
$view->setParam('accessobject', $accessop); $view->setParam('accessobject', $accessop);
$view($_GET); $view($_GET);

View File

@ -43,27 +43,25 @@ if(!$settings->_enableFullSearch) {
$index = null; $index = null;
if(!isset($_GET['action']) || $_GET['action'] == 'show') { if(!isset($_GET['action']) || $_GET['action'] == 'show') {
if($indexconf) { if($fulltextservice) {
if(isset($_GET['create']) && $_GET['create'] == 1) { if(isset($_GET['create']) && $_GET['create'] == 1) {
if(isset($_GET['confirm']) && $_GET['confirm'] == 1) { if(isset($_GET['confirm']) && $_GET['confirm'] == 1) {
$index = $indexconf['Indexer']::create($settings->_luceneDir); $index = $fulltextservice->Indexer(true);
if(!$index) { if(!$index) {
UI::exitError(getMLText("admin_tools"),getMLText("no_fulltextindex")); UI::exitError(getMLText("admin_tools"),getMLText("no_fulltextindex"));
} }
$indexconf['Indexer']::init($settings->_stopWordsFile);
} else { } else {
header('Location: out.CreateIndex.php'); header('Location: out.CreateIndex.php');
exit; exit;
} }
} else { } else {
$index = $indexconf['Indexer']::open($settings->_luceneDir); $index = $fulltextservice->Indexer(false);
if(!$index) { if(!$index) {
$index = $indexconf['Indexer']::create($settings->_luceneDir); $index = $fulltextservice->Indexer(true);
if(!$index) { if(!$index) {
UI::exitError(getMLText("admin_tools"),getMLText("no_fulltextindex")); UI::exitError(getMLText("admin_tools"),getMLText("no_fulltextindex"));
} }
} }
$indexconf['Indexer']::init($settings->_stopWordsFile);
} }
} }
} }
@ -77,8 +75,7 @@ else {
$folder = $dms->getFolder($folderid); $folder = $dms->getFolder($folderid);
if($view) { if($view) {
$view->setParam('index', $index); $view->setParam('fulltextservice', $fulltextservice);
$view->setParam('indexconf', $indexconf);
$view->setParam('recreate', (isset($_GET['create']) && $_GET['create']==1)); $view->setParam('recreate', (isset($_GET['create']) && $_GET['create']==1));
$view->setParam('forceupdate', (isset($_GET['forceupdate']) && $_GET['forceupdate']==1)); $view->setParam('forceupdate', (isset($_GET['forceupdate']) && $_GET['forceupdate']==1));
$view->setParam('folder', $folder); $view->setParam('folder', $folder);

View File

@ -72,12 +72,20 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
// category // category
$categories = array(); $categories = array();
$categorynames = array(); $categorynames = array();
if(isset($_GET['categoryids']) && $_GET['categoryids']) { if(isset($_GET['category']) && $_GET['category']) {
foreach($_GET['category'] as $catname) {
if($catname) {
$cat = $dms->getDocumentCategoryByName($catname);
$categories[] = $cat;
$categorynames[] = $cat->getName();
}
}
} elseif(isset($_GET['categoryids']) && $_GET['categoryids']) {
foreach($_GET['categoryids'] as $catid) { foreach($_GET['categoryids'] as $catid) {
if($catid > 0) { if($catid) {
$category = $dms->getDocumentCategory($catid); $cat = $dms->getDocumentCategory($catid);
$categories[] = $category; $categories[] = $cat;
$categorynames[] = $category->getName(); $categorynames[] = $cat->getName();
} }
} }
} }
@ -104,66 +112,123 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
// Check to see if the search has been restricted to a particular // Check to see if the search has been restricted to a particular
// document owner. // document owner.
$owner = null; $owner = [];
if (isset($_GET["ownerid"]) && is_numeric($_GET["ownerid"]) && $_GET["ownerid"]!=-1) { if (isset($_GET["owner"])) {
$owner = $dms->getUser($_GET["ownerid"]); if (!is_array($_GET['owner'])) {
if (!is_object($owner)) { if(!empty($_GET['owner']) && $o = $dms->getUserByLogin($_GET['owner']))
UI::exitError(getMLText("search_results"),getMLText("unknown_owner")); $owner[] = $o->getLogin();
else
UI::exitError(getMLText("search"),getMLText("unknown_owner"));
} else {
foreach($_GET["owner"] as $l) {
if($l && $o = $dms->getUserByLogin($l))
$owner[] = $o->getLogin();
}
} }
} }
$startTime = getTime(); // Check to see if the search has been restricted to a particular
if($settings->_enableFullSearch) { // mimetype.
if($settings->_fullSearchEngine == 'lucene') { $mimetype = [];
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8'); if (isset($_GET["mimetype"])) {
if (!is_array($_GET['mimetype'])) {
if(!empty($_GET['mimetype']))
$mimetype[] = $_GET['mimetype'];
} else {
foreach($_GET["mimetype"] as $l) {
if($l)
$mimetype[] = $l;
}
} }
} }
// status
$status = array();
if (isset($_GET["pendingReview"])){
$status[] = S_DRAFT_REV;
}
if (isset($_GET["pendingApproval"])){
$status[] = S_DRAFT_APP;
}
if (isset($_GET["inWorkflow"])){
$status[] = S_IN_WORKFLOW;
}
if (isset($_GET["released"])){
$status[] = S_RELEASED;
}
if (isset($_GET["rejected"])){
$status[] = S_REJECTED;
}
if (isset($_GET["obsolete"])){
$status[] = S_OBSOLETE;
}
if (isset($_GET["expired"])){
$status[] = S_EXPIRED;
}
$startTime = getTime();
if($settings->_fullSearchEngine == 'lucene') {
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
}
if(strlen($query) < 4 && strpos($query, '*')) { if(strlen($query) < 4 && strpos($query, '*')) {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm'))); $session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
$dcount = 0;
$totalPages = 0; $totalPages = 0;
$entries = array(); $entries = array();
$searchTime = 0; $searchTime = 0;
} else { } else {
$startTime = getTime(); $startTime = getTime();
$index = $indexconf['Indexer']::open($settings->_luceneDir); $index = $fulltextservice->Indexer();
$lucenesearch = new $indexconf['Search']($index); if($index) {
$hits = $lucenesearch->search($query, $owner ? $owner->getLogin() : '', '', $categorynames, array(), $user->isAdmin() ? [] : [$user->getLogin()]); $limit = 20;
if($hits === false) { $lucenesearch = $fulltextservice->Search();
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm'))); $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))));
$totalPages = 0; if($searchresult === false) {
$entries = array(); $session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
$searchTime = 0; $dcount = 0;
} else { $fcount = 0;
$entries = array(); $totalPages = 0;
$dcount = 0; $entries = array();
$fcount = 0; $facets = array();
if($hits) { $searchTime = 0;
foreach($hits as $hit) { } else {
if($tmp = $dms->getDocument($hit['document_id'])) { $entries = array();
if($tmp->getAccessMode($user) >= M_READ) { $facets = $searchresult['facets'];
if($tmp->getLatestContent()) { $dcount = $searchresult['count']; //0;
$fcount = 0;
if($searchresult) {
foreach($searchresult['hits'] as $hit) {
if($tmp = $dms->getDocument($hit['document_id'])) {
if($tmp->getAccessMode($user) >= M_READ) {
$tmp->verifyLastestContentExpriry(); $tmp->verifyLastestContentExpriry();
$entries[] = $tmp; $entries[] = $tmp;
$dcount++; // $dcount++;
} }
} }
} }
} }
if($pageNumber != 'all' && $dcount > $limit) {
$totalPages = (int) ($dcount/$limit);
if($dcount%$limit)
$totalPages++;
// if($limit > 0)
// $entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
} else {
$totalPages = 1;
}
} }
$limit = 20; $searchTime = getTime() - $startTime;
if($pageNumber != 'all' && count($entries) > $limit) { $searchTime = round($searchTime, 2);
$totalPages = (int) (count($entries)/$limit); } else {
if(count($entries)%$limit) $session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_search_service')));
$totalPages++; $dcount = 0;
if($limit > 0) $fcount = 0;
$entries = array_slice($entries, ($pageNumber-1)*$limit, $limit); $totalPages = 0;
} else { $entries = array();
$totalPages = 1; $facets = array();
} $searchTime = 0;
} }
$searchTime = getTime() - $startTime;
$searchTime = round($searchTime, 2);
} }
$reception = array(); $reception = array();
// }}} // }}}
@ -232,11 +297,22 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
// Check to see if the search has been restricted to a particular // Check to see if the search has been restricted to a particular
// document owner. // document owner.
$owner = null; $owner = array();
if (isset($_GET["ownerid"]) && is_numeric($_GET["ownerid"]) && $_GET["ownerid"]!=-1) { $ownerobjs = array();
$owner = $dms->getUser($_GET["ownerid"]); if (isset($_GET["owner"])) {
if (!is_object($owner)) { if (!is_array($_GET['owner'])) {
UI::exitError(getMLText("search"),getMLText("unknown_owner")); if(!empty($_GET['owner']) && $o = $dms->getUserByLogin($_GET['owner'])) {
$ownerobjs[] = $o;
$owner = $o->getLogin();
} else
UI::exitError(getMLText("search"),getMLText("unknown_owner"));
} else {
foreach($_GET["owner"] as $l) {
if($o = $dms->getUserByLogin($l)) {
$ownerobjs[] = $o;
$owner[] = $o->getLogin();
}
}
} }
} }
@ -348,10 +424,14 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
// category // category
$categories = array(); $categories = array();
if(isset($_GET['categoryids']) && $_GET['categoryids']) { $categorynames = array();
foreach($_GET['categoryids'] as $catid) { if(isset($_GET['category']) && $_GET['category']) {
if($catid > 0) foreach($_GET['category'] as $catname) {
$categories[] = $dms->getDocumentCategory($catid); if($catname) {
$cat = $dms->getDocumentCategoryByName($catname);
$categories[] = $cat;
$categorynames[] = $cat->getName();
}
} }
} }
@ -393,7 +473,7 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
'logicalmode'=>$mode, 'logicalmode'=>$mode,
'searchin'=>$searchin, 'searchin'=>$searchin,
'startFolder'=>$startFolder, 'startFolder'=>$startFolder,
'owner'=>$owner, 'owner'=>$ownerobjs,
'status'=>$status, 'status'=>$status,
'creationstartdate'=>$creationdate ? $startdate : array(), 'creationstartdate'=>$creationdate ? $startdate : array(),
'creationenddate'=>$creationdate ? $stopdate : array(), 'creationenddate'=>$creationdate ? $stopdate : array(),
@ -440,7 +520,9 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
if(count($entries)%$limit) if(count($entries)%$limit)
$totalPages++; $totalPages++;
$entries = array_slice($entries, ($pageNumber-1)*$limit, $limit); $entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
} } else
$totalPages = 1;
$facets = array();
// }}} // }}}
} }
@ -460,6 +542,7 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); $view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); $accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if($view) { if($view) {
$view->setParam('facets', $facets);
$view->setParam('accessobject', $accessop); $view->setParam('accessobject', $accessop);
$view->setParam('query', $query); $view->setParam('query', $query);
$view->setParam('searchhits', $entries); $view->setParam('searchhits', $entries);
@ -491,6 +574,8 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
$view->setParam('expirationdate', isset($expirationdate) ? $expirationdate: ''); $view->setParam('expirationdate', isset($expirationdate) ? $expirationdate: '');
$view->setParam('status', isset($status) ? $status : array()); $view->setParam('status', isset($status) ? $status : array());
$view->setParam('categories', isset($categories) ? $categories : ''); $view->setParam('categories', isset($categories) ? $categories : '');
$view->setParam('category', isset($categorynames) ? $categorynames : '');
$view->setParam('mimetype', isset($mimetype) ? $mimetype : '');
$view->setParam('attributes', isset($attributes) ? $attributes : ''); $view->setParam('attributes', isset($attributes) ? $attributes : '');
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_document, SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_folder, SeedDMS_Core_AttributeDefinition::objtype_all)); $attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_document, SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_folder, SeedDMS_Core_AttributeDefinition::objtype_all));
$view->setParam('attrdefs', $attrdefs); $view->setParam('attrdefs', $attrdefs);

View File

@ -59,38 +59,21 @@ include($myincpath."/inc/inc.Init.php");
include($myincpath."/inc/inc.Extension.php"); include($myincpath."/inc/inc.Extension.php");
include($myincpath."/inc/inc.DBInit.php"); include($myincpath."/inc/inc.DBInit.php");
if($settings->_fullSearchEngine == 'sqlitefts') { function tree($dms, $fulltextservice, $folder, $indent='') { /* {{{ */
$indexconf = array(
'Indexer' => 'SeedDMS_SQLiteFTS_Indexer',
'Search' => 'SeedDMS_SQLiteFTS_Search',
'IndexedDocument' => 'SeedDMS_SQLiteFTS_IndexedDocument'
);
require_once('SeedDMS/SQLiteFTS.php');
} else {
$indexconf = array(
'Indexer' => 'SeedDMS_Lucene_Indexer',
'Search' => 'SeedDMS_Lucene_Search',
'IndexedDocument' => 'SeedDMS_Lucene_IndexedDocument'
);
require_once('SeedDMS/Lucene.php');
}
function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
global $settings, $themes; global $settings, $themes;
echo $themes->black($indent."D ".$folder->getName()).PHP_EOL; echo $themes->black($indent."D ".$folder->getName()).PHP_EOL;
$subfolders = $folder->getSubFolders(); $subfolders = $folder->getSubFolders();
foreach($subfolders as $subfolder) { foreach($subfolders as $subfolder) {
tree($dms, $index, $indexconf, $subfolder, $indent.' '); tree($dms, $fulltextservice, $subfolder, $indent.' ');
} }
$documents = $folder->getDocuments(); $documents = $folder->getDocuments();
$index = $fulltextservice->Indexer();
$lucenesearch = $fulltextservice->Search();
foreach($documents as $document) { foreach($documents as $document) {
echo $themes->black($indent." ".$document->getId().":".$document->getName()." "); echo $themes->black($indent." ".$document->getId().":".$document->getName()." ");
$lucenesearch = new $indexconf['Search']($index);
if(!($hit = $lucenesearch->getDocument($document->getId()))) { if(!($hit = $lucenesearch->getDocument($document->getId()))) {
try { try {
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout); $idoc = $fulltextservice->IndexedDocument($document, true);
if(isset($GLOBALS['SEEDDMS_HOOKS']['indexDocument'])) { if(isset($GLOBALS['SEEDDMS_HOOKS']['indexDocument'])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['indexDocument'] as $hookObj) { foreach($GLOBALS['SEEDDMS_HOOKS']['indexDocument'] as $hookObj) {
if (method_exists($hookObj, 'preIndexDocument')) { if (method_exists($hookObj, 'preIndexDocument')) {
@ -115,7 +98,7 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
} else { } else {
$index->delete($hit->id); $index->delete($hit->id);
try { try {
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout); $idoc = $fulltextservice->IndexedDocument($document, true);
if(isset($GLOBALS['SEEDDMS_HOOKS']['indexDocument'])) { if(isset($GLOBALS['SEEDDMS_HOOKS']['indexDocument'])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['indexDocument'] as $hookObj) { foreach($GLOBALS['SEEDDMS_HOOKS']['indexDocument'] as $hookObj) {
if (method_exists($hookObj, 'preIndexDocument')) { if (method_exists($hookObj, 'preIndexDocument')) {
@ -135,19 +118,14 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
$themes = new \AlecRabbit\ConsoleColour\Themes(); $themes = new \AlecRabbit\ConsoleColour\Themes();
if($recreate) $index = $fulltextservice->Indexer($recreate);
$index = $indexconf['Indexer']::create($settings->_luceneDir);
else
$index = $indexconf['Indexer']::open($settings->_luceneDir);
if(!$index) { if(!$index) {
echo $themes->error("Could not create index.").PHP_EOL; echo $themes->error("Could not create index.").PHP_EOL;
exit(1); exit(1);
} }
$indexconf['Indexer']::init($settings->_stopWordsFile);
$folder = $dms->getFolder($settings->_rootFolderID); $folder = $dms->getFolder($settings->_rootFolderID);
tree($dms, $index, $indexconf, $folder); tree($dms, $fulltextservice, $folder);
$index->commit(); $index->commit();
$index->optimize(); $index->optimize();

View File

@ -34,8 +34,6 @@ class SeedDMS_View_IndexInfo extends SeedDMS_Bootstrap_Style {
function show() { /* {{{ */ function show() { /* {{{ */
$dms = $this->params['dms']; $dms = $this->params['dms'];
$user = $this->params['user']; $user = $this->params['user'];
$luceneclassdir = $this->params['luceneclassdir'];
$lucenedir = $this->params['lucenedir'];
$index = $this->params['index']; $index = $this->params['index'];
$this->htmlStartPage(getMLText('fulltext_info')); $this->htmlStartPage(getMLText('fulltext_info'));
@ -50,8 +48,8 @@ class SeedDMS_View_IndexInfo extends SeedDMS_Bootstrap_Style {
$this->contentContainerStart(); $this->contentContainerStart();
for ($id = 0; $id < $numDocs; $id++) { for ($id = 0; $id < $numDocs; $id++) {
if (!$index->isDeleted($id)) { if (!$index->isDeleted($id)) {
$hit = $index->getDocument($id); if($hit = $index->getDocument($id))
echo "<span title=\"".$hit->document_id."\">".htmlspecialchars($hit->title)."</span>\n"; echo "<span title=\"".$hit->document_id."\">".htmlspecialchars($hit->title)."</span>\n";
} }
} }
$this->contentContainerEnd(); $this->contentContainerEnd();
@ -70,6 +68,7 @@ class SeedDMS_View_IndexInfo extends SeedDMS_Bootstrap_Style {
$field = $term->field; $field = $term->field;
} }
echo htmlspecialchars($term->text)."\n"; echo htmlspecialchars($term->text)."\n";
// echo "<span title=\"".$term->_occurrence."\">".htmlspecialchars($term->text)."</span>\n";
} }
$this->contentContainerEnd(); $this->contentContainerEnd();
// echo "</pre>"; // echo "</pre>";

View File

@ -29,61 +29,42 @@ class SeedDMS_View_Indexer_Process_Folder { /* {{{ */
protected $index; protected $index;
protected $indexconf; public function __construct($fulltextservice, $forceupdate) { /* {{{ */
$this->fulltextservice = $fulltextservice;
public function __construct($index, $indexconf, $forceupdate) { /* {{{ */
$this->index = $index;
$this->indexconf = $indexconf;
$this->forceupdate = $forceupdate; $this->forceupdate = $forceupdate;
} /* }}} */ } /* }}} */
public function process($folder) { /* {{{ */ public function process($folder) { /* {{{ */
$documents = $folder->getDocuments(); $documents = $folder->getDocuments();
if($documents) { if($documents) {
$lucenesearch = $this->fulltextservice->Search();
echo "<div class=\"folder\">".$folder->getFolderPathPlain()."</div>"; echo "<div class=\"folder\">".$folder->getFolderPathPlain()."</div>";
foreach($documents as $document) { foreach($documents as $document) {
echo "<div class=\"document\">".$document->getId().":".htmlspecialchars($document->getName()); echo "<div class=\"document\">".$document->getId().":".htmlspecialchars($document->getName());
/* If the document wasn't indexed before then just add it */ /* If the document wasn't indexed before then just add it */
$lucenesearch = new $this->indexconf['Search']($this->index); if(!($hit = $lucenesearch->getDocument($document->getId()))) {
if(!($hit = $lucenesearch->getDocument($document->getId()))) {
echo " <span id=\"status_".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting')."</span>";
/*
try {
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, $this->converters ? $this->converters : null, false, $this->timeout));
echo "(document added)";
} catch(Exception $e) {
echo $indent."(adding document failed '".$e->getMessage()."')";
}
*/
} else {
/* Check if the attribute created is set or has a value older
* than the lastet content. Documents without such an attribute
* where added when a new document was added to the dms. In such
* a case the document content wasn't indexed.
*/
try {
$created = (int) $hit->getDocument()->getFieldValue('created');
} catch (/* Zend_Search_Lucene_ */Exception $e) {
$created = 0;
}
$content = $document->getLatestContent();
if($created >= $content->getDate() && !$this->forceupdate) {
echo "<span id=\"status_".$document->getID()."\" class=\"indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_document_unchanged')."</span>";
} else {
$this->index->delete($hit->id);
echo " <span id=\"status_".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting')."</span>"; echo " <span id=\"status_".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting')."</span>";
/* } else {
try { /* Check if the attribute created is set or has a value older
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, $this->converters ? $this->converters : null, false, $this->timeout)); * than the lastet content. Documents without such an attribute
echo $indent."(document updated)"; * where added when a new document was added to the dms. In such
} catch(Exception $e) { * a case the document content wasn't indexed.
echo $indent."(updating document failed)";
}
*/ */
try {
$created = (int) $hit->getDocument()->getFieldValue('created');
} catch (/* Zend_Search_Lucene_ */Exception $e) {
$created = 0;
}
$content = $document->getLatestContent();
if($created >= $content->getDate() && !$this->forceupdate) {
echo "<span id=\"status_".$document->getID()."\" class=\"indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_document_unchanged')."</span>";
} else {
$this->fulltextservice->Indexer()->delete($hit->id);
echo " <span id=\"status_".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting')."</span>";
}
} }
echo "</div>";
} }
echo "</div>";
}
} }
} /* }}} */ } /* }}} */
} /* }}} */ } /* }}} */
@ -110,13 +91,13 @@ class SeedDMS_View_Indexer extends SeedDMS_Bootstrap_Style {
var queue_count = 0; // Number of functions being called var queue_count = 0; // Number of functions being called
var funcArray = []; // Array of functions waiting var funcArray = []; // Array of functions waiting
var MAX_REQUESTS = 5; // Max requests var MAX_REQUESTS = 5; // Max requests
var CALL_WAIT = 100; // 100ms var CALL_WAIT = 20; // 100ms
var docstoindex = 0; // total number of docs to index var docstoindex = 0; // total number of docs to index
function check_queue() { function check_queue() {
// Check if count doesn't exceeds or if there aren't any functions to call // Check if count doesn't exceeds or if there aren't any functions to call
console.log('Queue has ' + funcArray.length + '/' + docstoindex + ' items'); // console.log('Queue has ' + funcArray.length + '/' + docstoindex + ' items');
console.log('Currently processing ' + queue_count + ' requests (' + $.active + ')'); // console.log('Currently processing ' + queue_count + ' requests (' + $.active + ')');
if(queue_count >= MAX_REQUESTS) { if(queue_count >= MAX_REQUESTS) {
setTimeout(function() { check_queue() }, CALL_WAIT); setTimeout(function() { check_queue() }, CALL_WAIT);
return; return;
@ -193,74 +174,10 @@ $(document).ready( function() {
<?php <?php
} /* }}} */ } /* }}} */
protected function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
$forceupdate = $this->params['forceupdate'];
set_time_limit(30);
// echo $indent."D ".htmlspecialchars($folder->getName())."\n";
echo '<ul class="nav nav-list"><li><label class="tree-toggle nav-header">'.htmlspecialchars($folder->getName()).'</label>'."\n";
$subfolders = $folder->getSubFolders();
foreach($subfolders as $subfolder) {
$this->tree($dms, $index, $indexconf, $subfolder, $indent.' ');
}
$documents = $folder->getDocuments();
if($documents) {
echo '<ul class="nav nav-list">'."\n";
foreach($documents as $document) {
// echo $indent." ".$document->getId().":".htmlspecialchars($document->getName());
echo "<li class=\"document\">".$document->getId().":".htmlspecialchars($document->getName());
/* If the document wasn't indexed before then just add it */
$lucenesearch = new $indexconf['Search']($index);
if(!($hit = $lucenesearch->getDocument($document->getId()))) {
echo " <span id=\"status_".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting')."</span>";
/*
try {
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, $this->converters ? $this->converters : null, false, $this->timeout));
echo "(document added)";
} catch(Exception $e) {
echo $indent."(adding document failed '".$e->getMessage()."')";
}
*/
} else {
/* Check if the attribute created is set or has a value older
* than the lastet content. Documents without such an attribute
* where added when a new document was added to the dms. In such
* a case the document content wasn't indexed.
*/
try {
$created = (int) $hit->getDocument()->getFieldValue('created');
} catch (/* Zend_Search_Lucene_ */Exception $e) {
$created = 0;
}
$content = $document->getLatestContent();
if($created >= $content->getDate() && !$forceupdate) {
echo $indent."<span id=\"status_".$document->getID()."\" class=\"indexstatus\" data-docid=\"".$document->getID()."\">document unchanged</span>";
} else {
$index->delete($hit->id);
echo " <span id=\"status_".$document->getID()."\" class=\"indexme indexstatus\" data-docid=\"".$document->getID()."\">".getMLText('index_waiting')."</span>";
/*
try {
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, $this->converters ? $this->converters : null, false, $this->timeout));
echo $indent."(document updated)";
} catch(Exception $e) {
echo $indent."(updating document failed)";
}
*/
}
}
echo "</li>";
echo "\n";
}
echo "</ul>\n";
}
echo "</li></ul>\n";
} /* }}} */
function show() { /* {{{ */ function show() { /* {{{ */
$dms = $this->params['dms']; $dms = $this->params['dms'];
$user = $this->params['user']; $user = $this->params['user'];
$index = $this->params['index']; $fulltextservice = $this->params['fulltextservice'];
$indexconf = $this->params['indexconf'];
$forceupdate = $this->params['forceupdate']; $forceupdate = $this->params['forceupdate'];
$folder = $this->params['folder']; $folder = $this->params['folder'];
$this->converters = $this->params['converters']; $this->converters = $this->params['converters'];
@ -271,7 +188,8 @@ $(document).ready( function() {
$this->contentStart(); $this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools"); $this->pageNavigation(getMLText("admin_tools"), "admin_tools");
$this->contentHeading(getMLText("update_fulltext_index")); $this->contentHeading(getMLText("update_fulltext_index"));
if($index) { if($fulltextservice) {
$index = $fulltextservice->Indexer();
?> ?>
<style type="text/css"> <style type="text/css">
li {line-height: 20px;} li {line-height: 20px;}
@ -299,10 +217,9 @@ div.folder {font-weight: bold; line-height: 20px; margin-top: 10px;}
<div class="bar-legend"><?php printMLText('indexing_tasks_in_queue'); ?></div> <div class="bar-legend"><?php printMLText('indexing_tasks_in_queue'); ?></div>
</div> </div>
<?php <?php
$folderprocess = new SeedDMS_View_Indexer_Process_Folder($index, $indexconf, $forceupdate); $folderprocess = new SeedDMS_View_Indexer_Process_Folder($fulltextservice, $forceupdate);
$tree = new SeedDMS_FolderTree($folder, array($folderprocess, 'process')); $tree = new SeedDMS_FolderTree($folder, array($folderprocess, 'process'));
call_user_func(array($folderprocess, 'process'), $folder); call_user_func(array($folderprocess, 'process'), $folder);
// $this->tree($dms, $index, $indexconf, $folder);
echo "</div>"; echo "</div>";
$index->commit(); $index->commit();

View File

@ -128,7 +128,9 @@ $(document).ready( function() {
$enablefullsearch = $this->params['enablefullsearch']; $enablefullsearch = $this->params['enablefullsearch'];
$enableclipboard = $this->params['enableclipboard']; $enableclipboard = $this->params['enableclipboard'];
$attributes = $this->params['attributes']; $attributes = $this->params['attributes'];
$category = $this->params['category'];
$categories = $this->params['categories']; $categories = $this->params['categories'];
$mimetype = $this->params['mimetype'];
$owner = $this->params['owner']; $owner = $this->params['owner'];
$startfolder = $this->params['startfolder']; $startfolder = $this->params['startfolder'];
$startdate = $this->params['startdate']; $startdate = $this->params['startdate'];
@ -141,6 +143,7 @@ $(document).ready( function() {
$this->query = $this->params['query']; $this->query = $this->params['query'];
$orderby = $this->params['orderby']; $orderby = $this->params['orderby'];
$entries = $this->params['searchhits']; $entries = $this->params['searchhits'];
$facets = $this->params['facets'];
$totalpages = $this->params['totalpages']; $totalpages = $this->params['totalpages'];
$pageNumber = $this->params['pagenumber']; $pageNumber = $this->params['pagenumber'];
$searchTime = $this->params['searchtime']; $searchTime = $this->params['searchtime'];
@ -220,13 +223,13 @@ $(document).ready( function() {
<tr> <tr>
<td><?php printMLText("owner");?>:</td> <td><?php printMLText("owner");?>:</td>
<td> <td>
<select class="chzn-select" name="ownerid" data-allow-clear="true" data-placeholder="<?php printMLText('select_users'); ?>" data-no_results_text="<?php printMLText('unknown_owner'); ?>"> <select class="chzn-select" name="owner[]" data-allow-clear="true" data-placeholder="<?php printMLText('select_users'); ?>" data-no_results_text="<?php printMLText('unknown_owner'); ?>">
<option value=""></option> <option value=""></option>
<?php <?php
foreach ($allUsers as $userObj) { foreach ($allUsers as $userObj) {
if ($userObj->isGuest() || ($userObj->isHidden() && $userObj->getID() != $user->getID() && !$user->isAdmin())) if ($userObj->isGuest() || ($userObj->isHidden() && $userObj->getID() != $user->getID() && !$user->isAdmin()))
continue; continue;
print "<option value=\"".$userObj->getID()."\" ".(($owner && $userObj->getID() == $owner->getID()) ? "selected" : "").">" . htmlspecialchars($userObj->getLogin()." - ".$userObj->getFullName()) . "</option>\n"; print "<option value=\"".$userObj->getLogin()."\" ".(in_array($userObj->getLogin(), $owner) ? "selected" : "").">" . htmlspecialchars($userObj->getLogin()." - ".$userObj->getFullName()) . "</option>\n";
} }
?> ?>
</select> </select>
@ -304,7 +307,7 @@ $(document).ready( function() {
} }
} }
} }
if($categories) if($category)
$openfilterdlg = true; $openfilterdlg = true;
if($status) if($status)
$openfilterdlg = true; $openfilterdlg = true;
@ -349,7 +352,7 @@ $(document).ready( function() {
<tr> <tr>
<td><?php printMLText("category");?>:</td> <td><?php printMLText("category");?>:</td>
<td> <td>
<select class="chzn-select" name="categoryids[]" multiple="multiple" data-placeholder="<?php printMLText('select_category'); ?>" data-no_results_text="<?php printMLText('unknown_document_category'); ?>"> <select class="chzn-select" name="category[]" multiple="multiple" data-placeholder="<?php printMLText('select_category'); ?>" data-no_results_text="<?php printMLText('unknown_document_category'); ?>">
<!-- <!--
<option value="-1"><?php printMLText("all_categories");?> <option value="-1"><?php printMLText("all_categories");?>
--> -->
@ -358,7 +361,7 @@ $(document).ready( function() {
foreach($categories as $tmpcat) foreach($categories as $tmpcat)
$tmpcatids[] = $tmpcat->getID(); $tmpcatids[] = $tmpcat->getID();
foreach ($allCats as $catObj) { foreach ($allCats as $catObj) {
print "<option value=\"".$catObj->getID()."\" ".(in_array($catObj->getID(), $tmpcatids) ? "selected" : "").">" . htmlspecialchars($catObj->getName()) . "\n"; print "<option value=\"".$catObj->getName()."\" ".(in_array($catObj->getID(), $tmpcatids) ? "selected" : "").">" . htmlspecialchars($catObj->getName()) . "\n";
} }
?> ?>
</select> </select>
@ -507,21 +510,24 @@ $(document).ready( function() {
--> -->
</td> </td>
</tr> </tr>
<?php if(!isset($facets['owner'])) { ?>
<tr> <tr>
<td><?php printMLText("owner");?>:</td> <td><?php printMLText("owner");?>:</td>
<td> <td>
<select class="chzn-select" name="ownerid" data-allow-clear="true" data-placeholder="<?php printMLText('select_users'); ?>" data-no_results_text="<?php printMLText('unknown_owner'); ?>"> <select class="chzn-select" name="owner[]" data-allow-clear="true" data-placeholder="<?php printMLText('select_users'); ?>" data-no_results_text="<?php printMLText('unknown_owner'); ?>">
<option value=""></option> <option value=""></option>
<?php <?php
foreach ($allUsers as $userObj) { foreach ($allUsers as $userObj) {
if ($userObj->isGuest() || ($userObj->isHidden() && $userObj->getID() != $user->getID() && !$user->isAdmin())) if ($userObj->isGuest() || ($userObj->isHidden() && $userObj->getID() != $user->getID() && !$user->isAdmin()))
continue; continue;
print "<option value=\"".$userObj->getID()."\" ".(($owner && $userObj->getID() == $owner->getID()) ? "selected" : "").">" . htmlspecialchars($userObj->getLogin()." - ".$userObj->getFullName()) . "</option>\n"; print "<option value=\"".$userObj->getLogin()."\" ".(in_array($userObj->getLogin(), $owner) ? "selected" : "").">" . htmlspecialchars($userObj->getLogin()." - ".$userObj->getFullName()) . "</option>\n";
} }
?> ?>
</select> </select>
</td> </td>
</tr> </tr>
<?php } ?>
<?php if(!isset($facets['category'])) { ?>
<tr> <tr>
<td><?php printMLText("category_filter");?>:</td> <td><?php printMLText("category_filter");?>:</td>
<td> <td>
@ -540,6 +546,54 @@ $(document).ready( function() {
</select> </select>
</td> </td>
</tr> </tr>
<?php } ?>
<tr>
<td><?php printMLText("status");?>:</td>
<td>
<?php if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') { ?>
<?php if($workflowmode == 'traditional') { ?>
<label class="checkbox" for='pendingReview'><input type="checkbox" id="pendingReview" name="pendingReview" value="1" <?php echo in_array(S_DRAFT_REV, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_DRAFT_REV);?></label>
<?php } ?>
<label class="checkbox" for='pendingApproval'><input type="checkbox" id="pendingApproval" name="pendingApproval" value="1" <?php echo in_array(S_DRAFT_APP, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_DRAFT_APP);?></label>
<?php } elseif($workflowmode == 'advanced') { ?>
<label class="checkbox" for='inWorkflow'><input type="checkbox" id="inWorkflow" name="inWorkflow" value="1" <?php echo in_array(S_IN_WORKFLOW, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_IN_WORKFLOW);?></label>
<?php } ?>
<label class="checkbox" for='released'><input type="checkbox" id="released" name="released" value="1" <?php echo in_array(S_RELEASED, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_RELEASED);?></label>
<label class="checkbox" for='rejected'><input type="checkbox" id="rejected" name="rejected" value="1" <?php echo in_array(S_REJECTED, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_REJECTED);?></label>
<label class="checkbox" for='obsolete'><input type="checkbox" id="obsolete" name="obsolete" value="1" <?php echo in_array(S_OBSOLETE, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_OBSOLETE);?></label>
<label class="checkbox" for='expired'><input type="checkbox" id="expired" name="expired" value="1" <?php echo in_array(S_EXPIRED, $status) ? "checked" : ""; ?>><?php printOverallStatusText(S_EXPIRED);?></label>
</td>
</tr>
<?php if($facets) {
foreach($facets as $facetname=>$values) {
?>
<tr>
<td><?= getMLText($facetname);?>:</td>
<td>
<?php
$options = array();
foreach($values as $v=>$c) {
$option = array($v, $v.' ('.$c.')');
if(isset(${$facetname}) && in_array($v, ${$facetname}))
$option[] = true;
$options[] = $option;
}
$this->formField(
null,
array(
'element'=>'select',
'id'=>$facetname,
'name'=>$facetname."[]",
'class'=>'chzn-select',
'attributes'=>array(array('data-placeholder', getMLText('select_'.$facetname))),
'options'=>$options,
'multiple'=>true
)
);
?>
</td>
</tr>
<?php }} ?>
<tr> <tr>
<td></td><td><button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> <?php printMLText("search"); ?></button></td> <td></td><td><button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> <?php printMLText("search"); ?></button></td>
</tr> </tr>

View File

@ -310,7 +310,15 @@ $this->showStartPaneContent('site', (!$currenttab || $currenttab == 'site'));
<?php $this->showConfigCheckbox('settings_enableUsersView', 'enableUsersView'); ?> <?php $this->showConfigCheckbox('settings_enableUsersView', 'enableUsersView'); ?>
<?php $this->showConfigCheckbox('settings_enableFullSearch', 'enableFullSearch'); ?> <?php $this->showConfigCheckbox('settings_enableFullSearch', 'enableFullSearch'); ?>
<?php $this->showConfigText('settings_maxSizeForFullText', 'maxSizeForFullText'); ?> <?php $this->showConfigText('settings_maxSizeForFullText', 'maxSizeForFullText'); ?>
<?php $this->showConfigOption('settings_fullSearchEngine', 'fullSearchEngine', array('lucene'=>'settings_fullSearchEngine_vallucene', 'sqlitefts'=>'settings_fullSearchEngine_valsqlitefts'), false, true); ?> <?php
$fullsearchengines = array(
'lucene'=>'settings_fullSearchEngine_vallucene',
'sqlitefts'=>'settings_fullSearchEngine_valsqlitefts'
);
if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk))
$fullsearchengines = array_merge($fullsearchengines, $kkk);
?>
<?php $this->showConfigOption('settings_fullSearchEngine', 'fullSearchEngine', $fullsearchengines, false, true); ?>
<?php $this->showConfigOption('settings_defaultSearchMethod', 'defaultSearchMethod', array('database'=>'settings_defaultSearchMethod_valdatabase', 'fulltext'=>'settings_defaultSearchMethod_valfulltext'), false, true); ?> <?php $this->showConfigOption('settings_defaultSearchMethod', 'defaultSearchMethod', array('database'=>'settings_defaultSearchMethod_valdatabase', 'fulltext'=>'settings_defaultSearchMethod_valfulltext'), false, true); ?>
<?php $this->showConfigCheckbox('settings_showSingleSearchHit', 'showSingleSearchHit'); ?> <?php $this->showConfigCheckbox('settings_showSingleSearchHit', 'showSingleSearchHit'); ?>
<?php $this->showConfigText('settings_stopWordsFile', 'stopWordsFile'); ?> <?php $this->showConfigText('settings_stopWordsFile', 'stopWordsFile'); ?>