-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMW_EXT_Color.class.php
More file actions
71 lines (59 loc) · 1.38 KB
/
MW_EXT_Color.class.php
File metadata and controls
71 lines (59 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace MediaWiki\Extension\PkgStore;
use OutputPage, Parser, PPFrame, Skin;
/**
* Class MW_EXT_Color
*/
class MW_EXT_Color
{
/**
* Register tag function.
*
* @param Parser $parser
*
* @return bool
* @throws \MWException
*/
public static function onParserFirstCallInit(Parser $parser)
{
$parser->setHook('color', [__CLASS__, 'onRenderTag']);
return true;
}
/**
* Render tag function.
*
* @param $input
* @param array $args
* @param Parser $parser
* @param PPFrame $frame
*
* @return string
*/
public static function onRenderTag($input, array $args, Parser $parser, PPFrame $frame)
{
// Argument: type.
$getType = MW_EXT_Kernel::outClear($args['type'] ?? '' ?: '');
$outType = empty($getType) ? '' : ' style="color:' . $getType . ';"';
// Get content.
$getContent = trim($input);
$outContent = $parser->recursiveTagParse($getContent, $frame);
// Out HTML.
$outHTML = '<span' . $outType . ' class="mw-ext-color">' . $outContent . '</span>';
// Out parser.
$outParser = $outHTML;
return $outParser;
}
/**
* Load resource function.
*
* @param OutputPage $out
* @param Skin $skin
*
* @return bool
*/
public static function onBeforePageDisplay(OutputPage $out, Skin $skin)
{
$out->addModuleStyles(['ext.mw.color.styles']);
return true;
}
}