本文整理汇总了PHP中SpecialPage::getLinkRenderer方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecialPage::getLinkRenderer方法的具体用法?PHP SpecialPage::getLinkRenderer怎么用?PHP SpecialPage::getLinkRenderer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpecialPage
的用法示例。
在下文中一共展示了SpecialPage::getLinkRenderer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserLinks
/**
* Links to different places.
*
* @note This function is also called in DeletedContributionsPage
* @param SpecialPage $sp SpecialPage instance, for context
* @param User $target Target user object
* @return array
*/
public static function getUserLinks(SpecialPage $sp, User $target)
{
$id = $target->getId();
$username = $target->getName();
$userpage = $target->getUserPage();
$talkpage = $target->getTalkPage();
$linkRenderer = $sp->getLinkRenderer();
$tools['user-talk'] = $linkRenderer->makeLink($talkpage, $sp->msg('sp-contributions-talk')->text());
if ($id !== null || $id === null && IP::isIPAddress($username)) {
if ($sp->getUser()->isAllowed('block')) {
# Block / Change block / Unblock links
if ($target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO) {
$tools['block'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Block', $username), $sp->msg('change-blocklink')->text());
$tools['unblock'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Unblock', $username), $sp->msg('unblocklink')->text());
} else {
# User is not blocked
$tools['block'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Block', $username), $sp->msg('blocklink')->text());
}
}
# Block log link
$tools['log-block'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Log', 'block'), $sp->msg('sp-contributions-blocklog')->text(), [], ['page' => $userpage->getPrefixedText()]);
# Suppression log link (bug 59120)
if ($sp->getUser()->isAllowed('suppressionlog')) {
$tools['log-suppression'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Log', 'suppress'), $sp->msg('sp-contributions-suppresslog', $username)->text(), [], ['offender' => $username]);
}
}
# Uploads
$tools['uploads'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Listfiles', $username), $sp->msg('sp-contributions-uploads')->text());
# Other logs link
$tools['logs'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Log', $username), $sp->msg('sp-contributions-logs')->text());
# Add link to deleted user contributions for priviledged users
if ($sp->getUser()->isAllowed('deletedhistory')) {
$tools['deletedcontribs'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('DeletedContributions', $username), $sp->msg('sp-contributions-deleted', $username)->text());
}
# Add a link to change user rights for privileged users
$userrightsPage = new UserrightsPage();
$userrightsPage->setContext($sp->getContext());
if ($userrightsPage->userCanChangeRights($target)) {
$tools['userrights'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Userrights', $username), $sp->msg('sp-contributions-userrights')->text());
}
Hooks::run('ContributionsToolLinks', [$id, $userpage, &$tools, $sp]);
return $tools;
}