当前位置: 首页>>代码示例>>PHP>>正文


PHP SearchEngine类代码示例

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


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


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