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
--------------------------------------------------------------------------------
- new api to fulltext search
--------------------------------------------------------------------------------
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()) {
$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) {
$path = $dms->contentDir . $version->getPath();
if(file_exists($path)) {

View File

@ -29,18 +29,22 @@ class SeedDMS_Lucene_Indexer {
*/
protected $indexname;
static function open($luceneDir) { /* {{{ */
static function open($conf) { /* {{{ */
try {
$index = Zend_Search_Lucene::open($luceneDir);
return($index);
$index = Zend_Search_Lucene::open($conf['indexdir']);
return($index);
} catch (Exception $e) {
return null;
}
} /* }}} */
static function create($luceneDir) { /* {{{ */
$index = Zend_Search_Lucene::create($luceneDir);
return($index);
static function create($conf) { /* {{{ */
try {
$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
* @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 = '';
if($fields) {
} else {
if($term)
$querystr .= trim($term);
if($term)
$querystr .= trim($term);
if(!empty($fields['owner'])) {
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($querystr)
$querystr .= ' && ';
$querystr .= 'owner:'.$owner;
}
if($categories) {
if(!empty($fields['category'])) {
if($querystr)
$querystr .= ' && ';
$querystr .= '(category:"';
$querystr .= implode('" || category:"', $categories);
$querystr .= implode('" || category:"', $fields['category']);
$querystr .= '")';
}
if($users) {
if(!empty($fields['status'])) {
if($querystr)
$querystr .= ' && ';
$querystr .= '(status:"';
$querystr .= implode('" || status:"', $fields['status']);
$querystr .= '")';
}
if(!empty($fields['user'])) {
if($querystr)
$querystr .= ' && ';
$querystr .= '(users:"';
$querystr .= implode('" || users:"', $users);
$querystr .= implode('" || users:"', $fields['user']);
$querystr .= '")';
}
try {
@ -90,10 +102,13 @@ class SeedDMS_Lucene_Search {
try {
$hits = $this->index->find($query);
$recs = array();
$c = 0;
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) {
return false;
}

View File

@ -11,11 +11,11 @@
<email>uwe@steinmann.cx</email>
<active>yes</active>
</lead>
<date>2020-09-02</date>
<date>2020-09-10</date>
<time>08:55:43</time>
<version>
<release>1.1.14</release>
<api>1.1.14</api>
<release>1.1.15</release>
<api>1.1.15</api>
</version>
<stability>
<release>stable</release>
@ -23,7 +23,12 @@
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<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>
<contents>
<dir baseinstalldir="SeedDMS" name="/">
@ -315,5 +320,21 @@ execWithTimeout() reads data from stderr and saves it into error msg
IndexedDocument() remembers cmd and mimetype
</notes>
</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>
</package>

View File

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

View File

@ -42,30 +42,30 @@ class SeedDMS_SQLiteFTS_Indexer {
*
* @param string $indexerDir directory on disk containing the index
*/
static function open($indexerDir) { /* {{{ */
if(file_exists($indexerDir.'/index.db')) {
return new SeedDMS_SQLiteFTS_Indexer($indexerDir);
static function open($conf) { /* {{{ */
if(file_exists($conf['indexdir'].'/index.db')) {
return new SeedDMS_SQLiteFTS_Indexer($conf['indexdir']);
} else
return self::create($indexerDir);
return self::create($conf['indexdir']);
} /* }}} */
/**
* 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) { /* {{{ */
if(file_exists($indexerDir.'/index.db'))
unlink($indexerDir.'/index.db');
$index = new SeedDMS_SQLiteFTS_Indexer($indexerDir);
static function create($conf) { /* {{{ */
if(file_exists($conf['indexdir'].'/index.db'))
unlink($conf['indexdir'].'/index.db');
$index = new SeedDMS_SQLiteFTS_Indexer($conf['indexdir']);
/* Make sure the sequence of fields is identical to the field list
* in SeedDMS_SQLiteFTS_Term
*/
$version = SQLite3::version();
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
$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);
if($res === false) {
return null;
@ -96,7 +96,7 @@ class SeedDMS_SQLiteFTS_Indexer {
if(!$this->_conn)
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);
if($res === false) {
return false;
@ -135,15 +135,29 @@ class SeedDMS_SQLiteFTS_Indexer {
/**
* Find documents in index
*
* @param object $doc indexed document of class
* SeedDMS_SQLiteFTS_IndexedDocument
* @return boolean false in case of an error, otherwise true
* @param string $query
* @param array $limit array with elements 'limit' and 'offset'
* @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)
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);
$hits = array();
if($res) {
@ -153,7 +167,7 @@ class SeedDMS_SQLiteFTS_Indexer {
$hits[] = $hit;
}
}
return $hits;
return array('count'=>$row['c'], 'hits'=>$hits);
} /* }}} */
/**
@ -189,7 +203,7 @@ class SeedDMS_SQLiteFTS_Indexer {
if(!$this->_conn)
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);
$doc = false;
if($res) {
@ -204,6 +218,7 @@ class SeedDMS_SQLiteFTS_Indexer {
$doc->addField('owner', $rec['owner']);
$doc->addField('created', $rec['created']);
$doc->addField('users', $rec['users']);
$doc->addField('status', $rec['status']);
}
return $doc;
} /* }}} */

View File

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

View File

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

View File

@ -11,11 +11,11 @@
<email>uwe@steinmann.cx</email>
<active>yes</active>
</lead>
<date>2020-09-02</date>
<date>2020-09-11</date>
<time>08:57:44</time>
<version>
<release>1.0.13</release>
<api>1.0.13</api>
<release>1.0.14</release>
<api>1.0.14</api>
</version>
<stability>
<release>stable</release>
@ -23,7 +23,12 @@
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<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>
<contents>
<dir baseinstalldir="SeedDMS" name="/">
@ -275,5 +280,21 @@ timestamp)
Index users with at least read access on a document
</notes>
</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>
</package>

View File

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

View File

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

View File

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

View File

@ -40,8 +40,7 @@ class SeedDMS_Controller_UpdateDocument extends SeedDMS_Controller_Common {
$user = $this->params['user'];
$document = $this->params['document'];
$settings = $this->params['settings'];
$index = $this->params['index'];
$indexconf = $this->params['indexconf'];
$fulltextservice = $this->params['fulltextservice'];
$folder = $this->params['folder'];
$userfiletmp = $this->getParam('userfiletmp');
$userfilename = $this->getParam('userfilename');
@ -94,12 +93,12 @@ class SeedDMS_Controller_UpdateDocument extends SeedDMS_Controller_Common {
return false;
}
if($index && $content) {
$lucenesearch = new $indexconf['Search']($index);
if($fulltextservice && ($index = $fulltextservice->Indexer()) && $content) {
$lucenesearch = $fulltextservice->Search();
if($hit = $lucenesearch->getDocument((int) $document->getId())) {
$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)) {
$index->addDocument($idoc);
$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.FulltextInit.php');

View File

@ -52,31 +52,6 @@ if (get_magic_quotes_gpc()) {
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
* 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 */
$notusers = array();
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('folder', $folder);
$controller->setParam('index', $index);
$controller->setParam('indexconf', $indexconf);
$controller->setParam('fulltextservice', $fulltextservice);
$controller->setParam('name', $name);
$controller->setParam('comment', $comment);
$controller->setParam('expires', $expires);

View File

@ -519,18 +519,9 @@ switch($command) {
);
$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->setParam('document', $document);
$controller->setParam('index', $index);
$controller->setParam('indexconf', $indexconf);
$controller->setParam('fulltextservice', $fulltextservice);
if($controller->run()) {
if ($notifier){
$subject = "document_deleted_email_subject";
@ -785,19 +776,10 @@ switch($command) {
$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->setParam('documentsource', 'upload');
$controller->setParam('folder', $folder);
$controller->setParam('index', $index);
$controller->setParam('indexconf', $indexconf);
$controller->setParam('fulltextservice', $fulltextservice);
$controller->setParam('name', $name);
$controller->setParam('comment', '');
$controller->setParam('expires', $expires);
@ -1009,13 +991,11 @@ switch($command) {
case 'indexdocument': /* {{{ */
if($user && $user->isAdmin()) {
if($settings->_enableFullSearch) {
if($fulltextservice) {
$document = $dms->getDocument($_REQUEST['id']);
if($document) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
if($index) {
$indexconf['Indexer']::init($settings->_stopWordsFile);
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout);
if($index = $fulltextservice->Indexer()) {
$idoc = $fulltextservice->IndexedDocument($document, true);
$error = $idoc->getErrorMsg();
if(!$error) {
$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();
/* Remove all preview images. */
@ -87,8 +79,7 @@ $nl = array(
$docname = $document->getName();
$controller->setParam('document', $document);
$controller->setParam('index', $index);
$controller->setParam('indexconf', $indexconf);
$controller->setParam('fulltextservice', $fulltextservice);
if(!$controller->run()) {
if ($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"));
}
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
$indexconf['Indexer']::init($settings->_stopWordsFile);
} else {
$index = null;
}
/*
function removePreviews($arr, $document) {
$previewer = $arr[0];
@ -86,8 +79,7 @@ $nl = array(
);
$controller->setParam('folder', $folder);
$controller->setParam('index', $index);
$controller->setParam('indexconf', $indexconf);
$controller->setParam('fulltextservice', $fulltextservice);
if(!$controller->run()) {
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 {
$nexturl = "../out/out.ViewFolder.php?folderid=".$folder->getId();
/* Remove the document from the fulltext index */
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
if($index) {
$lucenesearch = new $indexconf['Search']($index);
if($hit = $lucenesearch->getDocument($documentid)) {
$index->delete($hit->id);
$index->commit();
}
if($fulltextservice && ($index = $fulltextservice->Index())) {
$lucenesearch = $fulltextservice->Search();
if($hit = $lucenesearch->getDocument($documentid)) {
$index->delete($hit->id);
$index->commit();
}
}
@ -142,18 +139,14 @@ else {
else
$nexturl = "../out/out.ViewDocument.php?documentid=".$documentid."&currenttab=previous";
/* Remove the document from the fulltext index and reindex latest version */
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
if($index) {
$lucenesearch = new $indexconf['Search']($index);
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();
if($fulltextservice && ($index = $fulltextservice->Indexer())) {
$lucenesearch = $fulltextservice->Search();
if($hit = $lucenesearch->getDocument($document->getID())) {
$index->delete($hit->id);
}
$version = $document->getLatestContent();
$index->addDocument($fulltextservice->IndexedDocument($document));
$index->commit();
}
// Notify affected users.

View File

@ -133,13 +133,6 @@ if (isset($_FILES['userfile']) && $_FILES['userfile']['error'] == 0) {
$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"]))
$comment = $_POST["comment"];
else
@ -349,8 +342,7 @@ default:
$controller->setParam('folder', $folder);
$controller->setParam('document', $document);
$controller->setParam('index', $index);
$controller->setParam('indexconf', $indexconf);
$controller->setParam('fulltextservice', $fulltextservice);
$controller->setParam('comment', $comment);
if($oldexpires != $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) {
echo getMLText("error_occured");
} else {
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
if($fulltextservice && ($index = $fulltextservice->Indexer())) {
if($index) {
$lucenesearch = new $indexconf['Search']($index);
$lucenesearch = $fulltextservice->Search();
if($hit = $lucenesearch->getDocument((int) $document->getId())) {
$index->delete($hit->id);
}
$indexconf['Indexer']::init($settings->_stopWordsFile);
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, !($filesize < $settings->_maxSizeForFullText)));
$index->addDocument($fulltextservice->IndexedDocument($document));
$index->commit();
}
}

View File

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

View File

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

View File

@ -72,12 +72,20 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
// category
$categories = 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) {
if($catid > 0) {
$category = $dms->getDocumentCategory($catid);
$categories[] = $category;
$categorynames[] = $category->getName();
if($catid) {
$cat = $dms->getDocumentCategory($catid);
$categories[] = $cat;
$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
// 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::exitError(getMLText("search_results"),getMLText("unknown_owner"));
$owner = [];
if (isset($_GET["owner"])) {
if (!is_array($_GET['owner'])) {
if(!empty($_GET['owner']) && $o = $dms->getUserByLogin($_GET['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();
if($settings->_enableFullSearch) {
if($settings->_fullSearchEngine == 'lucene') {
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
// Check to see if the search has been restricted to a particular
// mimetype.
$mimetype = [];
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, '*')) {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
$dcount = 0;
$totalPages = 0;
$entries = array();
$searchTime = 0;
} else {
$startTime = getTime();
$index = $indexconf['Indexer']::open($settings->_luceneDir);
$lucenesearch = new $indexconf['Search']($index);
$hits = $lucenesearch->search($query, $owner ? $owner->getLogin() : '', '', $categorynames, array(), $user->isAdmin() ? [] : [$user->getLogin()]);
if($hits === false) {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
$totalPages = 0;
$entries = array();
$searchTime = 0;
} else {
$entries = array();
$dcount = 0;
$fcount = 0;
if($hits) {
foreach($hits as $hit) {
if($tmp = $dms->getDocument($hit['document_id'])) {
if($tmp->getAccessMode($user) >= M_READ) {
if($tmp->getLatestContent()) {
$index = $fulltextservice->Indexer();
if($index) {
$limit = 20;
$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))));
if($searchresult === false) {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
$dcount = 0;
$fcount = 0;
$totalPages = 0;
$entries = array();
$facets = array();
$searchTime = 0;
} else {
$entries = array();
$facets = $searchresult['facets'];
$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();
$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;
if($pageNumber != 'all' && count($entries) > $limit) {
$totalPages = (int) (count($entries)/$limit);
if(count($entries)%$limit)
$totalPages++;
if($limit > 0)
$entries = array_slice($entries, ($pageNumber-1)*$limit, $limit);
} else {
$totalPages = 1;
}
$searchTime = getTime() - $startTime;
$searchTime = round($searchTime, 2);
} else {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_search_service')));
$dcount = 0;
$fcount = 0;
$totalPages = 0;
$entries = array();
$facets = array();
$searchTime = 0;
}
$searchTime = getTime() - $startTime;
$searchTime = round($searchTime, 2);
}
$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
// 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::exitError(getMLText("search"),getMLText("unknown_owner"));
$owner = array();
$ownerobjs = array();
if (isset($_GET["owner"])) {
if (!is_array($_GET['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
$categories = array();
if(isset($_GET['categoryids']) && $_GET['categoryids']) {
foreach($_GET['categoryids'] as $catid) {
if($catid > 0)
$categories[] = $dms->getDocumentCategory($catid);
$categorynames = array();
if(isset($_GET['category']) && $_GET['category']) {
foreach($_GET['category'] as $catname) {
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,
'searchin'=>$searchin,
'startFolder'=>$startFolder,
'owner'=>$owner,
'owner'=>$ownerobjs,
'status'=>$status,
'creationstartdate'=>$creationdate ? $startdate : array(),
'creationenddate'=>$creationdate ? $stopdate : array(),
@ -440,7 +520,9 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
if(count($entries)%$limit)
$totalPages++;
$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));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if($view) {
$view->setParam('facets', $facets);
$view->setParam('accessobject', $accessop);
$view->setParam('query', $query);
$view->setParam('searchhits', $entries);
@ -491,6 +574,8 @@ if($settings->_showSingleSearchHit && count($entries) == 1) {
$view->setParam('expirationdate', isset($expirationdate) ? $expirationdate: '');
$view->setParam('status', isset($status) ? $status : array());
$view->setParam('categories', isset($categories) ? $categories : '');
$view->setParam('category', isset($categorynames) ? $categorynames : '');
$view->setParam('mimetype', isset($mimetype) ? $mimetype : '');
$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));
$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.DBInit.php");
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'
);
require_once('SeedDMS/Lucene.php');
}
function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
function tree($dms, $fulltextservice, $folder, $indent='') { /* {{{ */
global $settings, $themes;
echo $themes->black($indent."D ".$folder->getName()).PHP_EOL;
$subfolders = $folder->getSubFolders();
foreach($subfolders as $subfolder) {
tree($dms, $index, $indexconf, $subfolder, $indent.' ');
tree($dms, $fulltextservice, $subfolder, $indent.' ');
}
$documents = $folder->getDocuments();
$index = $fulltextservice->Indexer();
$lucenesearch = $fulltextservice->Search();
foreach($documents as $document) {
echo $themes->black($indent." ".$document->getId().":".$document->getName()." ");
$lucenesearch = new $indexconf['Search']($index);
if(!($hit = $lucenesearch->getDocument($document->getId()))) {
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'])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['indexDocument'] as $hookObj) {
if (method_exists($hookObj, 'preIndexDocument')) {
@ -115,7 +98,7 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
} else {
$index->delete($hit->id);
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'])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['indexDocument'] as $hookObj) {
if (method_exists($hookObj, 'preIndexDocument')) {
@ -135,19 +118,14 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
$themes = new \AlecRabbit\ConsoleColour\Themes();
if($recreate)
$index = $indexconf['Indexer']::create($settings->_luceneDir);
else
$index = $indexconf['Indexer']::open($settings->_luceneDir);
$index = $fulltextservice->Indexer($recreate);
if(!$index) {
echo $themes->error("Could not create index.").PHP_EOL;
exit(1);
}
$indexconf['Indexer']::init($settings->_stopWordsFile);
$folder = $dms->getFolder($settings->_rootFolderID);
tree($dms, $index, $indexconf, $folder);
tree($dms, $fulltextservice, $folder);
$index->commit();
$index->optimize();

View File

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

View File

@ -29,61 +29,42 @@ class SeedDMS_View_Indexer_Process_Folder { /* {{{ */
protected $index;
protected $indexconf;
public function __construct($index, $indexconf, $forceupdate) { /* {{{ */
$this->index = $index;
$this->indexconf = $indexconf;
public function __construct($fulltextservice, $forceupdate) { /* {{{ */
$this->fulltextservice = $fulltextservice;
$this->forceupdate = $forceupdate;
} /* }}} */
public function process($folder) { /* {{{ */
$documents = $folder->getDocuments();
if($documents) {
$lucenesearch = $this->fulltextservice->Search();
echo "<div class=\"folder\">".$folder->getFolderPathPlain()."</div>";
foreach($documents as $document) {
echo "<div class=\"document\">".$document->getId().":".htmlspecialchars($document->getName());
/* If the document wasn't indexed before then just add it */
$lucenesearch = new $this->indexconf['Search']($this->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() && !$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 "<div class=\"document\">".$document->getId().":".htmlspecialchars($document->getName());
/* If the document wasn't indexed before then just add it */
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 $indent."(document updated)";
} catch(Exception $e) {
echo $indent."(updating document failed)";
}
} 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->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 funcArray = []; // Array of functions waiting
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
function check_queue() {
// 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('Currently processing ' + queue_count + ' requests (' + $.active + ')');
// console.log('Queue has ' + funcArray.length + '/' + docstoindex + ' items');
// console.log('Currently processing ' + queue_count + ' requests (' + $.active + ')');
if(queue_count >= MAX_REQUESTS) {
setTimeout(function() { check_queue() }, CALL_WAIT);
return;
@ -193,74 +174,10 @@ $(document).ready( function() {
<?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() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$index = $this->params['index'];
$indexconf = $this->params['indexconf'];
$fulltextservice = $this->params['fulltextservice'];
$forceupdate = $this->params['forceupdate'];
$folder = $this->params['folder'];
$this->converters = $this->params['converters'];
@ -271,7 +188,8 @@ $(document).ready( function() {
$this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
$this->contentHeading(getMLText("update_fulltext_index"));
if($index) {
if($fulltextservice) {
$index = $fulltextservice->Indexer();
?>
<style type="text/css">
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>
<?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'));
call_user_func(array($folderprocess, 'process'), $folder);
// $this->tree($dms, $index, $indexconf, $folder);
echo "</div>";
$index->commit();

View File

@ -128,7 +128,9 @@ $(document).ready( function() {
$enablefullsearch = $this->params['enablefullsearch'];
$enableclipboard = $this->params['enableclipboard'];
$attributes = $this->params['attributes'];
$category = $this->params['category'];
$categories = $this->params['categories'];
$mimetype = $this->params['mimetype'];
$owner = $this->params['owner'];
$startfolder = $this->params['startfolder'];
$startdate = $this->params['startdate'];
@ -141,6 +143,7 @@ $(document).ready( function() {
$this->query = $this->params['query'];
$orderby = $this->params['orderby'];
$entries = $this->params['searchhits'];
$facets = $this->params['facets'];
$totalpages = $this->params['totalpages'];
$pageNumber = $this->params['pagenumber'];
$searchTime = $this->params['searchtime'];
@ -220,13 +223,13 @@ $(document).ready( function() {
<tr>
<td><?php printMLText("owner");?>:</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>
<?php
foreach ($allUsers as $userObj) {
if ($userObj->isGuest() || ($userObj->isHidden() && $userObj->getID() != $user->getID() && !$user->isAdmin()))
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>
@ -304,7 +307,7 @@ $(document).ready( function() {
}
}
}
if($categories)
if($category)
$openfilterdlg = true;
if($status)
$openfilterdlg = true;
@ -349,7 +352,7 @@ $(document).ready( function() {
<tr>
<td><?php printMLText("category");?>:</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");?>
-->
@ -358,7 +361,7 @@ $(document).ready( function() {
foreach($categories as $tmpcat)
$tmpcatids[] = $tmpcat->getID();
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>
@ -507,21 +510,24 @@ $(document).ready( function() {
-->
</td>
</tr>
<?php if(!isset($facets['owner'])) { ?>
<tr>
<td><?php printMLText("owner");?>:</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>
<?php
foreach ($allUsers as $userObj) {
if ($userObj->isGuest() || ($userObj->isHidden() && $userObj->getID() != $user->getID() && !$user->isAdmin()))
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>
</td>
</tr>
<?php } ?>
<?php if(!isset($facets['category'])) { ?>
<tr>
<td><?php printMLText("category_filter");?>:</td>
<td>
@ -540,6 +546,54 @@ $(document).ready( function() {
</select>
</td>
</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>
<td></td><td><button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> <?php printMLText("search"); ?></button></td>
</tr>

View File

@ -310,7 +310,15 @@ $this->showStartPaneContent('site', (!$currenttab || $currenttab == 'site'));
<?php $this->showConfigCheckbox('settings_enableUsersView', 'enableUsersView'); ?>
<?php $this->showConfigCheckbox('settings_enableFullSearch', 'enableFullSearch'); ?>
<?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->showConfigCheckbox('settings_showSingleSearchHit', 'showSingleSearchHit'); ?>
<?php $this->showConfigText('settings_stopWordsFile', 'stopWordsFile'); ?>