本文整理汇总了PHP中SpecialPage::getTitleValueFor方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecialPage::getTitleValueFor方法的具体用法?PHP SpecialPage::getTitleValueFor怎么用?PHP SpecialPage::getTitleValueFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpecialPage
的用法示例。
在下文中一共展示了SpecialPage::getTitleValueFor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pageInfo
/**
* Returns page information in an easily-manipulated format. Array keys are used so extensions
* may add additional information in arbitrary positions. Array values are arrays with one
* element to be rendered as a header, arrays with two elements to be rendered as a table row.
*
* @return array
*/
protected function pageInfo()
{
global $wgContLang;
$user = $this->getUser();
$lang = $this->getLanguage();
$title = $this->getTitle();
$id = $title->getArticleID();
$config = $this->context->getConfig();
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
$pageCounts = $this->pageCounts($this->page);
$pageProperties = [];
$props = PageProps::getInstance()->getAllProperties($title);
if (isset($props[$id])) {
$pageProperties = $props[$id];
}
// Basic information
$pageInfo = [];
$pageInfo['header-basic'] = [];
// Display title
$displayTitle = $title->getPrefixedText();
if (isset($pageProperties['displaytitle'])) {
$displayTitle = $pageProperties['displaytitle'];
}
$pageInfo['header-basic'][] = [$this->msg('pageinfo-display-title'), $displayTitle];
// Is it a redirect? If so, where to?
if ($title->isRedirect()) {
$pageInfo['header-basic'][] = [$this->msg('pageinfo-redirectsto'), Linker::link($this->page->getRedirectTarget()) . $this->msg('word-separator')->escaped() . $this->msg('parentheses')->rawParams(Linker::link($this->page->getRedirectTarget(), $this->msg('pageinfo-redirectsto-info')->escaped(), [], ['action' => 'info']))->escaped()];
}
// Default sort key
$sortKey = $title->getCategorySortkey();
if (isset($pageProperties['defaultsort'])) {
$sortKey = $pageProperties['defaultsort'];
}
$sortKey = htmlspecialchars($sortKey);
$pageInfo['header-basic'][] = [$this->msg('pageinfo-default-sort'), $sortKey];
// Page length (in bytes)
$pageInfo['header-basic'][] = [$this->msg('pageinfo-length'), $lang->formatNum($title->getLength())];
// Page ID (number not localised, as it's a database ID)
$pageInfo['header-basic'][] = [$this->msg('pageinfo-article-id'), $id];
// Language in which the page content is (supposed to be) written
$pageLang = $title->getPageLanguage()->getCode();
if ($config->get('PageLanguageUseDB') && $this->getTitle()->userCan('pagelang', $this->getUser())) {
// Link to Special:PageLanguage with pre-filled page title if user has permissions
$titleObj = SpecialPage::getTitleFor('PageLanguage', $title->getPrefixedText());
$langDisp = Linker::link($titleObj, $this->msg('pageinfo-language')->escaped());
} else {
// Display just the message
$langDisp = $this->msg('pageinfo-language')->escaped();
}
$pageInfo['header-basic'][] = [$langDisp, Language::fetchLanguageName($pageLang, $lang->getCode()) . ' ' . $this->msg('parentheses', $pageLang)->escaped()];
// Content model of the page
$modelHtml = htmlspecialchars(ContentHandler::getLocalizedName($title->getContentModel()));
// If the user can change it, add a link to Special:ChangeContentModel
if ($title->quickUserCan('editcontentmodel')) {
$modelHtml .= ' ' . $this->msg('parentheses')->rawParams($linkRenderer->makeLink(SpecialPage::getTitleValueFor('ChangeContentModel', $title->getPrefixedText()), $this->msg('pageinfo-content-model-change')->text()))->escaped();
}
$pageInfo['header-basic'][] = [$this->msg('pageinfo-content-model'), $modelHtml];
if ($title->inNamespace(NS_USER)) {
$pageUser = User::newFromName($title->getRootText());
if ($pageUser && $pageUser->getId() && !$pageUser->isHidden()) {
$pageInfo['header-basic'][] = [$this->msg('pageinfo-user-id'), $pageUser->getId()];
}
}
// Search engine status
$pOutput = new ParserOutput();
if (isset($pageProperties['noindex'])) {
$pOutput->setIndexPolicy('noindex');
}
if (isset($pageProperties['index'])) {
$pOutput->setIndexPolicy('index');
}
// Use robot policy logic
$policy = $this->page->getRobotPolicy('view', $pOutput);
$pageInfo['header-basic'][] = [$this->msg('pageinfo-robot-policy'), $this->msg("pageinfo-robot-{$policy['index']}")];
$unwatchedPageThreshold = $config->get('UnwatchedPageThreshold');
if ($user->isAllowed('unwatchedpages') || $unwatchedPageThreshold !== false && $pageCounts['watchers'] >= $unwatchedPageThreshold) {
// Number of page watchers
$pageInfo['header-basic'][] = [$this->msg('pageinfo-watchers'), $lang->formatNum($pageCounts['watchers'])];
if ($config->get('ShowUpdatedMarker') && isset($pageCounts['visitingWatchers'])) {
$minToDisclose = $config->get('UnwatchedPageSecret');
if ($pageCounts['visitingWatchers'] > $minToDisclose || $user->isAllowed('unwatchedpages')) {
$pageInfo['header-basic'][] = [$this->msg('pageinfo-visiting-watchers'), $lang->formatNum($pageCounts['visitingWatchers'])];
} else {
$pageInfo['header-basic'][] = [$this->msg('pageinfo-visiting-watchers'), $this->msg('pageinfo-few-visiting-watchers')];
}
}
} elseif ($unwatchedPageThreshold !== false) {
$pageInfo['header-basic'][] = [$this->msg('pageinfo-watchers'), $this->msg('pageinfo-few-watchers')->numParams($unwatchedPageThreshold)];
}
// Redirects to this page
$whatLinksHere = SpecialPage::getTitleFor('Whatlinkshere', $title->getPrefixedText());
$pageInfo['header-basic'][] = [Linker::link($whatLinksHere, $this->msg('pageinfo-redirects-name')->escaped(), [], ['hidelinks' => 1, 'hidetrans' => 1, 'hideimages' => $title->getNamespace() == NS_FILE]), $this->msg('pageinfo-redirects-value')->numParams(count($title->getRedirectsHere()))];
// Is it counted as a content page?
//.........这里部分代码省略.........
示例2: normaliseSpecialPage
/**
* @since 1.16.3
* @param LinkTarget $target
* @return LinkTarget
*/
public static function normaliseSpecialPage(LinkTarget $target)
{
if ($target->getNamespace() == NS_SPECIAL && !$target->isExternal()) {
list($name, $subpage) = SpecialPageFactory::resolveAlias($target->getDBkey());
if (!$name) {
return $target;
}
$ret = SpecialPage::getTitleValueFor($name, $subpage, $target->getFragment());
return $ret;
} else {
return $target;
}
}