|
|
@ -3,6 +3,7 @@ namespace Isekai\Widgets;
|
|
|
|
|
|
|
|
|
|
|
|
use Title;
|
|
|
|
use Title;
|
|
|
|
use Html;
|
|
|
|
use Html;
|
|
|
|
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
|
|
|
|
|
|
class ButtonLinkWidget {
|
|
|
|
class ButtonLinkWidget {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -15,13 +16,13 @@ class ButtonLinkWidget {
|
|
|
|
public static function create($text, $params, \Parser $parser, \PPFrame $frame) {
|
|
|
|
public static function create($text, $params, \Parser $parser, \PPFrame $frame) {
|
|
|
|
$out = $parser->getOutput();
|
|
|
|
$out = $parser->getOutput();
|
|
|
|
$out->addModules([
|
|
|
|
$out->addModules([
|
|
|
|
"ext.isekai.buttonLink"
|
|
|
|
"oojs-ui-core"
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($params['page'])) {
|
|
|
|
if (!empty($params['page'])) {
|
|
|
|
$title = Title::newFromText($params['page']);
|
|
|
|
$title = Title::newFromText($params['page']);
|
|
|
|
if ($title) {
|
|
|
|
if ($title) {
|
|
|
|
$params['href'] = $title->getFullURL();
|
|
|
|
$params['href'] = $title->getLocalURL();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -61,15 +62,32 @@ class ButtonLinkWidget {
|
|
|
|
$flags[] = $type;
|
|
|
|
$flags[] = $type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$flags = implode(' ', $flags);
|
|
|
|
$classList = ['oo-ui-widget', 'oo-ui-widget-enabled', 'oo-ui-buttonElement', 'oo-ui-labelElement', 'oo-ui-buttonWidget'];
|
|
|
|
|
|
|
|
|
|
|
|
$html = Html::element('a', [
|
|
|
|
if ($framed) {
|
|
|
|
'class' => 'isekai-buttonlink',
|
|
|
|
$classList[] = 'oo-ui-buttonElement-framed';
|
|
|
|
'href' => $params['href'] || '#',
|
|
|
|
} else {
|
|
|
|
'target' => $params['target'] || '_self',
|
|
|
|
$classList[] = 'oo-ui-buttonElement-frameless';
|
|
|
|
'data-framed' => $framed ? 'true' : 'false',
|
|
|
|
}
|
|
|
|
'data-flags' => $flags
|
|
|
|
|
|
|
|
], $text);
|
|
|
|
foreach ($flags as $flag) {
|
|
|
|
|
|
|
|
$classList[] = 'oo-ui-flaggedElement-' . $flag;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$html = Html::rawElement('span', ['class' => implode(' ', $classList)],
|
|
|
|
|
|
|
|
Html::rawElement('a', [
|
|
|
|
|
|
|
|
'class' => 'oo-ui-buttonElement-button',
|
|
|
|
|
|
|
|
'role' => 'button',
|
|
|
|
|
|
|
|
'tabindex' => '0',
|
|
|
|
|
|
|
|
'href' => $params['href'] ?? '#',
|
|
|
|
|
|
|
|
'target' => $params['target'] ?? '_self',
|
|
|
|
|
|
|
|
'rel' => 'nofollow'
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
Html::element('span', ['class' => 'oo-ui-iconElement-icon oo-ui-iconElement-noIcon']) .
|
|
|
|
|
|
|
|
Html::element('span', ['class' => 'oo-ui-labelElement-label'], $text) .
|
|
|
|
|
|
|
|
Html::element('span', ['class' => 'oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator'])
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return [$html, "markerType" => 'nowiki'];
|
|
|
|
return [$html, "markerType" => 'nowiki'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|