本文整理汇总了PHP中Indexer::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Indexer::get方法的具体用法?PHP Indexer::get怎么用?PHP Indexer::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Indexer
的用法示例。
在下文中一共展示了Indexer::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
function setup()
{
//Indexer::checkForRegisteredTypes();
$this->indexer = Indexer::get();
$this->path = KT_DIR . '/tests/documentProcessor/dataset/';
$this->tempPath = KT_DIR . '/var/tmp';
}
示例2: do_main
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;
}
示例3: do_main
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;
}
示例4: checkLucene
function checkLucene()
{
$indexer = Indexer::get();
$diagnose = $indexer->diagnose();
if (!is_null($diagnose)) {
$this->addIssue('Document Indexer', $diagnose);
}
}
示例5: do_main
/**
* 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);
}
示例6: __construct
/**
* 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();
}
示例7: setup
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';
}
示例8: do_main
/**
* 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);
}
示例9: do_main
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;
}
示例10: do_main
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;
}
示例11: chdir
* 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;
示例12: getIndexStatistics
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;
}
示例13: getDirectories
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;
}
示例14: exec_text_query
/**
* 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;
}
示例15: extractTextContent
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);
}