• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP SearchEngine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中SearchEngine的典型用法代码示例。如果您正苦于以下问题:PHP SearchEngine类的具体用法?PHP SearchEngine怎么用?PHP SearchEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SearchEngine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: Fire

 public function Fire()
 {
     if ($this->input->do == 'submit') {
         $bug = new Bug($this->input->bug_id);
         try {
             $bug->FetchInto();
         } catch (phalanx\data\ModelException $e) {
             EventPump::Pump()->RaiseEvent(new StandardErrorEvent(l10n::S('BUG_ID_NOT_FOUND')));
             return;
         }
         $body = trim($this->input->body);
         if (empty($body)) {
             EventPump::Pump()->RaiseEvent(new StandardErrorEvent(l10n::S('COMMENT_MISSING_BODY')));
             return;
         }
         $comment = new Comment();
         $comment->bug_id = $bug_id;
         $comment->post_user_id = Bugdar::$auth->current_user();
         $comment->post_date = time();
         $comment->body = $body;
         $comment->Insert();
         $this->comment_id = $comment->comment_id;
         $search = new SearchEngine();
         $search->IndexBug($bug);
         EventPump::Pump()->PostEvent(new StandardSuccessEvent('view_bug/' . $bug_id, l10n::S('USER_REGISTER_SUCCESS')));
     }
 }
开发者ID:rsesek,项目名称:Bugdar2,代码行数:27,代码来源:comment_new.php


示例2: isBookingStillAvailable

 public function isBookingStillAvailable()
 {
     $searchEngine = new SearchEngine($this->searchCriteria);
     $availableRooms = $searchEngine->runSearchForRoom($this->room->id);
     if ($availableRooms == null) {
         $this->errors = $searchEngine->errors;
         return false;
     }
     $roomCount = sizeof($availableRooms);
     return $roomCount > 0;
 }
开发者ID:earthtravels,项目名称:maxtena,代码行数:11,代码来源:BookingDetails.class.php


