This repository has been archived by the owner on May 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SemanticExpressiveness.hooks.php
74 lines (68 loc) · 1.71 KB
/
SemanticExpressiveness.hooks.php
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
72
73
74
<?php
namespace SemEx;
/**
* Hooks used by 'SemanticExpressiveness'
*
* @since 0.1
*
* @file
* @ingroup SemanticExpressiveness
*
* @author Daniel Werner < [email protected] >
*/
Class Hooks {
/**
* For requesting resource loader module for CSS and JavaScript.
* NOTE: We can't add this just within SemExShortQueryResult since it's possible to get a
* short query result from another page which is stored within a SMW property!
*
* @see https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageParserOutput
*
* @param \OutputPage &$out
* @param \ParserOutput $parseroutput
* @return bool true
*/
public static function onOutputPageParserOutput( \OutputPage &$out, \ParserOutput $parseroutput ) {
$out->addModules( 'ext.semex' );
return true;
}
/**
* Parses the whole articles wikitext for SemEx special syntax
*
* @see https://www.mediawiki.org/wiki/Manual:Hooks/InternalParseBeforeSanitize
* (new hook in MW 1.20)
*
* @since 0.1
*
* @param \Parser &$parser
* @param string &$text
*
* @return boolean
*/
public static function onInternalParseBeforeSanitize( \Parser &$parser, &$text ) {
$exprString = new ExpressiveString( $text, $parser, SEMEX_EXPR_PIECE_SQ );
$text = $exprString->getWikiText();
return true;
}
/**
* Register PHPUnit tests.
* @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList
*
* @since 0.1
*
* @param array &$files
*
* @return boolean
*/
public static function registerUnitTests( array &$files ) {
// @codeCoverageIgnoreStart
$testFiles = array(
'ExpressiveString',
);
foreach ( $testFiles as $file ) {
$files[] = __DIR__ . "/tests/phpunit/{$file}Test.php";
}
return true;
// @codeCoverageIgnoreEnd
}
}