2021-04-19 13:54:41 +00:00
|
|
|
<?php
|
|
|
|
|
2023-02-20 15:07:22 +00:00
|
|
|
function getAttributesCallback($dms) {
|
|
|
|
return function () use ($dms) {
|
|
|
|
return $dms->getAllAttributeDefinitions();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-19 08:17:08 +00:00
|
|
|
function reindexDocumentOrFolderCallback($fulltextservice, $object) {
|
|
|
|
if($fulltextservice && ($index = $fulltextservice->Indexer())) {
|
|
|
|
$lucenesearch = $fulltextservice->Search();
|
|
|
|
if($object->isType('document'))
|
|
|
|
$hit = $lucenesearch->getDocument($object->getId());
|
|
|
|
elseif($object->isType('folder'))
|
|
|
|
$hit = $lucenesearch->getFolder($object->getId());
|
2023-04-28 16:39:53 +00:00
|
|
|
elseif($object->isType('documentcontent'))
|
|
|
|
$hit = $lucenesearch->getDocument($object->getDocument()->getId());
|
2023-03-19 08:17:08 +00:00
|
|
|
if($hit) {
|
|
|
|
$index->reindexDocument($hit->id);
|
|
|
|
$index->commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-19 13:54:41 +00:00
|
|
|
$fulltextservice = null;
|
|
|
|
if($settings->_enableFullSearch) {
|
|
|
|
require_once("inc.ClassFulltextService.php");
|
|
|
|
$fulltextservice = new SeedDMS_FulltextService();
|
2022-05-16 13:45:23 +00:00
|
|
|
$fulltextservice->setLogger($logger);
|
2021-04-19 13:54:41 +00:00
|
|
|
|
|
|
|
if($settings->_fullSearchEngine == 'sqlitefts') {
|
|
|
|
$indexconf = array(
|
|
|
|
'Indexer' => 'SeedDMS_SQLiteFTS_Indexer',
|
|
|
|
'Search' => 'SeedDMS_SQLiteFTS_Search',
|
|
|
|
'IndexedDocument' => 'SeedDMS_SQLiteFTS_IndexedDocument',
|
2023-02-20 15:07:22 +00:00
|
|
|
'Conf' => array(
|
|
|
|
'indexdir' => $settings->_luceneDir,
|
|
|
|
'attrcallback' => getAttributesCallback($dms)
|
|
|
|
)
|
2021-04-19 13:54:41 +00:00
|
|
|
);
|
|
|
|
$fulltextservice->addService('sqlitefts', $indexconf);
|
|
|
|
|
2023-01-21 08:15:46 +00:00
|
|
|
require_once('vendor/seeddms/sqlitefts/SQLiteFTS.php');
|
2021-04-19 13:54:41 +00:00
|
|
|
} elseif($settings->_fullSearchEngine == 'lucene') {
|
|
|
|
$indexconf = array(
|
|
|
|
'Indexer' => 'SeedDMS_Lucene_Indexer',
|
|
|
|
'Search' => 'SeedDMS_Lucene_Search',
|
|
|
|
'IndexedDocument' => 'SeedDMS_Lucene_IndexedDocument',
|
|
|
|
'Conf' => array('indexdir' => $settings->_luceneDir)
|
|
|
|
);
|
|
|
|
$fulltextservice->addService('lucene', $indexconf);
|
|
|
|
|
|
|
|
if(!empty($settings->_luceneClassDir))
|
|
|
|
require_once($settings->_luceneClassDir.'/Lucene.php');
|
|
|
|
else
|
2023-01-21 08:09:57 +00:00
|
|
|
require_once('vendor/seeddms/lucene/Lucene.php');
|
2021-04-19 13:54:41 +00:00
|
|
|
} else {
|
|
|
|
$indexconf = null;
|
|
|
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['initFulltext'])) {
|
|
|
|
foreach($GLOBALS['SEEDDMS_HOOKS']['initFulltext'] as $hookObj) {
|
2023-01-09 14:30:18 +00:00
|
|
|
if (method_exists($hookObj, 'isFulltextService') && $hookObj->isFulltextService($settings->_fullSearchEngine)) {
|
|
|
|
if (method_exists($hookObj, 'initFulltextService')) {
|
|
|
|
$indexconf = $hookObj->initFulltextService(array('engine'=>$settings->_fullSearchEngine, 'dms'=>$dms, 'settings'=>$settings));
|
|
|
|
}
|
2021-04-19 13:54:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($indexconf) {
|
|
|
|
$fulltextservice->addService($settings->_fullSearchEngine, $indexconf);
|
|
|
|
}
|
|
|
|
}
|
2023-01-04 13:33:36 +00:00
|
|
|
/* setConverters() is deprecated */
|
2021-04-19 13:54:41 +00:00
|
|
|
$fulltextservice->setConverters(isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null);
|
2021-10-06 12:59:46 +00:00
|
|
|
$fulltextservice->setConversionMgr($conversionmgr);
|
2021-04-19 13:54:41 +00:00
|
|
|
$fulltextservice->setMaxSize($settings->_maxSizeForFullText);
|
|
|
|
$fulltextservice->setCmdTimeout($settings->_cmdTimeout);
|
2023-01-22 18:15:11 +00:00
|
|
|
// require_once("vendor/seeddms/preview/Preview.php");
|
2023-01-03 13:06:24 +00:00
|
|
|
$txtpreviewer = new SeedDMS_Preview_TxtPreviewer($settings->_cacheDir, $settings->_cmdTimeout, $settings->_enableXsendfile);
|
|
|
|
if($conversionmgr)
|
|
|
|
$txtpreviewer->setConversionMgr($conversionmgr);
|
|
|
|
$fulltextservice->setPreviewer($txtpreviewer);
|
2023-03-19 08:17:08 +00:00
|
|
|
|
|
|
|
$dms->addCallback('onPostSetFolder', 'reindexDocumentOrFolderCallback', $fulltextservice);
|
|
|
|
$dms->addCallback('onPostSetName', 'reindexDocumentOrFolderCallback', $fulltextservice);
|
|
|
|
$dms->addCallback('onPostSetComment', 'reindexDocumentOrFolderCallback', $fulltextservice);
|
|
|
|
$dms->addCallback('onPostSetKeywords', 'reindexDocumentOrFolderCallback', $fulltextservice);
|
|
|
|
$dms->addCallback('onPostSetKategories', 'reindexDocumentOrFolderCallback', $fulltextservice);
|
|
|
|
$dms->addCallback('onPostAddKategories', 'reindexDocumentOrFolderCallback', $fulltextservice);
|
|
|
|
$dms->addCallback('onPostRemoveKategories', 'reindexDocumentOrFolderCallback', $fulltextservice);
|
2023-04-28 16:39:53 +00:00
|
|
|
$dms->addCallback('onPostAddAttribute', 'reindexDocumentOrFolderCallback', $fulltextservice);
|
|
|
|
$dms->addCallback('onPostUpdateAttribute', 'reindexDocumentOrFolderCallback', $fulltextservice);
|
|
|
|
$dms->addCallback('onPostRemoveAttribute', 'reindexDocumentOrFolderCallback', $fulltextservice);
|
2021-04-19 13:54:41 +00:00
|
|
|
}
|
|
|
|
|