/** * Return a new SearchResult and initializes it with a title. * * @param Title $title * @param SearchResultSet $parentSet * @return SearchResult */ public static function newFromTitle($title, SearchResultSet $parentSet = null) { $result = new static(); $result->initFromTitle($title); if ($parentSet) { $parentSet->augmentResult($result); } return $result; }
/** * Produce data to augment search result set. * @param SearchResultSet $resultSet * @return array Data for all results */ public function augmentAll(SearchResultSet $resultSet) { $data = []; foreach ($resultSet->extractResults() as $result) { $id = $result->getTitle()->getArticleID(); if (!$id) { continue; } $data[$id] = $this->rowAugmentor->augment($result); } return $data; }
/** * Show results from other wikis * * @param SearchResultSet $matches */ protected function showInterwiki(&$matches, $query) { global $wgContLang; wfProfileIn(__METHOD__); $terms = $wgContLang->convertForSearchResult($matches->termMatches()); $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>" . wfMsg('search-interwiki-caption') . "</div>\n"; $off = $this->offset + 1; $out .= "<ul class='mw-search-iwresults'>\n"; // work out custom project captions $customCaptions = array(); $customLines = explode("\n", wfMsg('search-interwiki-custom')); // format per line <iwprefix>:<caption> foreach ($customLines as $line) { $parts = explode(":", $line, 2); if (count($parts) == 2) { // validate line $customCaptions[$parts[0]] = $parts[1]; } } $prev = null; while ($result = $matches->next()) { $out .= $this->showInterwikiHit($result, $prev, $terms, $query, $customCaptions); $prev = $result->getInterwikiPrefix(); } // TODO: should support paging in a non-confusing way (not sure how though, maybe via ajax).. $out .= "</ul></div>\n"; // convert the whole thing to desired language variant $out = $wgContLang->convert($out); wfProfileOut(__METHOD__); return $out; }
/** * Show whole set of results * * @param SearchResultSet $matches * * @return string */ protected function showMatches(&$matches) { global $wgContLang; $profile = new ProfileSection(__METHOD__); $terms = $wgContLang->convertForSearchResult($matches->termMatches()); $out = "<ul class='mw-search-results'>\n"; $result = $matches->next(); while ($result) { $out .= $this->showHit($result, $terms); $result = $matches->next(); } $out .= "</ul>\n"; // convert the whole thing to desired language variant $out = $wgContLang->convert($out); return $out; }
/** * Show whole set of results * * @param SearchResultSet $matches * @param string $interwiki Interwiki name * * @return string */ protected function showMatches(&$matches, $interwiki = null) { global $wgContLang; $terms = $wgContLang->convertForSearchResult($matches->termMatches()); $out = ''; $result = $matches->next(); $pos = $this->offset; if ($result && $interwiki) { $out .= $this->interwikiHeader($interwiki, $result); } $out .= "<ul class='mw-search-results'>\n"; while ($result) { $out .= $this->showHit($result, $terms, ++$pos); $result = $matches->next(); } $out .= "</ul>\n"; // convert the whole thing to desired language variant $out = $wgContLang->convert($out); return $out; }
/** * @param SearchResultSet $matches * @param string $terms partial regexp for highlighting terms */ function showMatches(&$matches) { $fname = 'SpecialSearch::showMatches'; wfProfileIn($fname); global $wgContLang; $tm = $wgContLang->convertForSearchResult($matches->termMatches()); $terms = implode('|', $tm); global $wgOut; $off = $this->offset + 1; $out = "<ol start='{$off}'>\n"; while ($result = $matches->next()) { $out .= $this->showHit($result, $terms); } $out .= "</ol>\n"; // convert the whole thing to desired language variant global $wgContLang; $out = $wgContLang->convert($out); wfProfileOut($fname); return $out; }
public function augmentAll(SearchResultSet $resultSet) { $titles = $resultSet->extractTitles(); return PageProps::getInstance()->getProperties($titles, $this->propnames); }
$request->SetSelect("ListingID,ListPrice,Beds,City"); $request->SetLimit(SearchRequest_LIMIT_DEFAULT); $request->SetOffset(SearchRequest_OFFSET_NONE); $request->SetCountType(SearchRequest_RECORD_COUNT_AND_RESULTS); $request->SetStandardNames(true); $filename = "rawsearch.xml"; $fd = fopen($filename, "w"); // Do the search and get all the raw XML. $results = $session->SearchAsString($request); fwrite($fd, $results); fclose($fd); // Reread the file and inject the content into the resultset for parsing. $fd = fopen($filename, "r"); $rawxml = fread($fd, filesize($filename)); fclose($fd); $results = new SearchResultSet(); $results->SetDataAsString($rawxml); print "Record count: " . $results->GetCount() . "\n"; $columns = $results->GetColumns(); while ($results->HasNext()) { for ($i = 0; $i < $columns->size(); $i++) { print $columns->get($i) . ": " . $results->GetString($i) . "\n"; } print "\n"; } } catch (Execption $e) { print "Exception: " . $e . "\n"; } $logout = $session->Logout(); print "Billing info: " . $logout->GetBillingInfo() . "\n"; print "Logout message: " . $logout->GetLogoutMessage() . "\n";