示例3: perform

 function perform()
 {
     // get the search terms that have already been validated...
     $this->_searchTerms = $this->_request->getValue("searchTerms");
     // check if the search feature is disabled in this site...
     $config =& Config::getConfig();
     if (!$config->getValue("search_engine_enabled")) {
         $this->_view = new ErrorView($this->_blogInfo, "error_search_engine_disabled");
         $this->setCommonData();
         return false;
     }
     // create the view and make sure that it hasn't been cached
     $this->_view = new BlogTemplatedView($this->_blogInfo, VIEW_SEARCH_TEMPLATE, array("searchTerms" => $this->_searchTerms));
     if ($this->_view->isCached()) {
         return true;
     }
     $searchEngine = new SearchEngine();
     $searchResults = $searchEngine->search($this->_blogInfo->getId(), $this->_searchTerms);
     // MARKWU: I add the searchterms variable for smarty/plog template
     $searchTerms = $searchEngine->getAdaptSearchTerms($this->_searchTerms);
     // if no search results, return an error message
     if (count($searchResults) == 0) {
         $this->_view = new ErrorView($this->_blogInfo, "error_no_search_results");
         $this->setCommonData();
         return true;
     }
     // if only one search result, we can see it straight away
     if (count($searchResults) == 1) {
         // we have to refill the $_REQUEST array, since the next action
         // is going to need some of the parameters
         $request =& HttpVars::getRequest();
         $searchResult = array_pop($searchResults);
         $article = $searchResult->getArticle();
         $request["articleId"] = $article->getId();
         $request["blogId"] = $this->_blogInfo->getId();
         HttpVars::setRequest($request);
         // since there is only one article, we can use the ViewArticleAction action
         // to display that article, instead of copy-pasting the code and doing it here.
         // You just have to love MVC and OOP :)
         return Controller::setForwardAction("ViewArticle");
     }
     // or else, show a list with all the posts that match the requested
     // search terms
     $this->_view->setValue("searchresults", $searchResults);
     // MARKWU: Now, I can use the searchterms to get the keyword
     $this->_view->setValue("searchterms", $searchTerms);
     // MARKWU:
     $config =& Config::getConfig();
     $urlmode = $config->getValue("request_format_mode");
     $this->_view->setValue("urlmode", $urlmode);
     $this->setCommonData();
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:53,代码来源:searchaction.class.php


示例4: testSearchWithOffset

 /**
  * @dataProvider provideSearch
  * @covers SearchEngine::defaultPrefixSearch
  */
 public function testSearchWithOffset(array $case)
 {
     $this->search->setLimitOffset(3, 1);
     $results = $this->search->defaultPrefixSearch($case['query']);
     $results = array_map(function (Title $t) {
         return $t->getPrefixedText();
     }, $results);
     // We don't expect the first result when offsetting
     array_shift($case['results']);
     // And sometimes we expect a different last result
     $expected = isset($case['offsetresult']) ? array_merge($case['results'], $case['offsetresult']) : $case['results'];
     $this->assertEquals($expected, $results, $case[0]);
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:17,代码来源:SearchEnginePrefixTest.php


示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $style = new OutputFormatterStyle('red', 'yellow', array('bold', 'blink'));
     $output->getFormatter()->setStyle('fire', $style);
     $style = new OutputFormatterStyle('green', 'default', array('bold'));
     $output->getFormatter()->setStyle('start', $style);
     $style = new OutputFormatterStyle('black', 'default', array('bold'));
     $output->getFormatter()->setStyle('end', $style);
     $searchEngine = new SearchEngine($this->getContainer()->get('doctrine')->getManager(), array());
     $output->writeln('<fire>Clearing existing index</fire>');
     $searchEngine->clearIndex();
     $output->writeln('<start>Indexing started</start>');
     $searchEngine->index();
     $output->writeln('<end>Index generated successfully</end>');
 }
开发者ID:beecms,项目名称:search-bundle,代码行数:15,代码来源:SearchIndexCommand.php


示例6: goResult

 public function goResult($term)
 {
     global $wgOut;
     # Try to go to page as entered.
     $t = Title::newFromText($term);
     # If the string cannot be used to create a title
     if (is_null($t)) {
         return $this->showResults($term);
     }
     # If there's an exact or very near match, jump right there.
     $t = SearchEngine::getNearMatch($term);
     if (!is_null($t)) {
         $wgOut->redirect($t->getFullURL());
         return;
     }
     # No match, generate an edit URL
     $t = Title::newFromText($term);
     if (!is_null($t)) {
         global $wgGoToEdit;
         wfRunHooks('SpecialSearchNogomatch', array(&$t));
         # If the feature is enabled, go straight to the edit page
         if ($wgGoToEdit) {
             $wgOut->redirect($t->getFullURL(array('action' => 'edit')));
             return;
         }
     }
 }
开发者ID:rodrigo-castillo,项目名称:cse,代码行数:27,代码来源:Specialcse.php


示例7: provideSearchOptionsTests

 function provideSearchOptionsTests()
 {
     $defaultNS = SearchEngine::defaultNamespaces();
     $EMPTY_REQUEST = array();
     $NO_USER_PREF = null;
     return array(array($EMPTY_REQUEST, $NO_USER_PREF, 'default', $defaultNS, 'Bug 33270: No request nor user preferences should give default profile'), array(array('ns5' => 1), $NO_USER_PREF, 'advanced', array(5), 'Web request with specific NS should override user preference'), array($EMPTY_REQUEST, array('searchNs2' => 1, 'searchNs14' => 1), 'advanced', array(2, 14), 'Bug 33583: search with no option should honor User search preferences'));
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:7,代码来源:SpecialSearchTest.php


示例8: getConfig

 /**
  * @param $context ResourceLoaderContext
  * @return array
  */
 protected function getConfig($context)
 {
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgDefaultDateFormat' => $wgContLang->getDefaultDateFormat(), 'wgMonthNames' => $wgContLang->getMonthNamesArray(), 'wgMonthNamesShort' => $wgContLang->getMonthAbbreviationsArray(), 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values($wgFileExtensions), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgSassParams' => SassUtil::getSassSettings());
     if ($wgUseAjax && $wgEnableMWSuggest) {
         $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
     }
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     return $vars;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:29,代码来源:ResourceLoaderStartUpModule.php


示例9: getSearchEngine

 static function getSearchEngine()
 {
     if (!self::$searchEngine) {
         self::$searchEngine = SearchEngine::create();
     }
     return self::$searchEngine;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:7,代码来源:AdvancedSearchCategoryIntersector.php


示例10: parseQuery

 function parseQuery($filteredText, $fulltext)
 {
     global $wgContLang;
     $lc = SearchEngine::legalSearchChars();
     $searchon = '';
     $this->searchTerms = array();
     # FIXME: This doesn't handle parenthetical expressions.
     if (preg_match_all('/([-+<>~]?)(([' . $lc . ']+)(\\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER)) {
         foreach ($m as $terms) {
             if ($searchon !== '') {
                 $searchon .= ' ';
             }
             if ($this->strictMatching && $terms[1] == '') {
                 $terms[1] = '+';
             }
             $searchon .= $terms[1] . $wgContLang->stripForSearch($terms[2]);
             if (!empty($terms[3])) {
                 $regexp = preg_quote($terms[3], '/');
                 if ($terms[4]) {
                     $regexp .= "[0-9A-Za-z_]+";
                 }
             } else {
                 $regexp = preg_quote(str_replace('"', '', $terms[2]), '/');
             }
             $this->searchTerms[] = $regexp;
         }
         wfDebug("Would search with '{$searchon}'\n");
         wfDebug("Match with /\\b" . implode('\\b|\\b', $this->searchTerms) . "\\b/\n");
     } else {
         wfDebug("Can't understand search query '{$this->filteredText}'\n");
     }
     $searchon = preg_replace('/(\\s+)/', '&', $searchon);
     $searchon = $this->db->strencode($searchon);
     return $searchon;
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:35,代码来源:SearchTsearch2.php


示例11: execute

 public function execute($parameters)
 {
     global $wgOut, $wgRequest, $wgDisableTextSearch, $wgScript;
     $this->setHeaders();
     list($limit, $offset) = wfCheckLimits();
     $wgOut->addWikiText(wfMsgForContentNoTrans('proofreadpage_specialpage_text'));
     $this->searchList = null;
     $this->searchTerm = $wgRequest->getText('key');
     $this->suppressSqlOffset = false;
     if (!$wgDisableTextSearch) {
         $self = $this->getTitle();
         $wgOut->addHTML(Xml::openElement('form', array('action' => $wgScript)) . Html::hidden('title', $this->getTitle()->getPrefixedText()) . Xml::input('limit', false, $limit, array('type' => 'hidden')) . Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('proofreadpage_specialpage_legend')) . Xml::input('key', 20, $this->searchTerm) . ' ' . Xml::submitButton(wfMsg('ilsubmit')) . Xml::closeElement('fieldset') . Xml::closeElement('form'));
         if ($this->searchTerm) {
             $index_namespace = $this->index_namespace;
             $index_ns_index = MWNamespace::getCanonicalIndex(strtolower(str_replace(' ', '_', $index_namespace)));
             $searchEngine = SearchEngine::create();
             $searchEngine->setLimitOffset($limit, $offset);
             $searchEngine->setNamespaces(array($index_ns_index));
             $searchEngine->showRedirects = false;
             $textMatches = $searchEngine->searchText($this->searchTerm);
             $escIndex = preg_quote($index_namespace, '/');
             $this->searchList = array();
             while ($result = $textMatches->next()) {
                 $title = $result->getTitle();
                 if ($title->getNamespace() == $index_ns_index) {
                     array_push($this->searchList, $title->getDBkey());
                 }
             }
             $this->suppressSqlOffset = true;
         }
     }
     parent::execute($parameters);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:33,代码来源:SpecialProofreadPages.php


示例12: logHttpReferer

 public static function logHttpReferer()
 {
     global $cookie;
     if (!isset($cookie->id_connections) or !Validate::isUnsignedId($cookie->id_connections)) {
         return false;
     }
     if (!isset($_SERVER['HTTP_REFERER']) and !Configuration::get('TRACKING_DIRECT_TRAFFIC')) {
         return false;
     }
     $source = new ConnectionsSource();
     if (isset($_SERVER['HTTP_REFERER']) and Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER'])) {
         if (preg_replace('/^www./', '', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)) and !strncmp(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH), parse_url('http://' . Tools::getHttpHost(false, false) . __PS_BASE_URI__, PHP_URL_PATH), strlen(__PS_BASE_URI__))) {
             return false;
         }
         if (Validate::isAbsoluteUrl(strval($_SERVER['HTTP_REFERER']))) {
             $source->http_referer = strval($_SERVER['HTTP_REFERER']);
             $source->keywords = trim(SearchEngine::getKeywords(strval($_SERVER['HTTP_REFERER'])));
             if (!Validate::isMessage($source->keywords)) {
                 return false;
             }
         }
     }
     $source->id_connections = intval($cookie->id_connections);
     $source->request_uri = Tools::getHttpHost(false, false);
     if (isset($_SERVER['REDIRECT_URL'])) {
         $source->request_uri .= strval($_SERVER['REDIRECT_URL']);
     } elseif (isset($_SERVER['REQUEST_URI'])) {
         $source->request_uri .= strval($_SERVER['REQUEST_URI']);
     }
     if (!Validate::isUrl($source->request_uri)) {
         unset($source->request_uri);
     }
     return $source->add();
 }
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:34,代码来源:ConnectionsSource.php


示例13: perform

 /**
  * carry out the search and execute it
  */
 function perform()
 {
     $search = new SearchEngine();
     // execute the search and check if there is any result
     $results = $search->siteSearch($this->_searchTerms);
     if (!$results || empty($results)) {
         // if not, then quit
         $this->_view = new SummaryView("summaryerror");
         $this->_view->setErrorMessage($this->_locale->tr("error_no_search_results"));
         return false;
     }
     // but if so, then continue...
     $this->_view = new SummaryView("searchresults");
     $this->_view->setValue("searchresults", $results);
     $this->setCommonData();
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:20,代码来源:summarysearchaction.class.php


示例14: efOpenSearchXmlTemplate

/**
 * @return string
 */
function efOpenSearchXmlTemplate() {
	global $wgCanonicalServer, $wgScriptPath;
	$ns = implode( '|', SearchEngine::defaultNamespaces() );
	if( !$ns ) {
		$ns = '0';
	}
	return $wgCanonicalServer . $wgScriptPath . '/api.php?action=opensearch&format=xml&search={searchTerms}&namespace=' . $ns;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:11,代码来源:OpenSearchXml.php


示例15: getFieldsForSearchIndex

 public function getFieldsForSearchIndex(SearchEngine $engine)
 {
     $fields['file_media_type'] = $engine->makeSearchFieldMapping('file_media_type', SearchIndexField::INDEX_TYPE_KEYWORD);
     $fields['file_media_type']->setFlag(SearchIndexField::FLAG_CASEFOLD);
     $fields['file_mime'] = $engine->makeSearchFieldMapping('file_mime', SearchIndexField::INDEX_TYPE_SHORT_TEXT);
     $fields['file_mime']->setFlag(SearchIndexField::FLAG_CASEFOLD);
     $fields['file_size'] = $engine->makeSearchFieldMapping('file_size', SearchIndexField::INDEX_TYPE_INTEGER);
     $fields['file_width'] = $engine->makeSearchFieldMapping('file_width', SearchIndexField::INDEX_TYPE_INTEGER);
     $fields['file_height'] = $engine->makeSearchFieldMapping('file_height', SearchIndexField::INDEX_TYPE_INTEGER);
     $fields['file_bits'] = $engine->makeSearchFieldMapping('file_bits', SearchIndexField::INDEX_TYPE_INTEGER);
     $fields['file_resolution'] = $engine->makeSearchFieldMapping('file_resolution', SearchIndexField::INDEX_TYPE_INTEGER);
     $fields['file_text'] = $engine->makeSearchFieldMapping('file_text', SearchIndexField::INDEX_TYPE_TEXT);
     return $fields;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:14,代码来源:FileContentHandler.php


示例16: provideSearchOptionsTests

 public static function provideSearchOptionsTests()
 {
     $defaultNS = SearchEngine::defaultNamespaces();
     $EMPTY_REQUEST = array();
     $NO_USER_PREF = null;
     return array(array($EMPTY_REQUEST, $NO_USER_PREF, 'default', $defaultNS, 'Bug 33270: No request nor user preferences should give default profile'), array(array('ns5' => 1), $NO_USER_PREF, 'advanced', array(5), 'Web request with specific NS should override user preference'), array($EMPTY_REQUEST, array('searchNs2' => 1, 'searchNs14' => 1) + array_fill_keys(array_map(function ($ns) {
         return "searchNs{$ns}";
     }, $defaultNS), 0), 'advanced', array(2, 14), 'Bug 33583: search with no option should honor User search preferences' . ' and have all other namespace disabled'));
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:9,代码来源:SpecialSearchTest.php


示例17: DoCheck

 public function DoCheck()
 {
     AssetLoadManager::register('tableList');
     // Search engine
     $vo_search_config_settings = SearchEngine::checkPluginConfiguration();
     $this->view->setVar('search_config_settings', $vo_search_config_settings);
     $this->view->setVar('search_config_engine_name', SearchEngine::getPluginEngineName());
     // Media
     $t_media = new Media();
     $va_plugin_names = $t_media->getPluginNames();
     $va_plugins = array();
     foreach ($va_plugin_names as $vs_plugin_name) {
         if ($va_plugin_status = $t_media->checkPluginStatus($vs_plugin_name)) {
             $va_plugins[$vs_plugin_name] = $va_plugin_status;
         }
     }
     $this->view->setVar('media_config_plugin_list', $va_plugins);
     // PDF Rendering
     $t_pdf_renderer = new PDFRenderer();
     $va_plugin_names = PDFRenderer::getAvailablePDFRendererPlugins();
     $va_plugins = array();
     foreach ($va_plugin_names as $vs_plugin_name) {
         if ($va_plugin_status = $t_pdf_renderer->checkPluginStatus($vs_plugin_name)) {
             $va_plugins[$vs_plugin_name] = $va_plugin_status;
         }
     }
     $this->view->setVar('pdf_renderer_config_plugin_list', $va_plugins);
     // Application plugins
     $va_plugin_names = ApplicationPluginManager::getPluginNames();
     $va_plugins = array();
     foreach ($va_plugin_names as $vs_plugin_name) {
         if ($va_plugin_status = ApplicationPluginManager::checkPluginStatus($vs_plugin_name)) {
             $va_plugins[$vs_plugin_name] = $va_plugin_status;
         }
     }
     $this->view->setVar('application_config_plugin_list', $va_plugins);
     // Barcode generation
     $vb_gd_is_available = caMediaPluginGDInstalled(true);
     $va_barcode_components = array();
     $va_gd = array('name' => 'GD', 'description' => _t('GD is a graphics processing library required for all barcode generation.'));
     if (!$vb_gd_is_available) {
         $va_gd['errors'][] = _t('Is not installed; barcode printing will not be possible.');
     }
     $va_gd['available'] = $vb_gd_is_available;
     $va_barcode_components['GD'] = $va_gd;
     $this->view->setVar('barcode_config_component_list', $va_barcode_components);
     // General system configuration issues
     if (!(bool) $this->request->config->get('dont_do_expensive_configuration_checks_in_web_ui')) {
         ConfigurationCheck::performExpensive();
         if (ConfigurationCheck::foundErrors()) {
             $this->view->setVar('configuration_check_errors', ConfigurationCheck::getErrors());
         }
     }
     $this->render('config_check_html.php');
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:55,代码来源:ConfigurationCheckController.php


示例18: onResourceLoaderGetConfigVarsWithContext

 public static function onResourceLoaderGetConfigVarsWithContext(&$vars, $context)
 {
     global $wgUseAjax;
     $skin = $context->getSkin();
     if ($skin == 'monobook' || $skin == 'uncyclopedia') {
         if (!empty($wgUseAjax)) {
             $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
         }
     }
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:GlobalNavigationHooks.class.php


示例19: efGoToCategory_SpecialSearchNogomatch

function efGoToCategory_SpecialSearchNogomatch($t)
{
    global $wgOut, $wgRequest;
    $term = $wgRequest->getText('search');
    if (!empty($term) && strpos('category:', strtolower($term)) !== 0) {
        $term = "Category:{$term}";
    }
    $title = SearchEngine::getNearMatch($term);
    if (!is_null($title)) {
        $wgOut->redirect($title->getFullURL());
    }
    return true;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:13,代码来源:GoToCategory.php


示例20: run

 /**
  * @param ApiPageSet $resultPageSet
  */
 private function run($resultPageSet = null)
 {
     $params = $this->extractRequestParams();
     $search = $params['search'];
     $limit = $params['limit'];
     $namespaces = $params['namespace'];
     $offset = $params['offset'];
     $searchEngine = SearchEngine::create();
     $searchEngine->setLimitOffset($limit + 1, $offset);
     $searchEngine->setNamespaces($namespaces);
     $titles = $searchEngine->extractTitles($searchEngine->completionSearchWithVariants($search));
     if ($resultPageSet) {
         $resultPageSet->setRedirectMergePolicy(function (array $current, array $new) {
             if (!isset($current['index']) || $new['index'] < $current['index']) {
                 $current['index'] = $new['index'];
             }
             return $current;
         });
         if (count($titles) > $limit) {
             $this->setContinueEnumParameter('offset', $offset + $params['limit']);
             array_pop($titles);
         }
         $resultPageSet->populateFromTitles($titles);
         foreach ($titles as $index => $title) {
             $resultPageSet->setGeneratorData($title, array('index' => $index + $offset + 1));
         }
     } else {
         $result = $this->getResult();
         $count = 0;
         foreach ($titles as $title) {
             if (++$count > $limit) {
                 $this->setContinueEnumParameter('offset', $offset + $params['limit']);
                 break;
             }
             $vals = array('ns' => intval($title->getNamespace()), 'title' => $title->getPrefixedText());
             if ($title->isSpecialPage()) {
                 $vals['special'] = true;
             } else {
                 $vals['pageid'] = intval($title->getArticleId());
             }
             $fit = $result->addValue(array('query', $this->getModuleName()), null, $vals);
             if (!$fit) {
                 $this->setContinueEnumParameter('offset', $offset + $count - 1);
                 break;
             }
         }
         $result->addIndexedTagName(array('query', $this->getModuleName()), $this->getModulePrefix());
     }
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:52,代码来源:ApiQueryPrefixSearch.php



注:本文中的SearchEngine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP SearchForm类代码示例发布时间:2022-05-23
下一篇:
PHP Search类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap