-
Notifications
You must be signed in to change notification settings - Fork 1
/
AsteroidOS.hooks.php
41 lines (34 loc) · 1.18 KB
/
AsteroidOS.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
<?php
namespace MediaWiki\Extensions\AsteroidOS;
use MediaWiki\MediaWikiServices;
class Hooks
{
public static function onBeforePageDisplay(\OutputPage &$outputPage, \Skin &$skin)
{
$outputPage->addModuleStyles('zzz.ext.AsteroidOS.styles');
$outputPage->addModules('zzz.ext.AsteroidOS.scripts');
}
public static function onAfterFinalPageOutput(\OutputPage $outputPage)
{
// Insert the navigation right after the <body> element
$out = preg_replace(
'/(<body[^>]*>)/s',
'$1' . self::geAOSNavBar($outputPage->getTitle()),
ob_get_clean()
);
ob_start();
echo $out;
return true;
}
private static function geAOSNavBar(string $title): string
{
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig('asteroidos');
$aosNavBar = $config->get("AOSNavBar");
$aosHome = $config->get("AOSHome");
$aosNavBarSelected = $config->get("AOSNavBarSelected");
$aosNavBarSelectedDefault = $config->get("AOSNavBarSelectedDefault");
ob_start();
include __DIR__ . '/AOSNavBar.php';
return ob_get_clean();
}
}