-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathHooks.php
67 lines (56 loc) · 1.63 KB
/
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
<?php
/**
* GoogleRichCards
* Google Rich Cards metadata generator
*
* PHP version 5.4
*
* @category Extension
* @package GoogleRichCards
* @author Igor Shishkin <me@teran.ru>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link https://github.com/teran/mediawiki-GoogleRichCards
*/
namespace MediaWiki\Extension\GoogleRichCards;
use OutputPage;
use Parser;
use Skin;
class Hooks {
/**
* Handle meta elements and page title modification.
* @link https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay
* @param OutputPage &$out The output page.
* @param Skin &$skin The current skin.
* @return bool
*/
public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin) {
global $wgGoogleRichCardsAnnotateArticles, $wgGoogleRichCardsAnnotateEvents, $wgGoogleRichCardsAnnotateWebSite;
if($wgGoogleRichCardsAnnotateArticles) {
$article = Article::getInstance();
$article->render($out);
}
if($wgGoogleRichCardsAnnotateEvents) {
$event = Event::getInstance();
$event->render($out);
}
if($wgGoogleRichCardsAnnotateWebSite) {
$website = WebSite::getInstance();
$website->render($out);
}
return true;
}
/**
* Handle invocation of article parser
*
* @link https://www.mediawiki.org/wiki/Manual:Hooks/ParserFirstCallInit
* @param Parser &$parser The global parser.
*/
public static function onParserFirstCallInit(Parser &$parser) {
global $wgGoogleRichCardsAnnotateEvents;
if($wgGoogleRichCardsAnnotateEvents) {
$event = Event::getInstance();
$parser->setHook('event', [$event, 'parse']);
}
}
}
?>