|
|
|
@ -13,7 +13,7 @@ use User;
|
|
|
|
|
use EditPage;
|
|
|
|
|
|
|
|
|
|
class Isekai {
|
|
|
|
|
public static function onLoad($output) {
|
|
|
|
|
public static function onLoad(OutputPage $output) {
|
|
|
|
|
$title = $output->getTitle();
|
|
|
|
|
|
|
|
|
|
self::setHeader($output);
|
|
|
|
@ -21,6 +21,10 @@ class Isekai {
|
|
|
|
|
if ($title->inNamespace(NS_USER)) {
|
|
|
|
|
self::onUserPage($output);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($title->inNamespace(NS_MAIN)) {
|
|
|
|
|
self::handleSubpageTitle($output);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function setHeader(OutputPage $outputPage) {
|
|
|
|
@ -168,15 +172,21 @@ HTML
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function onSkinTemplateOutputPageBeforeExec(\SkinTemplate &$skin, \QuickTemplate &$template) {
|
|
|
|
|
if (!$skin->getOutput()->isArticle()) return;
|
|
|
|
|
$title = $skin->getTitle();
|
|
|
|
|
public static function handleSubpageTitle(OutputPage $outputPage) {
|
|
|
|
|
if (!$outputPage->isArticle()) return;
|
|
|
|
|
|
|
|
|
|
$title = $outputPage->getTitle();
|
|
|
|
|
if ($title && $title->isSubpage()) {
|
|
|
|
|
//更改显示的标题
|
|
|
|
|
$titleText = $template->get('title');
|
|
|
|
|
if ($titleText) {
|
|
|
|
|
$template->set('title', basename($titleText));
|
|
|
|
|
$titleText = $title->getPrefixedText();
|
|
|
|
|
|
|
|
|
|
$baseTitleText = basename($titleText);
|
|
|
|
|
$htmlTitle = $outputPage->getHTMLTitle();
|
|
|
|
|
if (strpos($htmlTitle, $baseTitleText) === 0) {
|
|
|
|
|
// 将HTML标题替换为完整标题
|
|
|
|
|
$outputPage->setHTMLTitle($titleText . substr($htmlTitle, strlen($baseTitleText)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//面包屑
|
|
|
|
|
$titlePathList = explode('/', $titleText);
|
|
|
|
|
$titlePathLen = count($titlePathList);
|
|
|
|
@ -189,15 +199,36 @@ HTML
|
|
|
|
|
$breadcrumbsHtml[] = Html::element('li', ['class' => 'active'], $titleName);
|
|
|
|
|
} else {
|
|
|
|
|
$titleSubPath = implode('/', array_slice($titlePathList, 0, $key + 1));
|
|
|
|
|
$breadcrumbsHtml[] = Html::openElement('li') .
|
|
|
|
|
$linkRender->makeLink(Title::newFromText($titleSubPath), $titleName) . Html::closeElement('li');
|
|
|
|
|
$currentTitle = Title::newFromText($titleSubPath);
|
|
|
|
|
if ($currentTitle) {
|
|
|
|
|
$link = $linkRender->makeLink(Title::newFromText($titleSubPath), $titleName);
|
|
|
|
|
} else {
|
|
|
|
|
$link = $titleSubPath;
|
|
|
|
|
}
|
|
|
|
|
$breadcrumbsHtml[] = Html::openElement('li') . $link . Html::closeElement('li');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$breadcrumbsHtml[] = Html::closeElement('ol');
|
|
|
|
|
$template->extend('subtitle', implode($breadcrumbsHtml));
|
|
|
|
|
$html = implode($breadcrumbsHtml);
|
|
|
|
|
|
|
|
|
|
// 阻止出现subtitle空行
|
|
|
|
|
$subtitle = $outputPage->getSubtitle();
|
|
|
|
|
$outputPage->setSubtitle($subtitle . $html);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function onParserBeforeInternalParse(\Parser $parser, &$text, $strip_state) {
|
|
|
|
|
$title = $parser->getPage();
|
|
|
|
|
|
|
|
|
|
if ($title !== null && $title instanceof \Title && $title->isSubpage()) {
|
|
|
|
|
//更改显示的标题
|
|
|
|
|
$titleText = $title->getPrefixedText();
|
|
|
|
|
if ($titleText) {
|
|
|
|
|
$parser->getOutput()->setTitleText('<span class="mw-page-title-main">' . basename($titleText) . '</span>');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function onHtmlPageLinkRendererBegin(
|
|
|
|
|
LinkRenderer $linkRenderer, LinkTarget $target,
|
|
|
|
|
&$text, &$extraAttribs, &$query, &$ret
|
|
|
|
|