-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadAloud.php
54 lines (48 loc) · 1.33 KB
/
ReadAloud.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
<?php
class ReadAloud {
/**
* @param OutputPage &$out
* @param Skin &$skin
*/
public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
$out->addModules( 'ext.ReadAloud' );
$out->addModuleStyles( 'ext.ReadAloud.styles' );
}
/**
* @param SkinTemplate $skinTemplate
* @param array &$links
*/
public static function onSkinTemplateNavigationUniversal( SkinTemplate $skinTemplate, array &$links ) {
global $wgReadAloudNamespaces, $wgReadAloudNearEdit;
// Only add the buttons in relevant pages
$skin = $skinTemplate->getSkin();
$title = $skin->getTitle();
if ( !$title->exists() ) {
return;
}
$context = $skin->getContext();
$action = Action::getActionName( $context );
if ( $action !== 'view' ) {
return;
}
$namespace = $title->getNamespace();
if ( !in_array( $namespace, $wgReadAloudNamespaces ) ) {
return;
}
// Define the buttons
$readAloud = [
'id' => 'ca-read-aloud',
'href' => '#',
'text' => wfMessage( 'readaloud-read-aloud' )->plain()
];
$pauseReading = [
'id' => 'ca-pause-reading',
'href' => '#',
'text' => wfMessage( 'readaloud-pause-reading' )->plain()
];
// Add the buttons
$location = $wgReadAloudNearEdit ? 'views' : 'actions';
$links[ $location ]['read-aloud'] = $readAloud;
$links[ $location ]['pause-reading'] = $pauseReading;
}
}