本文整理汇总了PHP中wfViewPrevNext函数的典型用法代码示例。如果您正苦于以下问题:PHP wfViewPrevNext函数的具体用法?PHP wfViewPrevNext怎么用?PHP wfViewPrevNext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfViewPrevNext函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wfShowIndirectLinks
/**
* @param int $level
* @param Title $target
* @param int $limit
* @param int $offset
* @access private
*/
function wfShowIndirectLinks($level, $target, $limit, $offset = 0)
{
global $wgOut, $wgUser;
$fname = 'wfShowIndirectLinks';
$dbr =& wfGetDB(DB_READ);
// Read one extra row as an at-end check
$queryLimit = $limit + 1;
$limitSql = $level == 0 ? "{$offset},{$queryLimit}" : $queryLimit;
$res = $dbr->select(array('pagelinks', 'page'), array('page_id', 'page_namespace', 'page_title', 'page_is_redirect'), array('pl_from=page_id', 'pl_namespace' => $target->getNamespace(), 'pl_title' => $target->getDbKey()), $fname, array('LIMIT' => $limitSql));
if (0 == $dbr->numRows($res)) {
if (0 == $level) {
$wgOut->addWikiText(wfMsg('nolinkshere'));
}
return;
}
if (0 == $level) {
$wgOut->addWikiText(wfMsg('linkshere'));
}
$sk = $wgUser->getSkin();
$isredir = ' (' . wfMsg('isredirect') . ")\n";
if ($dbr->numRows($res) == 0) {
return;
}
$atend = $dbr->numRows($res) <= $limit;
if ($level == 0) {
$specialTitle = Title::makeTitle(NS_SPECIAL, 'Whatlinkshere');
$prevnext = wfViewPrevNext($offset, $limit, $specialTitle, 'target=' . urlencode($target->getPrefixedDbKey()), $atend);
$wgOut->addHTML($prevnext);
}
$wgOut->addHTML('<ul>');
$linksShown = 0;
while ($row = $dbr->fetchObject($res)) {
if (++$linksShown > $limit) {
// Last row is for checks only; don't display it.
break;
}
$nt = Title::makeTitle($row->page_namespace, $row->page_title);
if ($row->page_is_redirect) {
$extra = 'redirect=no';
} else {
$extra = '';
}
$link = $sk->makeKnownLinkObj($nt, '', $extra);
$wgOut->addHTML('<li>' . $link);
if ($row->page_is_redirect) {
$wgOut->addHTML($isredir);
if ($level < 2) {
wfShowIndirectLinks($level + 1, $nt, 500);
}
}
$wgOut->addHTML("</li>\n");
}
$wgOut->addHTML("</ul>\n");
if ($level == 0) {
$wgOut->addHTML($prevnext);
}
}
示例2: getNavigationBar
function getNavigationBar() {
global $wgContLang;
return wfViewPrevNext(
$this->mOffset,
$this->mLimit,
$wgContLang->specialpage( 'WhosOnline' ),
'',
$this->countUsersOnline() < ( $this->mLimit + $this->mOffset ) // show next link
);
}
示例3: doQuery
/**
* As with QueryPage, this is the actual workhorse. It does everything
* needed to make a real, honest-to-gosh query page.
*
* @param $offset database query offset
* @param $limit database query limit
* @param $shownavigation show navigation like "next 200"?
*/
function doQuery($offset, $limit, $shownavigation = true)
{
global $wgUser, $wgOut, $wgContLang;
$this->offset = $offset;
$this->limit = $limit;
$sname = $this->getName();
$fname = get_class($this) . '::doQuery';
$sk = $wgUser->getSkin();
$wgOut->setSyndicated($this->isSyndicated());
$query = MwRdf::Query($this->getQuery(), $this->getBaseUrl(), $this->getQueryLanguage());
$librdf_res = $query->execute(MwRdf::StoredModel());
# let's just dump the tuples into a normal php array shall
# we? This will avoid memory management hassels.
$res = array();
foreach ($librdf_res as $tuple) {
$res[] = $tuple;
}
$num = count($res);
$res = $this->preprocessResults($res);
if ($shownavigation) {
$wgOut->addHTML($this->getPageHeader());
$top = wfShowingResults($offset, $num);
$wgOut->addHTML("<p>{$top}\n");
# often disable 'next' link when we reach the end
$atend = $num < $limit;
$sl = wfViewPrevNext($offset, $limit, $wgContLang->specialPage($sname), wfArrayToCGI($this->linkParameters()), $atend);
$wgOut->addHTML("<br />{$sl}</p>\n");
}
if ($num > 0) {
$s = array();
if (!$this->listoutput) {
$s[] = "<ol start='" . ($offset + 1) . "' class='special'>";
}
# here's where we do the offset and limit
for ($i = $offset; $i < $num && $i < $offset + $limit; $i++) {
$format = $this->formatResult($sk, $res[$i]);
if ($format) {
$s[] = $this->listoutput ? $format : "<li>{$format}</li>\n";
}
}
if (!$this->listoutput) {
$s[] = '</ol>';
}
$str = $this->listoutput ? $wgContLang->listToText($s) : implode('', $s);
$wgOut->addHTML($str);
}
if ($shownavigation) {
$wgOut->addHTML("<p>{$sl}</p>\n");
}
return $num;
}
示例4: doQuery
/**
* This is the actual workhorse. It does everything needed to make a
* real, honest-to-gosh query page.
* Alas, we need to overwrite the whole beast since we do not assume
* an SQL-based storage backend.
*
* @param $offset database query offset
* @param $limit database query limit
*/
function doQuery($offset = false, $limit = false)
{
global $wgOut, $wgContLang;
$options = new SMWRequestOptions();
$options->limit = $limit;
$options->offset = $offset;
$options->sort = true;
$res = $this->getResults($options);
$num = count($res);
$sk = $this->getSkin();
$sname = $this->getName();
$wgOut->addHTML($this->getPageHeader());
// if list is empty, show it
if ($num == 0) {
$wgOut->addHTML('<p>' . wfMsgHTML('specialpage-empty') . '</p>');
return;
}
$top = wfShowingResults($offset, $num);
$wgOut->addHTML("<p>{$top}\n");
// often disable 'next' link when we reach the end
$atend = $num < $limit;
$sl = wfViewPrevNext($offset, $limit, $wgContLang->specialPage($sname), wfArrayToCGI($this->linkParameters()), $atend);
$wgOut->addHTML("<br />{$sl}</p>\n");
if ($num > 0) {
$s = array();
if (!$this->listoutput) {
$s[] = $this->openList($offset);
}
foreach ($res as $r) {
$format = $this->formatResult($sk, $r);
if ($format) {
$s[] = $this->listoutput ? $format : "<li>{$format}</li>\n";
}
}
if (!$this->listoutput) {
$s[] = $this->closeList();
}
$str = $this->listoutput ? $wgContLang->listToText($s) : implode('', $s);
$wgOut->addHTML($str);
}
$wgOut->addHTML("<p>{$sl}</p>\n");
return $num;
}
示例5: execute
function execute($par)
{
global $wgOut, $wgUser, $wgRequest;
if ($wgUser->getID() == 0 || !($wgUser->isSysop() || in_array('newarticlepatrol', $wgUser->getRights()) || $wgUser->getName() == "Gloster flyer" || $wgUser->getName() == "Byankno1")) {
$wgOut->setRobotpolicy('noindex,nofollow');
$wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
return;
}
wfLoadExtensionMessages('Spellchecker');
$wgOut->setHTMLTitle('Spellchecker Proposed Whitelist');
$wgOut->setPageTitle('Spellchecker Proposed Whitelist');
$wgOut->addHTML("<style type='text/css' media='all'>/*<![CDATA[*/ @import '" . wfGetPad('/extensions/min/f/extensions/wikihow/spellchecker/spellchecker.css?') . WH_SITEREV . "'; /*]]>*/</style> ");
$dbr = wfGetDB(DB_SLAVE);
$wgOut->addHTML("<p>" . wfMsgWikiHtml('spch-proposedwhitelist') . "</p>");
if ($wgRequest->wasPosted()) {
$wordsAdded = array();
$wordsRemoved = array();
$dbw = wfGetDB(DB_MASTER);
foreach ($wgRequest->getValues() as $key => $value) {
$wordId = intval(substr($key, 5));
// 5 = "word-"
$word = $dbr->selectField(wikiHowDictionary::WHITELIST_TABLE, 'sw_word', array('sw_id' => $wordId), __METHOD__);
$msg = "";
switch ($value) {
case "lower":
$lWord = lcfirst($word);
$lWordId = $dbr->selectField(wikiHowDictionary::WHITELIST_TABLE, 'sw_id', array('sw_word' => $lWord), __METHOD__);
if ($lWordId == $wordId) {
//submitting the same word as was entered
$dbw->update(wikiHowDictionary::WHITELIST_TABLE, array('sw_active' => 1), array('sw_id' => $wordId));
$msg = "Accepted {$word} into the whitelist";
} else {
//they've chosen to make it lowercase, when it wasn't to start
if ($lWordId === false) {
//doesn't exist yet
$dbw->insert(wikiHowDictionary::WHITELIST_TABLE, array(wikiHowDictionary::WORD_FIELD => $lWord, wikiHowDictionary::USER_FIELD => $wgUser->getID(), wikiHowDictionary::ACTIVE_FIELD => 1), __METHOD__, "IGNORE");
} else {
//already exists, so update it
$dbw->update(wikiHowDictionary::WHITELIST_TABLE, array('sw_active' => 1), array('sw_id' => $lWordId));
}
$dbw->delete(wikiHowDictionary::WHITELIST_TABLE, array('sw_id' => $wordId));
$msg = "Put {$lWord} into whitelist as lowercase. Removed uppercase version.";
}
wikiHowDictionary::invalidateArticlesWithWord($dbr, $dbw, $lWord);
$wordsAdded[] = $lWord;
break;
case "reject":
$dbw->delete(wikiHowDictionary::WHITELIST_TABLE, array('sw_id' => $wordId));
$msg = "Removed {$word} from the whitelist";
$wordsRemoved[] = $word;
break;
case "caps":
$uWord = ucfirst($word);
$uWordId = $dbr->selectField(wikiHowDictionary::WHITELIST_TABLE, 'sw_id', array('sw_word' => $uWord), __METHOD__);
if ($uWordId == $wordId) {
//submitting the same word as was entered
$dbw->update(wikiHowDictionary::WHITELIST_TABLE, array('sw_active' => 1), array('sw_id' => $wordId));
$msg = "Accepted {$word} into the whitelist";
} else {
//they've chosen to make it lowercase, when it wasn't to start
if ($uWordId === false) {
//doesn't exist yet
$dbw->insert(wikiHowDictionary::WHITELIST_TABLE, array(wikiHowDictionary::WORD_FIELD => $uWord, wikiHowDictionary::USER_FIELD => $wgUser->getID(), wikiHowDictionary::ACTIVE_FIELD => 1), __METHOD__, "IGNORE");
} else {
//already exists, so update it
$dbw->update(wikiHowDictionary::WHITELIST_TABLE, array('sw_active' => 1), array('sw_id' => $uWordId));
}
$dbw->delete(wikiHowDictionary::WHITELIST_TABLE, array('sw_id' => $wordId));
$msg = "Put {$uWord} into whitelist as uppercase. Removed lowercase version.";
}
wikiHowDictionary::invalidateArticlesWithWord($dbr, $dbw, $uWord);
$wordsAdded[] = $uWord;
break;
case "ignore":
default:
break;
}
if ($msg != "") {
$log = new LogPage('whitelist', false);
// false - dont show in recentchanges
$t = Title::newFromText("Special:ProposedWhitelist");
$log->addEntry($value, $t, $msg);
}
}
if (count($wordsAdded) > 0) {
$wgOut->addHTML("<p><b>" . implode(", ", $wordsAdded) . "</b> " . (count($wordsAdded) > 1 ? "were" : "was") . " added to the whitelist.</p>");
}
if (count($wordsRemoved) > 0) {
$wgOut->addHTML("<p><b>" . implode(", ", $wordsRemoved) . "</b> " . (count($wordsRemoved) > 1 ? "were" : "was") . " were removed from the whitelist.</p>");
}
}
//show table
list($limit, $offset) = wfCheckLimits(50, '');
$res = $dbr->select(wikiHowDictionary::WHITELIST_TABLE, '*', array(wikiHowDictionary::ACTIVE_FIELD => 0), __METHOD__, array("LIMIT" => $limit, "OFFSET" => $offset));
$num = $dbr->numRows($res);
$words = array();
foreach ($res as $item) {
$words[] = $item;
}
$paging = wfViewPrevNext($offset, $limit, "Special:ProposedWhitelist", "", $num < $limit);
//.........这里部分代码省略.........
示例6: getBody
public function getBody()
{
$res = $this->reallyDoQuery();
$this->preprocessResults($res);
$prevnext = wfViewPrevNext($this->mOffset, $this->mLimit, SpecialPage::getTitleFor('AdvancedSearch'), wfArrayToCGI($this->getDefaultQuery()), $this->getNumRows() < $this->mLimit);
$retval = $this->getStartBody();
$row = $res->fetchObject();
while ($row) {
$retval .= $this->formatRow($row);
}
$retval .= $this->getEndBody();
return $prevnext . $retval . $prevnext;
}
示例7: showPrevNext
function showPrevNext(&$out)
{
global $wgContLang, $wgRequest;
list($limit, $offset) = $wgRequest->getLimitOffset();
$target = 'target=' . urlencode($wgRequest->getVal('target'));
$mode = '&mode=' . urlencode($wgRequest->getVal('mode'));
$html = wfViewPrevNext($offset, $limit, $wgContLang->specialpage('Regexblockstats'), $target . $mode, $this->numResults - $offset <= $limit);
$out->addHTML('<p>' . $html . '</p>');
}
示例8: execute
/**
* This is the actual workhorse. It does everything needed to make a
* real, honest-to-gosh query page.
*/
function execute($par)
{
global $wgUser, $wgOut, $wgLang, $wgRequest;
if (!$this->userCanExecute($wgUser)) {
$this->displayRestrictionError();
return;
}
if ($this->limit == 0 && $this->offset == 0) {
list($this->limit, $this->offset) = $wgRequest->getLimitOffset();
}
$dbr = wfGetDB(DB_SLAVE);
$this->setHeaders();
$wgOut->setSyndicated($this->isSyndicated());
if ($this->isCached() && !$this->isCacheable()) {
$wgOut->setSyndicated(false);
$wgOut->addWikiMsg('querypage-disabled');
return 0;
}
// TODO: Use doQuery()
// $res = null;
if (!$this->isCached()) {
$res = $this->reallyDoQuery($this->limit, $this->offset);
} else {
# Get the cached result
$res = $this->fetchFromCache($this->limit, $this->offset);
if (!$this->listoutput) {
# Fetch the timestamp of this update
$ts = $this->getCachedTimestamp();
if ($ts) {
$updated = $wgLang->timeanddate($ts, true, true);
$updateddate = $wgLang->date($ts, true, true);
$updatedtime = $wgLang->time($ts, true, true);
$wgOut->addMeta('Data-Cache-Time', $ts);
$wgOut->addInlineScript("var dataCacheTime = '{$ts}';");
$wgOut->addWikiMsg('perfcachedts', $updated, $updateddate, $updatedtime);
} else {
$wgOut->addWikiMsg('perfcached');
}
# If updates on this page have been disabled, let the user know
# that the data set won't be refreshed for now
global $wgDisableQueryPageUpdate;
if (is_array($wgDisableQueryPageUpdate) && in_array($this->getName(), $wgDisableQueryPageUpdate)) {
$wgOut->addWikiMsg('querypage-no-updates');
}
}
}
$this->numRows = $dbr->numRows($res);
$this->preprocessResults($dbr, $res);
$wgOut->addHTML(Xml::openElement('div', array('class' => 'mw-spcontent')));
# Top header and navigation
if ($this->shownavigation) {
$wgOut->addHTML($this->getPageHeader());
if ($this->numRows > 0) {
$wgOut->addHTML('<p>' . wfShowingResults($this->offset, $this->numRows) . '</p>');
# Disable the "next" link when we reach the end
$paging = wfViewPrevNext($this->offset, $this->limit, $this->getTitle($par), wfArrayToCGI($this->linkParameters()), $this->numRows < $this->limit);
$wgOut->addHTML('<p>' . $paging . '</p>');
} else {
# No results to show, so don't bother with "showing X of Y" etc.
# -- just let the user know and give up now
$wgOut->addHTML('<p>' . wfMsgHtml('specialpage-empty') . '</p>');
$wgOut->addHTML(Xml::closeElement('div'));
return;
}
}
# The actual results; specialist subclasses will want to handle this
# with more than a straight list, so we hand them the info, plus
# an OutputPage, and let them get on with it
$this->outputResults($wgOut, $this->getSkin(), $dbr, $res, $this->numRows, $this->offset);
# Repeat the paging links at the bottom
if ($this->shownavigation) {
$wgOut->addHTML('<p>' . $paging . '</p>');
}
$wgOut->addHTML(Xml::closeElement('div'));
return $this->numRows;
}
示例9: showResults
//.........这里部分代码省略.........
$textMatches = $search->searchText($query);
}
// did you mean... suggestions
if ($textMatches && $textMatches->hasSuggestion()) {
$st = SpecialPage::getTitleFor('SolrSearch');
# mirror Go/Search behaviour of original request ..
$didYouMeanParams = array('solrsearch' => $textMatches->getSuggestionQuery());
$stParams = $didYouMeanParams;
$suggestionSnippet = $textMatches->getSuggestionSnippet();
if ($suggestionSnippet == '') {
$suggestionSnippet = null;
}
$suggestLink = $sk->linkKnown($st, $suggestionSnippet, array(), $stParams);
$this->didYouMeanHtml = '<div class="searchdidyoumean">' . wfMsg('search-suggest', $suggestLink) . '</div>';
}
} catch (Exception $exc) {
#Todo: Catch different Exceptions not just one for all
$textMatches = false;
$titleMatches = false;
$wgOut->addHTML('<p class="solr-error">' . wfMsg('solrstore-error') . '<p\\>');
if ($wgSolrDebug) {
$wgOut->addHTML('<p class="solr-error">' . $exc . '<p\\>');
}
}
// start rendering the page
$wgOut->addHtml(Xml::openElement('form', array('id' => 'solrsearch', 'method' => 'get', 'action' => $wgScript)));
$wgOut->addHtml(Xml::openElement('table', array('id' => 'mw-search-top-table', 'border' => 0, 'cellpadding' => 0, 'cellspacing' => 0)) . Xml::openElement('tr') . Xml::openElement('td') . "\n" . $this->shortDialog($fieldSet) . Xml::closeElement('td') . Xml::closeElement('tr') . Xml::closeElement('table'));
// Sometimes the search engine knows there are too many hits
if ($titleMatches instanceof SearchResultTooMany) {
$wgOut->addWikiText('==' . wfMsg('toomanymatches') . "==\n");
wfProfileOut(__METHOD__);
return;
}
$filePrefix = $wgContLang->getFormattedNsText(NS_FILE) . ':';
if (trim($query) === '' || $filePrefix === trim($query)) {
$wgOut->addHTML($this->formHeader(0, 0));
$wgOut->addHTML('</form>');
// Empty query -- straight view of search form
wfProfileOut(__METHOD__);
return;
}
// Get number of results
$titleMatchesNum = $titleMatches ? $titleMatches->numRows() : 0;
$textMatchesNum = $textMatches ? $textMatches->numRows() : 0;
// Total initial query matches (possible false positives)
$num = $titleMatchesNum + $textMatchesNum;
// Get total actual results (after second filtering, if any)
$numTitleMatches = $titleMatches && !is_null($titleMatches->getTotalHits()) ? $titleMatches->getTotalHits() : $titleMatchesNum;
$numTextMatches = $textMatches && !is_null($textMatches->getTotalHits()) ? $textMatches->getTotalHits() : $textMatchesNum;
// get total number of results if backend can calculate it
$totalRes = 0;
if ($titleMatches && !is_null($titleMatches->getTotalHits())) {
$totalRes += $titleMatches->getTotalHits();
}
if ($textMatches && !is_null($textMatches->getTotalHits())) {
$totalRes += $textMatches->getTotalHits();
}
// show number of results and current offset
$wgOut->addHTML($this->formHeader($num, $totalRes));
$wgOut->addHtml(Xml::closeElement('form'));
$wgOut->addHtml("<div class='searchresults'>");
// prev/next links
if ($num || $this->offset) {
// Show the create link ahead
if ($wgSolrShowRelated) {
$this->showCreateLink($t);
}
$prevnext = wfViewPrevNext($this->offset, $this->limit, SpecialPage::getTitleFor('SolrSearch/' . $fieldSet->mName), wfArrayToCGI($fieldSet->mFields), max($titleMatchesNum, $textMatchesNum) < $this->limit);
wfRunHooks('SpecialSolrSearchResults', array($fieldSet, &$titleMatches, &$textMatches));
} else {
wfRunHooks('SpecialSolrSearchNoResults', array($fieldSet));
}
if ($titleMatches) {
if ($numTitleMatches > 0) {
$wgOut->wrapWikiMsg("==\$1==\n", 'titlematches');
$wgOut->addHTML($this->showMatches($titleMatches));
}
$titleMatches->free();
}
if ($textMatches) {
// output appropriate heading
if ($numTextMatches > 0 && $numTitleMatches > 0) {
// if no title matches the heading is redundant
$wgOut->wrapWikiMsg("==\$1==\n", 'textmatches');
} elseif ($totalRes == 0) {
# Don't show the 'no text matches' if we received title matches
$wgOut->wrapWikiMsg("==\$1==\n", 'notextmatches');
}
// show results
if ($numTextMatches > 0) {
$wgOut->addHTML($this->showMatches($textMatches));
}
$textMatches->free();
}
$wgOut->addHtml("</div>");
if ($num || $this->offset) {
$wgOut->addHTML("<p class='mw-search-pager-bottom'>{$prevnext}</p>\n");
}
wfProfileOut(__METHOD__);
}
示例10: showPrevNext
/**
* @param OutputPage &$out where to send output
* @private
*/
function showPrevNext(&$out)
{
global $wgContLang, $wgRequest;
$pieces = array();
$pieces[] = 'type=' . urlencode($this->reader->queryType());
$pieces[] = 'user=' . urlencode($this->reader->queryUser());
$pieces[] = 'page=' . urlencode($this->reader->queryTitle());
$pieces[] = 'pattern=' . urlencode($this->reader->queryPattern());
$bits = implode('&', $pieces);
list($limit, $offset) = $wgRequest->getLimitOffset();
# TODO: use timestamps instead of offsets to make it more natural
# to go huge distances in time
$html = wfViewPrevNext($offset, $limit, $wgContLang->specialpage('Log'), $bits, $this->numResults < $limit);
$out->addHTML('<p>' . $html . '</p>');
}
示例11: doQuery
/**
* This is the actual workhorse. It does everything needed to make a
* real, honest-to-gosh query page.
*
* @param $offset database query offset
* @param $limit database query limit
* @param $shownavigation show navigation like "next 200"?
*/
function doQuery($offset, $limit, $shownavigation = true)
{
global $wgUser, $wgOut, $wgLang, $wgRequest, $wgContLang;
global $wgMiserMode;
$sname = $this->getName();
$fname = get_class($this) . '::doQuery';
$sql = $this->getSQL();
$dbr =& wfGetDB(DB_SLAVE);
$dbw =& wfGetDB(DB_MASTER);
$querycache = $dbr->tableName('querycache');
$wgOut->setSyndicated($this->isSyndicated());
if ($this->isExpensive()) {
// Disabled recache parameter due to retry problems -- TS
if ($wgMiserMode) {
$type = $dbr->strencode($sname);
$sql = "SELECT qc_type as type, qc_namespace as namespace,qc_title as title, qc_value as value\n\t\t\t\t\t FROM {$querycache} WHERE qc_type='{$type}'";
$wgOut->addWikiText(wfMsg('perfcached'));
}
}
$res = $dbr->query($sql . $this->getOrder() . $dbr->limitResult($limit, $offset), $fname);
$num = $dbr->numRows($res);
$sk = $wgUser->getSkin();
if ($shownavigation) {
$wgOut->addHTML($this->getPageHeader());
$top = wfShowingResults($offset, $num);
$wgOut->addHTML("<p>{$top}\n");
# often disable 'next' link when we reach the end
if ($num < $limit) {
$atend = true;
} else {
$atend = false;
}
$sl = wfViewPrevNext($offset, $limit, $wgContLang->specialPage($sname), wfArrayToCGI($this->linkParameters()), $atend);
$wgOut->addHTML("<br />{$sl}</p>\n");
}
if ($num > 0) {
$s = "<ol start='" . ($offset + 1) . "' class='special'>";
# Only read at most $num rows, because $res may contain the whole 1000
for ($i = 0; $i < $num && ($obj = $dbr->fetchObject($res)); $i++) {
$format = $this->formatResult($sk, $obj);
if ($format) {
$attr = isset($obj->usepatrol) && $obj->usepatrol && $obj->patrolled == 0 ? ' class="not-patrolled"' : '';
$s .= "<li{$attr}>{$format}</li>\n";
}
}
if ($this->tryLastResult()) {
// flush the very last result
$obj = null;
$format = $this->formatResult($sk, $obj);
if ($format) {
$attr = isset($obj->usepatrol) && $obj->usepatrol && $obj->patrolled == 0 ? ' class="not-patrolled"' : '';
$s .= "<li{$attr}>{$format}</li>\n";
}
}
$dbr->freeResult($res);
$s .= '</ol>';
$wgOut->addHTML($s);
}
if ($shownavigation) {
$wgOut->addHTML("<p>{$sl}</p>\n");
}
return $num;
}
示例12: showResults
/**
* @param string $term
* @public
*/
function showResults($term)
{
$fname = 'SpecialSearch::showResults';
wfProfileIn($fname);
$this->setupPage($term);
global $wgOut;
$wgOut->addWikiMsg('searchresulttext');
if ('' === trim($term)) {
// Empty query -- straight view of search form
$wgOut->setSubtitle('');
$wgOut->addHTML($this->powerSearchBox($term));
$wgOut->addHTML($this->powerSearchFocus());
wfProfileOut($fname);
return;
}
global $wgDisableTextSearch;
if ($wgDisableTextSearch) {
global $wgForwardSearchUrl;
if ($wgForwardSearchUrl) {
$url = str_replace('$1', urlencode($term), $wgForwardSearchUrl);
$wgOut->redirect($url);
return;
}
global $wgInputEncoding;
$wgOut->addHTML(wfMsg('searchdisabled'));
$wgOut->addHTML(wfMsg('googlesearch', htmlspecialchars($term), htmlspecialchars($wgInputEncoding), htmlspecialchars(wfMsg('searchbutton'))));
wfProfileOut($fname);
return;
}
$search = SearchEngine::create();
$search->setLimitOffset($this->limit, $this->offset);
$search->setNamespaces($this->namespaces);
$search->showRedirects = $this->searchRedirects;
$titleMatches = $search->searchTitle($term);
// Sometimes the search engine knows there are too many hits
if ($titleMatches instanceof SearchResultTooMany) {
$wgOut->addWikiText('==' . wfMsg('toomanymatches') . "==\n");
$wgOut->addHTML($this->powerSearchBox($term));
$wgOut->addHTML($this->powerSearchFocus());
wfProfileOut($fname);
return;
}
$textMatches = $search->searchText($term);
$num = ($titleMatches ? $titleMatches->numRows() : 0) + ($textMatches ? $textMatches->numRows() : 0);
if ($num > 0) {
if ($num >= $this->limit) {
$top = wfShowingResults($this->offset, $this->limit);
} else {
$top = wfShowingResultsNum($this->offset, $this->limit, $num);
}
$wgOut->addHTML("<p>{$top}</p>\n");
}
if ($num || $this->offset) {
$prevnext = wfViewPrevNext($this->offset, $this->limit, SpecialPage::getTitleFor('Search'), wfArrayToCGI($this->powerSearchOptions(), array('search' => $term)), $num < $this->limit);
$wgOut->addHTML("<br />{$prevnext}\n");
}
if ($titleMatches) {
if ($titleMatches->numRows()) {
$wgOut->wrapWikiMsg("==\$1==\n", 'titlematches');
$wgOut->addHTML($this->showMatches($titleMatches));
} else {
$wgOut->wrapWikiMsg("==\$1==\n", 'notitlematches');
}
$titleMatches->free();
}
if ($textMatches) {
if ($textMatches->numRows()) {
$wgOut->wrapWikiMsg("==\$1==\n", 'textmatches');
$wgOut->addHTML($this->showMatches($textMatches));
} elseif ($num == 0) {
# Don't show the 'no text matches' if we received title matches
$wgOut->wrapWikiMsg("==\$1==\n", 'notextmatches');
}
$textMatches->free();
}
if ($num == 0) {
$wgOut->addWikiMsg('nonefound');
}
if ($num || $this->offset) {
$wgOut->addHTML("<p>{$prevnext}</p>\n");
}
$wgOut->addHTML($this->powerSearchBox($term));
wfProfileOut($fname);
}
示例13: showResults
/**
* @param string $term
* @public
*/
function showResults($term)
{
wfProfileIn(__METHOD__);
global $wgOut, $wgUser;
$sk = $wgUser->getSkin();
$search = SearchEngine::create();
$search->setLimitOffset($this->limit, $this->offset);
$search->setNamespaces($this->namespaces);
$search->showRedirects = $this->searchRedirects;
$search->prefix = $this->mPrefix;
$term = $search->transformSearchTerm($term);
$this->setupPage($term);
$rewritten = $search->replacePrefixes($term);
$titleMatches = $search->searchTitle($rewritten);
$textMatches = $search->searchText($rewritten);
// did you mean... suggestions
if ($textMatches && $textMatches->hasSuggestion()) {
$st = SpecialPage::getTitleFor('Search');
$stParams = wfArrayToCGI(array('search' => $textMatches->getSuggestionQuery(), 'fulltext' => wfMsg('search')), $this->powerSearchOptions());
$suggestLink = $sk->makeKnownLinkObj($st, $textMatches->getSuggestionSnippet(), $stParams);
$wgOut->addHTML('<div class="searchdidyoumean">' . wfMsg('search-suggest', $suggestLink) . '</div>');
}
$wgOut->addWikiMsg('searchresulttext');
if ('' === trim($term)) {
// Empty query -- straight view of search form
$wgOut->setSubtitle('');
$wgOut->addHTML($this->powerSearchBox($term));
$wgOut->addHTML($this->powerSearchFocus());
wfProfileOut(__METHOD__);
return;
}
global $wgDisableTextSearch;
if ($wgDisableTextSearch) {
global $wgSearchForwardUrl;
if ($wgSearchForwardUrl) {
$url = str_replace('$1', urlencode($term), $wgSearchForwardUrl);
$wgOut->redirect($url);
wfProfileOut(__METHOD__);
return;
}
global $wgInputEncoding;
$wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('search-external')) . Xml::element('p', array('class' => 'mw-searchdisabled'), wfMsg('searchdisabled')) . wfMsg('googlesearch', htmlspecialchars($term), htmlspecialchars($wgInputEncoding), htmlspecialchars(wfMsg('searchbutton'))) . Xml::closeElement('fieldset'));
wfProfileOut(__METHOD__);
return;
}
$wgOut->addHTML($this->shortDialog($term));
// Sometimes the search engine knows there are too many hits
if ($titleMatches instanceof SearchResultTooMany) {
$wgOut->addWikiText('==' . wfMsg('toomanymatches') . "==\n");
$wgOut->addHTML($this->powerSearchBox($term));
$wgOut->addHTML($this->powerSearchFocus());
wfProfileOut(__METHOD__);
return;
}
// show number of results
$num = ($titleMatches ? $titleMatches->numRows() : 0) + ($textMatches ? $textMatches->numRows() : 0);
$totalNum = 0;
if ($titleMatches && !is_null($titleMatches->getTotalHits())) {
$totalNum += $titleMatches->getTotalHits();
}
if ($textMatches && !is_null($textMatches->getTotalHits())) {
$totalNum += $textMatches->getTotalHits();
}
if ($num > 0) {
if ($totalNum > 0) {
$top = wfMsgExt('showingresultstotal', array('parseinline'), $this->offset + 1, $this->offset + $num, $totalNum, $num);
} elseif ($num >= $this->limit) {
$top = wfShowingResults($this->offset, $this->limit);
} else {
$top = wfShowingResultsNum($this->offset, $this->limit, $num);
}
$wgOut->addHTML("<p class='mw-search-numberresults'>{$top}</p>\n");
}
// prev/next links
if ($num || $this->offset) {
$prevnext = wfViewPrevNext($this->offset, $this->limit, SpecialPage::getTitleFor('Search'), wfArrayToCGI($this->powerSearchOptions(), array('search' => $term)), $num < $this->limit);
$wgOut->addHTML("<p class='mw-search-pager-top'>{$prevnext}</p>\n");
wfRunHooks('SpecialSearchResults', array($term, &$titleMatches, &$textMatches));
} else {
wfRunHooks('SpecialSearchNoResults', array($term));
}
if ($titleMatches) {
if ($titleMatches->numRows()) {
$wgOut->wrapWikiMsg("==\$1==\n", 'titlematches');
$wgOut->addHTML($this->showMatches($titleMatches));
}
$titleMatches->free();
}
if ($textMatches) {
// output appropriate heading
if ($textMatches->numRows()) {
if ($titleMatches) {
$wgOut->wrapWikiMsg("==\$1==\n", 'textmatches');
} else {
// if no title matches the heading is redundant
$wgOut->addHTML("<hr/>");
//.........这里部分代码省略.........
示例14: wfSpecialMissingLanguageLinks
/**
*
*/
function wfSpecialMissingLanguageLinks()
{
global $wgUser, $wgOut, $wgContLang, $wgTitle, $wgRequest;
$fname = 'wfSpecialMissingLanguageLinks';
$thelang = $wgRequest->getText('thelang');
if ($thelang == 'w') {
$thelang = 'en';
}
# Fix for international wikis
list($limit, $offset) = wfCheckLimits();
$dbr =& wfGetDB(DB_SLAVE);
$cur = $dbr->tableName('cur');
$sql = "SELECT cur_title FROM {$cur} " . "WHERE cur_namespace=" . NS_MAIN . " AND cur_is_redirect=0 " . "AND cur_title NOT LIKE '%/%' AND cur_text NOT LIKE '%[[" . wfStrencode($thelang) . ":%' " . "LIMIT {$offset}, {$limit}";
$res = $dbr->query($sql, $fname);
$mll = wfMsg('missinglanguagelinkstext', $wgContLang->getLanguageName($thelang));
$top = getMaintenancePageBacklink('missinglanguagelinks');
$top .= "<p>{$mll}</p><br />";
$top .= wfShowingResults($offset, $limit);
$wgOut->addHTML("<p>{$top}\n");
$sl = wfViewPrevNext($offset, $limit, 'REPLACETHIS');
$sl = str_replace('REPLACETHIS', sns() . ":Maintenance&subfunction=missinglanguagelinks&thelang=" . htmlspecialchars($thelang), $sl);
$wgOut->addHTML("<br />{$sl}\n");
$sk = $wgUser->getSkin();
$s = '<ol start=' . ($offset + 1) . '>';
while ($obj = $dbr->fetchObject($res)) {
$s .= "<li>" . $sk->makeKnownLink($obj->cur_title) . "</li>\n";
}
$dbr->freeResult($res);
$s .= '</ol>';
$wgOut->addHTML($s);
$wgOut->addHTML("<p>{$sl}\n");
}
示例15: showStatsList
/**
* Display some statistics when a user clicks stats link (&action=stats)
*
* @param $blckid Int: ID number of the block
*/
private function showStatsList($blckid)
{
global $wgOut, $wgLang, $wgUser, $wgContLang;
wfProfileIn(__METHOD__);
$action = $this->mTitle->escapeLocalURL($this->makeListUrlParams(true));
$skin = $wgUser->getSkin();
$regexData = new RegexBlockData();
$this->numStatResults = $regexData->fetchNbrStatResults($blckid);
$filter = 'action=stats&filter=' . urlencode($this->mFilter) . '&blckid=' . urlencode($blckid);
$pager = wfViewPrevNext($this->mOffset, $this->mLimit, $wgContLang->specialpage('RegexBlock'), $filter, $this->numStatResults - $this->mOffset <= $this->mLimit);
/* allow display by specific blockers only */
$blockInfo = $regexData->getRegexBlockById($blckid);
$stats_list = array();
if (!empty($blockInfo) && is_object($blockInfo)) {
$stats_list = $regexData->getStatsData($blckid, $this->mLimit, $this->mOffset);
}
$blocker_link = $skin->makeKnownLinkObj($this->mTitle, $blockInfo->blckby_blocker, 'filter=' . urlencode($blockInfo->blckby_blocker));
$blockername_link = $skin->makeKnownLinkObj($this->mTitle, $blockInfo->blckby_name, 'rfilter=' . urlencode($blockInfo->blckby_name));
$blockReason = $blockInfo->blckby_reason ? wfMsg('regexblock-form-reason') . $blockInfo->blckby_reason : wfMsg('regexblock-view-reason-default');
$wgOut->addHTML('<h5>' . wfMsg('regexblock-stats-title') . ' <strong> ' . $blockername_link . '</strong> (' . wfMsg('regexblock-view-block-by') . ' <b>' . $blocker_link . '</b>, <i>' . $blockReason . '</i>)</h5><br />');
if (!empty($stats_list)) {
$wgOut->addHTML('<p>' . $pager . '</p><br /><ul>');
foreach ($stats_list as $id => $row) {
$wgOut->addHTML('<li style="border-bottom:1px dashed #778899; padding-bottom:2px;font-size:11px">
' . wfMsg('regexblock-match-stats-record', array($row->stats_match, $row->stats_user, htmlspecialchars($row->stats_dbname), $wgLang->timeanddate(wfTimestamp(TS_MW, $row->stats_timestamp), true), $row->stats_ip, $wgLang->date(wfTimestamp(TS_MW, $row->stats_timestamp), true), $wgLang->time(wfTimestamp(TS_MW, $row->stats_timestamp), true))) . '
</li>');
}
$wgOut->addHTML('</ul><br />
<p>' . $pager . '</p>');
} else {
$wgOut->addWikiMsg('regexblock-nodata-found');
}
wfProfileOut(__METHOD__);
}