/** * Perform actual update for the entry */ public function doUpdate() { global $wgDisableSearchUpdate; if ($wgDisableSearchUpdate || !$this->id) { return; } wfProfileIn(__METHOD__); $page = WikiPage::newFromId($this->id, WikiPage::READ_LATEST); $indexTitle = Title::indexTitle($this->title->getNamespace(), $this->title->getText()); foreach (SearchEngine::getSearchTypes() as $type) { $search = SearchEngine::create($type); if (!$search->supports('search-update')) { continue; } $normalTitle = $search->normalizeText($indexTitle); if ($page === null) { $search->delete($this->id, $normalTitle); continue; } elseif ($this->content === false) { $search->updateTitle($this->id, $normalTitle); continue; } $text = $search->getTextFromContent($this->title, $this->content); if (!$search->textAlreadyUpdatedForIndex()) { $text = self::updateText($text); } # Perform the actual update $search->update($this->id, $normalTitle, $search->normalizeText($text)); } wfProfileOut(__METHOD__); }
/** * Perform actual update for the entry */ public function doUpdate() { global $wgDisableSearchUpdate; if ($wgDisableSearchUpdate || !$this->id) { return; } foreach (SearchEngine::getSearchTypes() as $type) { $search = SearchEngine::create($type); if (!$search->supports('search-update')) { continue; } $normalTitle = $this->getNormalizedTitle($search); if ($this->getLatestPage() === null) { $search->delete($this->id, $normalTitle); continue; } elseif ($this->content === false) { $search->updateTitle($this->id, $normalTitle); continue; } $text = $search->getTextFromContent($this->title, $this->content); if (!$search->textAlreadyUpdatedForIndex()) { $text = self::updateText($text); } # Perform the actual update $search->update($this->id, $normalTitle, $search->normalizeText($text)); } }
public function getAllowedParams() { $params = array('search' => array(ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true), 'namespace' => array(ApiBase::PARAM_DFLT => NS_MAIN, ApiBase::PARAM_TYPE => 'namespace', ApiBase::PARAM_ISMULTI => true), 'what' => array(ApiBase::PARAM_DFLT => null, ApiBase::PARAM_TYPE => array('title', 'text', 'nearmatch')), 'info' => array(ApiBase::PARAM_DFLT => 'totalhits|suggestion|rewrittenquery', ApiBase::PARAM_TYPE => array('totalhits', 'suggestion', 'rewrittenquery'), ApiBase::PARAM_ISMULTI => true), 'prop' => array(ApiBase::PARAM_DFLT => 'size|wordcount|timestamp|snippet', ApiBase::PARAM_TYPE => array('size', 'wordcount', 'timestamp', 'snippet', 'titlesnippet', 'redirecttitle', 'redirectsnippet', 'sectiontitle', 'sectionsnippet', 'isfilematch', 'categorysnippet', 'score', 'hasrelated'), ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_HELP_MSG_PER_VALUE => array()), 'offset' => array(ApiBase::PARAM_DFLT => 0, ApiBase::PARAM_HELP_MSG => 'api-help-param-continue'), 'limit' => array(ApiBase::PARAM_DFLT => 10, ApiBase::PARAM_TYPE => 'limit', ApiBase::PARAM_MIN => 1, ApiBase::PARAM_MAX => ApiBase::LIMIT_SML1, ApiBase::PARAM_MAX2 => ApiBase::LIMIT_SML2), 'interwiki' => false, 'enablerewrites' => false); $alternatives = SearchEngine::getSearchTypes(); if (count($alternatives) > 1) { if ($alternatives[0] === null) { $alternatives[0] = self::BACKEND_NULL_PARAM; } $params['backend'] = array(ApiBase::PARAM_DFLT => $this->getConfig()->get('SearchType'), ApiBase::PARAM_TYPE => $alternatives); } return $params; }
public function getParamDescription() { $descriptions = array('search' => 'Search for all page titles (or content) that has this value', 'namespace' => 'The namespace(s) to enumerate', 'what' => 'Search inside the text or titles', 'info' => 'What metadata to return', 'prop' => array('What properties to return', ' size - Adds the size of the page in bytes', ' wordcount - Adds the word count of the page', ' timestamp - Adds the timestamp of when the page was last edited', ' score - DEPRECATED and IGNORED', ' snippet - Adds a parsed snippet of the page', ' titlesnippet - Adds a parsed snippet of the page title', ' redirectsnippet - Adds a parsed snippet of the redirect title', ' redirecttitle - Adds the title of the matching redirect', ' sectionsnippet - Adds a parsed snippet of the matching section title', ' sectiontitle - Adds the title of the matching section', ' hasrelated - DEPRECATED and IGNORED'), 'offset' => 'Use this value to continue paging (return by query)', 'limit' => 'How many total pages to return', 'interwiki' => 'Include interwiki results in the search, if available'); if (count(SearchEngine::getSearchTypes()) > 1) { $descriptions['backend'] = 'Which search backend to use, if not the default'; } return $descriptions; }
/** * @see Page::readData() */ public function readData() { parent::readData(); if (!count($_POST)) { // set current date $this->untilDay = intval(DateUtil::formatDate('%d', null, false, true)); $this->untilMonth = intval(DateUtil::formatDate('%m', null, false, true)); $this->untilYear = intval(DateUtil::formatDate('%Y', null, false, true)); } $this->availableTypes = SearchEngine::getSearchTypes(); }