-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRealnames.php
More file actions
178 lines (156 loc) · 6.06 KB
/
Realnames.php
File metadata and controls
178 lines (156 loc) · 6.06 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
/*
Copyright 2011 Olivier Finlay Beaton. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY Olivier Finlay Beaton ''AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Olivier Finlay Beaton OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Extension to display a user's real name wherever and whenever possible.
* @file
* @ingroup Extensions
* @version 0.3.1
* @authors Olivier Finlay Beaton (olivierbeaton.com)
* @copyright BSD-2-Clause http://www.opensource.org/licenses/BSD-2-Clause
* @note this extension is pay-what-you-want, please consider a purchase at http://olivierbeaton.com/
* @since 2011-09-15, 0.1
* @note requires MediaWiki 1.7.0
* @note coding convention followed: http://www.mediawiki.org/wiki/Manual:Coding_conventions
*/
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This file is a MediaWiki extension, it is not a valid entry point' );
}
/* (not our var to doc)
* extension credits
* @since 2011-09-16, 0.1
*/
$wgExtensionCredits['parserhook'][] = array(
'name' => 'Realnames',
'author' =>array( '[http://olivierbeaton.com/ Olivier Finlay Beaton]', '[https://github.com/LitusProject The Litus Project]' ),
'version' => '0.3.1',
'url' => 'http://www.mediawiki.org/wiki/Extension:Realnames',
'description' => 'Displays a user\'s real name everywhere',
);
/**
* The format to apply to a user link.
* @since 2011-09-15, 0.1
* @see $wgRealnamesFormats
*/
$wgRealnamesLinkStyle = 'replace';
/**
* The format to apply to a user's name in text.
* This typically only replaces User: text in titles
* @since 2011-09-16, 0.1
*/
$wgRealnamesBareStyle = false;
/**
* Do you want to show blank real names?
* If this is false, then it will fall back on a 'replace' username style.
* If true, then in a style like 'append' ( Joe [Joe Cardigan] )you will see: Joe []
* @note User:Joe text will still become Joe.
* @since 2011-09-15, 0.1
*/
$wgRealnamesBlank = false;
/**
* Ability to turn on/off replacement in each area.
* This runs a bit counter to the idea of the extension, to simply replace all
* names on the page, however baring better names handling sometimes turning off
* say (titles) is the only way to go and I don't want people to have to fork/patch
* the code to do so.
* @attention use of opt-outs here is discouraged.
* @since 2011-11-05, 0.1
*/
$wgRealnamesReplacements = array(
'title' => TRUE,
'subtitle' => TRUE,
'personnal' => TRUE,
'body' => TRUE,
);
/**
* Possible styles to pick from, you can define new ones as well.
* The following variables are set:<br>
* \li $1 link start
* \li $2 username
* \li $3 real name
* \li $4 link end
* @note If you want to add markup, you should set $wgRealnamesBareStyle to a style without html (it's doesnt work in bare)
* @since 2011-09-15, 0.1
*/
$wgRealnamesStyles = array(
'standard' => '$1$2$4',
'append' => '$1$2$4 [$3]',
'replace' => '$1$3$4',
'reverse' => '$1$3$4 [$2]',
'dash' => '$1$2$4 – $3',
);
/**
* Allows you to turn off smart behaviour.
* Set the var to FALSE to disable all,
* or turn off individual features.
*/
$wgRealnamesSmart = array(
'same' => TRUE,
);
/**
* extra namespaces names to look for.
* @note do not include the ':'
* @note this is a regexp so escaping may be required.
* @since 2011-09-22, 0.2
*/
$wgRealnamesNamespaces = array();
if ( isset( $wgConfigureAdditionalExtensions ) && is_array( $wgConfigureAdditionalExtensions ) ) {
/* (not our var to doc)
* attempt to tell Extension:Configure how to web configure our extension
* @since 2011-09-22, 0.2
*/
$wgConfigureAdditionalExtensions[] = array(
'name' => 'Realnames',
'settings' => array(
'wgRealnamesLinkStyle' => 'text',
'wgRealnamesBareStyle' => 'bool',
'wgRealnamesBlank' => 'bool',
'wgRealnamesStyles' => 'array',
'wgRealnamesSmart' => 'array',
'wgRealnamesReplacements' => 'array',
'wgRealnamesNamespaces' => 'array',
),
'array' => array(
'wgRealnamesStyles' => 'assoc',
'wgRealnamesSmart' => 'assoc',
'wgRealnamesReplacements' => 'assoc',
'wgRealnamesNamespaces' => 'simple',
),
'schema' => false,
'url' => 'http://www.mediawiki.org/wiki/Extension:Realnames',
);
} // $wgConfigureAdditionalExtensions exists
/* (not our var to doc)
* Our extension class, it will load the first time the core tries to access it
* @since 2011-09-16, 0.1
*/
$wgAutoloadClasses['ExtRealnames'] = __DIR__ . '/Realnames.body.php';
/* (not our var to doc)
* This hook is called before the article is displayed.
* @since 2011-09-16, 0.1
* @see $wgAutoloadClasses for how the class gets defined.
*/
$wgHooks['BeforePageDisplay'][] = 'ExtRealnames::hookBeforePageDisplay';
/* (not our var to doc)
* This hook is called before the user links are displayed.
* @since 2011-09-22, 0.2
* @see $wgAutoloadClasses for how the class gets defined.
*/
$wgHooks['PersonalUrls'][] = 'ExtRealnames::hookPersonalUrls';