function setup() { //Indexer::checkForRegisteredTypes(); $this->indexer = Indexer::get(); $this->path = KT_DIR . '/tests/documentProcessor/dataset/'; $this->tempPath = KT_DIR . '/var/tmp'; }
function do_main() { //registerTypes registers the mime types and populates the needed tables. $indexer = Indexer::get(); $indexer->registerTypes(); $oTemplating =& KTTemplating::getSingleton(); $oTemplate =& $oTemplating->loadTemplate('ktcore/search2/reporting/managemimetypes'); $aMimeTypes = KTMime::getAllMimeTypesInformation(); $indexer = Indexer::get(); $numExtensions = 0; $numIndexedExtensions = 0; foreach ($aMimeTypes as $key => $mimeType) { $extractorClass = $mimeType['extractor']; $numExtensions++; if (empty($extractorClass)) { continue; } $extractor = $indexer->getExtractor($extractorClass); $aMimeTypes[$key]['extractor'] = $extractor->getDisplayName(); $numIndexedExtensions++; } $indexedPercentage = 0; if ($numExtensions > 0) { $indexedPercentage = number_format($numIndexedExtensions * 100 / $numExtensions, 2, '.', ','); } $oTemplate->setData(array('context' => $this, 'mime_types' => $aMimeTypes, 'numExtensions' => $numExtensions, 'numIndexedExtensions' => $numIndexedExtensions, 'indexedPercentage' => $indexedPercentage)); return $oTemplate; }
function do_main() { //registerTypes registers the mime types and populates the needed tables. $indexer = Indexer::get(); $indexer->registerTypes(); $oTemplating =& KTTemplating::getSingleton(); $oTemplating->addLocation('Extractor Information', '/plugins/search2/reporting/templates'); $oTemplate =& $oTemplating->loadTemplate('extractorinfo'); $aExtractorInfo = KTMime::getMimeExtractorInformation(); if (empty($aExtractorInfo)) { $oTemplate->setData(array('context' => $this, 'extractor_info' => $aExtractorInfo)); return $oTemplate; } foreach ($aExtractorInfo as $key => $info) { $extractorClass = $info['name']; $extractor = $indexer->getExtractor($extractorClass); $info['mimeTypes'] = array(); $aMimeTypes = $this->getSupportedMimeTypesDB($extractorClass); //$extractor->getSupportedMimeTypes(); foreach ($aMimeTypes as $mimeType) { $sMimeInfo = KTMime::getFriendlyNameAndExtension($mimeType); $info['mimeTypes'][$mimeType] = array('description' => $sMimeInfo[0]['friendly_name'], 'extensions' => array($sMimeInfo[0]['filetypes'])); $extensions = array(); foreach ($sMimeInfo as $item) { $extensions[] = $item['filetypes']; } $info['mimeTypes'][$mimeType]['extensions'] = implode(', ', $extensions); } $aExtractorInfo[$key] = $info; } $oTemplate->setData(array('context' => $this, 'extractor_info' => $aExtractorInfo)); return $oTemplate; }
function checkLucene() { $indexer = Indexer::get(); $diagnose = $indexer->diagnose(); if (!is_null($diagnose)) { $this->addIssue('Document Indexer', $diagnose); } }
/** * Dispatch function */ function do_main() { $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Document Indexer Statistics')); $indexer = Indexer::get(); $stats = $indexer->getIndexStatistics(); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/search2/lucene_statistics'); $aTemplateData = array('context' => $this, 'stats' => $stats); return $oTemplate->render($aTemplateData); }
/** * Initialise the indexer and processors * */ public function __construct() { global $default; // Set the number of documents in a batch (config setting: indexer/batchDocuments) $max = $default->batchDocuments; $this->limit = is_numeric($max) ? $max : $this->limit; // Load processors $this->processors = $this->loadProcessors(); // Initialise the indexer $this->indexer = Indexer::get(); }
function setup() { $this->indexer = Indexer::get(); //$this->path = KT_DIR . '/tests/documentProcessor/dataset/'; $tempPath = KT_DIR . '/var/tmp'; $this->targetFile = tempnam($tempPath, 'ktindexer'); file_put_contents($this->targetFile, $this->getContent()); $this->id = 'test_id_1'; $this->title = 'The Critique of Pure Reason'; $this->version = '0.1'; }
/** * Dispatch function */ function do_main() { // Load Templating Engine $oTemplating =& KTTemplating::getSingleton(); // Set Template to use $oTemplate = $oTemplating->loadTemplate('ktcore/search2/indexing_status'); // Do a runtime Service Resource Check $checker = new ResourceChecker(); $checker->check(); // Get Results $serviceErrors = KTUtil::getSystemSetting('externalResourceIssues'); $serviceErrors = unserialize($serviceErrors); // Array to Hold Items not working $this->serviceErrors = array(); // A reference array to use with extractors that depend on the service $errorReference = array(); if (count($serviceErrors) > 0) { // Add Service Errors foreach ($serviceErrors as $error) { $this->serviceErrors[$error['name']] = array('name' => $error['name'], 'status' => $error['status'], 'help' => IndexingHelp::getHelp($error['name'])); // Create Reference to the array $errorReference[$error['status']] =& $this->serviceErrors[$error['name']]; } } // --------------------------- // Do a run time check for extractors not working $indexer = Indexer::get(); $extractorDiagnosis = $indexer->diagnoseExtractors(); // Create an Array to store errors $this->extractorErrors = array(); if (count($extractorDiagnosis > 0)) { foreach ($extractorDiagnosis as $extractor => $props) { // Check if Extractor fault is due to a service not running if (array_key_exists($props['diagnosis'], $errorReference)) { // One service may affect multiple extractors $errorReference[$props['diagnosis']]['alsoaffects'] = array(array('extractor' => $props['name'], 'affectedtypes' => IndexingHelp::affectedTypes($extractor))); } else { // Else list as normal extractor error $this->extractorErrors[$extractor] = array('name' => $props['name'], 'status' => $props['diagnosis'], 'help' => IndexingHelp::getHelp($extractor), 'affectedtypes' => IndexingHelp::affectedTypes($extractor)); } } } // Create URL to Send to Template $url = KTUtil::kt_url(); // Prepare Template Data $aTemplateData = array('context' => $this, 'serviceErrors' => $this->serviceErrors, 'extractorErrors' => $this->extractorErrors, 'url' => $url); // Send to template and render return $oTemplate->render($aTemplateData); }
function do_main() { //registerTypes registers the mime types and populates the needed tables. $indexer = Indexer::get(); $indexer->registerTypes(); $oTemplating =& KTTemplating::getSingleton(); $oTemplate =& $oTemplating->loadTemplate('ktcore/search2/reporting/rescheduledocuments'); if ($_REQUEST['rescheduleValue'] == 'reschedule') { Indexer::indexAll(); $oTemplate->setData(array('context' => $this, 'rescheduleDone' => true)); return $oTemplate; } $oTemplate->setData(array('context' => $this, 'rescheduleDone' => false)); return $oTemplate; }
function do_main() { //registerTypes registers the mime types and populates the needed tables. $indexer = Indexer::get(); $indexer->registerTypes(); $aPendingDocs = Indexer::getPendingIndexingQueue(); foreach ($aPendingDocs as $key => $doc) { $extractor = $indexer->getExtractor($doc['extractor']); if (is_null($extractor)) { $doc['extractor'] = 'n/a'; continue; } $doc['extractor'] = $extractor->getDisplayName(); $aPendingDocs[$key] = $doc; } $oTemplating =& KTTemplating::getSingleton(); $oTemplate =& $oTemplating->loadTemplate('ktcore/search2/reporting/pendingdocuments'); $config = KTConfig::getSingleton(); $rootUrl = $config->get('KnowledgeTree/rootUrl'); $oTemplate->setData(array('context' => $this, 'pending_docs' => $aPendingDocs, 'root_url' => $rootUrl)); return $oTemplate; }
* You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, * California 94120-7775, or email info@knowledgetree.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices * must display the words "Powered by KnowledgeTree" and retain the original * copyright notice. * Contributor( s): ______________________________________ * */ /** * PURPOSE: * * This script is to be called periodically to index documents. */ chdir(dirname(__FILE__)); require_once realpath('../../../config/dmsDefaults.php'); require_once 'indexing/indexerCore.inc.php'; $indexer = Indexer::get(); $indexer->indexDocuments(); $indexer->updateIndexStats(); exit;
public function getIndexStatistics() { $optimisationDate = KTUtil::getSystemSetting('luceneOptimisationDate', ''); $noOptimisation = false; if ($optimisationDate == '') { $optimisationDate = _kt('N/A'); $optimisationPeriod = $optimisationDate; } else { $optimisationPeriod = KTUtil::computePeriodToDate($optimisationDate, null, true); $noOptimisation = $optimisationPeriod['days'] > 2; $optimisationPeriod = $optimisationPeriod['str']; $optimisationDate = date('Y-m-d H:i:s', $optimisationDate); } $indexingDate = KTUtil::getSystemSetting('luceneIndexingDate', ''); if ($indexingDate == '') { $indexingDate = _kt('N/A'); $indexingPeriod = $indexingDate; } else { $indexingPeriod = KTUtil::computePeriodToDate($indexingDate); $indexingDate = date('Y-m-d H:i:s', $indexingDate); } $index = Indexer::get(); $docsInIndex = $index->getDocumentsInIndex(); // we are only interested in documents that are active $sql = "SELECT count(*) as docsInQueue FROM index_files i inner join documents d on i.document_id = d.id where (i.status_msg is null or i.status_msg = '') and d.status_id=1"; $docsInQueue = DBUtil::getOneResultKey($sql, 'docsInQueue'); $sql = "SELECT count(*) as errorsInQueue FROM index_files i inner join documents d on i.document_id = d.id where (i.status_msg is not null or i.status_msg <> '') and d.status_id=1"; $errorsInQueue = DBUtil::getOneResultKey($sql, 'errorsInQueue'); $sql = "SELECT count(*) as docsInRepository FROM documents where status_id=1"; $docsInRepository = DBUtil::getOneResultKey($sql, 'docsInRepository'); if ($docsInRepository == 0) { $indexingCoverage = '0.00%'; $queueCoverage = $indexingCoverage; } else { // compute indexing coverage $indexingCoverage = _kt('Not Available'); if (is_numeric($docsInIndex)) { $indexingCoverage = $docsInIndex * 100 / $docsInRepository; $indexingCoverage = number_format($indexingCoverage, 2, '.', ',') . '%'; } // compute queue coverage $queueCoverage = _kt('Not Available'); if (is_numeric($docsInQueue)) { $queueCoverage = $docsInQueue * 100 / $docsInRepository; $queueCoverage = number_format($queueCoverage, 2, '.', ',') . '%'; } } $stats = array('optimisationDate' => $optimisationDate, 'optimisationPeriod' => $optimisationPeriod, 'indexingDate' => $indexingDate, 'indexingPeriod' => $indexingPeriod, 'docsInIndex' => $docsInIndex, 'docsInQueue' => $docsInQueue, 'errorsInQueue' => $errorsInQueue, 'docsInRepository' => $docsInRepository, 'indexingCoverage' => $indexingCoverage, 'queueCoverage' => $queueCoverage, 'noOptimisation' => $noOptimisation); return $stats; }
private static function getDirectories() { $config = KTConfig::getSingleton(); $cacheDir = $config->get('cache/cacheDirectory'); $tempDir = $config->get('urls/tmpDirectory'); $logDir = $config->get('urls/logDirectory'); $docsDir = $config->get('urls/documentRoot'); $indexer = Indexer::get(); $luceneDir = $indexer->getIndexDirectory(); $systemDir = OS_UNIX ? '/tmp' : 'c:/windows/temp'; $folders = array(array('name' => _kt('Smarty Cache'), 'folder' => $tempDir, 'pattern' => '^%%.*', 'canClean' => true), array('name' => _kt('System Cache'), 'folder' => $cacheDir, 'pattern' => '', 'canClean' => true), array('name' => _kt('System Logs'), 'folder' => $logDir, 'pattern' => '.+\\.txt$', 'canClean' => true)); $folders[] = array('name' => _kt('Temporary Folder'), 'folder' => $tempDir, 'pattern' => '', 'canClean' => true); $folders[] = array('name' => _kt('System Temporary Folder'), 'folder' => $systemDir, 'pattern' => '(sess_.+)?(.+\\.log$)?', 'canClean' => true); if (is_dir($docsDir)) { $folders[] = array('name' => _kt('Documents'), 'folder' => $docsDir, 'pattern' => '', 'canClean' => false); } if (is_dir($luceneDir)) { $folders[] = array('name' => _kt('Document Index'), 'folder' => $luceneDir, 'pattern' => '', 'canClean' => false); } return $folders; }
/** * Executes a text search query against the Lucene indexer * * @global object $default Default config settings * @param string $op The operation to perform * @param array $group * @return array $results */ private function exec_text_query($op, $group) { global $default; // if the indexer has been disabled, return an empty array if (!$default->enableIndexing) { $default->log->debug("SEARCH LUCENE: indexer has been disabled."); return array(); } if ($this->getContext() != ExprContext::DOCUMENT || empty($group)) { return array(); } $exprbuilder = new TextQueryBuilder(); if (count($group) == 1) { $query = $exprbuilder->buildComplexQuery($group[0]); } else { $query = $exprbuilder->buildSimpleQuery($op, $group); } if (empty($query)) { return array(); } $indexer = Indexer::get(); $indexer->setIncludeStatus($this->incl_status); global $default; $default->log->debug("SEARCH LUCENE: {$query}"); $results = $indexer->query($query); foreach ($results as $item) { $item->Rank = $exprbuilder->getRanking($item); $exprbuilder->setQuery($query); //$item->Text = $exprbuilder->getResultText($item); ?? wipe - done at indexer level } return $results; }
public function extractTextContent() { global $default; $docId = $this->document->getId(); if (empty($this->extension)) { $default->log->info("DocumentId: {$docId} - Document does not have an extension"); Indexer::unqueueDocument($docId, sprintf("Removing document from queue: documentId %d", $docId)); return false; } // Open Office does not support the following files if (in_array($this->extension, array('xlt'))) { $default->log->info("DocumentId: {$docId} - Open Office does not support .xlt."); Indexer::unqueueDocument($docId, sprintf("Removing document from queue - Open Office does not support .xlt: documentId %d", $docId)); return false; } if (false === parent::extractTextContent()) { if (strpos($this->output, 'OpenOffice process not found or not listening') !== false) { $indexer = Indexer::get(); $indexer->restartBatch(); return false; } elseif (strpos($this->output, 'Unexpected connection closure') !== false || strpos($this->output, '\'NoneType\' object has no attribute \'storeToURL\'') !== false || strpos($this->output, 'The document could not be opened for conversion. This could indicate an unsupported mimetype.') !== false || strpos($this->output, 'URL seems to be an unsupported one.') !== false || strpos($this->output, '__main__.com.sun.star.task.ErrorCodeIOException') !== false) { $default->log->info("DocumentId: {$docId} - Suspect the file cannot be indexed by Open Office."); file_put_contents($this->targetfile, ''); $indexer = Indexer::get(); $indexer->restartBatch(); Indexer::unqueueDocument($docId, sprintf(_kt("Removing document from queue: documentId %d"), $docId)); return true; } return false; } if ($this->targetExtension != 'html') { file_put_contents($this->targetfile, ''); return true; } $content = file_get_contents($this->targetfile); $this->setTargetFile($this->targetfile . '.txt'); $content = $this->filter($content); if (empty($content)) { return touch($this->targetfile); } return file_put_contents($this->targetfile, $content); }
function postValidate() { $oDocument =& $this->aInfo["document"]; $oSubscriptionEvent = new SubscriptionEvent(); $oFolder = Folder::get($oDocument->getFolderID()); $oSubscriptionEvent->DiscussDocument($oDocument, $oFolder); $indexer = Indexer::get(); $indexer->index($oDocument, 'D'); }
function do_main() { //Number of items on a page $itemsPerPage = 50; $pageNum = 1; if (isset($_REQUEST['itemsPerPage'])) { $itemsPerPage = $_REQUEST['itemsPerPage']; } //registerTypes registers the mime types and populates the needed tables. $indexer = Indexer::get(); $indexer->registerTypes(); $aPendingDocs = Indexer::getPendingIndexingQueue(); foreach ($aPendingDocs as $key => $doc) { $extractor = $indexer->getExtractor($doc['extractor']); if (is_null($extractor)) { $doc['extractor'] = 'n/a'; continue; } $doc['extractor'] = $extractor->getDisplayName(); $aPendingDocs[$key] = $doc; } $aPendingList = array(); //creating page variables and loading the items for the current page if (!empty($aPendingDocs)) { $items = count($aPendingDocs); if (fmod($items, $itemsPerPage) > 0) { $pages = floor($items / $itemsPerPage) + 1; } else { $pages = $items / $itemsPerPage; } for ($i = 1; $i <= $pages; $i++) { $aPages[] = $i; } if ($items < $itemsPerPage) { $limit = $items - 1; } else { $limit = $itemsPerPage - 1; } if (isset($_REQUEST['pageValue'])) { $pageNum = (int) $_REQUEST['pageValue']; if ($pageNum > $pages) { $pageNum = $pages; } $start = ($pageNum - 1) * $itemsPerPage - 1; $limit = $start + $itemsPerPage; for ($i = $start; $i <= $limit; $i++) { if (isset($aPendingDocs[$i])) { $aPendingList[] = $aPendingDocs[$i]; } } } else { for ($i = 0; $i <= $limit; $i++) { $aPendingList[] = $aPendingDocs[$i]; } } } $oTemplating =& KTTemplating::getSingleton(); $oTemplate =& $oTemplating->loadTemplate('ktcore/search2/reporting/pendingdocuments'); $config = KTConfig::getSingleton(); $rootUrl = $config->get('KnowledgeTree/rootUrl'); $oTemplate->setData(array('context' => $this, 'pageList' => $aPages, 'pageCount' => $pages, 'pageNum' => $pageNum, 'itemCount' => $items, 'itemsPerPage' => $itemsPerPage, 'pending_docs' => $aPendingList, 'root_url' => $rootUrl)); return $oTemplate; }
/** * This updates the system metadata on the document. * * @author KnowledgeTree Team * @access public * @param array $sysdata The system metadata to be applied * @return void|PEAR_Error Returns nothing on success | a PEAR_Error on failure */ function update_sysdata($sysdata) { global $default; if (empty($sysdata)) { return; } $owner_mapping = array('created_by' => 'creator_id', 'modified_by' => 'modified_user_id', 'owner' => 'owner_id'); $documents = array(); $document_content = array(); $indexContent = null; $uniqueOemNo = false; foreach ($sysdata as $rec) { if (is_object($rec)) { $name = $rec->name; $value = sanitizeForSQL($rec->value); } elseif (is_array($rec)) { $name = $rec['name']; $value = sanitizeForSQL($rec['value']); } else { // just ignore continue; } switch (strtolower($name)) { case 'unique_oem_document_no': $documents['oem_no'] = $value; $uniqueOemNo = true; break; case 'oem_document_no': $documents['oem_no'] = $value; break; case 'index_content': $indexContent = $value; break; case 'created_date': if (!empty($value)) { $documents['created'] = $value; } break; case 'modified_date': if (!empty($value)) { $documents['modified'] = $value; } break; case 'is_immutable': $documents['immutable'] = in_array(strtolower($value), array('1', 'true', 'on', 'yes')) ? '1' : '0'; break; case 'filename': $value = KTUtil::replaceInvalidCharacters($value); $document_content['filename'] = $value; break; case 'major_version': $document_content['major_version'] = $value; break; case 'minor_version': $document_content['minor_version'] = $value; break; case 'version': $version = number_format($value + 0, 5); list($major_version, $minor_version) = explode('.', $version); $document_content['major_version'] = $major_version; $document_content['minor_version'] = $minor_version; break; case 'mime_type': $sql = "select id from mime_types where mimetypes='{$value}'"; $value = DBUtil::getResultArray($sql); if (PEAR::isError($value)) { $default->log->error("Problem resolving mime type '{$value}' for document id {$this->documentid}. Reason: " . $value->getMessage()); return $value; } if (count($value) == 0) { $default->log->error("Problem resolving mime type '{$value}' for document id {$this->documentid}. None found."); break; } $value = $value[0]['id']; $document_content['mime_id'] = $value; break; case 'owner': case 'created_by': case 'modified_by': $sql = "select id from users where name='{$value}'"; $userId = DBUtil::getResultArray($sql); if (PEAR::isError($userId)) { $default->log->error("Problem resolving user '{$value}' for document id {$this->documentid}. Reason: " . $userId->getMessage()); return $userId; } if (empty($userId)) { $sql = "select id from users where username='******'"; $userId = DBUtil::getResultArray($sql); if (PEAR::isError($userId)) { $default->log->error("Problem resolving username '{$value}' for document id {$this->documentid}. Reason: " . $userId->getMessage()); return $userId; } } if (empty($userId)) { $default->log->error("Problem resolving user based on '{$value}' for document id {$this->documentid}. No user found"); // if not found, not much we can do break; } $userId = $userId[0]; $userId = $userId['id']; $name = $owner_mapping[$name]; $documents[$name] = $userId; break; default: $default->log->error("Problem updating field '{$name}' with value '{$value}' for document id {$this->documentid}. Field is unknown."); // TODO: we should do some logging //return new PEAR_Error('Unexpected field: ' . $name); } } if (count($documents) > 0) { $sql = "UPDATE documents SET "; $i = 0; foreach ($documents as $name => $value) { if ($i++ > 0) { $sql .= ","; } $value = sanitizeForSQL($value); $sql .= "{$name}='{$value}'"; } $sql .= " WHERE id={$this->documentid}"; $result = DBUtil::runQuery($sql); if (PEAR::isError($result)) { return $result; } if ($uniqueOemNo) { $oem_no = sanitizeForSQL($documents['oem_no']); $sql = "UPDATE documents SET oem_no=null WHERE oem_no = '{$oem_no}' AND id != {$this->documentid}"; $result = DBUtil::runQuery($sql); } } if (count($document_content) > 0) { $content_id = $this->document->getContentVersionId(); $sql = "UPDATE document_content_version SET "; $i = 0; foreach ($document_content as $name => $value) { if ($i++ > 0) { $sql .= ","; } $value = sanitizeForSQL($value); $sql .= "{$name}='{$value}'"; } $sql .= " WHERE id={$content_id}"; $result = DBUtil::runQuery($sql); if (PEAR::isError($result)) { return $result; } } if (!is_null($indexContent)) { $indexer = Indexer::get(); $result = $indexer->diagnose(); if (empty($result)) { $indexer->updateDocumentIndex($this->documentid, $indexContent); } else { $default->log->error("Problem updating index with value '{$value}' for document id {$this->documentid}. Problem with indexer."); } } }
function do_main() { //Number of items on a page $itemsPerPage = 50; $pageNum = 1; if (isset($_REQUEST['itemsPerPage'])) { $itemsPerPage = $_REQUEST['itemsPerPage']; } //registerTypes registers the mime types and populates the needed tables. $indexer = Indexer::get(); $indexer->registerTypes(); switch ($_REQUEST['rescheduleValue']) { case 'reschedule': foreach (KTUtil::arrayGet($_REQUEST, 'index_error', array()) as $sDocId => $v) { Indexer::reindexDocument($sDocId); } break; case 'remove': foreach (KTUtil::arrayGet($_REQUEST, 'index_error', array()) as $sDocId => $v) { Indexer::unqueueDocument($sDocId, 'Document removed from queue via admin interface. Normally this is because an indexer is not able to process the document.'); } break; case 'rescheduleall': $aIndexerValues = Indexer::getIndexingQueue(); foreach ($aIndexerValues as $sDocValues) { Indexer::reindexDocument($sDocValues['document_id']); } break; case 'removeall': $aIndexerValues = Indexer::getIndexingQueue(); foreach ($aIndexerValues as $sDocValues) { Indexer::unqueueDocument($sDocValues['document_id'], 'Document removed from queue via admin interface. Normally this is because an indexer is not able to process the document.'); } break; } $oTemplating =& KTTemplating::getSingleton(); $oTemplate =& $oTemplating->loadTemplate('ktcore/search2/reporting/indexerrors'); $aIndexerValues = Indexer::getIndexingQueue(); foreach ($aIndexerValues as $key => $doc) { $extractor = $indexer->getExtractor($doc['extractor']); if (is_null($extractor)) { $doc['extractor'] = 'n/a'; continue; } $doc['extractor'] = $extractor->getDisplayName(); $aIndexerValues[$key] = $doc; } $aIndexList = array(); //creating page variables and loading the items for the current page if (!empty($aIndexerValues)) { $items = count($aIndexerValues); if (fmod($items, $itemsPerPage) > 0) { $pages = floor($items / $itemsPerPage) + 1; } else { $pages = $items / $itemsPerPage; } for ($i = 1; $i <= $pages; $i++) { $aPages[] = $i; } if ($items < $itemsPerPage) { $limit = $items - 1; } else { $limit = $itemsPerPage - 1; } if (isset($_REQUEST['pageValue'])) { $pageNum = (int) $_REQUEST['pageValue']; if ($pageNum > $pages) { $pageNum = $pages; } $start = ($pageNum - 1) * $itemsPerPage - 1; $limit = $start + $itemsPerPage; for ($i = $start; $i <= $limit; $i++) { if (isset($aIndexerValues[$i])) { $aIndexList[] = $aIndexerValues[$i]; } } } else { for ($i = 0; $i <= $limit; $i++) { $aIndexList[] = $aIndexerValues[$i]; } } } $config = KTConfig::getSingleton(); $rootUrl = $config->get('KnowledgeTree/rootUrl'); $oTemplate->setData(array('context' => $this, 'pageList' => $aPages, 'pageCount' => $pages, 'pageNum' => $pageNum, 'itemCount' => $items, 'itemsPerPage' => $itemsPerPage, 'indexErrors' => $aIndexList, 'root_url' => $rootUrl)); return $oTemplate; }
/** * Remove the documents (already marked as deleted) from the * storage. */ function expunge(&$oDocument) { $documentid = $oDocument->getId(); $indexer = Indexer::get(); $indexer->deleteDocument($documentid); }
function addNewDocument($title, $filename, $i, $content = null) { $file = $this->createFile($filename, $content); $document = $this->root->add_document($title, $filename, 'Default', $file); $this->indexer = Indexer::get(); $this->docId[$i] = $document->get_documentid(); $version = '0.1'; $file = $this->createFile($filename, $content); // ktapi add_document deletes the temp file so recreate it for indexing. $status = $this->indexer->indexDocument($this->docId[$i], $file, $title, $version); @unlink($file); if (PEAR::isError($document)) { return; } $this->doc[$i] = $document; }
function do_refreshLuceneStats() { $indexer = Indexer::get(); $indexer->updateIndexStats(); redirect(KTUtil::kt_url() . '/dashboard.php'); }