Skip to content

Commit fac3349

Browse files
committed
Little refactoring
1 parent 7de585c commit fac3349

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

includes/MultiCodeBlock.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
* @author QuickWrite
2424
*/
2525
class MultiCodeBlock {
26+
/**
27+
* Sets a hook for the MediaWiki parser to be able to use the <multicodeblock>-Tag in the MediaWiki syntax.
28+
*
29+
* @param Parser &$parser The Parser Element as a reference.
30+
*/
2631
public static function onParserFirstCallInit( Parser &$parser ) {
2732
$parser->setHook( 'multicodeblock', [ self::class, 'renderMultiCodeBlock' ] );
2833
}

includes/utils/HTMLFramework.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,7 @@
77
*/
88

99
/**
10-
* Creates an HTML-Element to warp around the content.
11-
*
12-
* @param string $code The code where the Element should wrap around
13-
* @param int $index The index of the element
14-
* @param string $extra Another class to be added to the element.
15-
*
16-
* @return string The full object.
17-
*/
18-
function createTab(string &$code, int $index, string $extra = 'outer') {
19-
return '<div class="'.$extra.' tab-content '.($index == 0 ? 'tc-active' : '').'" data-tab="'.$index.'">'.$code.'</div>';
20-
}
21-
22-
/**
23-
* Returns the MultiCodeBlock as a whole.
10+
* Returns the MultiCodeBlock as a whole element.
2411
*
2512
* @param array $lang All of the languages of the different codeblocks.
2613
* @param string $code The codeblocks as a whole.
@@ -55,7 +42,7 @@ function createFrame(array &$lang, string &$code, bool $addCopy = true, string $
5542
* @param Parser $parser The parser object by MediaWiki.
5643
* @param Highlighter $h1 The highlighter object.
5744
*
58-
* @return array The codeblock as the first element and the language as the second element.
45+
* @return array Array consisting of the codeblock and the language of the specific codeblock.
5946
*/
6047
function createCodeBlock(array &$codeTags, DOMNodeList &$descriptions, $lang, Parser &$parser, \Highlight\Highlighter &$h1) {
6148
if($lang == null) {
@@ -89,4 +76,17 @@ function createCodeBlock(array &$codeTags, DOMNodeList &$descriptions, $lang, Pa
8976
$return = createFrame($versions, $return, false, 'inner');
9077

9178
return array($return, replaceLang($lang));
92-
}
79+
}
80+
81+
/**
82+
* Creates an HTML-Element to wrap around the content.
83+
*
84+
* @param string $content The content where the Element should wrap around
85+
* @param int $index The index of the element
86+
* @param string $extra Another class to be added to the element.
87+
*
88+
* @return string The full object.
89+
*/
90+
function createTab(string &$content, int $index, string $extra = 'outer') {
91+
return '<div class="'.$extra.' tab-content '.($index == 0 ? 'tc-active' : '').'" data-tab="'.$index.'">'.$content.'</div>';
92+
}

0 commit comments

Comments
 (0)