-
Notifications
You must be signed in to change notification settings - Fork 12
/
Hooks.php
57 lines (46 loc) · 1.59 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
<?php
namespace Avatar;
use MediaWiki\MediaWikiServices;
class Hooks {
public static function onGetPreferences(\User $user, &$preferences) {
$link = MediaWikiServices::getInstance()->getLinkRenderer()
->makeLink(\SpecialPage::getTitleFor("UploadAvatar"), wfMessage('uploadavatar')->text());
$preferences['editavatar'] = array(
'type' => 'info',
'raw' => true,
'label-message' => 'prefs-editavatar',
'default' => '<img src="' . Avatars::getLinkFor($user->getName()) . '" width="32"></img> ' . $link,
'section' => 'personal/info',
);
return true;
}
public static function onSidebarBeforeOutput(\Skin $skin, &$sidebar) {
$user = $skin->getRelevantUser();
if ($user) {
$sidebar['TOOLBOX'][] = [
'text' => wfMessage('sidebar-viewavatar')->text(),
'href' => \SpecialPage::getTitleFor('ViewAvatar')->getLocalURL(array(
'user' => $user->getName(),
)),
];
}
}
public static function onBaseTemplateToolbox(\BaseTemplate &$baseTemplate, array &$toolbox) {
if (isset($baseTemplate->data['nav_urls']['viewavatar'])
&& $baseTemplate->data['nav_urls']['viewavatar']) {
$toolbox['viewavatar'] = $baseTemplate->data['nav_urls']['viewavatar'];
$toolbox['viewavatar']['id'] = 't-viewavatar';
}
}
public static function onSetup() {
global $wgAvatarUploadPath, $wgAvatarUploadDirectory;
if ($wgAvatarUploadPath === false) {
global $wgUploadPath;
$wgAvatarUploadPath = $wgUploadPath . '/avatars';
}
if ($wgAvatarUploadDirectory === false) {
global $wgUploadDirectory;
$wgAvatarUploadDirectory = $wgUploadDirectory . '/avatars';
}
}
}