diff --git a/plugins/ktstandard/KTIndexer.php b/plugins/ktstandard/KTIndexer.php new file mode 100644 index 0000000..4f2a2ee --- /dev/null +++ b/plugins/ktstandard/KTIndexer.php @@ -0,0 +1,12 @@ +registerPlugin('KTIndexerPlugin', 'ktstandard.indexer.plugin', __FILE__); +$oPlugin =& $oPluginRegistry->getPlugin('ktstandard.indexer.plugin'); + +$oPlugin->registerTrigger('content', 'transform', 'KTWordIndexerTrigger', 'ktstandard.indexer.triggers.word', 'contents/WordIndexer.php'); +$oPlugin->register(); diff --git a/plugins/ktstandard/contents/WordIndexer.php b/plugins/ktstandard/contents/WordIndexer.php new file mode 100644 index 0000000..e869a56 --- /dev/null +++ b/plugins/ktstandard/contents/WordIndexer.php @@ -0,0 +1,26 @@ +oDocument = $oDocument; + } + + function transform() { + $oStorage = KTStorageManagerUtil::getSingleton(); + $sFile = $oStorage->temporaryFile($this->oDocument); + + $cmdline = array("catdoc", $sFile); + $myfilename = tempnam("/tmp", "kt.catdoc"); + $command = KTUtil::safeShellString($cmdline) . " >> " . $myfilename; + system($command); + $contents = file_get_contents($myfilename); + $aInsertValues = array( + 'document_id' => $this->oDocument->getId(), + 'document_text' => $contents, + ); + $sTable = KTUtil::getTableName('document_text'); + DBUtil::autoInsert($sTable, $aInsertValues, array('noid' => true)); + } +} + +?>