Index: trunk/phase3/includes/Linker.php |
— | — | @@ -99,16 +99,16 @@ |
100 | 100 | * the end of the link. |
101 | 101 | */ |
102 | 102 | function makeLink( $title, $text = '', $query = '', $trail = '' ) { |
103 | | - wfProfileIn( 'Linker::makeLink' ); |
| 103 | + wfProfileIn( __METHOD__ ); |
104 | 104 | $nt = Title::newFromText( $title ); |
105 | | - if ($nt) { |
| 105 | + if ( $nt instanceof Title ) { |
106 | 106 | $result = $this->makeLinkObj( $nt, $text, $query, $trail ); |
107 | 107 | } else { |
108 | 108 | wfDebug( 'Invalid title passed to Linker::makeLink(): "'.$title."\"\n" ); |
109 | 109 | $result = $text == "" ? $title : $text; |
110 | 110 | } |
111 | 111 | |
112 | | - wfProfileOut( 'Linker::makeLink' ); |
| 112 | + wfProfileOut( __METHOD__ ); |
113 | 113 | return $result; |
114 | 114 | } |
115 | 115 | |
— | — | @@ -125,8 +125,8 @@ |
126 | 126 | */ |
127 | 127 | function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') { |
128 | 128 | $nt = Title::newFromText( $title ); |
129 | | - if ($nt) { |
130 | | - return $this->makeKnownLinkObj( Title::newFromText( $title ), $text, $query, $trail, $prefix , $aprops ); |
| 129 | + if ( $nt instanceof Title ) { |
| 130 | + return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix , $aprops ); |
131 | 131 | } else { |
132 | 132 | wfDebug( 'Invalid title passed to Linker::makeKnownLink(): "'.$title."\"\n" ); |
133 | 133 | return $text == '' ? $title : $text; |
— | — | @@ -146,8 +146,8 @@ |
147 | 147 | */ |
148 | 148 | function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) { |
149 | 149 | $nt = Title::newFromText( $title ); |
150 | | - if ($nt) { |
151 | | - return $this->makeBrokenLinkObj( Title::newFromText( $title ), $text, $query, $trail ); |
| 150 | + if ( $nt instanceof Title ) { |
| 151 | + return $this->makeBrokenLinkObj( $nt, $text, $query, $trail ); |
152 | 152 | } else { |
153 | 153 | wfDebug( 'Invalid title passed to Linker::makeBrokenLink(): "'.$title."\"\n" ); |
154 | 154 | return $text == '' ? $title : $text; |
— | — | @@ -167,8 +167,8 @@ |
168 | 168 | */ |
169 | 169 | function makeStubLink( $title, $text = '', $query = '', $trail = '' ) { |
170 | 170 | $nt = Title::newFromText( $title ); |
171 | | - if ($nt) { |
172 | | - return $this->makeStubLinkObj( Title::newFromText( $title ), $text, $query, $trail ); |
| 171 | + if ( $nt instanceof Title ) { |
| 172 | + return $this->makeStubLinkObj( $nt, $text, $query, $trail ); |
173 | 173 | } else { |
174 | 174 | wfDebug( 'Invalid title passed to Linker::makeStubLink(): "'.$title."\"\n" ); |
175 | 175 | return $text == '' ? $title : $text; |
— | — | @@ -191,13 +191,11 @@ |
192 | 192 | */ |
193 | 193 | function makeLinkObj( $nt, $text= '', $query = '', $trail = '', $prefix = '' ) { |
194 | 194 | global $wgUser; |
195 | | - $fname = 'Linker::makeLinkObj'; |
196 | | - wfProfileIn( $fname ); |
| 195 | + wfProfileIn( __METHOD__ ); |
197 | 196 | |
198 | | - # Fail gracefully |
199 | | - if ( ! is_object($nt) ) { |
200 | | - # throw new MWException(); |
201 | | - wfProfileOut( $fname ); |
| 197 | + if ( !$nt instanceof Title ) { |
| 198 | + # Fail gracefully |
| 199 | + wfProfileOut( __METHOD__ ); |
202 | 200 | return "<!-- ERROR -->{$prefix}{$text}{$trail}"; |
203 | 201 | } |
204 | 202 | |
— | — | @@ -217,13 +215,13 @@ |
218 | 216 | } |
219 | 217 | $t = "<a href=\"{$u}\"{$style}>{$text}{$inside}</a>"; |
220 | 218 | |
221 | | - wfProfileOut( $fname ); |
| 219 | + wfProfileOut( __METHOD__ ); |
222 | 220 | return $t; |
223 | 221 | } elseif ( $nt->isAlwaysKnown() ) { |
224 | 222 | # Image links, special page links and self-links with fragements are always known. |
225 | 223 | $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix ); |
226 | 224 | } else { |
227 | | - wfProfileIn( $fname.'-immediate' ); |
| 225 | + wfProfileIn( __METHOD__.'-immediate' ); |
228 | 226 | |
229 | 227 | # Handles links to special pages wich do not exist in the database: |
230 | 228 | if( $nt->getNamespace() == NS_SPECIAL ) { |
— | — | @@ -232,8 +230,8 @@ |
233 | 231 | } else { |
234 | 232 | $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix ); |
235 | 233 | } |
236 | | - wfProfileOut( $fname.'-immediate' ); |
237 | | - wfProfileOut( $fname ); |
| 234 | + wfProfileOut( __METHOD__.'-immediate' ); |
| 235 | + wfProfileOut( __METHOD__ ); |
238 | 236 | return $retVal; |
239 | 237 | } |
240 | 238 | |
— | — | @@ -251,7 +249,7 @@ |
252 | 250 | array( 'page' ), |
253 | 251 | array( 'page_len', |
254 | 252 | 'page_is_redirect' ), |
255 | | - array( 'page_id' => $aid ), $fname ) ; |
| 253 | + array( 'page_id' => $aid ), __METHOD__ ) ; |
256 | 254 | $stub = ( $s !== false && !$s->page_is_redirect && |
257 | 255 | $s->page_len < $threshold ); |
258 | 256 | } |
— | — | @@ -262,9 +260,9 @@ |
263 | 261 | $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix ); |
264 | 262 | } |
265 | 263 | } |
266 | | - wfProfileOut( $fname.'-immediate' ); |
| 264 | + wfProfileOut( __METHOD__.'-immediate' ); |
267 | 265 | } |
268 | | - wfProfileOut( $fname ); |
| 266 | + wfProfileOut( __METHOD__ ); |
269 | 267 | return $retVal; |
270 | 268 | } |
271 | 269 | |
— | — | @@ -283,13 +281,12 @@ |
284 | 282 | * @return the a-element |
285 | 283 | */ |
286 | 284 | function makeKnownLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) { |
| 285 | + wfProfileIn( __METHOD__ ); |
287 | 286 | |
288 | | - $fname = 'Linker::makeKnownLinkObj'; |
289 | | - wfProfileIn( $fname ); |
290 | | - |
291 | | - if ( !is_object( $nt ) ) { |
292 | | - wfProfileOut( $fname ); |
293 | | - return $text; |
| 287 | + if ( !$nt instanceof Title ) { |
| 288 | + # Fail gracefully |
| 289 | + wfProfileOut( __METHOD__ ); |
| 290 | + return "<!-- ERROR -->{$prefix}{$text}{$trail}"; |
294 | 291 | } |
295 | 292 | |
296 | 293 | $u = $nt->escapeLocalURL( $query ); |
— | — | @@ -313,7 +310,7 @@ |
314 | 311 | |
315 | 312 | list( $inside, $trail ) = Linker::splitTrail( $trail ); |
316 | 313 | $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}"; |
317 | | - wfProfileOut( $fname ); |
| 314 | + wfProfileOut( __METHOD__ ); |
318 | 315 | return $r; |
319 | 316 | } |
320 | 317 | |
— | — | @@ -328,15 +325,14 @@ |
329 | 326 | * the end of the link. |
330 | 327 | */ |
331 | 328 | function makeBrokenLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { |
332 | | - # Fail gracefully |
333 | | - if ( ! isset($nt) ) { |
334 | | - # throw new MWException(); |
| 329 | + wfProfileIn( __METHOD__ ); |
| 330 | + |
| 331 | + if ( !$nt instanceof Title ) { |
| 332 | + # Fail gracefully |
| 333 | + wfProfileOut( __METHOD__ ); |
335 | 334 | return "<!-- ERROR -->{$prefix}{$text}{$trail}"; |
336 | 335 | } |
337 | 336 | |
338 | | - $fname = 'Linker::makeBrokenLinkObj'; |
339 | | - wfProfileIn( $fname ); |
340 | | - |
341 | 337 | if( $nt->getNamespace() == NS_SPECIAL ) { |
342 | 338 | $q = $query; |
343 | 339 | } else if ( '' == $query ) { |
— | — | @@ -354,7 +350,7 @@ |
355 | 351 | list( $inside, $trail ) = Linker::splitTrail( $trail ); |
356 | 352 | $s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}"; |
357 | 353 | |
358 | | - wfProfileOut( $fname ); |
| 354 | + wfProfileOut( __METHOD__ ); |
359 | 355 | return $s; |
360 | 356 | } |
361 | 357 | |
— | — | @@ -1103,7 +1099,7 @@ |
1104 | 1100 | /** @todo document */ |
1105 | 1101 | function tocList($toc) { |
1106 | 1102 | global $wgJsMimeType; |
1107 | | - $title = wfMsgHtml('toc') ; |
| 1103 | + $title = wfMsgHtml('toc') ; |
1108 | 1104 | return |
1109 | 1105 | '<table id="toc" class="toc" summary="' . $title .'"><tr><td>' |
1110 | 1106 | . '<div id="toctitle"><h2>' . $title . "</h2></div>\n" |