You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB
PHP

<?php
namespace Isekai\Widgets;
use MediaWiki\Parser\Parser;
use MediaWiki\Html\Html;
use PPFrame;
class Html5Widget {
public static function createDetails(string $text, array $args, Parser $parser, PPFrame $frame) {
$parser->getOutput()->addModules(['ext.isekai.collapse']);
$allowedAttr = ['class'];
$htmlArgs = array_filter($args, function($k) use($allowedAttr) {
return in_array($k, $allowedAttr);
}, ARRAY_FILTER_USE_KEY);
$content = '';
if ($text) {
$content = Utils::makeParagraph($parser->recursiveTagParse($text, $frame), true);
}
return [Html::rawElement('details', $htmlArgs, $content), "markerType" => 'nowiki'];
}
public static function createSummary(string $text, array $args, Parser $parser, PPFrame $frame) {
$allowedAttr = ['class'];
$htmlArgs = array_filter($args, function($k) use($allowedAttr) {
return in_array($k, $allowedAttr);
}, ARRAY_FILTER_USE_KEY);
$content = '';
if ($text) {
$content = $parser->recursiveTagParse($text, $frame);
}
return [Html::rawElement('summary', $htmlArgs, $content), "markerType" => 'nowiki'];
}
}