本文整理汇总了PHP中Indexer类的典型用法代码示例。如果您正苦于以下问题:PHP Indexer类的具体用法?PHP Indexer怎么用?PHP Indexer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Indexer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIndex
public function testIndex()
{
$account = Account::login("searchzen.org", "test");
$c = $account->collections[0];
$indexer = new Indexer($c);
$indexer->start();
}
示例2: usage
function usage($message = null)
{
if ($message != null) {
echo "\n*** {$message} ***\n";
}
echo "\nUsage: php makeindex.php [-options] [<csv filename>]";
echo "\n\nwhere options include:";
echo "\n\n";
echo "-h\t\tprint this information\n";
echo "-f\t\tforce indexation\n";
$indexer = new Indexer();
echo "-d <dir>\tindex data files in directory <dir> (defaults to " . $indexer->get_data_root() . ")\n";
echo "\n";
echo "If <csv filename> is present, index only that file; otherwise index all csv files newer than main index.\n\n";
}
示例3: 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;
}
示例4: setup
function setup()
{
//Indexer::checkForRegisteredTypes();
$this->indexer = Indexer::get();
$this->path = KT_DIR . '/tests/documentProcessor/dataset/';
$this->tempPath = KT_DIR . '/var/tmp';
}
示例5: instance
public static function instance()
{
if (self::$instance == null) {
self::$instance = new Indexer();
}
return self::$instance;
}
示例6: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$watches = array();
$in = inotify_init();
// add watches starting from root directory
$root = Path::fromRelative('');
$this->addWatches($in, $root, $watches);
printf("\nReading for events\n");
while (true) {
$events = inotify_read($in);
foreach ($events as $event) {
$path = $watches[$event['wd']];
$expanded = $this->expandMask($event['mask']);
$eventName = trim(implode(', ', $expanded), ', ');
// if the event has a name attached, then index that
if ($event['name']) {
$newPathName = $path->getPathname() . '/' . $event['name'];
$newPath = new Path($newPathName);
Indexer::index($newPath, 1);
// this may be a new directory, so add a watch to it anyway
if ($newPath->exists() && $newPath->isDir()) {
try {
$wd = inotify_add_watch($in, $newPath->getPathname(), $this->computedMask);
$watches[$wd] = $newPath;
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
}
} else {
// event must apply to this directory, so index it, 1 level deep
Indexer::index($path, 1);
}
}
}
}
示例7: 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;
}
示例8: _query
/**
* @internal
**/
public static function _query($args, $pageIndex, $size, $sortByDate = false)
{
$query = new \Elastica\Query($args);
$query->setFrom($pageIndex * $size);
$query->setSize($size);
$query->setFields(array('id'));
Config::apply_filters('searcher_query', $query);
try {
$index = Indexer::_index(false);
$search = new \Elastica\Search($index->getClient());
$search->addIndex($index);
if (!$query->hasParam('sort')) {
if ($sortByDate) {
$query->addSort(array('post_date' => 'desc'));
} else {
$query->addSort('_score');
}
}
Config::apply_filters('searcher_search', $search, $query);
$results = $search->search($query);
return self::_parseResults($results);
} catch (\Exception $ex) {
error_log($ex);
return null;
}
}
示例9: process_actions
/**
* @brief Process resource actions
* @global type $tool_content
* @global type $id
* @global type $langResourceCourseUnitDeleted
* @global type $langResourceUnitModified
* @global type $course_id
* @global type $course_code
* @return string
*/
function process_actions()
{
global $tool_content, $id, $langResourceCourseUnitDeleted, $langResourceUnitModified, $course_id, $course_code, $webDir;
// update index and refresh course metadata
require_once 'modules/search/indexer.class.php';
require_once 'modules/course_metadata/CourseXML.php';
if (isset($_REQUEST['edit'])) {
$res_id = intval($_GET['edit']);
if ($id = check_admin_unit_resource($res_id)) {
return edit_res($res_id);
}
} elseif (isset($_REQUEST['edit_res_submit'])) {
// edit resource
$res_id = intval($_REQUEST['resource_id']);
if ($id = check_admin_unit_resource($res_id)) {
@($restitle = $_REQUEST['restitle']);
$rescomments = purify($_REQUEST['rescomments']);
$result = Database::get()->query("UPDATE course_weekly_view_activities SET\n title = ?s,\n comments = ?s\n WHERE course_weekly_view_id = ?d AND id = ?d", $restitle, $rescomments, $id, $res_id);
Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_UNITRESOURCE, $res_id);
Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_COURSE, $course_id);
CourseXMLElement::refreshCourse($course_id, $course_code);
}
$tool_content .= "<div class='alert alert-success'>{$langResourceUnitModified}</div>";
} elseif (isset($_REQUEST['del'])) {
// delete resource from course unit
$res_id = intval($_GET['del']);
if ($id = check_admin_unit_resource($res_id)) {
Database::get()->query("DELETE FROM course_weekly_view_activities WHERE id = ?d", $res_id);
Indexer::queueAsync(Indexer::REQUEST_REMOVE, Indexer::RESOURCE_UNITRESOURCE, $res_id);
Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_COURSE, $course_id);
CourseXMLElement::refreshCourse($course_id, $course_code);
$tool_content .= "<div class='alert alert-success'>{$langResourceCourseUnitDeleted}</div>";
}
} elseif (isset($_REQUEST['vis'])) {
// modify visibility in text resources only
$res_id = intval($_REQUEST['vis']);
if ($id = check_admin_unit_resource($res_id)) {
$vis = Database::get()->querySingle("SELECT `visible` FROM course_weekly_view_activities WHERE id = ?d", $res_id)->visible;
$newvis = $vis == 1 ? 0 : 1;
Database::get()->query("UPDATE course_weekly_view_activities SET visible = '{$newvis}' WHERE id = ?d", $res_id);
Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_UNITRESOURCE, $res_id);
Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_COURSE, $course_id);
CourseXMLElement::refreshCourse($course_id, $course_code);
}
} elseif (isset($_REQUEST['down'])) {
// change order down
$res_id = intval($_REQUEST['down']);
if ($id = check_admin_unit_resource($res_id)) {
move_order('course_weekly_view_activities', 'id', $res_id, 'order', 'down', "course_weekly_view_id={$id}");
}
} elseif (isset($_REQUEST['up'])) {
// change order up
$res_id = intval($_REQUEST['up']);
if ($id = check_admin_unit_resource($res_id)) {
move_order('course_weekly_view_activities', 'id', $res_id, 'order', 'up', "course_weekly_view_id={$id}");
}
}
return '';
}
示例10: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$basePath = Config::get('app.manga_path');
$path = new Path($basePath);
$count = 0;
Indexer::index($path, null, $count);
$this->info(sprintf('Added %s new paths', $count));
}
示例11: checkLucene
function checkLucene()
{
$indexer = Indexer::get();
$diagnose = $indexer->diagnose();
if (!is_null($diagnose)) {
$this->addIssue('Document Indexer', $diagnose);
}
}
示例12: 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);
}
示例13: reindex
function reindex()
{
try {
echo Indexer::reindex($_POST['page']);
} catch (\Exception $ex) {
header("HTTP/1.0 500 Internal Server Error");
echo $ex->getMessage();
}
die;
}
示例14: 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';
}
示例15: delete_post
function delete_post($post_id)
{
if (is_object($post_id)) {
$post = $post_id;
} else {
$post = get_post($post_id);
}
if ($post == null || !in_array($post->post_type, Config::types())) {
return;
}
Indexer::delete($post);
}