Skip to content

Commit e1cb2e1

Browse files
committed
Rearranged some code snippets and fixed and error
Rearranged some parts of the MultiCodeBlock and added a comment.
1 parent 1d70815 commit e1cb2e1

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

includes/MultiCodeBlock.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@
2020
* Returns a string based on the MultiCodeBlock HTML-Element
2121
*
2222
* @param string $input The content of the MultiCodeBlock HTML-Element
23-
* @param array $args The arguments of the MultiCodeBlock HTML-Element
2423
* @param Parser $parser The MediaWiki syntax parser
25-
* @param PPFrame $frame MediaWiki frame
24+
*
25+
* @return string The MultiCodeBlock
2626
*/
2727
function createMultiCodeBlock(string &$input, Parser &$parser) {
28-
$out = $parser->getOutput();
29-
$out->addModuleStyles(['ext.multicodeblock.styles']);
30-
$out->addModules(['ext.multicodeblock.js']);
31-
3228
$code = findCodeBlocks($input);
3329

3430
$replaced = str_replace($code, 'test', $input);
@@ -63,7 +59,7 @@ function createMultiCodeBlock(string &$input, Parser &$parser) {
6359
array_push($languages, $codeblock[1]);
6460
}
6561

66-
return array(createFrame($languages, $return), 'markerType' => 'nowiki');
62+
return createFrame($languages, $return);
6763
}
6864

6965
/**

includes/class/Description.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
* @global array $texts An array of all the different descriptions.
1515
* @global array $keys The lines where the descriptions should start.
1616
*
17-
* @param DOMDocument $dom A string that has the content of the <desc>-element.
17+
* @param $dom A string that has the content of the <desc>-element.
1818
*/
1919
class Description {
2020
public $texts = array();
2121
public $keys = array();
2222

23-
public function __construct(DOMDocument $dom = null) {
23+
public function __construct($dom = null) {
2424
if($dom === null) {
2525
array_push($this->texts, '');
2626
array_push($this->keys, 1);
@@ -47,9 +47,9 @@ public function getNext($index) {
4747
/**
4848
* Inserts the description into the attrributes.
4949
*
50-
* @param DOMDocument $dom A string that has the content of the <desc>-element.
50+
* @param $dom A string that has the content of the <desc>-element.
5151
*/
52-
public function setTexts(DOMDocument &$dom) {
52+
public function setTexts(&$dom) {
5353
$positions = $dom->getElementsByTagName('position');
5454
$numberOfPos = sizeof($positions);
5555

includes/hooks/MultiCodeBlockHooks.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,23 @@ public static function onParserFirstCallInit( Parser &$parser ) {
3030
$parser->setHook( 'multicodeblock', [ self::class, 'renderMultiCodeBlock' ] );
3131
}
3232

33+
/**
34+
* Returns the full MultiCodeBlock with differnt flags and adds specific Modules to the parser.
35+
*
36+
* @param string $input The content of the MultiCodeBlock HTML-Element
37+
* @param array $args The arguments of the MultiCodeBlock HTML-Element
38+
* @param Parser $parser The MediaWiki syntax parser
39+
* @param PPFrame $frame MediaWiki frame
40+
*
41+
* @return array The MultiCodeBlock with flags as an array.
42+
*/
3343
public static function renderMultiCodeBlock(string $input, array $args, Parser $parser, PPFrame $frame) {
3444
require_once __DIR__ . '/../MultiCodeBlock.php';
3545

36-
return createMultiCodeBlock($input, $parser);
46+
$out = $parser->getOutput();
47+
$out->addModuleStyles(['ext.multicodeblock.styles']);
48+
$out->addModules(['ext.multicodeblock.js']);
49+
50+
return [createMultiCodeBlock($input, $parser), 'noparse' => true, 'isHTML' => true, 'markerType' => 'nowiki'];
3751
}
3852
}

0 commit comments

Comments
 (0)