call hooks

This commit is contained in:
Uwe Steinmann 2017-12-22 13:05:35 +01:00
parent 63f9170671
commit 21518adecc

View File

@ -1,5 +1,7 @@
<?php
require_once("../inc/inc.ClassSettings.php");
#require_once("../inc/inc.ClassSettings.php");
include("../inc/inc.Settings.php");
include("../inc/inc.Extension.php");
function usage() { /* {{{ */
echo "Usage:\n";
@ -15,7 +17,7 @@ function usage() { /* {{{ */
echo " --config: set alternative config file.\n";
} /* }}} */
$version = "0.0.1";
$version = "0.0.2";
$shortoptions = "hvc";
$longoptions = array('help', 'version', 'config:');
if(false === ($options = getopt($shortoptions, $longoptions))) {
@ -83,7 +85,16 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
$lucenesearch = new $indexconf['Search']($index);
if(!($hit = $lucenesearch->getDocument($document->getId()))) {
try {
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout));
# $index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout));
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout);
if(isset($GLOBALS['SEEDDMS_HOOKS']['indexDocument'])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['indexDocument'] as $hookObj) {
if (method_exists($hookObj, 'preIndexDocument')) {
$hookObj->preIndexDocument(null, $document, $idoc);
}
}
}
$index->addDocument($idoc);
echo " (Document added)\n";
} catch(Exception $e) {
echo " (Timeout)\n";
@ -100,7 +111,17 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
} else {
$index->delete($hit->id);
try {
$index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout));
# $index->addDocument(new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout));
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, false, $settings->_cmdTimeout);
if(isset($GLOBALS['SEEDDMS_HOOKS']['indexDocument'])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['indexDocument'] as $hookObj) {
if (method_exists($hookObj, 'preIndexDocument')) {
$hookObj->preIndexDocument(null, $document, $idoc);
}
}
}
$index->addDocument($idoc);
echo " (Document updated)\n";
} catch(Exception $e) {
echo " (Timeout)\n";