Index: trunk/phase3/includes/Action.php |
— | — | @@ -160,6 +160,17 @@ |
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
| 164 | + * Get a Message object with context set |
| 165 | + * Parameters are the same as wfMessage() |
| 166 | + * |
| 167 | + * @return Message object |
| 168 | + */ |
| 169 | + protected final function msg() { |
| 170 | + $params = func_get_args(); |
| 171 | + return call_user_func_array( array( $this->getContext(), 'msg' ), $params ); |
| 172 | + } |
| 173 | + |
| 174 | + /** |
164 | 175 | * Protected constructor: use Action::factory( $action, $page ) to actually build |
165 | 176 | * these things in the real world |
166 | 177 | * @param Page $page |
Index: trunk/phase3/includes/actions/CreditsAction.php |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | wfProfileIn( __METHOD__ ); |
48 | 48 | |
49 | 49 | if ( $this->page->getID() == 0 ) { |
50 | | - $s = wfMsg( 'nocredits' ); |
| 50 | + $s = $this->msg( 'nocredits' )->parse(); |
51 | 51 | } else { |
52 | 52 | $s = $this->getCredits( -1 ); |
53 | 53 | } |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | $s = ''; |
70 | 70 | |
71 | 71 | if ( $cnt != 0 ) { |
72 | | - $s = self::getAuthor( $this->page ); |
| 72 | + $s = $this->getAuthor( $this->page ); |
73 | 73 | if ( $cnt > 1 || $cnt < 0 ) { |
74 | 74 | $s .= ' ' . $this->getContributors( $cnt - 1, $showIfMax ); |
75 | 75 | } |
— | — | @@ -83,20 +83,20 @@ |
84 | 84 | * @param $article Article object |
85 | 85 | * @return String HTML |
86 | 86 | */ |
87 | | - protected static function getAuthor( Page $article ) { |
88 | | - global $wgLang; |
| 87 | + protected function getAuthor( Page $article ) { |
| 88 | + $user = User::newFromName( $article->getUserText(), false ); |
89 | 89 | |
90 | | - $user = User::newFromId( $article->getUser() ); |
91 | | - |
92 | 90 | $timestamp = $article->getTimestamp(); |
93 | 91 | if ( $timestamp ) { |
94 | | - $d = $wgLang->date( $article->getTimestamp(), true ); |
95 | | - $t = $wgLang->time( $article->getTimestamp(), true ); |
| 92 | + $lang = $this->getLang(); |
| 93 | + $d = $lang->date( $article->getTimestamp(), true ); |
| 94 | + $t = $lang->time( $article->getTimestamp(), true ); |
96 | 95 | } else { |
97 | 96 | $d = ''; |
98 | 97 | $t = ''; |
99 | 98 | } |
100 | | - return wfMessage( 'lastmodifiedatby', $d, $t )->rawParams( self::userLink( $user ) )->params( $user->getName() )->escaped(); |
| 99 | + return $this->msg( 'lastmodifiedatby', $d, $t )->rawParams( |
| 100 | + $this->userLink( $user ) )->params( $user->getName() )->escaped(); |
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
— | — | @@ -106,7 +106,7 @@ |
107 | 107 | * @return String: html |
108 | 108 | */ |
109 | 109 | protected function getContributors( $cnt, $showIfMax ) { |
110 | | - global $wgLang, $wgHiddenPrefs; |
| 110 | + global $wgHiddenPrefs; |
111 | 111 | |
112 | 112 | $contributors = $this->page->getContributors(); |
113 | 113 | |
— | — | @@ -116,7 +116,8 @@ |
117 | 117 | if ( $cnt > 0 && $contributors->count() > $cnt ) { |
118 | 118 | $others_link = $this->othersLink(); |
119 | 119 | if ( !$showIfMax ) |
120 | | - return wfMessage( 'othercontribs' )->rawParams( $others_link )->params( $contributors->count() )->escaped(); |
| 120 | + return $this->msg( 'othercontribs' )->rawParams( |
| 121 | + $others_link )->params( $contributors->count() )->escaped(); |
121 | 122 | } |
122 | 123 | |
123 | 124 | $real_names = array(); |
— | — | @@ -127,14 +128,14 @@ |
128 | 129 | foreach ( $contributors as $user ) { |
129 | 130 | $cnt--; |
130 | 131 | if ( $user->isLoggedIn() ) { |
131 | | - $link = self::link( $user ); |
| 132 | + $link = $this->link( $user ); |
132 | 133 | if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) { |
133 | 134 | $real_names[] = $link; |
134 | 135 | } else { |
135 | 136 | $user_names[] = $link; |
136 | 137 | } |
137 | 138 | } else { |
138 | | - $anon_ips[] = self::link( $user ); |
| 139 | + $anon_ips[] = $this->link( $user ); |
139 | 140 | } |
140 | 141 | |
141 | 142 | if ( $cnt == 0 ) { |
— | — | @@ -142,22 +143,24 @@ |
143 | 144 | } |
144 | 145 | } |
145 | 146 | |
| 147 | + $lang = $this->getLang(); |
| 148 | + |
146 | 149 | if ( count( $real_names ) ) { |
147 | | - $real = $wgLang->listToText( $real_names ); |
| 150 | + $real = $lang->listToText( $real_names ); |
148 | 151 | } else { |
149 | 152 | $real = false; |
150 | 153 | } |
151 | 154 | |
152 | 155 | # "ThisSite user(s) A, B and C" |
153 | 156 | if ( count( $user_names ) ) { |
154 | | - $user = wfMessage( 'siteusers' )->rawParams( $wgLang->listToText( $user_names ) )->params( |
| 157 | + $user = $this->msg( 'siteusers' )->rawParams( $lang->listToText( $user_names ) )->params( |
155 | 158 | count( $user_names ) )->escaped(); |
156 | 159 | } else { |
157 | 160 | $user = false; |
158 | 161 | } |
159 | 162 | |
160 | 163 | if ( count( $anon_ips ) ) { |
161 | | - $anon = wfMessage( 'anonusers' )->rawParams( $wgLang->listToText( $anon_ips ) )->params( |
| 164 | + $anon = $this->msg( 'anonusers' )->rawParams( $lang->listToText( $anon_ips ) )->params( |
162 | 165 | count( $anon_ips ) )->escaped(); |
163 | 166 | } else { |
164 | 167 | $anon = false; |
— | — | @@ -174,8 +177,8 @@ |
175 | 178 | $count = count( $fulllist ); |
176 | 179 | # "Based on work by ..." |
177 | 180 | return $count |
178 | | - ? wfMessage( 'othercontribs' )->rawParams( |
179 | | - $wgLang->listToText( $fulllist ) )->params( $count )->escaped() |
| 181 | + ? $this->msg( 'othercontribs' )->rawParams( |
| 182 | + $lang->listToText( $fulllist ) )->params( $count )->escaped() |
180 | 183 | : ''; |
181 | 184 | } |
182 | 185 | |
— | — | @@ -184,7 +187,7 @@ |
185 | 188 | * @param $user User object |
186 | 189 | * @return String: html |
187 | 190 | */ |
188 | | - protected static function link( User $user ) { |
| 191 | + protected function link( User $user ) { |
189 | 192 | global $wgHiddenPrefs; |
190 | 193 | if ( !in_array( 'realname', $wgHiddenPrefs ) && !$user->isAnon() ) { |
191 | 194 | $real = $user->getRealName(); |
— | — | @@ -204,16 +207,16 @@ |
205 | 208 | * @param $user User object |
206 | 209 | * @return String: html |
207 | 210 | */ |
208 | | - protected static function userLink( User $user ) { |
209 | | - $link = self::link( $user ); |
| 211 | + protected function userLink( User $user ) { |
| 212 | + $link = $this->link( $user ); |
210 | 213 | if ( $user->isAnon() ) { |
211 | | - return wfMsgExt( 'anonuser', array( 'parseinline', 'replaceafter' ), $link ); |
| 214 | + return $this->msg( 'anonuser' )->rawParams( $link )->parse(); |
212 | 215 | } else { |
213 | 216 | global $wgHiddenPrefs; |
214 | 217 | if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) { |
215 | 218 | return $link; |
216 | 219 | } else { |
217 | | - return wfMessage( 'siteuser' )->rawParams( $link )->params( $user->getName() )->escaped(); |
| 220 | + return $this->msg( 'siteuser' )->rawParams( $link )->params( $user->getName() )->escaped(); |
218 | 221 | } |
219 | 222 | } |
220 | 223 | } |
— | — | @@ -224,12 +227,11 @@ |
225 | 228 | * @return String: html |
226 | 229 | */ |
227 | 230 | protected function othersLink() { |
228 | | - return Linker::link( |
| 231 | + return Linker::linkKnown( |
229 | 232 | $this->getTitle(), |
230 | | - wfMsgHtml( 'others' ), |
| 233 | + $this->msg( 'others' )->escaped(), |
231 | 234 | array(), |
232 | | - array( 'action' => 'credits' ), |
233 | | - array( 'known' ) |
| 235 | + array( 'action' => 'credits' ) |
234 | 236 | ); |
235 | 237 | } |
236 | 238 | } |