Skip to content

Commit 9a90ba7

Browse files
committed
Resolved nbdd0121#2
1 parent e3907ac commit 9a90ba7

File tree

5 files changed

+50
-7
lines changed

5 files changed

+50
-7
lines changed

Hooks.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class Hooks {
55

6-
public static function onGetPreferences($user, &$preferences) {
6+
public static function onGetPreferences(\User $user, &$preferences) {
77
$link = \Linker::link(\SpecialPage::getTitleFor("UploadAvatar"), wfMsg('uploadavatar'));
88

99
$preferences['editavatar'] = array(
@@ -16,4 +16,20 @@ public static function onGetPreferences($user, &$preferences) {
1616

1717
return true;
1818
}
19+
20+
public static function onSkinBuildSidebar(\Skin $skin, &$bar) {
21+
$relevUser = $skin->getRelevantUser();
22+
if ($relevUser) {
23+
$bar['sidebar-section-extension'][] =
24+
array(
25+
'text' => wfMsg('sidebar-viewavatar'),
26+
'href' => \SpecialPage::getTitleFor('ViewAvatar')->getLocalURL(array(
27+
'user' => $relevUser->getName(),
28+
)),
29+
'id' => 'n-viewavatar',
30+
'active' => '',
31+
);
32+
}
33+
return true;
34+
}
1935
}

extension.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
]
1616
},
1717
"Hooks": {
18-
"GetPreferences": "Avatar\\Hooks::onGetPreferences"
18+
"GetPreferences": "Avatar\\Hooks::onGetPreferences",
19+
"SkinBuildSidebar": "Avatar\\Hooks::onSkinBuildSidebar"
1920
},
2021
"ResourceModules": {
2122
"ext.avatar.upload": {
@@ -36,7 +37,8 @@
3637
"Avatar\\Avatars": "Avatar_body.php",
3738
"Avatar\\Thumbnail": "Thumbnail.php",
3839
"Avatar\\SpecialUpload": "SpecialUpload.php",
39-
"Avatar\\SpecialView": "SpecialView.php"
40+
"Avatar\\SpecialView": "SpecialView.php",
41+
"Avatar\\UploadLogFormatter": "includes/UploadLogFormatter.php"
4042
},
4143
"ResourceFileModulePaths": {
4244
"localBasePath": "",
@@ -62,7 +64,7 @@
6264
"avatar"
6365
],
6466
"LogActionsHandlers": {
65-
"avatar/upload": "LogFormatter",
67+
"avatar/upload": "Avatar\\UploadLogFormatter",
6668
"avatar/delete": "LogFormatter"
6769
},
6870
"config": {

i18n/en.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"log-description-avatar": "This page shows uploads and administrative activities about avatars.",
2222
"logentry-avatar-upload": "$1 uploaded an avatar",
2323
"logentry-avatar-delete": "$1 deleted $3's avatar",
24+
"logentry-avatar-action-view": "View",
2425

2526
"viewavatar": "View Avatars",
2627
"viewavatar-legend": "View Avatars",
@@ -30,7 +31,8 @@
3031
"viewavatar-delete-reason": "Reason: ",
3132
"viewavatar-delete-submit": "Delete",
3233
"viewavatar-noavatar": "* This user does not have an avatar.",
33-
"viewavatar-nouser": "* No such user."
34-
34+
"viewavatar-nouser": "* No such user.",
3535

36+
"sidebar-section-extension": "Extension",
37+
"sidebar-viewavatar": "View Avatar"
3638
}

i18n/zh-hans.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"log-description-avatar": "这个页面显示了头像的上传和管理活动。",
2222
"logentry-avatar-upload": "$1上传了一个头像",
2323
"logentry-avatar-delete": "$1删除了$3的头像",
24+
"logentry-avatar-action-view": "查看",
2425

2526
"viewavatar": "查看头像",
2627
"viewavatar-legend": "查看头像",
@@ -30,5 +31,8 @@
3031
"viewavatar-delete-reason": "理由:",
3132
"viewavatar-delete-submit": "删除",
3233
"viewavatar-noavatar": "* 该用户没有头像。",
33-
"viewavatar-nouser": "* 该用户不存在。"
34+
"viewavatar-nouser": "* 该用户不存在。",
35+
36+
"sidebar-section-extension": "扩展程序",
37+
"sidebar-viewavatar": "查看头像"
3438
}

includes/UploadLogFormatter.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
namespace Avatar;
3+
class UploadLogFormatter extends \LogFormatter {
4+
5+
public function getActionLinks() {
6+
$user = $this->entry->getPerformer();
7+
$view = \Linker::linkKnown(
8+
\SpecialPage::getTitleFor('ViewAvatar'),
9+
$this->msg('logentry-avatar-action-view')->escaped(),
10+
array(),
11+
array(
12+
'user' => $user->getName(),
13+
)
14+
);
15+
return $this->msg('parentheses')->rawParams($view)->escaped();
16+
17+
}
18+
19+
}

0 commit comments

Comments
 (0)