本文整理汇总了PHP中Linker类的典型用法代码示例。如果您正苦于以下问题:PHP Linker类的具体用法?PHP Linker怎么用?PHP Linker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Linker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFeedItem
private function createFeedItem($row)
{
global $wgOut;
$thread = Thread::newFromRow($row);
$linker = new Linker();
$titleStr = $thread->subject();
$completeText = $thread->root()->getContent();
$completeText = $wgOut->parse($completeText);
$threadTitle = clone $thread->topmostThread()->title();
$threadTitle->setFragment('#' . $thread->getAnchorName());
$titleUrl = $threadTitle->getFullURL();
$timestamp = $thread->created();
$user = $thread->author()->getName();
// Grab the title for the superthread, if one exists.
$stTitle = null;
if ($thread->hasSuperThread()) {
$stTitle = clone $thread->topmostThread()->title();
$stTitle->setFragment('#' . $thread->superthread()->getAnchorName());
}
// Prefix content with a quick description
$userLink = $linker->userLink($thread->author()->getId(), $user);
$talkpageLink = $linker->link($thread->getTitle());
$superthreadLink = $linker->link($stTitle);
$description = wfMsgExt($thread->hasSuperThread() ? 'lqt-feed-reply-intro' : 'lqt-feed-new-thread-intro', array('parse', 'replaceafter'), array($talkpageLink, $userLink, $superthreadLink));
$completeText = $description . $completeText;
return new FeedItem($titleStr, $completeText, $titleUrl, $timestamp, $user);
}
示例2: wfSajaxSearch
function wfSajaxSearch($term)
{
global $wgContLang, $wgOut;
$limit = 16;
$l = new Linker();
$term = str_replace(' ', '_', $wgContLang->ucfirst($wgContLang->checkTitleEncoding($wgContLang->recodeInput(js_unescape($term)))));
if (strlen(str_replace('_', '', $term)) < 3) {
return;
}
$db =& wfGetDB(DB_SLAVE);
$res = $db->select('page', 'page_title', array('page_namespace' => 0, "page_title LIKE '" . $db->strencode($term) . "%'"), "wfSajaxSearch", array('LIMIT' => $limit + 1));
$r = "";
$i = 0;
while (($row = $db->fetchObject($res)) && ++$i <= $limit) {
$nt = Title::newFromDBkey($row->page_title);
$r .= '<li>' . $l->makeKnownLinkObj($nt) . "</li>\n";
}
if ($i > $limit) {
$more = '<i>' . $l->makeKnownLink($wgContLang->specialPage("Allpages"), wfMsg('moredotdotdot'), "namespace=0&from=" . wfUrlEncode($term)) . '</i>';
} else {
$more = '';
}
$subtitlemsg = Title::newFromText($term) ? 'searchsubtitle' : 'searchsubtitleinvalid';
$subtitle = $wgOut->parse(wfMsg($subtitlemsg, wfEscapeWikiText($term)));
#FIXME: parser is missing mTitle !
$term = htmlspecialchars($term);
$html = '<div style="float:right; border:solid 1px black;background:gainsboro;padding:2px;"><a onclick="Searching_Hide_Results();">' . wfMsg('hideresults') . '</a></div>' . '<h1 class="firstHeading">' . wfMsg('search') . '</h1><div id="contentSub">' . $subtitle . '</div><ul><li>' . $l->makeKnownLink($wgContLang->specialPage('Search'), wfMsg('searchcontaining', $term), "search={$term}&fulltext=Search") . '</li><li>' . $l->makeKnownLink($wgContLang->specialPage('Search'), wfMsg('searchnamed', $term), "search={$term}&go=Go") . "</li></ul><h2>" . wfMsg('articletitles', $term) . "</h2>" . '<ul>' . $r . '</ul>' . $more;
$response = new AjaxResponse($html);
$response->setCacheDuration(30 * 60);
return $response;
}
示例3: addPage
function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) {
// From CategoryViewer::addPage
global $wgContLang;
$this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstChar( $sortkey ) );
// Customization
global $wgPeopleCategories;
$name = $title->getText();
if( in_array( $this->title->getText(), $wgPeopleCategories ) && strpos( $name, ' ' ) ) {
$first = substr( $name, 0, strrpos( $name, ' ' ) );
$last = substr( $name, strrpos( $name, ' ' ) + 1 );
$name = $last . ', ' . $first;
}
if( $title->getNamespace() !== NS_MAIN ) {
$name = $title->getNsText() . ':' . $name;
}
$linker = new Linker;
if( $isRedirect ) {
$this->articles[] =
'<span class="redirect-in-category">' .
$linker->link( $title, $name ) .
'</span>';
} else {
$this->articles[] = $linker->link( $title, $name );
}
}
示例4: formatLog
/**
* a StaffLog::formatRow hook
*
* Formats a log entry to be displayed on Special:StaffLog
*/
public static function formatLog($type, $result, $time, $linker, &$out)
{
if ('spamwiki' == $type) {
$l = new Linker();
$out = "{$time} {$type} - user {$l->userLink($result->slog_user, $result->slog_user_name)} {$result->slog_comment}.";
}
return true;
}
示例5: genContributionScoreTable
/**
* Function generates Contribution Scores tables in HTML format (not wikiText)
*
* @param $days int Days in the past to run report for
* @param $limit int Maximum number of users to return (default 50)
* @param $title Title (default null)
* @param $options array of options (default none; nosort/notools)
* @return Html Table representing the requested Contribution Scores.
*/
function genContributionScoreTable($days, $limit, $title = null, $options = 'none')
{
global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgContribScoresUseRealName;
$opts = explode(',', strtolower($options));
$dbr = wfGetDB(DB_SLAVE);
$userTable = $dbr->tableName('user');
$userGroupTable = $dbr->tableName('user_groups');
$revTable = $dbr->tableName('revision');
$ipBlocksTable = $dbr->tableName('ipblocks');
$sqlWhere = "";
$nextPrefix = "WHERE";
if ($days > 0) {
$date = time() - 60 * 60 * 24 * $days;
$dateString = $dbr->timestamp($date);
$sqlWhere .= " {$nextPrefix} rev_timestamp > '{$dateString}'";
$nextPrefix = "AND";
}
if ($wgContribScoreIgnoreBlockedUsers) {
$sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ipb_user FROM {$ipBlocksTable} WHERE ipb_user <> 0)";
$nextPrefix = "AND";
}
if ($wgContribScoreIgnoreBots) {
$sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ug_user FROM {$userGroupTable} WHERE ug_group='bot')";
}
$sqlMostPages = "SELECT rev_user,\n\t\t\t\t\t\t COUNT(DISTINCT rev_page) AS page_count,\n\t\t\t\t\t\t COUNT(rev_id) AS rev_count\n\t\t\t\t\t\t FROM {$revTable}\n\t\t\t\t\t\t {$sqlWhere}\n\t\t\t\t\t\t GROUP BY rev_user\n\t\t\t\t\t\t ORDER BY page_count DESC\n\t\t\t\t\t\t LIMIT {$limit}";
$sqlMostRevs = "SELECT rev_user,\n\t\t\t\t\t\t COUNT(DISTINCT rev_page) AS page_count,\n\t\t\t\t\t\t COUNT(rev_id) AS rev_count\n\t\t\t\t\t\t FROM {$revTable}\n\t\t\t\t\t\t {$sqlWhere}\n\t\t\t\t\t\t GROUP BY rev_user\n\t\t\t\t\t\t ORDER BY rev_count DESC\n\t\t\t\t\t\t LIMIT {$limit}";
$sql = "SELECT user_id, " . "user_name, " . "user_real_name, " . "page_count, " . "rev_count, " . "page_count+SQRT(rev_count-page_count)*2 AS wiki_rank " . "FROM {$userTable} u JOIN (({$sqlMostPages}) UNION ({$sqlMostRevs})) s ON (user_id=rev_user) " . "ORDER BY wiki_rank DESC " . "LIMIT {$limit}";
$res = $dbr->query($sql);
$sortable = in_array('nosort', $opts) ? '' : ' sortable';
$output = "<table class=\"wikitable contributionscores plainlinks{$sortable}\" >\n" . "<tr class='header'>\n" . Html::element('th', array(), $this->msg('contributionscores-score')->text()) . Html::element('th', array(), $this->msg('contributionscores-pages')->text()) . Html::element('th', array(), $this->msg('contributionscores-changes')->text()) . Html::element('th', array(), $this->msg('contributionscores-username')->text());
$altrow = '';
$lang = $this->getLanguage();
foreach ($res as $row) {
// Use real name if option used and real name present.
if ($wgContribScoresUseRealName && $row->user_real_name !== '') {
$userLink = Linker::userLink($row->user_id, $row->user_name, $row->user_real_name);
} else {
$userLink = Linker::userLink($row->user_id, $row->user_name);
}
$output .= Html::closeElement('tr');
$output .= "<tr class='{$altrow}'>\n<td class='content'>" . $lang->formatNum(round($row->wiki_rank, 0)) . "\n</td><td class='content'>" . $lang->formatNum($row->page_count) . "\n</td><td class='content'>" . $lang->formatNum($row->rev_count) . "\n</td><td class='content'>" . $userLink;
# Option to not display user tools
if (!in_array('notools', $opts)) {
$output .= Linker::userToolLinks($row->user_id, $row->user_name);
}
$output .= Html::closeElement('td') . "\n";
if ($altrow == '' && empty($sortable)) {
$altrow = 'odd ';
} else {
$altrow = '';
}
}
$output .= Html::closeElement('tr');
$output .= Html::closeElement('table');
$dbr->freeResult($res);
if (!empty($title)) {
$output = Html::rawElement('table', array('style' => 'border-spacing: 0; padding: 0', 'class' => 'contributionscores-wrapper', 'lang' => htmlspecialchars($lang->getCode()), 'dir' => $lang->getDir()), "\n" . "<tr>\n" . "<td style='padding: 0px;'>{$title}</td>\n" . "</tr>\n" . "<tr>\n" . "<td style='padding: 0px;'>{$output}</td>\n" . "</tr>\n");
}
return $output;
}
示例6: getFormattedValue
/**
* (non-PHPdoc)
* @see EPPager::getFormattedValue()
*/
protected function getFormattedValue($name, $value)
{
switch ($name) {
case 'id':
$value = Linker::linkKnown(SpecialPage::getTitleFor('Student', $value), htmlspecialchars($this->getLanguage()->formatNum($value, true)));
break;
case 'user_id':
$user = User::newFromId($value);
$name = $user->getRealName() === '' ? $user->getName() : $user->getRealName();
$value = Linker::userLink($value, $name) . Linker::userToolLinks($value, $name);
break;
case 'first_enroll':
case 'last_active':
$value = htmlspecialchars($this->getLanguage()->date($value));
break;
case 'active_enroll':
$value = wfMsgHtml($value === '1' ? 'epstudentpager-yes' : 'epstudentpager-no');
break;
case '_courses_current':
$value = $this->getLanguage()->pipeList(array_map(function (EPCourse $course) {
return $course->getLink();
}, $this->currentObject->getCoursesWithState('current', 'name')));
break;
}
return $value;
}
示例7: formatRow
function formatRow($row)
{
$time = htmlspecialchars($this->getLanguage()->userDate($row->log_timestamp, $this->getUser()));
$paramsSerialized = unserialize($row->log_params);
$paramsOldFormat = null;
// If the params aren't serialized, it's an older log format
if ($paramsSerialized === false) {
$paramsOldFormat = explode("\n", $row->log_params);
}
$targetName = $paramsSerialized === false ? $paramsOldFormat[0] : $paramsSerialized['4::target'];
$logPageId = (int) $row->log_page;
$currentTitle = $logPageId && $logPageId !== 0 ? Title::newFromID($logPageId) : null;
$targetTitleObj = Title::newFromText($targetName);
// Make sure the target is NS_MAIN
if ($targetTitleObj->getNamespace() !== NS_MAIN) {
return false;
}
$originalNameDisplay = '';
if ($currentTitle && $targetName !== $currentTitle->getFullText()) {
$originalNameDisplay = ' ' . $this->msg('newarticles-original-title')->params($targetName);
}
$pageLink = Linker::link($originalNameDisplay ? $currentTitle : $targetTitleObj);
$articleTypeDisplay = '';
if (isset($row->pp_value) && $row->pp_value === 'portal') {
$pageLink = Html::rawElement('strong', [], $pageLink);
$articleTypeReadable = WRArticleType::getReadableArticleTypeFromCode($row->pp_value);
$articleTypeDisplay = $this->msg('newarticles-articletype')->params($articleTypeReadable)->text();
$articleTypeDisplay = ' ' . $articleTypeDisplay;
}
$formattedRow = Html::rawElement('li', [], "{$time}: {$pageLink}{$articleTypeDisplay}{$originalNameDisplay}") . "\n";
return $formattedRow;
}
示例8: formatLogEntry
static function formatLogEntry($type, $action, $title, $sk, $parameters)
{
$msg = "lqt-log-action-{$action}";
switch ($action) {
case 'merge':
if ($parameters[0]) {
$msg = 'lqt-log-action-merge-across';
} else {
$msg = 'lqt-log-action-merge-down';
}
break;
case 'move':
$smt = new SpecialMoveThread();
$rightsCheck = $smt->checkUserRights($parameters[1] instanceof Title ? $parameters[1] : Title::newFromText($parameters[1]), $parameters[0] instanceof Title ? $parameters[0] : Title::newFromText($parameters[0]));
if ($rightsCheck === true) {
$parameters[] = Message::rawParam(Linker::link(SpecialPage::getTitleFor('MoveThread', $title), wfMessage('revertmove')->text(), array(), array('dest' => $parameters[0])));
} else {
$parameters[] = '';
}
break;
default:
// Give grep a chance to find the usages:
// lqt-log-action-move, lqt-log-action-split, lqt-log-action-subjectedit,
// lqt-log-action-resort, lqt-log-action-signatureedit
$msg = "lqt-log-action-{$action}";
break;
}
array_unshift($parameters, $title->getPrefixedText());
$html = wfMessage($msg, $parameters);
if ($sk === null) {
return StringUtils::delimiterReplace('<', '>', '', $html->inContentLanguage()->parse());
}
return $html->parse();
}
示例9: formatResult
/**
* @param $skin Skin
* @param $result
* @return string
*/
function formatResult($skin, $result)
{
$title = Title::makeTitleSafe($result->namespace, $result->title);
$count = $this->msg('ncategories')->numParams($result->value)->escaped();
$link = Linker::link($title);
return $this->getLanguage()->specialList($link, $count);
}
示例10: formatValue
function formatValue($name, $value)
{
global $wgContLang;
switch ($name) {
case 'article_title':
$articleId = $this->mCurrentRow->article_id;
$title = Title::newFromID($articleId);
return $title ? Linker::link($title) : '(unknown, id: ' . $articleId . ')';
break;
case 'page_ns':
return ($value != 0 ? $wgContLang->getNsText($value) : $this->mainNamespaceText) . " [{$value}]";
break;
case 'average_time':
case 'minimum_time':
case 'maximum_time':
return $value . " s";
break;
case 'wikitext_size':
case 'html_size':
return sprintf("%.1f kb", $value / 1000);
break;
default:
return $value;
}
}
示例11: formatResult
/**
* @param Skin $skin
* @param object $result Result row
* @return string
*/
function formatResult($skin, $result)
{
$title = Title::makeTitle(NS_TEMPLATE, $result->title);
$pageLink = Linker::linkKnown($title, null, array(), array('redirect' => 'no'));
$wlhLink = Linker::linkKnown(SpecialPage::getTitleFor('Whatlinkshere', $title->getPrefixedText()), $this->msg('unusedtemplateswlh')->escaped());
return $this->getLanguage()->specialList($pageLink, $wlhLink);
}
示例12: doTagRow
function doTagRow($tag, $hitcount)
{
static $doneTags = array();
if (in_array($tag, $doneTags)) {
return '';
}
$newRow = '';
$newRow .= Xml::tags('td', null, Xml::element('code', null, $tag));
$disp = ChangeTags::tagDescription($tag);
$disp .= ' ';
$editLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), $this->msg('tags-edit')->escaped());
$disp .= $this->msg('parentheses')->rawParams($editLink)->escaped();
$newRow .= Xml::tags('td', null, $disp);
$msg = $this->msg("tag-{$tag}-description");
$desc = !$msg->exists() ? '' : $msg->parse();
$desc .= ' ';
$editDescLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), $this->msg('tags-edit')->escaped());
$desc .= $this->msg('parentheses')->rawParams($editDescLink)->escaped();
$newRow .= Xml::tags('td', null, $desc);
$hitcount = $this->msg('tags-hitcount')->numParams($hitcount)->escaped();
$hitcount = Linker::link(SpecialPage::getTitleFor('Recentchanges'), $hitcount, array(), array('tagfilter' => $tag));
$newRow .= Xml::tags('td', null, $hitcount);
$doneTags[] = $tag;
return Xml::tags('tr', null, $newRow) . "\n";
}
示例13: formatRow
public function formatRow($row)
{
$title = Title::makeTitle($row->page_namespace, $row->page_title);
// Link to page
$link = Linker::link($title);
// Helpful utility links
$utilLinks = array();
$utilLinks[] = Linker::link($title, wfMsgHtml('stablepages-config'), array(), array('action' => 'protect'), 'known');
$utilLinks[] = Linker::link($title, wfMsgHtml('history'), array(), array('action' => 'history'), 'known');
$utilLinks[] = Linker::link(SpecialPage::getTitleFor('Log', 'stable'), wfMsgHtml('stable-logpage'), array(), array('page' => $title->getPrefixedText()), 'known');
// Autoreview/review restriction level
$restr = '';
if ($row->fpc_level != '') {
$restr = 'autoreview=' . htmlspecialchars($row->fpc_level);
$restr = "[{$restr}]";
}
// When these configuration settings expire
if ($row->fpc_expiry != 'infinity' && strlen($row->fpc_expiry)) {
$expiry_description = " (" . wfMsgForContent('protect-expiring', $this->getLang()->timeanddate($row->fpc_expiry), $this->getLang()->date($row->fpc_expiry), $this->getLang()->time($row->fpc_expiry)) . ")";
} else {
$expiry_description = "";
}
$utilLinks = $this->getLang()->pipeList($utilLinks);
return "<li>{$link} ({$utilLinks}) {$restr}<i>{$expiry_description}</i></li>";
}
示例14: getHTML
/**
* @return string A HTML <li> element representing this revision, showing
* change tags and everything
*/
public function getHTML()
{
$date = htmlspecialchars($this->list->getLanguage()->userTimeAndDate($this->row->log_timestamp, $this->list->getUser()));
$title = Title::makeTitle($this->row->log_namespace, $this->row->log_title);
$formatter = LogFormatter::newFromRow($this->row);
$formatter->setContext($this->list->getContext());
$formatter->setAudience(LogFormatter::FOR_THIS_USER);
// Log link for this page
$loglink = Linker::link(SpecialPage::getTitleFor('Log'), $this->list->msg('log')->escaped(), array(), array('page' => $title->getPrefixedText()));
$loglink = $this->list->msg('parentheses')->rawParams($loglink)->escaped();
// User links and action text
$action = $formatter->getActionText();
// Comment
$comment = $this->list->getLanguage()->getDirMark() . $formatter->getComment();
if (LogEventsList::isDeleted($this->row, LogPage::DELETED_COMMENT)) {
$comment = '<span class="history-deleted">' . $comment . '</span>';
}
$content = "{$loglink} {$date} {$action} {$comment}";
$attribs = array();
$tags = $this->getTags();
if ($tags) {
list($tagSummary, $classes) = ChangeTags::formatSummaryRow($tags, 'edittags', $this->list->getContext());
$content .= " {$tagSummary}";
$attribs['class'] = implode(' ', $classes);
}
return Xml::tags('li', $attribs, $content);
}
示例15: getButtons
function getButtons()
{
$buttons = '';
if ($this->mShowSubmit) {
$attribs = array();
if (isset($this->mSubmitID)) {
$attribs['id'] = $this->mSubmitID;
}
if (isset($this->mSubmitName)) {
$attribs['name'] = $this->mSubmitName;
}
if (isset($this->mSubmitTooltip)) {
$attribs += Linker::tooltipAndAccesskeyAttribs($this->mSubmitTooltip);
}
$attribs['class'] = array('mw-htmlform-submit', 'mw-ui-button mw-ui-big mw-ui-block', $this->mSubmitModifierClass);
$buttons .= Xml::submitButton($this->getSubmitText(), $attribs) . "\n";
}
if ($this->mShowReset) {
$buttons .= Html::element('input', array('type' => 'reset', 'value' => $this->msg('htmlform-reset')->text(), 'class' => 'mw-ui-button mw-ui-big mw-ui-block')) . "\n";
}
foreach ($this->mButtons as $button) {
$attrs = array('type' => 'submit', 'name' => $button['name'], 'value' => $button['value']);
if ($button['attribs']) {
$attrs += $button['attribs'];
}
if (isset($button['id'])) {
$attrs['id'] = $button['id'];
}
$attrs['class'] = isset($attrs['class']) ? (array) $attrs['class'] : array();
$attrs['class'][] = 'mw-ui-button mw-ui-big mw-ui-block';
$buttons .= Html::element('input', $attrs) . "\n";
}
$html = Html::rawElement('div', array('class' => 'mw-htmlform-submit-buttons'), "\n{$buttons}") . "\n";
return $html;
}