Index: trunk/phase3/includes/Article.php |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | * @param $title Reference to a Title object. |
49 | 49 | * @param $oldId Integer revision ID, null to fetch from request, zero for current |
50 | 50 | */ |
51 | | - function __construct( Title $title, $oldId = null ) { |
| 51 | + public function __construct( Title $title, $oldId = null ) { |
52 | 52 | $this->mTitle =& $title; |
53 | 53 | $this->mOldId = $oldId; |
54 | 54 | } |
— | — | @@ -58,7 +58,6 @@ |
59 | 59 | */ |
60 | 60 | public static function newFromID( $id ) { |
61 | 61 | $t = Title::newFromID( $id ); |
62 | | - |
63 | 62 | return $t == null ? null : new Article( $t ); |
64 | 63 | } |
65 | 64 | |
— | — | @@ -67,7 +66,7 @@ |
68 | 67 | * from another page on the wiki. |
69 | 68 | * @param $from Title object. |
70 | 69 | */ |
71 | | - function setRedirectedFrom( $from ) { |
| 70 | + public function setRedirectedFrom( $from ) { |
72 | 71 | $this->mRedirectedFrom = $from; |
73 | 72 | } |
74 | 73 | |
— | — | @@ -79,22 +78,20 @@ |
80 | 79 | * @return mixed Title object, or null if this page is not a redirect |
81 | 80 | */ |
82 | 81 | public function getRedirectTarget() { |
83 | | - if(!$this->mTitle || !$this->mTitle->isRedirect()) |
| 82 | + if( !$this->mTitle || !$this->mTitle->isRedirect() ) |
84 | 83 | return null; |
85 | | - if(!is_null($this->mRedirectTarget)) |
| 84 | + if( !is_null($this->mRedirectTarget) ) |
86 | 85 | return $this->mRedirectTarget; |
87 | | - |
88 | 86 | # Query the redirect table |
89 | | - $dbr = wfGetDB(DB_SLAVE); |
90 | | - $res = $dbr->select('redirect', |
91 | | - array('rd_namespace', 'rd_title'), |
92 | | - array('rd_from' => $this->getID()), |
93 | | - __METHOD__ |
| 87 | + $dbr = wfGetDB( DB_SLAVE ); |
| 88 | + $res = $dbr->select( 'redirect', |
| 89 | + array('rd_namespace', 'rd_title'), |
| 90 | + array('rd_from' => $this->getID()), |
| 91 | + __METHOD__ |
94 | 92 | ); |
95 | | - $row = $dbr->fetchObject($res); |
96 | | - if($row) |
| 93 | + if( $row = $dbr->fetchObject($res) ) { |
97 | 94 | return $this->mRedirectTarget = Title::makeTitle($row->rd_namespace, $row->rd_title); |
98 | | - |
| 95 | + } |
99 | 96 | # This page doesn't have an entry in the redirect table |
100 | 97 | return $this->mRedirectTarget = $this->insertRedirect(); |
101 | 98 | } |
— | — | @@ -106,15 +103,19 @@ |
107 | 104 | * @return Title object |
108 | 105 | */ |
109 | 106 | public function insertRedirect() { |
110 | | - $retval = Title::newFromRedirect($this->getContent()); |
111 | | - if(!$retval) |
| 107 | + $retval = Title::newFromRedirect( $this->getContent() ); |
| 108 | + if( !$retval ) { |
112 | 109 | return null; |
113 | | - $dbw = wfGetDB(DB_MASTER); |
114 | | - $dbw->replace('redirect', array('rd_from'), array( |
| 110 | + } |
| 111 | + $dbw = wfGetDB( DB_MASTER ); |
| 112 | + $dbw->replace( 'redirect', array('rd_from'), |
| 113 | + array( |
115 | 114 | 'rd_from' => $this->getID(), |
116 | 115 | 'rd_namespace' => $retval->getNamespace(), |
117 | 116 | 'rd_title' => $retval->getDBKey() |
118 | | - ), __METHOD__); |
| 117 | + ), |
| 118 | + __METHOD__ |
| 119 | + ); |
119 | 120 | return $retval; |
120 | 121 | } |
121 | 122 | |
— | — | @@ -143,7 +144,6 @@ |
144 | 145 | // |
145 | 146 | // This can be hard to reverse and may produce loops, |
146 | 147 | // so they may be disabled in the site configuration. |
147 | | - |
148 | 148 | $source = $this->mTitle->getFullURL( 'redirect=no' ); |
149 | 149 | return $rt->getFullURL( 'rdfrom=' . urlencode( $source ) ); |
150 | 150 | } |
— | — | @@ -154,7 +154,6 @@ |
155 | 155 | // the rest of the page we're on. |
156 | 156 | // |
157 | 157 | // This can be hard to reverse, so they may be disabled. |
158 | | - |
159 | 158 | if( $rt->isSpecial( 'Userlogout' ) ) { |
160 | 159 | // rolleyes |
161 | 160 | } else { |
— | — | @@ -171,7 +170,7 @@ |
172 | 171 | /** |
173 | 172 | * get the title object of the article |
174 | 173 | */ |
175 | | - function getTitle() { |
| 174 | + public function getTitle() { |
176 | 175 | return $this->mTitle; |
177 | 176 | } |
178 | 177 | |
— | — | @@ -179,7 +178,7 @@ |
180 | 179 | * Clear the object |
181 | 180 | * @private |
182 | 181 | */ |
183 | | - function clear() { |
| 182 | + public function clear() { |
184 | 183 | $this->mDataLoaded = false; |
185 | 184 | $this->mContentLoaded = false; |
186 | 185 | |
— | — | @@ -202,30 +201,23 @@ |
203 | 202 | * Note that getContent/loadContent do not follow redirects anymore. |
204 | 203 | * If you need to fetch redirectable content easily, try |
205 | 204 | * the shortcut in Article::followContent() |
206 | | - * FIXME |
207 | | - * @todo There are still side-effects in this! |
208 | | - * In general, you should use the Revision class, not Article, |
209 | | - * to fetch text for purposes other than page views. |
210 | 205 | * |
211 | 206 | * @return Return the text of this revision |
212 | 207 | */ |
213 | | - function getContent() { |
| 208 | + public function getContent() { |
214 | 209 | global $wgUser, $wgOut, $wgMessageCache; |
215 | | - |
216 | 210 | wfProfileIn( __METHOD__ ); |
217 | | - |
218 | | - if ( 0 == $this->getID() ) { |
219 | | - wfProfileOut( __METHOD__ ); |
220 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
221 | | - |
222 | | - if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| 211 | + if( $this->getID() === 0 ) { |
| 212 | + # If this is a MediaWiki:x message, then load the messages |
| 213 | + # and return the message value for x. |
| 214 | + if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
223 | 215 | $wgMessageCache->loadAllMessages(); |
224 | | - $ret = wfMsgWeirdKey ( $this->mTitle->getText() ) ; |
| 216 | + $text = wfMsgWeirdKey( $this->mTitle->getText() ) ; |
225 | 217 | } else { |
226 | | - $ret = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ); |
| 218 | + $text = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ); |
227 | 219 | } |
228 | | - |
229 | | - return "<div class='noarticletext'>\n$ret\n</div>"; |
| 220 | + wfProfileOut( __METHOD__ ); |
| 221 | + return $text; |
230 | 222 | } else { |
231 | 223 | $this->loadContent(); |
232 | 224 | wfProfileOut( __METHOD__ ); |
— | — | @@ -245,7 +237,7 @@ |
246 | 238 | * @return string text of the requested section |
247 | 239 | * @deprecated |
248 | 240 | */ |
249 | | - function getSection($text,$section) { |
| 241 | + public function getSection( $text, $section ) { |
250 | 242 | global $wgParser; |
251 | 243 | return $wgParser->getSection( $text, $section ); |
252 | 244 | } |
— | — | @@ -254,8 +246,8 @@ |
255 | 247 | * @return int The oldid of the article that is to be shown, 0 for the |
256 | 248 | * current revision |
257 | 249 | */ |
258 | | - function getOldID() { |
259 | | - if ( is_null( $this->mOldId ) ) { |
| 250 | + public function getOldID() { |
| 251 | + if( is_null( $this->mOldId ) ) { |
260 | 252 | $this->mOldId = $this->getOldIDFromRequest(); |
261 | 253 | } |
262 | 254 | return $this->mOldId; |
— | — | @@ -270,28 +262,23 @@ |
271 | 263 | global $wgRequest; |
272 | 264 | $this->mRedirectUrl = false; |
273 | 265 | $oldid = $wgRequest->getVal( 'oldid' ); |
274 | | - if ( isset( $oldid ) ) { |
| 266 | + if( isset( $oldid ) ) { |
275 | 267 | $oldid = intval( $oldid ); |
276 | | - if ( $wgRequest->getVal( 'direction' ) == 'next' ) { |
| 268 | + if( $wgRequest->getVal( 'direction' ) == 'next' ) { |
277 | 269 | $nextid = $this->mTitle->getNextRevisionID( $oldid ); |
278 | | - if ( $nextid ) { |
| 270 | + if( $nextid ) { |
279 | 271 | $oldid = $nextid; |
280 | 272 | } else { |
281 | 273 | $this->mRedirectUrl = $this->mTitle->getFullURL( 'redirect=no' ); |
282 | 274 | } |
283 | | - } elseif ( $wgRequest->getVal( 'direction' ) == 'prev' ) { |
| 275 | + } elseif( $wgRequest->getVal( 'direction' ) == 'prev' ) { |
284 | 276 | $previd = $this->mTitle->getPreviousRevisionID( $oldid ); |
285 | | - if ( $previd ) { |
| 277 | + if( $previd ) { |
286 | 278 | $oldid = $previd; |
287 | | - } else { |
288 | | - # TODO |
289 | 279 | } |
290 | 280 | } |
291 | | - # unused: |
292 | | - # $lastid = $oldid; |
293 | 281 | } |
294 | | - |
295 | | - if ( !$oldid ) { |
| 282 | + if( !$oldid ) { |
296 | 283 | $oldid = 0; |
297 | 284 | } |
298 | 285 | return $oldid; |
— | — | @@ -301,15 +288,15 @@ |
302 | 289 | * Load the revision (including text) into this object |
303 | 290 | */ |
304 | 291 | function loadContent() { |
305 | | - if ( $this->mContentLoaded ) return; |
306 | | - |
| 292 | + if( $this->mContentLoaded ) return; |
| 293 | + wfProfileIn( __METHOD__ ); |
307 | 294 | # Query variables :P |
308 | 295 | $oldid = $this->getOldID(); |
309 | | - |
310 | 296 | # Pre-fill content with error message so that if something |
311 | 297 | # fails we'll have something telling us what we intended. |
312 | 298 | $this->mOldId = $oldid; |
313 | 299 | $this->fetchContent( $oldid ); |
| 300 | + wfProfileOut( __METHOD__ ); |
314 | 301 | } |
315 | 302 | |
316 | 303 | |
— | — | @@ -317,9 +304,8 @@ |
318 | 305 | * Fetch a page record with the given conditions |
319 | 306 | * @param Database $dbr |
320 | 307 | * @param array $conditions |
321 | | - * @private |
322 | 308 | */ |
323 | | - function pageData( $dbr, $conditions ) { |
| 309 | + protected function pageData( $dbr, $conditions ) { |
324 | 310 | $fields = array( |
325 | 311 | 'page_id', |
326 | 312 | 'page_namespace', |
— | — | @@ -348,7 +334,7 @@ |
349 | 335 | * @param Database $dbr |
350 | 336 | * @param Title $title |
351 | 337 | */ |
352 | | - function pageDataFromTitle( $dbr, $title ) { |
| 338 | + public function pageDataFromTitle( $dbr, $title ) { |
353 | 339 | return $this->pageData( $dbr, array( |
354 | 340 | 'page_namespace' => $title->getNamespace(), |
355 | 341 | 'page_title' => $title->getDBkey() ) ); |
— | — | @@ -358,7 +344,7 @@ |
359 | 345 | * @param Database $dbr |
360 | 346 | * @param int $id |
361 | 347 | */ |
362 | | - function pageDataFromId( $dbr, $id ) { |
| 348 | + protected function pageDataFromId( $dbr, $id ) { |
363 | 349 | return $this->pageData( $dbr, array( 'page_id' => $id ) ); |
364 | 350 | } |
365 | 351 | |
— | — | @@ -367,16 +353,15 @@ |
368 | 354 | * some source. |
369 | 355 | * |
370 | 356 | * @param object $data |
371 | | - * @private |
372 | 357 | */ |
373 | | - function loadPageData( $data = 'fromdb' ) { |
374 | | - if ( $data === 'fromdb' ) { |
| 358 | + public function loadPageData( $data = 'fromdb' ) { |
| 359 | + if( $data === 'fromdb' ) { |
375 | 360 | $dbr = wfGetDB( DB_MASTER ); |
376 | 361 | $data = $this->pageDataFromId( $dbr, $this->getId() ); |
377 | 362 | } |
378 | 363 | |
379 | 364 | $lc = LinkCache::singleton(); |
380 | | - if ( $data ) { |
| 365 | + if( $data ) { |
381 | 366 | $lc->addGoodLinkObj( $data->page_id, $this->mTitle, $data->page_len, $data->page_is_redirect ); |
382 | 367 | |
383 | 368 | $this->mTitle->mArticleID = $data->page_id; |
— | — | @@ -389,7 +374,7 @@ |
390 | 375 | $this->mIsRedirect = $data->page_is_redirect; |
391 | 376 | $this->mLatest = $data->page_latest; |
392 | 377 | } else { |
393 | | - if ( is_object( $this->mTitle ) ) { |
| 378 | + if( is_object( $this->mTitle ) ) { |
394 | 379 | $lc->addBadLinkObj( $this->mTitle ); |
395 | 380 | } |
396 | 381 | $this->mTitle->mArticleID = 0; |
— | — | @@ -405,7 +390,7 @@ |
406 | 391 | * @return string |
407 | 392 | */ |
408 | 393 | function fetchContent( $oldid = 0 ) { |
409 | | - if ( $this->mContentLoaded ) { |
| 394 | + if( $this->mContentLoaded ) { |
410 | 395 | return $this->mContent; |
411 | 396 | } |
412 | 397 | |
— | — | @@ -469,7 +454,7 @@ |
470 | 455 | * |
471 | 456 | * @param $x Mixed: FIXME |
472 | 457 | */ |
473 | | - function forUpdate( $x = NULL ) { |
| 458 | + public function forUpdate( $x = NULL ) { |
474 | 459 | return wfSetVar( $this->mForUpdate, $x ); |
475 | 460 | } |
476 | 461 | |
— | — | @@ -491,9 +476,9 @@ |
492 | 477 | * the default |
493 | 478 | * @return Array: options |
494 | 479 | */ |
495 | | - function getSelectOptions( $options = '' ) { |
496 | | - if ( $this->mForUpdate ) { |
497 | | - if ( is_array( $options ) ) { |
| 480 | + protected function getSelectOptions( $options = '' ) { |
| 481 | + if( $this->mForUpdate ) { |
| 482 | + if( is_array( $options ) ) { |
498 | 483 | $options[] = 'FOR UPDATE'; |
499 | 484 | } else { |
500 | 485 | $options = 'FOR UPDATE'; |
— | — | @@ -505,7 +490,7 @@ |
506 | 491 | /** |
507 | 492 | * @return int Page ID |
508 | 493 | */ |
509 | | - function getID() { |
| 494 | + public function getID() { |
510 | 495 | if( $this->mTitle ) { |
511 | 496 | return $this->mTitle->getArticleID(); |
512 | 497 | } else { |
— | — | @@ -516,22 +501,26 @@ |
517 | 502 | /** |
518 | 503 | * @return bool Whether or not the page exists in the database |
519 | 504 | */ |
520 | | - function exists() { |
521 | | - return $this->getId() != 0; |
| 505 | + public function exists() { |
| 506 | + return $this->getId() > 0; |
522 | 507 | } |
523 | 508 | |
524 | 509 | /** |
525 | 510 | * @return int The view count for the page |
526 | 511 | */ |
527 | | - function getCount() { |
528 | | - if ( -1 == $this->mCounter ) { |
| 512 | + public function getCount() { |
| 513 | + if( -1 == $this->mCounter ) { |
529 | 514 | $id = $this->getID(); |
530 | | - if ( $id == 0 ) { |
| 515 | + if( $id == 0 ) { |
531 | 516 | $this->mCounter = 0; |
532 | 517 | } else { |
533 | 518 | $dbr = wfGetDB( DB_SLAVE ); |
534 | | - $this->mCounter = $dbr->selectField( 'page', 'page_counter', array( 'page_id' => $id ), |
535 | | - 'Article::getCount', $this->getSelectOptions() ); |
| 519 | + $this->mCounter = $dbr->selectField( 'page', |
| 520 | + 'page_counter', |
| 521 | + array( 'page_id' => $id ), |
| 522 | + __METHOD__, |
| 523 | + $this->getSelectOptions() |
| 524 | + ); |
536 | 525 | } |
537 | 526 | } |
538 | 527 | return $this->mCounter; |
— | — | @@ -544,14 +533,11 @@ |
545 | 534 | * @param $text String: text to analyze |
546 | 535 | * @return bool |
547 | 536 | */ |
548 | | - function isCountable( $text ) { |
| 537 | + public function isCountable( $text ) { |
549 | 538 | global $wgUseCommaCount; |
550 | 539 | |
551 | 540 | $token = $wgUseCommaCount ? ',' : '[['; |
552 | | - return |
553 | | - $this->mTitle->isContentPage() |
554 | | - && !$this->isRedirect( $text ) |
555 | | - && in_string( $token, $text ); |
| 541 | + return $this->mTitle->isContentPage() && !$this->isRedirect($text) && in_string($token,$text); |
556 | 542 | } |
557 | 543 | |
558 | 544 | /** |
— | — | @@ -560,11 +546,11 @@ |
561 | 547 | * @param $text String: FIXME |
562 | 548 | * @return bool |
563 | 549 | */ |
564 | | - function isRedirect( $text = false ) { |
565 | | - if ( $text === false ) { |
566 | | - if ( $this->mDataLoaded ) |
| 550 | + public function isRedirect( $text = false ) { |
| 551 | + if( $text === false ) { |
| 552 | + if( $this->mDataLoaded ) { |
567 | 553 | return $this->mIsRedirect; |
568 | | - |
| 554 | + } |
569 | 555 | // Apparently loadPageData was never called |
570 | 556 | $this->loadContent(); |
571 | 557 | $titleObj = Title::newFromRedirect( $this->fetchContent() ); |
— | — | @@ -579,28 +565,25 @@ |
580 | 566 | * to this page (and it exists). |
581 | 567 | * @return bool |
582 | 568 | */ |
583 | | - function isCurrent() { |
| 569 | + public function isCurrent() { |
584 | 570 | # If no oldid, this is the current version. |
585 | | - if ($this->getOldID() == 0) |
| 571 | + if( $this->getOldID() == 0 ) { |
586 | 572 | return true; |
587 | | - |
588 | | - return $this->exists() && |
589 | | - isset( $this->mRevision ) && |
590 | | - $this->mRevision->isCurrent(); |
| 573 | + } |
| 574 | + return $this->exists() && isset($this->mRevision) && $this->mRevision->isCurrent(); |
591 | 575 | } |
592 | 576 | |
593 | 577 | /** |
594 | 578 | * Loads everything except the text |
595 | 579 | * This isn't necessary for all uses, so it's only done if needed. |
596 | | - * @private |
597 | 580 | */ |
598 | | - function loadLastEdit() { |
599 | | - if ( -1 != $this->mUser ) |
| 581 | + protected function loadLastEdit() { |
| 582 | + if( -1 != $this->mUser ) |
600 | 583 | return; |
601 | 584 | |
602 | 585 | # New or non-existent articles have no user information |
603 | 586 | $id = $this->getID(); |
604 | | - if ( 0 == $id ) return; |
| 587 | + if( 0 == $id ) return; |
605 | 588 | |
606 | 589 | $this->mLastRevision = Revision::loadFromPageId( wfGetDB( DB_MASTER ), $id ); |
607 | 590 | if( !is_null( $this->mLastRevision ) ) { |
— | — | @@ -613,35 +596,36 @@ |
614 | 597 | } |
615 | 598 | } |
616 | 599 | |
617 | | - function getTimestamp() { |
| 600 | + public function getTimestamp() { |
618 | 601 | // Check if the field has been filled by ParserCache::get() |
619 | | - if ( !$this->mTimestamp ) { |
| 602 | + if( !$this->mTimestamp ) { |
620 | 603 | $this->loadLastEdit(); |
621 | 604 | } |
622 | 605 | return wfTimestamp(TS_MW, $this->mTimestamp); |
623 | 606 | } |
624 | 607 | |
625 | | - function getUser() { |
| 608 | + public function getUser() { |
626 | 609 | $this->loadLastEdit(); |
627 | 610 | return $this->mUser; |
628 | 611 | } |
629 | 612 | |
630 | | - function getUserText() { |
| 613 | + public function getUserText() { |
631 | 614 | $this->loadLastEdit(); |
632 | 615 | return $this->mUserText; |
633 | 616 | } |
634 | 617 | |
635 | | - function getComment() { |
| 618 | + public function getComment() { |
636 | 619 | $this->loadLastEdit(); |
637 | 620 | return $this->mComment; |
638 | 621 | } |
639 | 622 | |
640 | | - function getMinorEdit() { |
| 623 | + public function getMinorEdit() { |
641 | 624 | $this->loadLastEdit(); |
642 | 625 | return $this->mMinorEdit; |
643 | 626 | } |
644 | 627 | |
645 | | - function getRevIdFetched() { |
| 628 | + /* Use this to fetch the rev ID used on page views */ |
| 629 | + public function getRevIdFetched() { |
646 | 630 | $this->loadLastEdit(); |
647 | 631 | return $this->mRevIdFetched; |
648 | 632 | } |
— | — | @@ -650,7 +634,7 @@ |
651 | 635 | * @param $limit Integer: default 0. |
652 | 636 | * @param $offset Integer: default 0. |
653 | 637 | */ |
654 | | - function getContributors($limit = 0, $offset = 0) { |
| 638 | + public function getContributors($limit = 0, $offset = 0) { |
655 | 639 | # XXX: this is expensive; cache this info somewhere. |
656 | 640 | |
657 | 641 | $contribs = array(); |
— | — | @@ -667,8 +651,8 @@ |
668 | 652 | GROUP BY rev_user, rev_user_text, user_real_name |
669 | 653 | ORDER BY timestamp DESC"; |
670 | 654 | |
671 | | - if ($limit > 0) { $sql .= ' LIMIT '.$limit; } |
672 | | - if ($offset > 0) { $sql .= ' OFFSET '.$offset; } |
| 655 | + if($limit > 0) { $sql .= ' LIMIT '.$limit; } |
| 656 | + if($offset > 0) { $sql .= ' OFFSET '.$offset; } |
673 | 657 | |
674 | 658 | $sql .= ' '. $this->getSelectOptions(); |
675 | 659 | |
— | — | @@ -681,7 +665,7 @@ |
682 | 666 | * This is the default action of the script: just view the page of |
683 | 667 | * the given title. |
684 | 668 | */ |
685 | | - function view() { |
| 669 | + public function view() { |
686 | 670 | global $wgUser, $wgOut, $wgRequest, $wgContLang; |
687 | 671 | global $wgEnableParserCache, $wgStylePath, $wgParser; |
688 | 672 | global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies; |
— | — | @@ -697,7 +681,7 @@ |
698 | 682 | $oldid = $this->getOldID(); |
699 | 683 | |
700 | 684 | # getOldID may want us to redirect somewhere else |
701 | | - if ( $this->mRedirectUrl ) { |
| 685 | + if( $this->mRedirectUrl ) { |
702 | 686 | $wgOut->redirect( $this->mRedirectUrl ); |
703 | 687 | wfProfileOut( __METHOD__ ); |
704 | 688 | return; |
— | — | @@ -714,7 +698,7 @@ |
715 | 699 | # Discourage indexing of printable versions, but encourage following |
716 | 700 | if( $wgOut->isPrintable() ) { |
717 | 701 | $policy = 'noindex,follow'; |
718 | | - } elseif ( isset( $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()] ) ) { |
| 702 | + } elseif( isset( $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()] ) ) { |
719 | 703 | $policy = $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()]; |
720 | 704 | } elseif( isset( $wgNamespaceRobotPolicies[$ns] ) ) { |
721 | 705 | # Honour customised robot policies for this namespace |
— | — | @@ -727,7 +711,7 @@ |
728 | 712 | # If we got diff and oldid in the query, we want to see a |
729 | 713 | # diff page instead of the article. |
730 | 714 | |
731 | | - if ( !is_null( $diff ) ) { |
| 715 | + if( !is_null( $diff ) ) { |
732 | 716 | $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); |
733 | 717 | |
734 | 718 | $diff = $wgRequest->getVal( 'diff' ); |
— | — | @@ -747,13 +731,13 @@ |
748 | 732 | return; |
749 | 733 | } |
750 | 734 | |
751 | | - if ( empty( $oldid ) && $this->checkTouched() ) { |
| 735 | + if( empty( $oldid ) && $this->checkTouched() ) { |
752 | 736 | $wgOut->setETag($parserCache->getETag($this, $wgUser)); |
753 | 737 | |
754 | 738 | if( $wgOut->checkLastModified( $this->mTouched ) ){ |
755 | 739 | wfProfileOut( __METHOD__ ); |
756 | 740 | return; |
757 | | - } else if ( $this->tryFileCache() ) { |
| 741 | + } else if( $this->tryFileCache() ) { |
758 | 742 | # tell wgOut that output is taken care of |
759 | 743 | $wgOut->disable(); |
760 | 744 | $this->viewUpdates(); |
— | — | @@ -765,27 +749,27 @@ |
766 | 750 | # Should the parser cache be used? |
767 | 751 | $pcache = $this->useParserCache( $oldid ); |
768 | 752 | wfDebug( 'Article::view using parser cache: ' . ($pcache ? 'yes' : 'no' ) . "\n" ); |
769 | | - if ( $wgUser->getOption( 'stubthreshold' ) ) { |
| 753 | + if( $wgUser->getOption( 'stubthreshold' ) ) { |
770 | 754 | wfIncrStats( 'pcache_miss_stub' ); |
771 | 755 | } |
772 | 756 | |
773 | 757 | $wasRedirected = false; |
774 | | - if ( isset( $this->mRedirectedFrom ) ) { |
| 758 | + if( isset( $this->mRedirectedFrom ) ) { |
775 | 759 | // This is an internally redirected page view. |
776 | 760 | // We'll need a backlink to the source page for navigation. |
777 | | - if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) { |
| 761 | + if( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) { |
778 | 762 | $redir = $sk->makeKnownLinkObj( $this->mRedirectedFrom, '', 'redirect=no' ); |
779 | 763 | $s = wfMsg( 'redirectedfrom', $redir ); |
780 | 764 | $wgOut->setSubtitle( $s ); |
781 | 765 | |
782 | 766 | // Set the fragment if one was specified in the redirect |
783 | | - if ( strval( $this->mTitle->getFragment() ) != '' ) { |
| 767 | + if( strval( $this->mTitle->getFragment() ) != '' ) { |
784 | 768 | $fragment = Xml::escapeJsString( $this->mTitle->getFragmentForURL() ); |
785 | 769 | $wgOut->addInlineScript( "redirectToFragment(\"$fragment\");" ); |
786 | 770 | } |
787 | 771 | $wasRedirected = true; |
788 | 772 | } |
789 | | - } elseif ( !empty( $rdfrom ) ) { |
| 773 | + } elseif( !empty( $rdfrom ) ) { |
790 | 774 | // This is an externally redirected view, from some other wiki. |
791 | 775 | // If it was reported from a trusted site, supply a backlink. |
792 | 776 | global $wgRedirectSources; |
— | — | @@ -799,44 +783,20 @@ |
800 | 784 | |
801 | 785 | $outputDone = false; |
802 | 786 | wfRunHooks( 'ArticleViewHeader', array( &$this, &$outputDone, &$pcache ) ); |
803 | | - if ( $pcache ) { |
804 | | - if ( $wgOut->tryParserCache( $this, $wgUser ) ) { |
805 | | - // Ensure that UI elements requiring revision ID have |
806 | | - // the correct version information. |
807 | | - $wgOut->setRevisionId( $this->mLatest ); |
808 | | - $outputDone = true; |
809 | | - } |
| 787 | + if( $pcache && $wgOut->tryParserCache( $this, $wgUser ) ) { |
| 788 | + // Ensure that UI elements requiring revision ID have |
| 789 | + // the correct version information. |
| 790 | + $wgOut->setRevisionId( $this->mLatest ); |
| 791 | + $outputDone = true; |
810 | 792 | } |
811 | 793 | # Fetch content and check for errors |
812 | | - if ( !$outputDone ) { |
| 794 | + if( !$outputDone ) { |
813 | 795 | # If the article does not exist and was deleted, show the log |
814 | | - if ($this->getID() == 0) { |
815 | | - $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut ); |
816 | | - $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() ); |
817 | | - $count = $pager->getNumRows(); |
818 | | - if( $count > 0 ) { |
819 | | - $pager->mLimit = 10; |
820 | | - $wgOut->addHTML( '<div class="mw-warning-with-logexcerpt">' ); |
821 | | - $wgOut->addWikiMsg( 'deleted-notice' ); |
822 | | - $wgOut->addHTML( |
823 | | - $loglist->beginLogEventsList() . |
824 | | - $pager->getBody() . |
825 | | - $loglist->endLogEventsList() |
826 | | - ); |
827 | | - if($count > 10){ |
828 | | - $wgOut->addHTML( $wgUser->getSkin()->link( |
829 | | - SpecialPage::getTitleFor( 'Log' ), |
830 | | - wfMsgHtml( 'deletelog-fulllog' ), |
831 | | - array(), |
832 | | - array( |
833 | | - 'type' => 'delete', |
834 | | - 'page' => $this->mTitle->getPrefixedText() ) ) ); |
835 | | - } |
836 | | - $wgOut->addHTML( '</div>' ); |
837 | | - } |
| 796 | + if( $this->getID() == 0 ) { |
| 797 | + $this->showDeletionLog(); |
838 | 798 | } |
839 | 799 | $text = $this->getContent(); |
840 | | - if ( $text === false ) { |
| 800 | + if( $text === false ) { |
841 | 801 | # Failed to load, replace text with error message |
842 | 802 | $t = $this->mTitle->getPrefixedText(); |
843 | 803 | if( $oldid ) { |
— | — | @@ -846,9 +806,14 @@ |
847 | 807 | $text = wfMsg( 'noarticletext' ); |
848 | 808 | } |
849 | 809 | } |
| 810 | + # Non-existent pages |
| 811 | + if( $this->getID() === 0 ) { |
| 812 | + $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
| 813 | + $text = "<div class='noarticletext'>\n$text\n</div>"; |
| 814 | + } |
850 | 815 | |
851 | 816 | # Another whitelist check in case oldid is altering the title |
852 | | - if ( !$this->mTitle->userCanRead() ) { |
| 817 | + if( !$this->mTitle->userCanRead() ) { |
853 | 818 | $wgOut->loginToUse(); |
854 | 819 | $wgOut->output(); |
855 | 820 | wfProfileOut( __METHOD__ ); |
— | — | @@ -856,7 +821,7 @@ |
857 | 822 | } |
858 | 823 | |
859 | 824 | # We're looking at an old revision |
860 | | - if ( !empty( $oldid ) ) { |
| 825 | + if( !empty( $oldid ) ) { |
861 | 826 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
862 | 827 | if( is_null( $this->mRevision ) ) { |
863 | 828 | // FIXME: This would be a nice place to load the 'no such page' text. |
— | — | @@ -890,12 +855,12 @@ |
891 | 856 | $wgOut->addHTML( htmlspecialchars( $this->mContent ) ); |
892 | 857 | $wgOut->addHTML( "\n</pre>\n" ); |
893 | 858 | } |
894 | | - } else if ( $rt = Title::newFromRedirect( $text ) ) { |
| 859 | + } else if( $rt = Title::newFromRedirect( $text ) ) { |
895 | 860 | # Don't append the subtitle if this was an old revision |
896 | 861 | $wgOut->addHTML( $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ) ); |
897 | 862 | $parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser)); |
898 | 863 | $wgOut->addParserOutputNoText( $parseout ); |
899 | | - } else if ( $pcache ) { |
| 864 | + } else if( $pcache ) { |
900 | 865 | # Display content and save to parser cache |
901 | 866 | $this->outputWikiText( $text ); |
902 | 867 | } else { |
— | — | @@ -911,7 +876,7 @@ |
912 | 877 | $time += wfTime(); |
913 | 878 | |
914 | 879 | # Timing hack |
915 | | - if ( $time > 3 ) { |
| 880 | + if( $time > 3 ) { |
916 | 881 | wfDebugLog( 'slow-parse', sprintf( "%-5.2f %s", $time, |
917 | 882 | $this->mTitle->getPrefixedDBkey())); |
918 | 883 | } |
— | — | @@ -954,12 +919,38 @@ |
955 | 920 | } |
956 | 921 | |
957 | 922 | # Trackbacks |
958 | | - if ($wgUseTrackbacks) |
| 923 | + if( $wgUseTrackbacks ) { |
959 | 924 | $this->addTrackbacks(); |
| 925 | + } |
960 | 926 | |
961 | 927 | $this->viewUpdates(); |
962 | 928 | wfProfileOut( __METHOD__ ); |
963 | 929 | } |
| 930 | + |
| 931 | + protected function showDeletionLog() { |
| 932 | + global $wgUser, $wgOut; |
| 933 | + $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut ); |
| 934 | + $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() ); |
| 935 | + if( $pager->getNumRows() > 0 ) { |
| 936 | + $pager->mLimit = 10; |
| 937 | + $wgOut->addHTML( '<div class="mw-warning-with-logexcerpt">' ); |
| 938 | + $wgOut->addWikiMsg( 'deleted-notice' ); |
| 939 | + $wgOut->addHTML( |
| 940 | + $loglist->beginLogEventsList() . |
| 941 | + $pager->getBody() . |
| 942 | + $loglist->endLogEventsList() |
| 943 | + ); |
| 944 | + if( $pager->getNumRows() > 10 ) { |
| 945 | + $wgOut->addHTML( $wgUser->getSkin()->link( |
| 946 | + SpecialPage::getTitleFor( 'Log' ), |
| 947 | + wfMsgHtml( 'deletelog-fulllog' ), |
| 948 | + array(), |
| 949 | + array( 'type' => 'delete', 'page' => $this->mTitle->getPrefixedText() ) |
| 950 | + ) ); |
| 951 | + } |
| 952 | + $wgOut->addHTML( '</div>' ); |
| 953 | + } |
| 954 | + } |
964 | 955 | |
965 | 956 | /* |
966 | 957 | * Should the parser cache be used? |
— | — | @@ -978,12 +969,11 @@ |
979 | 970 | /** |
980 | 971 | * View redirect |
981 | 972 | * @param Title $target Title of destination to redirect |
982 | | - * @param Bool $appendSubtitle Object[optional] |
| 973 | + * @param Bool $appendSubtitle [optional] |
983 | 974 | * @param Bool $forceKnown Should the image be shown as a bluelink regardless of existence? |
984 | 975 | */ |
985 | 976 | public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) { |
986 | 977 | global $wgParser, $wgOut, $wgContLang, $wgStylePath, $wgUser; |
987 | | - |
988 | 978 | # Display redirect |
989 | 979 | $imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr'; |
990 | 980 | $imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png'; |
— | — | @@ -992,35 +982,31 @@ |
993 | 983 | $wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) ); |
994 | 984 | } |
995 | 985 | $sk = $wgUser->getSkin(); |
996 | | - if ( $forceKnown ) |
| 986 | + if( $forceKnown ) { |
997 | 987 | $link = $sk->makeKnownLinkObj( $target, htmlspecialchars( $target->getFullText() ) ); |
998 | | - else |
| 988 | + } else { |
999 | 989 | $link = $sk->makeLinkObj( $target, htmlspecialchars( $target->getFullText() ) ); |
1000 | | - |
| 990 | + } |
1001 | 991 | return '<img src="'.$imageUrl.'" alt="#REDIRECT " />' . |
1002 | 992 | '<span class="redirectText">'.$link.'</span>'; |
1003 | 993 | |
1004 | 994 | } |
1005 | 995 | |
1006 | | - function addTrackbacks() { |
| 996 | + public function addTrackbacks() { |
1007 | 997 | global $wgOut, $wgUser; |
1008 | | - |
1009 | | - $dbr = wfGetDB(DB_SLAVE); |
1010 | | - $tbs = $dbr->select( |
1011 | | - /* FROM */ 'trackbacks', |
1012 | | - /* SELECT */ array('tb_id', 'tb_title', 'tb_url', 'tb_ex', 'tb_name'), |
1013 | | - /* WHERE */ array('tb_page' => $this->getID()) |
| 998 | + $dbr = wfGetDB( DB_SLAVE ); |
| 999 | + $tbs = $dbr->select( 'trackbacks', |
| 1000 | + array('tb_id', 'tb_title', 'tb_url', 'tb_ex', 'tb_name'), |
| 1001 | + array('tb_page' => $this->getID() ) |
1014 | 1002 | ); |
| 1003 | + if( !$dbr->numRows($tbs) ) return; |
1015 | 1004 | |
1016 | | - if (!$dbr->numrows($tbs)) |
1017 | | - return; |
1018 | | - |
1019 | 1005 | $tbtext = ""; |
1020 | | - while ($o = $dbr->fetchObject($tbs)) { |
| 1006 | + while( $o = $dbr->fetchObject($tbs) ) { |
1021 | 1007 | $rmvtxt = ""; |
1022 | | - if ($wgUser->isAllowed( 'trackback' )) { |
1023 | | - $delurl = $this->mTitle->getFullURL("action=deletetrackback&tbid=" |
1024 | | - . $o->tb_id . "&token=" . urlencode( $wgUser->editToken() ) ); |
| 1008 | + if( $wgUser->isAllowed( 'trackback' ) ) { |
| 1009 | + $delurl = $this->mTitle->getFullURL("action=deletetrackback&tbid=" . |
| 1010 | + $o->tb_id . "&token=" . urlencode( $wgUser->editToken() ) ); |
1025 | 1011 | $rmvtxt = wfMsg( 'trackbackremove', htmlspecialchars( $delurl ) ); |
1026 | 1012 | } |
1027 | 1013 | $tbtext .= "\n"; |
— | — | @@ -1032,33 +1018,31 @@ |
1033 | 1019 | $rmvtxt); |
1034 | 1020 | } |
1035 | 1021 | $wgOut->addWikiMsg( 'trackbackbox', $tbtext ); |
| 1022 | + $this->mTitle->invalidateCache(); |
1036 | 1023 | } |
1037 | 1024 | |
1038 | | - function deletetrackback() { |
| 1025 | + public function deletetrackback() { |
1039 | 1026 | global $wgUser, $wgRequest, $wgOut, $wgTitle; |
1040 | | - |
1041 | | - if (!$wgUser->matchEditToken($wgRequest->getVal('token'))) { |
| 1027 | + if( !$wgUser->matchEditToken($wgRequest->getVal('token')) ) { |
1042 | 1028 | $wgOut->addWikiMsg( 'sessionfailure' ); |
1043 | 1029 | return; |
1044 | 1030 | } |
1045 | 1031 | |
1046 | 1032 | $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser ); |
1047 | | - |
1048 | | - if (count($permission_errors)>0) |
1049 | | - { |
| 1033 | + if( count($permission_errors) ) { |
1050 | 1034 | $wgOut->showPermissionsErrorPage( $permission_errors ); |
1051 | 1035 | return; |
1052 | 1036 | } |
1053 | 1037 | |
1054 | | - $db = wfGetDB(DB_MASTER); |
1055 | | - $db->delete('trackbacks', array('tb_id' => $wgRequest->getInt('tbid'))); |
1056 | | - $wgTitle->invalidateCache(); |
1057 | | - $wgOut->addWikiMsg('trackbackdeleteok'); |
| 1038 | + $db = wfGetDB( DB_MASTER ); |
| 1039 | + $db->delete( 'trackbacks', array('tb_id' => $wgRequest->getInt('tbid')) ); |
| 1040 | + |
| 1041 | + $wgOut->addWikiMsg( 'trackbackdeleteok' ); |
| 1042 | + $this->mTitle->invalidateCache(); |
1058 | 1043 | } |
1059 | 1044 | |
1060 | | - function render() { |
| 1045 | + public function render() { |
1061 | 1046 | global $wgOut; |
1062 | | - |
1063 | 1047 | $wgOut->setArticleBodyOnly(true); |
1064 | 1048 | $this->view(); |
1065 | 1049 | } |
— | — | @@ -1066,10 +1050,9 @@ |
1067 | 1051 | /** |
1068 | 1052 | * Handle action=purge |
1069 | 1053 | */ |
1070 | | - function purge() { |
| 1054 | + public function purge() { |
1071 | 1055 | global $wgUser, $wgRequest, $wgOut; |
1072 | | - |
1073 | | - if ( $wgUser->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) { |
| 1056 | + if( $wgUser->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) { |
1074 | 1057 | if( wfRunHooks( 'ArticlePurge', array( &$this ) ) ) { |
1075 | 1058 | $this->doPurge(); |
1076 | 1059 | $this->view(); |
— | — | @@ -1091,12 +1074,12 @@ |
1092 | 1075 | /** |
1093 | 1076 | * Perform the actions of a page purging |
1094 | 1077 | */ |
1095 | | - function doPurge() { |
| 1078 | + public function doPurge() { |
1096 | 1079 | global $wgUseSquid; |
1097 | 1080 | // Invalidate the cache |
1098 | 1081 | $this->mTitle->invalidateCache(); |
1099 | 1082 | |
1100 | | - if ( $wgUseSquid ) { |
| 1083 | + if( $wgUseSquid ) { |
1101 | 1084 | // Commit the transaction before the purge is sent |
1102 | 1085 | $dbw = wfGetDB( DB_MASTER ); |
1103 | 1086 | $dbw->immediateCommit(); |
— | — | @@ -1105,9 +1088,9 @@ |
1106 | 1089 | $update = SquidUpdate::newSimplePurge( $this->mTitle ); |
1107 | 1090 | $update->doUpdate(); |
1108 | 1091 | } |
1109 | | - if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| 1092 | + if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
1110 | 1093 | global $wgMessageCache; |
1111 | | - if ( $this->getID() == 0 ) { |
| 1094 | + if( $this->getID() == 0 ) { |
1112 | 1095 | $text = false; |
1113 | 1096 | } else { |
1114 | 1097 | $text = $this->getContent(); |
— | — | @@ -1127,7 +1110,7 @@ |
1128 | 1111 | * @return int The newly created page_id key, or false if the title already existed |
1129 | 1112 | * @private |
1130 | 1113 | */ |
1131 | | - function insertOn( $dbw ) { |
| 1114 | + public function insertOn( $dbw ) { |
1132 | 1115 | wfProfileIn( __METHOD__ ); |
1133 | 1116 | |
1134 | 1117 | $page_id = $dbw->nextSequenceValue( 'page_page_id_seq' ); |
— | — | @@ -1146,7 +1129,7 @@ |
1147 | 1130 | ), __METHOD__, 'IGNORE' ); |
1148 | 1131 | |
1149 | 1132 | $affected = $dbw->affectedRows(); |
1150 | | - if ( $affected ) { |
| 1133 | + if( $affected ) { |
1151 | 1134 | $newid = $dbw->insertId(); |
1152 | 1135 | $this->mTitle->resetArticleId( $newid ); |
1153 | 1136 | } |
— | — | @@ -1169,7 +1152,7 @@ |
1170 | 1153 | * @return bool true on success, false on failure |
1171 | 1154 | * @private |
1172 | 1155 | */ |
1173 | | - function updateRevisionOn( &$dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null ) { |
| 1156 | + public function updateRevisionOn( &$dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null ) { |
1174 | 1157 | wfProfileIn( __METHOD__ ); |
1175 | 1158 | |
1176 | 1159 | $text = $revision->getText(); |
— | — | @@ -1193,8 +1176,7 @@ |
1194 | 1177 | __METHOD__ ); |
1195 | 1178 | |
1196 | 1179 | $result = $dbw->affectedRows() != 0; |
1197 | | - |
1198 | | - if ($result) { |
| 1180 | + if( $result ) { |
1199 | 1181 | $this->updateRedirectOn( $dbw, $rt, $lastRevIsRedirect ); |
1200 | 1182 | } |
1201 | 1183 | |
— | — | @@ -1213,38 +1195,32 @@ |
1214 | 1196 | * @return bool true on success, false on failure |
1215 | 1197 | * @private |
1216 | 1198 | */ |
1217 | | - function updateRedirectOn( &$dbw, $redirectTitle, $lastRevIsRedirect = null ) { |
1218 | | - |
| 1199 | + public function updateRedirectOn( &$dbw, $redirectTitle, $lastRevIsRedirect = null ) { |
1219 | 1200 | // Always update redirects (target link might have changed) |
1220 | 1201 | // Update/Insert if we don't know if the last revision was a redirect or not |
1221 | 1202 | // Delete if changing from redirect to non-redirect |
1222 | 1203 | $isRedirect = !is_null($redirectTitle); |
1223 | | - if ($isRedirect || is_null($lastRevIsRedirect) || $lastRevIsRedirect !== $isRedirect) { |
1224 | | - |
| 1204 | + if($isRedirect || is_null($lastRevIsRedirect) || $lastRevIsRedirect !== $isRedirect) { |
1225 | 1205 | wfProfileIn( __METHOD__ ); |
1226 | | - |
1227 | | - if ($isRedirect) { |
1228 | | - |
| 1206 | + if( $isRedirect ) { |
1229 | 1207 | // This title is a redirect, Add/Update row in the redirect table |
1230 | 1208 | $set = array( /* SET */ |
1231 | 1209 | 'rd_namespace' => $redirectTitle->getNamespace(), |
1232 | 1210 | 'rd_title' => $redirectTitle->getDBkey(), |
1233 | 1211 | 'rd_from' => $this->getId(), |
1234 | 1212 | ); |
1235 | | - |
1236 | 1213 | $dbw->replace( 'redirect', array( 'rd_from' ), $set, __METHOD__ ); |
1237 | 1214 | } else { |
1238 | 1215 | // This is not a redirect, remove row from redirect table |
1239 | 1216 | $where = array( 'rd_from' => $this->getId() ); |
1240 | 1217 | $dbw->delete( 'redirect', $where, __METHOD__); |
1241 | 1218 | } |
1242 | | - |
1243 | | - if( $this->getTitle()->getNamespace() == NS_IMAGE ) |
| 1219 | + if( $this->getTitle()->getNamespace() == NS_IMAGE ) { |
1244 | 1220 | RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $this->getTitle() ); |
| 1221 | + } |
1245 | 1222 | wfProfileOut( __METHOD__ ); |
1246 | 1223 | return ( $dbw->affectedRows() != 0 ); |
1247 | 1224 | } |
1248 | | - |
1249 | 1225 | return true; |
1250 | 1226 | } |
1251 | 1227 | |
— | — | @@ -1255,9 +1231,8 @@ |
1256 | 1232 | * @param Database $dbw |
1257 | 1233 | * @param Revision $revision |
1258 | 1234 | */ |
1259 | | - function updateIfNewerOn( &$dbw, $revision ) { |
| 1235 | + public function updateIfNewerOn( &$dbw, $revision ) { |
1260 | 1236 | wfProfileIn( __METHOD__ ); |
1261 | | - |
1262 | 1237 | $row = $dbw->selectRow( |
1263 | 1238 | array( 'revision', 'page' ), |
1264 | 1239 | array( 'rev_id', 'rev_timestamp', 'page_is_redirect' ), |
— | — | @@ -1277,7 +1252,6 @@ |
1278 | 1253 | $prev = 0; |
1279 | 1254 | $lastRevIsRedirect = null; |
1280 | 1255 | } |
1281 | | - |
1282 | 1256 | $ret = $this->updateRevisionOn( $dbw, $revision, $prev, $lastRevIsRedirect ); |
1283 | 1257 | wfProfileOut( __METHOD__ ); |
1284 | 1258 | return $ret; |
— | — | @@ -1286,19 +1260,18 @@ |
1287 | 1261 | /** |
1288 | 1262 | * @return string Complete article text, or null if error |
1289 | 1263 | */ |
1290 | | - function replaceSection($section, $text, $summary = '', $edittime = NULL) { |
| 1264 | + function replaceSection( $section, $text, $summary = '', $edittime = NULL ) { |
1291 | 1265 | wfProfileIn( __METHOD__ ); |
1292 | | - |
1293 | | - if( $section == '' ) { |
1294 | | - // Whole-page edit; let the text through unmolested. |
| 1266 | + if( $section === '' ) { |
| 1267 | + // Whole-page edit; let the whole text through |
1295 | 1268 | } else { |
1296 | | - if( is_null( $edittime ) ) { |
| 1269 | + if( is_null($edittime) ) { |
1297 | 1270 | $rev = Revision::newFromTitle( $this->mTitle ); |
1298 | 1271 | } else { |
1299 | 1272 | $dbw = wfGetDB( DB_MASTER ); |
1300 | 1273 | $rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime ); |
1301 | 1274 | } |
1302 | | - if( is_null( $rev ) ) { |
| 1275 | + if( !$rev ) { |
1303 | 1276 | wfDebug( "Article::replaceSection asked for bogus section (page: " . |
1304 | 1277 | $this->getId() . "; section: $section; edittime: $edittime)\n" ); |
1305 | 1278 | return null; |
— | — | @@ -1316,9 +1289,7 @@ |
1317 | 1290 | global $wgParser; |
1318 | 1291 | $text = $wgParser->replaceSection( $oldtext, $section, $text ); |
1319 | 1292 | } |
1320 | | - |
1321 | 1293 | } |
1322 | | - |
1323 | 1294 | wfProfileOut( __METHOD__ ); |
1324 | 1295 | return $text; |
1325 | 1296 | } |
— | — | @@ -1327,27 +1298,28 @@ |
1328 | 1299 | * @deprecated use Article::doEdit() |
1329 | 1300 | */ |
1330 | 1301 | function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false, $bot=false ) { |
| 1302 | + wfDeprecated( __METHOD__ ); |
1331 | 1303 | $flags = EDIT_NEW | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY | |
1332 | 1304 | ( $isminor ? EDIT_MINOR : 0 ) | |
1333 | 1305 | ( $suppressRC ? EDIT_SUPPRESS_RC : 0 ) | |
1334 | 1306 | ( $bot ? EDIT_FORCE_BOT : 0 ); |
1335 | 1307 | |
1336 | 1308 | # If this is a comment, add the summary as headline |
1337 | | - if ( $comment && $summary != "" ) { |
| 1309 | + if( $comment && $summary != "" ) { |
1338 | 1310 | $text = wfMsgForContent('newsectionheaderdefaultlevel',$summary) . "\n\n".$text; |
1339 | 1311 | } |
1340 | 1312 | |
1341 | 1313 | $this->doEdit( $text, $summary, $flags ); |
1342 | 1314 | |
1343 | 1315 | $dbw = wfGetDB( DB_MASTER ); |
1344 | | - if ($watchthis) { |
1345 | | - if (!$this->mTitle->userIsWatching()) { |
| 1316 | + if($watchthis) { |
| 1317 | + if(!$this->mTitle->userIsWatching()) { |
1346 | 1318 | $dbw->begin(); |
1347 | 1319 | $this->doWatch(); |
1348 | 1320 | $dbw->commit(); |
1349 | 1321 | } |
1350 | 1322 | } else { |
1351 | | - if ( $this->mTitle->userIsWatching() ) { |
| 1323 | + if( $this->mTitle->userIsWatching() ) { |
1352 | 1324 | $dbw->begin(); |
1353 | 1325 | $this->doUnwatch(); |
1354 | 1326 | $dbw->commit(); |
— | — | @@ -1360,24 +1332,25 @@ |
1361 | 1333 | * @deprecated use Article::doEdit() |
1362 | 1334 | */ |
1363 | 1335 | function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) { |
| 1336 | + wfDeprecated( __METHOD__ ); |
1364 | 1337 | $flags = EDIT_UPDATE | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY | |
1365 | 1338 | ( $minor ? EDIT_MINOR : 0 ) | |
1366 | 1339 | ( $forceBot ? EDIT_FORCE_BOT : 0 ); |
1367 | 1340 | |
1368 | 1341 | $status = $this->doEdit( $text, $summary, $flags ); |
1369 | | - if ( !$status->isOK() ) { |
| 1342 | + if( !$status->isOK() ) { |
1370 | 1343 | return false; |
1371 | 1344 | } |
1372 | 1345 | |
1373 | 1346 | $dbw = wfGetDB( DB_MASTER ); |
1374 | | - if ($watchthis) { |
1375 | | - if (!$this->mTitle->userIsWatching()) { |
| 1347 | + if($watchthis) { |
| 1348 | + if(!$this->mTitle->userIsWatching()) { |
1376 | 1349 | $dbw->begin(); |
1377 | 1350 | $this->doWatch(); |
1378 | 1351 | $dbw->commit(); |
1379 | 1352 | } |
1380 | 1353 | } else { |
1381 | | - if ( $this->mTitle->userIsWatching() ) { |
| 1354 | + if( $this->mTitle->userIsWatching() ) { |
1382 | 1355 | $dbw->begin(); |
1383 | 1356 | $this->doUnwatch(); |
1384 | 1357 | $dbw->commit(); |
— | — | @@ -1440,7 +1413,7 @@ |
1441 | 1414 | * |
1442 | 1415 | * Compatibility note: this function previously returned a boolean value indicating success/failure |
1443 | 1416 | */ |
1444 | | - function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) { |
| 1417 | + public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) { |
1445 | 1418 | global $wgUser, $wgDBtransactions, $wgUseAutomaticEditSummaries; |
1446 | 1419 | |
1447 | 1420 | # Low-level sanity check |
— | — | @@ -1450,30 +1423,27 @@ |
1451 | 1424 | |
1452 | 1425 | wfProfileIn( __METHOD__ ); |
1453 | 1426 | |
1454 | | - if ($user == null) { |
1455 | | - $user = $wgUser; |
1456 | | - } |
| 1427 | + $user = is_null($user) ? $wgUser : $user; |
1457 | 1428 | $status = Status::newGood( array() ); |
1458 | 1429 | |
1459 | 1430 | # Load $this->mTitle->getArticleID() and $this->mLatest if it's not already |
1460 | 1431 | $this->loadPageData(); |
1461 | 1432 | |
1462 | | - if ( !($flags & EDIT_NEW) && !($flags & EDIT_UPDATE) ) { |
| 1433 | + if( !($flags & EDIT_NEW) && !($flags & EDIT_UPDATE) ) { |
1463 | 1434 | $aid = $this->mTitle->getArticleID(); |
1464 | | - if ( $aid ) { |
| 1435 | + if( $aid ) { |
1465 | 1436 | $flags |= EDIT_UPDATE; |
1466 | 1437 | } else { |
1467 | 1438 | $flags |= EDIT_NEW; |
1468 | 1439 | } |
1469 | 1440 | } |
1470 | 1441 | |
1471 | | - if( !wfRunHooks( 'ArticleSave', array( &$this, &$user, &$text, |
1472 | | - &$summary, $flags & EDIT_MINOR, |
1473 | | - null, null, &$flags, &$status ) ) ) |
| 1442 | + if( !wfRunHooks( 'ArticleSave', array( &$this, &$user, &$text, &$summary, |
| 1443 | + $flags & EDIT_MINOR, null, null, &$flags, &$status ) ) ) |
1474 | 1444 | { |
1475 | 1445 | wfDebug( __METHOD__ . ": ArticleSave hook aborted save!\n" ); |
1476 | 1446 | wfProfileOut( __METHOD__ ); |
1477 | | - if ( $status->isOK() ) { |
| 1447 | + if( $status->isOK() ) { |
1478 | 1448 | $status->fatal( 'edit-hook-aborted'); |
1479 | 1449 | } |
1480 | 1450 | return $status; |
— | — | @@ -1498,10 +1468,9 @@ |
1499 | 1469 | $dbw = wfGetDB( DB_MASTER ); |
1500 | 1470 | $now = wfTimestampNow(); |
1501 | 1471 | |
1502 | | - if ( $flags & EDIT_UPDATE ) { |
| 1472 | + if( $flags & EDIT_UPDATE ) { |
1503 | 1473 | # Update article, but only if changed. |
1504 | 1474 | $status->value['new'] = false; |
1505 | | - |
1506 | 1475 | # Make sure the revision is either completely inserted or not inserted at all |
1507 | 1476 | if( !$wgDBtransactions ) { |
1508 | 1477 | $userAbort = ignore_user_abort( true ); |
— | — | @@ -1511,12 +1480,12 @@ |
1512 | 1481 | |
1513 | 1482 | $changed = ( strcmp( $text, $oldtext ) != 0 ); |
1514 | 1483 | |
1515 | | - if ( $changed ) { |
| 1484 | + if( $changed ) { |
1516 | 1485 | $this->mGoodAdjustment = (int)$this->isCountable( $text ) |
1517 | 1486 | - (int)$this->isCountable( $oldtext ); |
1518 | 1487 | $this->mTotalAdjustment = 0; |
1519 | 1488 | |
1520 | | - if ( !$this->mLatest ) { |
| 1489 | + if( !$this->mLatest ) { |
1521 | 1490 | # Article gone missing |
1522 | 1491 | wfDebug( __METHOD__.": EDIT_UPDATE specified but article doesn't exist\n" ); |
1523 | 1492 | $status->fatal( 'edit-gone-missing' ); |
— | — | @@ -1550,7 +1519,7 @@ |
1551 | 1520 | /* Belated edit conflict! Run away!! */ |
1552 | 1521 | $status->fatal( 'edit-conflict' ); |
1553 | 1522 | # Delete the invalid revision if the DB is not transactional |
1554 | | - if ( !$wgDBtransactions ) { |
| 1523 | + if( !$wgDBtransactions ) { |
1555 | 1524 | $dbw->delete( 'revision', array( 'rev_id' => $revisionId ), __METHOD__ ); |
1556 | 1525 | } |
1557 | 1526 | $revisionId = 0; |
— | — | @@ -1589,7 +1558,7 @@ |
1590 | 1559 | ignore_user_abort( $userAbort ); |
1591 | 1560 | } |
1592 | 1561 | // Now that ignore_user_abort is restored, we can respond to fatal errors |
1593 | | - if ( !$status->isOK() ) { |
| 1562 | + if( !$status->isOK() ) { |
1594 | 1563 | wfProfileOut( __METHOD__ ); |
1595 | 1564 | return $status; |
1596 | 1565 | } |
— | — | @@ -1615,7 +1584,7 @@ |
1616 | 1585 | # This will return false if the article already exists |
1617 | 1586 | $newid = $this->insertOn( $dbw ); |
1618 | 1587 | |
1619 | | - if ( $newid === false ) { |
| 1588 | + if( $newid === false ) { |
1620 | 1589 | $dbw->rollback(); |
1621 | 1590 | $status->fatal( 'edit-already-exists' ); |
1622 | 1591 | wfProfileOut( __METHOD__ ); |
— | — | @@ -1666,7 +1635,7 @@ |
1667 | 1636 | } |
1668 | 1637 | |
1669 | 1638 | # Do updates right now unless deferral was requested |
1670 | | - if ( !( $flags & EDIT_DEFER_UPDATES ) ) { |
| 1639 | + if( !( $flags & EDIT_DEFER_UPDATES ) ) { |
1671 | 1640 | wfDoUpdates(); |
1672 | 1641 | } |
1673 | 1642 | |
— | — | @@ -1683,7 +1652,8 @@ |
1684 | 1653 | /** |
1685 | 1654 | * @deprecated wrapper for doRedirect |
1686 | 1655 | */ |
1687 | | - function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid ) { |
| 1656 | + public function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid ) { |
| 1657 | + wfDeprecated( __METHOD__ ); |
1688 | 1658 | $this->doRedirect( $this->isRedirect( $text ), $sectionanchor ); |
1689 | 1659 | } |
1690 | 1660 | |
— | — | @@ -1695,9 +1665,9 @@ |
1696 | 1666 | * @param string $sectionAnchor section to redirect to, including "#" |
1697 | 1667 | * @param string $extraQuery, extra query params |
1698 | 1668 | */ |
1699 | | - function doRedirect( $noRedir = false, $sectionAnchor = '', $extraQuery = '' ) { |
| 1669 | + public function doRedirect( $noRedir = false, $sectionAnchor = '', $extraQuery = '' ) { |
1700 | 1670 | global $wgOut; |
1701 | | - if ( $noRedir ) { |
| 1671 | + if( $noRedir ) { |
1702 | 1672 | $query = 'redirect=no'; |
1703 | 1673 | if( $extraQuery ) |
1704 | 1674 | $query .= "&$query"; |
— | — | @@ -1710,14 +1680,14 @@ |
1711 | 1681 | /** |
1712 | 1682 | * Mark this particular edit/page as patrolled |
1713 | 1683 | */ |
1714 | | - function markpatrolled() { |
| 1684 | + public function markpatrolled() { |
1715 | 1685 | global $wgOut, $wgRequest, $wgUseRCPatrol, $wgUseNPPatrol, $wgUser; |
1716 | 1686 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
1717 | 1687 | |
1718 | 1688 | # If we haven't been given an rc_id value, we can't do anything |
1719 | 1689 | $rcid = (int) $wgRequest->getVal('rcid'); |
1720 | 1690 | $rc = RecentChange::newFromId($rcid); |
1721 | | - if ( is_null($rc) ) { |
| 1691 | + if( is_null($rc) ) { |
1722 | 1692 | $wgOut->showErrorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' ); |
1723 | 1693 | return; |
1724 | 1694 | } |
— | — | @@ -1729,24 +1699,24 @@ |
1730 | 1700 | $dbw = wfGetDB( DB_MASTER ); |
1731 | 1701 | $errors = $rc->doMarkPatrolled(); |
1732 | 1702 | |
1733 | | - if ( in_array(array('rcpatroldisabled'), $errors) ) { |
| 1703 | + if( in_array(array('rcpatroldisabled'), $errors) ) { |
1734 | 1704 | $wgOut->showErrorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' ); |
1735 | 1705 | return; |
1736 | 1706 | } |
1737 | 1707 | |
1738 | | - if ( in_array(array('hookaborted'), $errors) ) { |
| 1708 | + if( in_array(array('hookaborted'), $errors) ) { |
1739 | 1709 | // The hook itself has handled any output |
1740 | 1710 | return; |
1741 | 1711 | } |
1742 | 1712 | |
1743 | | - if ( in_array(array('markedaspatrollederror-noautopatrol'), $errors) ) { |
| 1713 | + if( in_array(array('markedaspatrollederror-noautopatrol'), $errors) ) { |
1744 | 1714 | $wgOut->setPageTitle( wfMsg( 'markedaspatrollederror' ) ); |
1745 | 1715 | $wgOut->addWikiMsg( 'markedaspatrollederror-noautopatrol' ); |
1746 | 1716 | $wgOut->returnToMain( false, $return ); |
1747 | 1717 | return; |
1748 | 1718 | } |
1749 | 1719 | |
1750 | | - if ( !empty($errors) ) { |
| 1720 | + if( !empty($errors) ) { |
1751 | 1721 | $wgOut->showPermissionsErrorPage( $errors ); |
1752 | 1722 | return; |
1753 | 1723 | } |
— | — | @@ -1761,26 +1731,21 @@ |
1762 | 1732 | * User-interface handler for the "watch" action |
1763 | 1733 | */ |
1764 | 1734 | |
1765 | | - function watch() { |
1766 | | - |
| 1735 | + public function watch() { |
1767 | 1736 | global $wgUser, $wgOut; |
1768 | | - |
1769 | | - if ( $wgUser->isAnon() ) { |
| 1737 | + if( $wgUser->isAnon() ) { |
1770 | 1738 | $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' ); |
1771 | 1739 | return; |
1772 | 1740 | } |
1773 | | - if ( wfReadOnly() ) { |
| 1741 | + if( wfReadOnly() ) { |
1774 | 1742 | $wgOut->readOnlyPage(); |
1775 | 1743 | return; |
1776 | 1744 | } |
1777 | | - |
1778 | 1745 | if( $this->doWatch() ) { |
1779 | 1746 | $wgOut->setPagetitle( wfMsg( 'addedwatch' ) ); |
1780 | 1747 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
1781 | | - |
1782 | 1748 | $wgOut->addWikiMsg( 'addedwatchtext', $this->mTitle->getPrefixedText() ); |
1783 | 1749 | } |
1784 | | - |
1785 | 1750 | $wgOut->returnToMain( true, $this->mTitle->getPrefixedText() ); |
1786 | 1751 | } |
1787 | 1752 | |
— | — | @@ -1788,44 +1753,36 @@ |
1789 | 1754 | * Add this page to $wgUser's watchlist |
1790 | 1755 | * @return bool true on successful watch operation |
1791 | 1756 | */ |
1792 | | - function doWatch() { |
| 1757 | + public function doWatch() { |
1793 | 1758 | global $wgUser; |
1794 | 1759 | if( $wgUser->isAnon() ) { |
1795 | 1760 | return false; |
1796 | 1761 | } |
1797 | | - |
1798 | | - if (wfRunHooks('WatchArticle', array(&$wgUser, &$this))) { |
| 1762 | + if( wfRunHooks('WatchArticle', array(&$wgUser, &$this)) ) { |
1799 | 1763 | $wgUser->addWatch( $this->mTitle ); |
1800 | | - |
1801 | 1764 | return wfRunHooks('WatchArticleComplete', array(&$wgUser, &$this)); |
1802 | 1765 | } |
1803 | | - |
1804 | 1766 | return false; |
1805 | 1767 | } |
1806 | 1768 | |
1807 | 1769 | /** |
1808 | 1770 | * User interface handler for the "unwatch" action. |
1809 | 1771 | */ |
1810 | | - function unwatch() { |
1811 | | - |
| 1772 | + public function unwatch() { |
1812 | 1773 | global $wgUser, $wgOut; |
1813 | | - |
1814 | | - if ( $wgUser->isAnon() ) { |
| 1774 | + if( $wgUser->isAnon() ) { |
1815 | 1775 | $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' ); |
1816 | 1776 | return; |
1817 | 1777 | } |
1818 | | - if ( wfReadOnly() ) { |
| 1778 | + if( wfReadOnly() ) { |
1819 | 1779 | $wgOut->readOnlyPage(); |
1820 | 1780 | return; |
1821 | 1781 | } |
1822 | | - |
1823 | 1782 | if( $this->doUnwatch() ) { |
1824 | 1783 | $wgOut->setPagetitle( wfMsg( 'removedwatch' ) ); |
1825 | 1784 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
1826 | | - |
1827 | 1785 | $wgOut->addWikiMsg( 'removedwatchtext', $this->mTitle->getPrefixedText() ); |
1828 | 1786 | } |
1829 | | - |
1830 | 1787 | $wgOut->returnToMain( true, $this->mTitle->getPrefixedText() ); |
1831 | 1788 | } |
1832 | 1789 | |
— | — | @@ -1833,25 +1790,22 @@ |
1834 | 1791 | * Stop watching a page |
1835 | 1792 | * @return bool true on successful unwatch |
1836 | 1793 | */ |
1837 | | - function doUnwatch() { |
| 1794 | + public function doUnwatch() { |
1838 | 1795 | global $wgUser; |
1839 | 1796 | if( $wgUser->isAnon() ) { |
1840 | 1797 | return false; |
1841 | 1798 | } |
1842 | | - |
1843 | | - if (wfRunHooks('UnwatchArticle', array(&$wgUser, &$this))) { |
| 1799 | + if( wfRunHooks('UnwatchArticle', array(&$wgUser, &$this)) ) { |
1844 | 1800 | $wgUser->removeWatch( $this->mTitle ); |
1845 | | - |
1846 | 1801 | return wfRunHooks('UnwatchArticleComplete', array(&$wgUser, &$this)); |
1847 | 1802 | } |
1848 | | - |
1849 | 1803 | return false; |
1850 | 1804 | } |
1851 | 1805 | |
1852 | 1806 | /** |
1853 | 1807 | * action=protect handler |
1854 | 1808 | */ |
1855 | | - function protect() { |
| 1809 | + public function protect() { |
1856 | 1810 | $form = new ProtectionForm( $this ); |
1857 | 1811 | $form->execute(); |
1858 | 1812 | } |
— | — | @@ -1859,7 +1813,7 @@ |
1860 | 1814 | /** |
1861 | 1815 | * action=unprotect handler (alias) |
1862 | 1816 | */ |
1863 | | - function unprotect() { |
| 1817 | + public function unprotect() { |
1864 | 1818 | $this->protect(); |
1865 | 1819 | } |
1866 | 1820 | |
— | — | @@ -1870,7 +1824,7 @@ |
1871 | 1825 | * @param string $reason |
1872 | 1826 | * @return bool true on success |
1873 | 1827 | */ |
1874 | | - function updateRestrictions( $limit = array(), $reason = '', $cascade = 0, $expiry = array() ) { |
| 1828 | + public function updateRestrictions( $limit = array(), $reason = '', $cascade = 0, $expiry = array() ) { |
1875 | 1829 | global $wgUser, $wgRestrictionTypes, $wgContLang; |
1876 | 1830 | |
1877 | 1831 | $id = $this->mTitle->getArticleID(); |
— | — | @@ -1957,7 +1911,7 @@ |
1958 | 1912 | $editComment .= "$cascade_description"; |
1959 | 1913 | # Update restrictions table |
1960 | 1914 | foreach( $limit as $action => $restrictions ) { |
1961 | | - if ($restrictions != '' ) { |
| 1915 | + if($restrictions != '' ) { |
1962 | 1916 | $dbw->replace( 'page_restrictions', array(array('pr_page', 'pr_type')), |
1963 | 1917 | array( 'pr_page' => $id, |
1964 | 1918 | 'pr_type' => $action, |
— | — | @@ -2009,9 +1963,8 @@ |
2010 | 1964 | * suitable for insertion into the page_restrictions field. |
2011 | 1965 | * @param array $limit |
2012 | 1966 | * @return string |
2013 | | - * @private |
2014 | 1967 | */ |
2015 | | - function flattenRestrictions( $limit ) { |
| 1968 | + protected static function flattenRestrictions( $limit ) { |
2016 | 1969 | if( !is_array( $limit ) ) { |
2017 | 1970 | throw new MWException( 'Article::flattenRestrictions given non-array restriction set' ); |
2018 | 1971 | } |
— | — | @@ -2104,7 +2057,7 @@ |
2105 | 2058 | /* |
2106 | 2059 | * UI entry point for page deletion |
2107 | 2060 | */ |
2108 | | - function delete() { |
| 2061 | + public function delete() { |
2109 | 2062 | global $wgUser, $wgOut, $wgRequest; |
2110 | 2063 | |
2111 | 2064 | $confirm = $wgRequest->wasPosted() && |
— | — | @@ -2115,10 +2068,10 @@ |
2116 | 2069 | |
2117 | 2070 | $reason = $this->DeleteReasonList; |
2118 | 2071 | |
2119 | | - if ( $reason != 'other' && $this->DeleteReason != '') { |
| 2072 | + if( $reason != 'other' && $this->DeleteReason != '') { |
2120 | 2073 | // Entry from drop down menu + additional comment |
2121 | 2074 | $reason .= ': ' . $this->DeleteReason; |
2122 | | - } elseif ( $reason == 'other' ) { |
| 2075 | + } elseif( $reason == 'other' ) { |
2123 | 2076 | $reason = $this->DeleteReason; |
2124 | 2077 | } |
2125 | 2078 | # Flag to hide all contents of the archived revisions |
— | — | @@ -2127,7 +2080,7 @@ |
2128 | 2081 | # This code desperately needs to be totally rewritten |
2129 | 2082 | |
2130 | 2083 | # Read-only check... |
2131 | | - if ( wfReadOnly() ) { |
| 2084 | + if( wfReadOnly() ) { |
2132 | 2085 | $wgOut->readOnlyPage(); |
2133 | 2086 | return; |
2134 | 2087 | } |
— | — | @@ -2135,7 +2088,7 @@ |
2136 | 2089 | # Check permissions |
2137 | 2090 | $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser ); |
2138 | 2091 | |
2139 | | - if (count($permission_errors)>0) { |
| 2092 | + if(count($permission_errors)>0) { |
2140 | 2093 | $wgOut->showPermissionsErrorPage( $permission_errors ); |
2141 | 2094 | return; |
2142 | 2095 | } |
— | — | @@ -2146,7 +2099,7 @@ |
2147 | 2100 | $dbw = wfGetDB( DB_MASTER ); |
2148 | 2101 | $conds = $this->mTitle->pageCond(); |
2149 | 2102 | $latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__ ); |
2150 | | - if ( $latest === false ) { |
| 2103 | + if( $latest === false ) { |
2151 | 2104 | $wgOut->showFatalError( wfMsg( 'cannotdelete' ) ); |
2152 | 2105 | return; |
2153 | 2106 | } |
— | — | @@ -2172,7 +2125,7 @@ |
2173 | 2126 | |
2174 | 2127 | // Generate deletion reason |
2175 | 2128 | $hasHistory = false; |
2176 | | - if ( !$reason ) $reason = $this->generateReason($hasHistory); |
| 2129 | + if( !$reason ) $reason = $this->generateReason($hasHistory); |
2177 | 2130 | |
2178 | 2131 | // If the page has a history, insert a warning |
2179 | 2132 | if( $hasHistory && !$confirm ) { |
— | — | @@ -2191,7 +2144,7 @@ |
2192 | 2145 | /** |
2193 | 2146 | * @return bool whether or not the page surpasses $wgDeleteRevisionsLimit revisions |
2194 | 2147 | */ |
2195 | | - function isBigDeletion() { |
| 2148 | + public function isBigDeletion() { |
2196 | 2149 | global $wgDeleteRevisionsLimit; |
2197 | 2150 | if( $wgDeleteRevisionsLimit ) { |
2198 | 2151 | $revCount = $this->estimateRevisionCount(); |
— | — | @@ -2203,7 +2156,7 @@ |
2204 | 2157 | /** |
2205 | 2158 | * @return int approximate revision count |
2206 | 2159 | */ |
2207 | | - function estimateRevisionCount() { |
| 2160 | + public function estimateRevisionCount() { |
2208 | 2161 | $dbr = wfGetDB( DB_SLAVE ); |
2209 | 2162 | // For an exact count... |
2210 | 2163 | //return $dbr->selectField( 'revision', 'COUNT(*)', |
— | — | @@ -2218,9 +2171,8 @@ |
2219 | 2172 | * @param string $revLatest The latest rev_id, selected from the master (optional) |
2220 | 2173 | * @return array Array of authors, duplicates not removed |
2221 | 2174 | */ |
2222 | | - function getLastNAuthors( $num, $revLatest = 0 ) { |
| 2175 | + public function getLastNAuthors( $num, $revLatest = 0 ) { |
2223 | 2176 | wfProfileIn( __METHOD__ ); |
2224 | | - |
2225 | 2177 | // First try the slave |
2226 | 2178 | // If that doesn't have the latest revision, try the master |
2227 | 2179 | $continue = 2; |
— | — | @@ -2237,12 +2189,12 @@ |
2238 | 2190 | 'LIMIT' => $num |
2239 | 2191 | ) ) |
2240 | 2192 | ); |
2241 | | - if ( !$res ) { |
| 2193 | + if( !$res ) { |
2242 | 2194 | wfProfileOut( __METHOD__ ); |
2243 | 2195 | return array(); |
2244 | 2196 | } |
2245 | 2197 | $row = $db->fetchObject( $res ); |
2246 | | - if ( $continue == 2 && $revLatest && $row->rev_id != $revLatest ) { |
| 2198 | + if( $continue == 2 && $revLatest && $row->rev_id != $revLatest ) { |
2247 | 2199 | $db = wfGetDB( DB_MASTER ); |
2248 | 2200 | $continue--; |
2249 | 2201 | } else { |
— | — | @@ -2262,7 +2214,7 @@ |
2263 | 2215 | * Output deletion confirmation dialog |
2264 | 2216 | * @param $reason string Prefilled reason |
2265 | 2217 | */ |
2266 | | - function confirmDelete( $reason ) { |
| 2218 | + public function confirmDelete( $reason ) { |
2267 | 2219 | global $wgOut, $wgUser; |
2268 | 2220 | |
2269 | 2221 | wfDebug( "Article::confirmDelete\n" ); |
— | — | @@ -2328,21 +2280,22 @@ |
2329 | 2281 | Xml::hidden( 'wpEditToken', $wgUser->editToken() ) . |
2330 | 2282 | Xml::closeElement( 'form' ); |
2331 | 2283 | |
2332 | | - if ( $wgUser->isAllowed( 'editinterface' ) ) { |
| 2284 | + if( $wgUser->isAllowed( 'editinterface' ) ) { |
2333 | 2285 | $skin = $wgUser->getSkin(); |
2334 | 2286 | $link = $skin->makeLink ( 'MediaWiki:Deletereason-dropdown', wfMsgHtml( 'delete-edit-reasonlist' ) ); |
2335 | 2287 | $form .= '<p class="mw-delete-editreasons">' . $link . '</p>'; |
2336 | 2288 | } |
2337 | 2289 | |
2338 | 2290 | $wgOut->addHTML( $form ); |
2339 | | - $this->showLogExtract( $wgOut ); |
| 2291 | + LogEventsList::showLogExtract( $wgOut, 'delete', $this->mTitle->getPrefixedText() ); |
2340 | 2292 | } |
2341 | 2293 | |
2342 | 2294 | |
2343 | 2295 | /** |
2344 | 2296 | * Show relevant lines from the deletion log |
2345 | 2297 | */ |
2346 | | - function showLogExtract( $out ) { |
| 2298 | + public function showLogExtract( $out ) { |
| 2299 | + wfDeprecated( __METHOD__ ); |
2347 | 2300 | $out->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) ); |
2348 | 2301 | LogEventsList::showLogExtract( $out, 'delete', $this->mTitle->getPrefixedText() ); |
2349 | 2302 | } |
— | — | @@ -2351,16 +2304,13 @@ |
2352 | 2305 | /** |
2353 | 2306 | * Perform a deletion and output success or failure messages |
2354 | 2307 | */ |
2355 | | - function doDelete( $reason, $suppress = false ) { |
| 2308 | + public function doDelete( $reason, $suppress = false ) { |
2356 | 2309 | global $wgOut, $wgUser; |
2357 | | - wfDebug( __METHOD__."\n" ); |
2358 | | - |
2359 | 2310 | $id = $this->mTitle->getArticleID( GAID_FOR_UPDATE ); |
2360 | 2311 | |
2361 | 2312 | $error = ''; |
2362 | | - |
2363 | | - if ( wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason, &$error)) ) { |
2364 | | - if ( $this->doDeleteArticle( $reason, $suppress, $id ) ) { |
| 2313 | + if( wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason, &$error)) ) { |
| 2314 | + if( $this->doDeleteArticle( $reason, $suppress, $id ) ) { |
2365 | 2315 | $deleted = $this->mTitle->getPrefixedText(); |
2366 | 2316 | |
2367 | 2317 | $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) ); |
— | — | @@ -2372,7 +2322,7 @@ |
2373 | 2323 | $wgOut->returnToMain( false ); |
2374 | 2324 | wfRunHooks('ArticleDeleteComplete', array(&$this, &$wgUser, $reason, $id)); |
2375 | 2325 | } else { |
2376 | | - if ($error == '') |
| 2326 | + if( $error == '' ) |
2377 | 2327 | $wgOut->showFatalError( wfMsg( 'cannotdelete' ) ); |
2378 | 2328 | else |
2379 | 2329 | $wgOut->showFatalError( $error ); |
— | — | @@ -2385,7 +2335,7 @@ |
2386 | 2336 | * Deletes the article with database consistency, writes logs, purges caches |
2387 | 2337 | * Returns success |
2388 | 2338 | */ |
2389 | | - function doDeleteArticle( $reason, $suppress = false, $id = 0 ) { |
| 2339 | + public function doDeleteArticle( $reason, $suppress = false, $id = 0 ) { |
2390 | 2340 | global $wgUseSquid, $wgDeferredUpdateList; |
2391 | 2341 | global $wgUseTrackbacks; |
2392 | 2342 | |
— | — | @@ -2396,7 +2346,7 @@ |
2397 | 2347 | $t = $this->mTitle->getDBkey(); |
2398 | 2348 | $id = $id ? $id : $this->mTitle->getArticleID( GAID_FOR_UPDATE ); |
2399 | 2349 | |
2400 | | - if ( $t == '' || $id == 0 ) { |
| 2350 | + if( $t == '' || $id == 0 ) { |
2401 | 2351 | return false; |
2402 | 2352 | } |
2403 | 2353 | |
— | — | @@ -2404,7 +2354,7 @@ |
2405 | 2355 | array_push( $wgDeferredUpdateList, $u ); |
2406 | 2356 | |
2407 | 2357 | // Bitfields to further suppress the content |
2408 | | - if ( $suppress ) { |
| 2358 | + if( $suppress ) { |
2409 | 2359 | $bitfield = 0; |
2410 | 2360 | // This should be 15... |
2411 | 2361 | $bitfield |= Revision::DELETED_TEXT; |
— | — | @@ -2460,10 +2410,10 @@ |
2461 | 2411 | } |
2462 | 2412 | |
2463 | 2413 | # If using cascading deletes, we can skip some explicit deletes |
2464 | | - if ( !$dbw->cascadingDeletes() ) { |
| 2414 | + if( !$dbw->cascadingDeletes() ) { |
2465 | 2415 | $dbw->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ ); |
2466 | 2416 | |
2467 | | - if ($wgUseTrackbacks) |
| 2417 | + if($wgUseTrackbacks) |
2468 | 2418 | $dbw->delete( 'trackbacks', array( 'tb_page' => $id ), __METHOD__ ); |
2469 | 2419 | |
2470 | 2420 | # Delete outgoing links |
— | — | @@ -2477,7 +2427,7 @@ |
2478 | 2428 | } |
2479 | 2429 | |
2480 | 2430 | # If using cleanup triggers, we can skip some manual deletes |
2481 | | - if ( !$dbw->cleanupTriggers() ) { |
| 2431 | + if( !$dbw->cleanupTriggers() ) { |
2482 | 2432 | # Clean up recentchanges entries... |
2483 | 2433 | $dbw->delete( 'recentchanges', |
2484 | 2434 | array( 'rc_type != '.RC_LOG, |
— | — | @@ -2547,7 +2497,7 @@ |
2548 | 2498 | if( !$wgUser->matchEditToken( $token, array( $this->mTitle->getPrefixedText(), $fromP ) ) ) |
2549 | 2499 | $errors[] = array( 'sessionfailure' ); |
2550 | 2500 | |
2551 | | - if ( $wgUser->pingLimiter('rollback') || $wgUser->pingLimiter() ) { |
| 2501 | + if( $wgUser->pingLimiter('rollback') || $wgUser->pingLimiter() ) { |
2552 | 2502 | $errors[] = array( 'actionthrottledtext' ); |
2553 | 2503 | } |
2554 | 2504 | # If there were errors, bail out now |
— | — | @@ -2597,7 +2547,7 @@ |
2598 | 2548 | $s = $dbw->selectRow( 'revision', |
2599 | 2549 | array( 'rev_id', 'rev_timestamp', 'rev_deleted' ), |
2600 | 2550 | array( 'rev_page' => $current->getPage(), |
2601 | | - "rev_user <> {$user} OR rev_user_text <> {$user_text}" |
| 2551 | + "rev_user != {$user} OR rev_user_text != {$user_text}" |
2602 | 2552 | ), __METHOD__, |
2603 | 2553 | array( 'USE INDEX' => 'page_timestamp', |
2604 | 2554 | 'ORDER BY' => 'rev_timestamp DESC' ) |
— | — | @@ -2611,16 +2561,16 @@ |
2612 | 2562 | } |
2613 | 2563 | |
2614 | 2564 | $set = array(); |
2615 | | - if ( $bot && $wgUser->isAllowed('markbotedits') ) { |
| 2565 | + if( $bot && $wgUser->isAllowed('markbotedits') ) { |
2616 | 2566 | # Mark all reverted edits as bot |
2617 | 2567 | $set['rc_bot'] = 1; |
2618 | 2568 | } |
2619 | | - if ( $wgUseRCPatrol ) { |
| 2569 | + if( $wgUseRCPatrol ) { |
2620 | 2570 | # Mark all reverted edits as patrolled |
2621 | 2571 | $set['rc_patrolled'] = 1; |
2622 | 2572 | } |
2623 | 2573 | |
2624 | | - if ( $set ) { |
| 2574 | + if( $set ) { |
2625 | 2575 | $dbw->update( 'recentchanges', $set, |
2626 | 2576 | array( /* WHERE */ |
2627 | 2577 | 'rc_cur_id' => $current->getPage(), |
— | — | @@ -2654,7 +2604,7 @@ |
2655 | 2605 | $flags |= EDIT_FORCE_BOT; |
2656 | 2606 | # Actually store the edit |
2657 | 2607 | $status = $this->doEdit( $target->getText(), $summary, $flags, $target->getId() ); |
2658 | | - if ( !empty( $status->value['revision'] ) ) { |
| 2608 | + if( !empty( $status->value['revision'] ) ) { |
2659 | 2609 | $revId = $status->value['revision']->getId(); |
2660 | 2610 | } else { |
2661 | 2611 | $revId = false; |
— | — | @@ -2674,7 +2624,7 @@ |
2675 | 2625 | /** |
2676 | 2626 | * User interface for rollback operations |
2677 | 2627 | */ |
2678 | | - function rollback() { |
| 2628 | + public function rollback() { |
2679 | 2629 | global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol; |
2680 | 2630 | $details = null; |
2681 | 2631 | |
— | — | @@ -2749,12 +2699,10 @@ |
2750 | 2700 | |
2751 | 2701 | /** |
2752 | 2702 | * Do standard deferred updates after page view |
2753 | | - * @private |
2754 | 2703 | */ |
2755 | | - function viewUpdates() { |
| 2704 | + protected function viewUpdates() { |
2756 | 2705 | global $wgDeferredUpdateList, $wgUser; |
2757 | | - |
2758 | | - if ( 0 != $this->getID() ) { |
| 2706 | + if( 0 != $this->getID() ) { |
2759 | 2707 | # Don't update page view counters on views from bot users (bug 14044) |
2760 | 2708 | global $wgDisableCounters; |
2761 | 2709 | if( !$wgDisableCounters && !$wgUser->isAllowed( 'bot' ) ) { |
— | — | @@ -2763,7 +2711,6 @@ |
2764 | 2712 | array_push( $wgDeferredUpdateList, $u ); |
2765 | 2713 | } |
2766 | 2714 | } |
2767 | | - |
2768 | 2715 | # Update newtalk / watchlist notification status |
2769 | 2716 | $wgUser->clearNotification( $this->mTitle ); |
2770 | 2717 | } |
— | — | @@ -2772,8 +2719,8 @@ |
2773 | 2720 | * Prepare text which is about to be saved. |
2774 | 2721 | * Returns a stdclass with source, pst and output members |
2775 | 2722 | */ |
2776 | | - function prepareTextForEdit( $text, $revid=null ) { |
2777 | | - if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid) { |
| 2723 | + public function prepareTextForEdit( $text, $revid=null ) { |
| 2724 | + if( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid) { |
2778 | 2725 | // Already prepared |
2779 | 2726 | return $this->mPreparedEdit; |
2780 | 2727 | } |
— | — | @@ -2805,14 +2752,14 @@ |
2806 | 2753 | * @param $newid rev_id value of the new revision |
2807 | 2754 | * @param $changed Whether or not the content actually changed |
2808 | 2755 | */ |
2809 | | - function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange, $newid, $changed = true ) { |
| 2756 | + public function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange, $newid, $changed = true ) { |
2810 | 2757 | global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgParser, $wgEnableParserCache; |
2811 | 2758 | |
2812 | 2759 | wfProfileIn( __METHOD__ ); |
2813 | 2760 | |
2814 | 2761 | # Parse the text |
2815 | 2762 | # Be careful not to double-PST: $text is usually already PST-ed once |
2816 | | - if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) { |
| 2763 | + if( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) { |
2817 | 2764 | wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" ); |
2818 | 2765 | $editInfo = $this->prepareTextForEdit( $text, $newid ); |
2819 | 2766 | } else { |
— | — | @@ -2821,7 +2768,7 @@ |
2822 | 2769 | } |
2823 | 2770 | |
2824 | 2771 | # Save it to the parser cache |
2825 | | - if ( $wgEnableParserCache ) { |
| 2772 | + if( $wgEnableParserCache ) { |
2826 | 2773 | $parserCache = ParserCache::singleton(); |
2827 | 2774 | $parserCache->save( $editInfo->output, $this, $wgUser ); |
2828 | 2775 | } |
— | — | @@ -2834,7 +2781,7 @@ |
2835 | 2782 | wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $changed ) ); |
2836 | 2783 | |
2837 | 2784 | if( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) { |
2838 | | - if ( 0 == mt_rand( 0, 99 ) ) { |
| 2785 | + if( 0 == mt_rand( 0, 99 ) ) { |
2839 | 2786 | // Flush old entries from the `recentchanges` table; we do this on |
2840 | 2787 | // random requests so as to avoid an increase in writes for no good reason |
2841 | 2788 | global $wgRCMaxAge; |
— | — | @@ -2850,7 +2797,7 @@ |
2851 | 2798 | $title = $this->mTitle->getPrefixedDBkey(); |
2852 | 2799 | $shortTitle = $this->mTitle->getDBkey(); |
2853 | 2800 | |
2854 | | - if ( 0 == $id ) { |
| 2801 | + if( 0 == $id ) { |
2855 | 2802 | wfProfileOut( __METHOD__ ); |
2856 | 2803 | return; |
2857 | 2804 | } |
— | — | @@ -2868,7 +2815,7 @@ |
2869 | 2816 | && !( $minoredit && $wgUser->isAllowed( 'nominornewtalk' ) ) ) { |
2870 | 2817 | if( wfRunHooks('ArticleEditUpdateNewTalk', array( &$this ) ) ) { |
2871 | 2818 | $other = User::newFromName( $shortTitle, false ); |
2872 | | - if ( !$other ) { |
| 2819 | + if( !$other ) { |
2873 | 2820 | wfDebug( __METHOD__.": invalid username\n" ); |
2874 | 2821 | } elseif( User::isIP( $shortTitle ) ) { |
2875 | 2822 | // An anonymous user |
— | — | @@ -2881,7 +2828,7 @@ |
2882 | 2829 | } |
2883 | 2830 | } |
2884 | 2831 | |
2885 | | - if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| 2832 | + if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
2886 | 2833 | $wgMessageCache->replace( $shortTitle, $text ); |
2887 | 2834 | } |
2888 | 2835 | |
— | — | @@ -2897,7 +2844,7 @@ |
2898 | 2845 | * other shitty functions like editUpdates and such so it's not needed |
2899 | 2846 | * anymore. |
2900 | 2847 | */ |
2901 | | - function createUpdates( $rev ) { |
| 2848 | + public function createUpdates( $rev ) { |
2902 | 2849 | $this->mGoodAdjustment = $this->isCountable( $rev->getText() ); |
2903 | 2850 | $this->mTotalAdjustment = 1; |
2904 | 2851 | $this->editUpdates( $rev->getText(), $rev->getComment(), |
— | — | @@ -2910,14 +2857,13 @@ |
2911 | 2858 | * Revision as of \<date\>; view current revision |
2912 | 2859 | * \<- Previous version | Next Version -\> |
2913 | 2860 | * |
2914 | | - * @private |
2915 | 2861 | * @param string $oldid Revision ID of this article revision |
2916 | 2862 | */ |
2917 | | - function setOldSubtitle( $oldid=0 ) { |
| 2863 | + protected function setOldSubtitle( $oldid=0 ) { |
2918 | 2864 | global $wgLang, $wgOut, $wgUser; |
2919 | 2865 | |
2920 | | - if ( !wfRunHooks( 'DisplayOldSubtitle', array(&$this, &$oldid) ) ) { |
2921 | | - return; |
| 2866 | + if( !wfRunHooks( 'DisplayOldSubtitle', array(&$this, &$oldid) ) ) { |
| 2867 | + return; |
2922 | 2868 | } |
2923 | 2869 | |
2924 | 2870 | $revision = Revision::newFromId( $oldid ); |
— | — | @@ -2987,7 +2933,7 @@ |
2988 | 2934 | * |
2989 | 2935 | * @param string $text |
2990 | 2936 | */ |
2991 | | - function preSaveTransform( $text ) { |
| 2937 | + public function preSaveTransform( $text ) { |
2992 | 2938 | global $wgParser, $wgUser; |
2993 | 2939 | return $wgParser->preSaveTransform( $text, $this->mTitle, $wgUser, ParserOptions::newFromUser( $wgUser ) ); |
2994 | 2940 | } |
— | — | @@ -2999,7 +2945,7 @@ |
3000 | 2946 | * output to the client that is necessary for this request. |
3001 | 2947 | * (that is, it has sent a cached version of the page) |
3002 | 2948 | */ |
3003 | | - function tryFileCache() { |
| 2949 | + protected function tryFileCache() { |
3004 | 2950 | static $called = false; |
3005 | 2951 | if( $called ) { |
3006 | 2952 | wfDebug( "Article::tryFileCache(): called twice!?\n" ); |
— | — | @@ -3027,7 +2973,7 @@ |
3028 | 2974 | * Check if the page can be cached |
3029 | 2975 | * @return bool |
3030 | 2976 | */ |
3031 | | - function isFileCacheable() { |
| 2977 | + public function isFileCacheable() { |
3032 | 2978 | global $wgUser, $wgUseFileCache, $wgShowIPinHeader, $wgRequest, $wgLang, $wgContLang; |
3033 | 2979 | // Get all query values |
3034 | 2980 | $queryVals = $wgRequest->getValues(); |
— | — | @@ -3061,7 +3007,7 @@ |
3062 | 3008 | * Loads page_touched and returns a value indicating if it should be used |
3063 | 3009 | * |
3064 | 3010 | */ |
3065 | | - function checkTouched() { |
| 3011 | + public function checkTouched() { |
3066 | 3012 | if( !$this->mDataLoaded ) { |
3067 | 3013 | $this->loadPageData(); |
3068 | 3014 | } |
— | — | @@ -3071,7 +3017,7 @@ |
3072 | 3018 | /** |
3073 | 3019 | * Get the page_touched field |
3074 | 3020 | */ |
3075 | | - function getTouched() { |
| 3021 | + public function getTouched() { |
3076 | 3022 | # Ensure that page data has been loaded |
3077 | 3023 | if( !$this->mDataLoaded ) { |
3078 | 3024 | $this->loadPageData(); |
— | — | @@ -3082,8 +3028,8 @@ |
3083 | 3029 | /** |
3084 | 3030 | * Get the page_latest field |
3085 | 3031 | */ |
3086 | | - function getLatest() { |
3087 | | - if ( !$this->mDataLoaded ) { |
| 3032 | + public function getLatest() { |
| 3033 | + if( !$this->mDataLoaded ) { |
3088 | 3034 | $this->loadPageData(); |
3089 | 3035 | } |
3090 | 3036 | return $this->mLatest; |
— | — | @@ -3098,7 +3044,7 @@ |
3099 | 3045 | * @param string $comment comment submitted |
3100 | 3046 | * @param bool $minor whereas it's a minor modification |
3101 | 3047 | */ |
3102 | | - function quickEdit( $text, $comment = '', $minor = 0 ) { |
| 3048 | + public function quickEdit( $text, $comment = '', $minor = 0 ) { |
3103 | 3049 | wfProfileIn( __METHOD__ ); |
3104 | 3050 | |
3105 | 3051 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -3119,10 +3065,9 @@ |
3120 | 3066 | /** |
3121 | 3067 | * Used to increment the view counter |
3122 | 3068 | * |
3123 | | - * @static |
3124 | 3069 | * @param integer $id article id |
3125 | 3070 | */ |
3126 | | - function incViewCount( $id ) { |
| 3071 | + public static function incViewCount( $id ) { |
3127 | 3072 | $id = intval( $id ); |
3128 | 3073 | global $wgHitcounterUpdateFreq, $wgDBtype; |
3129 | 3074 | |
— | — | @@ -3155,14 +3100,14 @@ |
3156 | 3101 | wfProfileIn( 'Article::incViewCount-collect' ); |
3157 | 3102 | $old_user_abort = ignore_user_abort( true ); |
3158 | 3103 | |
3159 | | - if ($wgDBtype == 'mysql') |
| 3104 | + if($wgDBtype == 'mysql') |
3160 | 3105 | $dbw->query("LOCK TABLES $hitcounterTable WRITE"); |
3161 | 3106 | $tabletype = $wgDBtype == 'mysql' ? "ENGINE=HEAP " : ''; |
3162 | 3107 | $dbw->query("CREATE TEMPORARY TABLE $acchitsTable $tabletype AS ". |
3163 | 3108 | "SELECT hc_id,COUNT(*) AS hc_n FROM $hitcounterTable ". |
3164 | 3109 | 'GROUP BY hc_id'); |
3165 | 3110 | $dbw->query("DELETE FROM $hitcounterTable"); |
3166 | | - if ($wgDBtype == 'mysql') { |
| 3111 | + if($wgDBtype == 'mysql') { |
3167 | 3112 | $dbw->query('UNLOCK TABLES'); |
3168 | 3113 | $dbw->query("UPDATE $pageTable,$acchitsTable SET page_counter=page_counter + hc_n ". |
3169 | 3114 | 'WHERE page_id = hc_id'); |
— | — | @@ -3193,7 +3138,7 @@ |
3194 | 3139 | |
3195 | 3140 | public static function onArticleCreate( $title ) { |
3196 | 3141 | # Update existence markers on article/talk tabs... |
3197 | | - if ( $title->isTalkPage() ) { |
| 3142 | + if( $title->isTalkPage() ) { |
3198 | 3143 | $other = $title->getSubjectPage(); |
3199 | 3144 | } else { |
3200 | 3145 | $other = $title->getTalkPage(); |
— | — | @@ -3221,7 +3166,7 @@ |
3222 | 3167 | $title->purgeSquid(); |
3223 | 3168 | |
3224 | 3169 | # File cache |
3225 | | - if ( $wgUseFileCache ) { |
| 3170 | + if( $wgUseFileCache ) { |
3226 | 3171 | $cm = new HTMLFileCache( $title ); |
3227 | 3172 | @unlink( $cm->fileCacheName() ); |
3228 | 3173 | } |
— | — | @@ -3259,7 +3204,7 @@ |
3260 | 3205 | $title->purgeSquid(); |
3261 | 3206 | |
3262 | 3207 | # Clear file cache for this page only |
3263 | | - if ( $wgUseFileCache ) { |
| 3208 | + if( $wgUseFileCache ) { |
3264 | 3209 | $cm = new HTMLFileCache( $title ); |
3265 | 3210 | @unlink( $cm->fileCacheName() ); |
3266 | 3211 | } |
— | — | @@ -3271,7 +3216,7 @@ |
3272 | 3217 | * Overriden by ImagePage class, only present here to avoid a fatal error |
3273 | 3218 | * Called for ?action=revert |
3274 | 3219 | */ |
3275 | | - public function revert(){ |
| 3220 | + public function revert() { |
3276 | 3221 | global $wgOut; |
3277 | 3222 | $wgOut->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
3278 | 3223 | } |
— | — | @@ -3282,10 +3227,10 @@ |
3283 | 3228 | * |
3284 | 3229 | * @public |
3285 | 3230 | */ |
3286 | | - function info() { |
| 3231 | + public function info() { |
3287 | 3232 | global $wgLang, $wgOut, $wgAllowPageInfo, $wgUser; |
3288 | 3233 | |
3289 | | - if ( !$wgAllowPageInfo ) { |
| 3234 | + if( !$wgAllowPageInfo ) { |
3290 | 3235 | $wgOut->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
3291 | 3236 | return; |
3292 | 3237 | } |
— | — | @@ -3334,7 +3279,6 @@ |
3335 | 3280 | $wgOut->addHTML( '<li>' . wfMsg('numtalkauthors', $wgLang->formatNum( $talkInfo['authors'] ) ) . '</li>' ); |
3336 | 3281 | } |
3337 | 3282 | $wgOut->addHTML( '</ul>' ); |
3338 | | - |
3339 | 3283 | } |
3340 | 3284 | } |
3341 | 3285 | |
— | — | @@ -3344,32 +3288,28 @@ |
3345 | 3289 | * |
3346 | 3290 | * @param Title $title |
3347 | 3291 | * @return array |
3348 | | - * @private |
3349 | 3292 | */ |
3350 | | - function pageCountInfo( $title ) { |
| 3293 | + protected function pageCountInfo( $title ) { |
3351 | 3294 | $id = $title->getArticleId(); |
3352 | 3295 | if( $id == 0 ) { |
3353 | 3296 | return false; |
3354 | 3297 | } |
3355 | | - |
3356 | 3298 | $dbr = wfGetDB( DB_SLAVE ); |
3357 | | - |
3358 | 3299 | $rev_clause = array( 'rev_page' => $id ); |
3359 | | - |
3360 | 3300 | $edits = $dbr->selectField( |
3361 | 3301 | 'revision', |
3362 | 3302 | 'COUNT(rev_page)', |
3363 | 3303 | $rev_clause, |
3364 | 3304 | __METHOD__, |
3365 | | - $this->getSelectOptions() ); |
3366 | | - |
| 3305 | + $this->getSelectOptions() |
| 3306 | + ); |
3367 | 3307 | $authors = $dbr->selectField( |
3368 | 3308 | 'revision', |
3369 | 3309 | 'COUNT(DISTINCT rev_user_text)', |
3370 | 3310 | $rev_clause, |
3371 | 3311 | __METHOD__, |
3372 | | - $this->getSelectOptions() ); |
3373 | | - |
| 3312 | + $this->getSelectOptions() |
| 3313 | + ); |
3374 | 3314 | return array( 'edits' => $edits, 'authors' => $authors ); |
3375 | 3315 | } |
3376 | 3316 | |
— | — | @@ -3385,13 +3325,12 @@ |
3386 | 3326 | if( $id == 0 ) { |
3387 | 3327 | return array(); |
3388 | 3328 | } |
3389 | | - |
3390 | 3329 | $dbr = wfGetDB( DB_SLAVE ); |
3391 | 3330 | $res = $dbr->select( array( 'templatelinks' ), |
3392 | 3331 | array( 'tl_namespace', 'tl_title' ), |
3393 | 3332 | array( 'tl_from' => $id ), |
3394 | 3333 | __METHOD__ ); |
3395 | | - if( false !== $res ) { |
| 3334 | + if( $res !== false ) { |
3396 | 3335 | foreach( $res as $row ) { |
3397 | 3336 | $result[] = Title::makeTitle( $row->tl_namespace, $row->tl_title ); |
3398 | 3337 | } |
— | — | @@ -3412,14 +3351,13 @@ |
3413 | 3352 | if( $id == 0 ) { |
3414 | 3353 | return array(); |
3415 | 3354 | } |
3416 | | - |
3417 | 3355 | $dbr = wfGetDB( DB_SLAVE ); |
3418 | 3356 | $res = $dbr->select( array( 'categorylinks', 'page_props', 'page' ), |
3419 | 3357 | array( 'cl_to' ), |
3420 | 3358 | array( 'cl_from' => $id, 'pp_page=page_id', 'pp_propname' => 'hiddencat', |
3421 | 3359 | 'page_namespace' => NS_CATEGORY, 'page_title=cl_to'), |
3422 | 3360 | __METHOD__ ); |
3423 | | - if ( false !== $res ) { |
| 3361 | + if( $res !== false ) { |
3424 | 3362 | foreach( $res as $row ) { |
3425 | 3363 | $result[] = Title::makeTitle( NS_CATEGORY, $row->cl_to ); |
3426 | 3364 | } |
— | — | @@ -3493,7 +3431,7 @@ |
3494 | 3432 | $popts, true, true, $this->getRevIdFetched() ); |
3495 | 3433 | $popts->setTidy(false); |
3496 | 3434 | $popts->enableLimitReport( false ); |
3497 | | - if ( $wgEnableParserCache && $cache && $this && $parserOutput->getCacheTime() != -1 ) { |
| 3435 | + if( $wgEnableParserCache && $cache && $this && $parserOutput->getCacheTime() != -1 ) { |
3498 | 3436 | $parserCache = ParserCache::singleton(); |
3499 | 3437 | $parserCache->save( $parserOutput, $this, $wgUser ); |
3500 | 3438 | } |
— | — | @@ -3504,7 +3442,7 @@ |
3505 | 3443 | $wgUseFileCache = false; |
3506 | 3444 | } |
3507 | 3445 | |
3508 | | - if ( $this->isCurrent() && !wfReadOnly() && $this->mTitle->areRestrictionsCascading() ) { |
| 3446 | + if( $this->isCurrent() && !wfReadOnly() && $this->mTitle->areRestrictionsCascading() ) { |
3509 | 3447 | // templatelinks table may have become out of sync, |
3510 | 3448 | // especially if using variable-based transclusions. |
3511 | 3449 | // For paranoia, check if things have changed and if |
— | — | @@ -3525,7 +3463,7 @@ |
3526 | 3464 | |
3527 | 3465 | global $wgContLang; |
3528 | 3466 | |
3529 | | - if ( false !== $res ) { |
| 3467 | + if( $res !== false ) { |
3530 | 3468 | foreach( $res as $row ) { |
3531 | 3469 | $tlTemplates[] = $wgContLang->getNsText( $row->tl_namespace ) . ':' . $row->tl_title ; |
3532 | 3470 | } |
— | — | @@ -3542,7 +3480,7 @@ |
3543 | 3481 | # Get the diff |
3544 | 3482 | $templates_diff = array_diff( $poTemplates, $tlTemplates ); |
3545 | 3483 | |
3546 | | - if ( count( $templates_diff ) > 0 ) { |
| 3484 | + if( count( $templates_diff ) > 0 ) { |
3547 | 3485 | # Whee, link updates time. |
3548 | 3486 | $u = new LinksUpdate( $this->mTitle, $parserOutput ); |
3549 | 3487 | $u->doUpdate(); |
— | — | @@ -3591,7 +3529,7 @@ |
3592 | 3530 | $removeFields[] = 'cat_files = cat_files - 1'; |
3593 | 3531 | } |
3594 | 3532 | |
3595 | | - if ( $added ) { |
| 3533 | + if( $added ) { |
3596 | 3534 | $dbw->update( |
3597 | 3535 | 'category', |
3598 | 3536 | $addFields, |
— | — | @@ -3599,7 +3537,7 @@ |
3600 | 3538 | __METHOD__ |
3601 | 3539 | ); |
3602 | 3540 | } |
3603 | | - if ( $deleted ) { |
| 3541 | + if( $deleted ) { |
3604 | 3542 | $dbw->update( |
3605 | 3543 | 'category', |
3606 | 3544 | $removeFields, |
Index: trunk/phase3/includes/ImagePage.php |
— | — | @@ -24,20 +24,20 @@ |
25 | 25 | } |
26 | 26 | |
27 | 27 | protected function loadFile() { |
28 | | - if ( $this->fileLoaded ) { |
| 28 | + if( $this->fileLoaded ) { |
29 | 29 | return true; |
30 | 30 | } |
31 | 31 | $this->fileLoaded = true; |
32 | 32 | |
33 | 33 | $this->displayImg = $this->img = false; |
34 | 34 | wfRunHooks( 'ImagePageFindFile', array( $this, &$this->img, &$this->displayImg ) ); |
35 | | - if ( !$this->img ) { |
| 35 | + if( !$this->img ) { |
36 | 36 | $this->img = wfFindFile( $this->mTitle ); |
37 | | - if ( !$this->img ) { |
| 37 | + if( !$this->img ) { |
38 | 38 | $this->img = wfLocalFile( $this->mTitle ); |
39 | 39 | } |
40 | 40 | } |
41 | | - if ( !$this->displayImg ) { |
| 41 | + if( !$this->displayImg ) { |
42 | 42 | $this->displayImg = $this->img; |
43 | 43 | } |
44 | 44 | $this->repo = $this->img->getRepo(); |
— | — | @@ -47,18 +47,18 @@ |
48 | 48 | * Handler for action=render |
49 | 49 | * Include body text only; none of the image extras |
50 | 50 | */ |
51 | | - function render() { |
| 51 | + public function render() { |
52 | 52 | global $wgOut; |
53 | 53 | $wgOut->setArticleBodyOnly( true ); |
54 | 54 | parent::view(); |
55 | 55 | } |
56 | 56 | |
57 | | - function view() { |
| 57 | + public function view() { |
58 | 58 | global $wgOut, $wgShowEXIF, $wgRequest, $wgUser; |
59 | 59 | $this->loadFile(); |
60 | 60 | |
61 | | - if ( $this->mTitle->getNamespace() == NS_IMAGE && $this->img->getRedirected() ) { |
62 | | - if ( $this->mTitle->getDBkey() == $this->img->getName() ) { |
| 61 | + if( $this->mTitle->getNamespace() == NS_IMAGE && $this->img->getRedirected() ) { |
| 62 | + if( $this->mTitle->getDBkey() == $this->img->getName() ) { |
63 | 63 | // mTitle is the same as the redirect target so ask Article |
64 | 64 | // to perform the redirect for us. |
65 | 65 | return Article::view(); |
— | — | @@ -76,10 +76,10 @@ |
77 | 77 | $diff = $wgRequest->getVal( 'diff' ); |
78 | 78 | $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) ); |
79 | 79 | |
80 | | - if ( $this->mTitle->getNamespace() != NS_IMAGE || ( isset( $diff ) && $diffOnly ) ) |
| 80 | + if( $this->mTitle->getNamespace() != NS_IMAGE || ( isset( $diff ) && $diffOnly ) ) |
81 | 81 | return Article::view(); |
82 | 82 | |
83 | | - if ( $wgShowEXIF && $this->displayImg->exists() ) { |
| 83 | + if( $wgShowEXIF && $this->displayImg->exists() ) { |
84 | 84 | // FIXME: bad interface, see note on MediaHandler::formatMetadata(). |
85 | 85 | $formattedMetadata = $this->displayImg->formatMetadata(); |
86 | 86 | $showmeta = $formattedMetadata !== false; |
— | — | @@ -87,13 +87,13 @@ |
88 | 88 | $showmeta = false; |
89 | 89 | } |
90 | 90 | |
91 | | - if ( $this->displayImg->exists() ) |
| 91 | + if( $this->displayImg->exists() ) |
92 | 92 | $wgOut->addHTML( $this->showTOC($showmeta) ); |
93 | 93 | |
94 | 94 | $this->openShowImage(); |
95 | 95 | |
96 | 96 | # No need to display noarticletext, we use our own message, output in openShowImage() |
97 | | - if ( $this->getID() ) { |
| 97 | + if( $this->getID() ) { |
98 | 98 | Article::view(); |
99 | 99 | } else { |
100 | 100 | # Just need to set the right headers |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | } |
106 | 106 | |
107 | 107 | # Show shared description, if needed |
108 | | - if ( $this->mExtraDescription ) { |
| 108 | + if( $this->mExtraDescription ) { |
109 | 109 | $fol = wfMsgNoTrans( 'shareddescriptionfollows' ); |
110 | 110 | if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) { |
111 | 111 | $wgOut->addWikiText( $fol ); |
— | — | @@ -124,12 +124,12 @@ |
125 | 125 | $this->imageDupes(); |
126 | 126 | // TODO: We may want to find local images redirecting to a foreign |
127 | 127 | // file: "The following local files redirect to this file" |
128 | | - if ( $this->img->isLocal() ) { |
| 128 | + if( $this->img->isLocal() ) { |
129 | 129 | $this->imageRedirects(); |
130 | 130 | } |
131 | 131 | $this->imageLinks(); |
132 | 132 | |
133 | | - if ( $showmeta ) { |
| 133 | + if( $showmeta ) { |
134 | 134 | global $wgStylePath, $wgStyleVersion; |
135 | 135 | $expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) ); |
136 | 136 | $collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) ); |
— | — | @@ -143,32 +143,32 @@ |
144 | 144 | |
145 | 145 | public function getRedirectTarget() { |
146 | 146 | $this->loadFile(); |
147 | | - if ( $this->img->isLocal() ) { |
| 147 | + if( $this->img->isLocal() ) { |
148 | 148 | return parent::getRedirectTarget(); |
149 | 149 | } |
150 | 150 | // Foreign image page |
151 | 151 | $from = $this->img->getRedirected(); |
152 | 152 | $to = $this->img->getName(); |
153 | | - if ( $from == $to ) { |
| 153 | + if( $from == $to ) { |
154 | 154 | return null; |
155 | 155 | } |
156 | 156 | return $this->mRedirectTarget = Title::makeTitle( NS_IMAGE, $to ); |
157 | 157 | } |
158 | 158 | public function followRedirect() { |
159 | 159 | $this->loadFile(); |
160 | | - if ( $this->img->isLocal() ) { |
| 160 | + if( $this->img->isLocal() ) { |
161 | 161 | return parent::followRedirect(); |
162 | 162 | } |
163 | 163 | $from = $this->img->getRedirected(); |
164 | 164 | $to = $this->img->getName(); |
165 | | - if ( $from == $to ) { |
| 165 | + if( $from == $to ) { |
166 | 166 | return false; |
167 | 167 | } |
168 | 168 | return Title::makeTitle( NS_IMAGE, $to ); |
169 | 169 | } |
170 | 170 | public function isRedirect( $text = false ) { |
171 | 171 | $this->loadFile(); |
172 | | - if ( $this->img->isLocal() ) |
| 172 | + if( $this->img->isLocal() ) |
173 | 173 | return parent::isRedirect( $text ); |
174 | 174 | |
175 | 175 | return (bool)$this->img->getRedirected(); |
— | — | @@ -191,10 +191,10 @@ |
192 | 192 | |
193 | 193 | public function getDuplicates() { |
194 | 194 | $this->loadFile(); |
195 | | - if ( !is_null($this->dupes) ) { |
| 195 | + if( !is_null($this->dupes) ) { |
196 | 196 | return $this->dupes; |
197 | 197 | } |
198 | | - if ( !( $hash = $this->img->getSha1() ) ) { |
| 198 | + if( !( $hash = $this->img->getSha1() ) ) { |
199 | 199 | return $this->dupes = array(); |
200 | 200 | } |
201 | 201 | $dupes = RepoGroup::singleton()->findBySha1( $hash ); |
— | — | @@ -203,9 +203,9 @@ |
204 | 204 | $size = $this->img->getSize(); |
205 | 205 | foreach ( $dupes as $index => $file ) { |
206 | 206 | $key = $file->getRepoName().':'.$file->getName(); |
207 | | - if ( $key == $self ) |
| 207 | + if( $key == $self ) |
208 | 208 | unset( $dupes[$index] ); |
209 | | - if ( $file->getSize() != $size ) |
| 209 | + if( $file->getSize() != $size ) |
210 | 210 | unset( $dupes[$index] ); |
211 | 211 | } |
212 | 212 | return $this->dupes = $dupes; |
— | — | @@ -216,12 +216,10 @@ |
217 | 217 | /** |
218 | 218 | * Create the TOC |
219 | 219 | * |
220 | | - * @access private |
221 | | - * |
222 | 220 | * @param bool $metadata Whether or not to show the metadata link |
223 | 221 | * @return string |
224 | 222 | */ |
225 | | - function showTOC( $metadata ) { |
| 223 | + protected function showTOC( $metadata ) { |
226 | 224 | global $wgLang; |
227 | 225 | $r = '<ul id="filetoc"> |
228 | 226 | <li><a href="#file">' . $wgLang->getNsText( NS_IMAGE ) . '</a></li> |
— | — | @@ -237,12 +235,10 @@ |
238 | 236 | * |
239 | 237 | * FIXME: bad interface, see note on MediaHandler::formatMetadata(). |
240 | 238 | * |
241 | | - * @access private |
242 | | - * |
243 | 239 | * @param array $exif The array containing the EXIF data |
244 | 240 | * @return string |
245 | 241 | */ |
246 | | - function makeMetadataTable( $metadata ) { |
| 242 | + protected function makeMetadataTable( $metadata ) { |
247 | 243 | $r = wfMsg( 'metadata-help' ) . "\n\n"; |
248 | 244 | $r .= "{| id=mw_metadata class=mw_metadata\n"; |
249 | 245 | foreach ( $metadata as $type => $stuff ) { |
— | — | @@ -266,7 +262,7 @@ |
267 | 263 | * Omit noarticletext if sharedupload; text will be fetched from the |
268 | 264 | * shared upload server if possible. |
269 | 265 | */ |
270 | | - function getContent() { |
| 266 | + public function getContent() { |
271 | 267 | $this->loadFile(); |
272 | 268 | if( $this->img && !$this->img->isLocal() && 0 == $this->getID() ) { |
273 | 269 | return ''; |
— | — | @@ -274,7 +270,7 @@ |
275 | 271 | return Article::getContent(); |
276 | 272 | } |
277 | 273 | |
278 | | - function openShowImage() { |
| 274 | + protected function openShowImage() { |
279 | 275 | global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgContLang; |
280 | 276 | |
281 | 277 | $this->loadFile(); |
— | — | @@ -298,10 +294,10 @@ |
299 | 295 | $sk = $wgUser->getSkin(); |
300 | 296 | $dirmark = $wgContLang->getDirMark(); |
301 | 297 | |
302 | | - if ( $this->displayImg->exists() ) { |
| 298 | + if( $this->displayImg->exists() ) { |
303 | 299 | # image |
304 | 300 | $page = $wgRequest->getIntOrNull( 'page' ); |
305 | | - if ( is_null( $page ) ) { |
| 301 | + if( is_null( $page ) ) { |
306 | 302 | $params = array(); |
307 | 303 | $page = 1; |
308 | 304 | } else { |
— | — | @@ -318,16 +314,16 @@ |
319 | 315 | |
320 | 316 | wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this , &$wgOut ) ) ; |
321 | 317 | |
322 | | - if ( $this->displayImg->allowInlineDisplay() ) { |
| 318 | + if( $this->displayImg->allowInlineDisplay() ) { |
323 | 319 | # image |
324 | 320 | |
325 | 321 | # "Download high res version" link below the image |
326 | 322 | #$msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->displayImg->getSize() ), $mime ); |
327 | 323 | # We'll show a thumbnail of this image |
328 | | - if ( $width > $maxWidth || $height > $maxHeight ) { |
| 324 | + if( $width > $maxWidth || $height > $maxHeight ) { |
329 | 325 | # Calculate the thumbnail size. |
330 | 326 | # First case, the limiting factor is the width, not the height. |
331 | | - if ( $width / $height >= $maxWidth / $maxHeight ) { |
| 327 | + if( $width / $height >= $maxWidth / $maxHeight ) { |
332 | 328 | $height = round( $height * $maxWidth / $width); |
333 | 329 | $width = $maxWidth; |
334 | 330 | # Note that $height <= $maxHeight now. |
— | — | @@ -361,11 +357,11 @@ |
362 | 358 | '<br />' . Xml::tags( 'a', $linkAttribs, $msgbig ) . "$dirmark " . $longDesc; |
363 | 359 | } |
364 | 360 | |
365 | | - if ( $this->displayImg->isMultipage() ) { |
| 361 | + if( $this->displayImg->isMultipage() ) { |
366 | 362 | $wgOut->addHTML( '<table class="multipageimage"><tr><td>' ); |
367 | 363 | } |
368 | 364 | |
369 | | - if ( $thumbnail ) { |
| 365 | + if( $thumbnail ) { |
370 | 366 | $options = array( |
371 | 367 | 'alt' => $this->displayImg->getTitle()->getPrefixedText(), |
372 | 368 | 'file-link' => true, |
— | — | @@ -375,10 +371,10 @@ |
376 | 372 | $anchorclose . '</div>' ); |
377 | 373 | } |
378 | 374 | |
379 | | - if ( $this->displayImg->isMultipage() ) { |
| 375 | + if( $this->displayImg->isMultipage() ) { |
380 | 376 | $count = $this->displayImg->pageCount(); |
381 | 377 | |
382 | | - if ( $page > 1 ) { |
| 378 | + if( $page > 1 ) { |
383 | 379 | $label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false ); |
384 | 380 | $link = $sk->makeKnownLinkObj( $this->mTitle, $label, 'page='. ($page-1) ); |
385 | 381 | $thumb1 = $sk->makeThumbLinkObj( $this->mTitle, $this->displayImg, $link, $label, 'none', |
— | — | @@ -387,7 +383,7 @@ |
388 | 384 | $thumb1 = ''; |
389 | 385 | } |
390 | 386 | |
391 | | - if ( $page < $count ) { |
| 387 | + if( $page < $count ) { |
392 | 388 | $label = wfMsg( 'imgmultipagenext' ); |
393 | 389 | $link = $sk->makeKnownLinkObj( $this->mTitle, $label, 'page='. ($page+1) ); |
394 | 390 | $thumb2 = $sk->makeThumbLinkObj( $this->mTitle, $this->displayImg, $link, $label, 'none', |
— | — | @@ -424,7 +420,7 @@ |
425 | 421 | } |
426 | 422 | } else { |
427 | 423 | #if direct link is allowed but it's not a renderable image, show an icon. |
428 | | - if ( $this->displayImg->isSafeFile() ) { |
| 424 | + if( $this->displayImg->isSafeFile() ) { |
429 | 425 | $icon= $this->displayImg->iconThumb(); |
430 | 426 | |
431 | 427 | $wgOut->addHTML( '<div class="fullImageLink" id="file">' . |
— | — | @@ -436,10 +432,10 @@ |
437 | 433 | } |
438 | 434 | |
439 | 435 | |
440 | | - if ($showLink) { |
| 436 | + if($showLink) { |
441 | 437 | $filename = wfEscapeWikiText( $this->displayImg->getName() ); |
442 | 438 | |
443 | | - if ( !$this->displayImg->isSafeFile() ) { |
| 439 | + if( !$this->displayImg->isSafeFile() ) { |
444 | 440 | $warning = wfMsgNoTrans( 'mediawarning' ); |
445 | 441 | $wgOut->addWikiText( <<<EOT |
446 | 442 | <div class="fullMedia"> |
— | — | @@ -476,7 +472,7 @@ |
477 | 473 | /** |
478 | 474 | * Show a notice that the file is from a shared repository |
479 | 475 | */ |
480 | | - function printSharedImageText() { |
| 476 | + protected function printSharedImageText() { |
481 | 477 | global $wgOut, $wgUser; |
482 | 478 | |
483 | 479 | $this->loadFile(); |
— | — | @@ -484,12 +480,12 @@ |
485 | 481 | $descUrl = $this->img->getDescriptionUrl(); |
486 | 482 | $descText = $this->img->getDescriptionText(); |
487 | 483 | $s = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml( 'sharedupload' ); |
488 | | - if ( $descUrl ) { |
| 484 | + if( $descUrl ) { |
489 | 485 | $sk = $wgUser->getSkin(); |
490 | 486 | $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadwiki-linktext' ) ); |
491 | 487 | $msg = ( $descText ) ? 'shareduploadwiki-desc' : 'shareduploadwiki'; |
492 | 488 | $msg = wfMsgExt( $msg, array( 'parseinline', 'replaceafter' ), $link ); |
493 | | - if ( $msg != '-' ) { |
| 489 | + if( $msg != '-' ) { |
494 | 490 | # Show message only if not voided by local sysops |
495 | 491 | $s .= $msg; |
496 | 492 | } |
— | — | @@ -497,7 +493,7 @@ |
498 | 494 | $s .= "</div>"; |
499 | 495 | $wgOut->addHTML( $s ); |
500 | 496 | |
501 | | - if ( $descText ) { |
| 497 | + if( $descText ) { |
502 | 498 | $this->mExtraDescription = $descText; |
503 | 499 | } |
504 | 500 | } |
— | — | @@ -505,7 +501,7 @@ |
506 | 502 | /* |
507 | 503 | * Check for files with the same name on the foreign repos. |
508 | 504 | */ |
509 | | - function checkSharedConflict() { |
| 505 | + protected function checkSharedConflict() { |
510 | 506 | global $wgOut, $wgUser; |
511 | 507 | |
512 | 508 | $repoGroup = RepoGroup::singleton(); |
— | — | @@ -540,7 +536,7 @@ |
541 | 537 | } |
542 | 538 | } |
543 | 539 | |
544 | | - function checkSharedConflictCallback( $repo ) { |
| 540 | + protected function checkSharedConflictCallback( $repo ) { |
545 | 541 | $this->loadFile(); |
546 | 542 | $dupfile = $repo->newFile( $this->img->getTitle() ); |
547 | 543 | if( $dupfile && $dupfile->exists() ) { |
— | — | @@ -550,7 +546,7 @@ |
551 | 547 | return false; |
552 | 548 | } |
553 | 549 | |
554 | | - function getUploadUrl() { |
| 550 | + public function getUploadUrl() { |
555 | 551 | $this->loadFile(); |
556 | 552 | $uploadTitle = SpecialPage::getTitleFor( 'Upload' ); |
557 | 553 | return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) ); |
— | — | @@ -560,7 +556,7 @@ |
561 | 557 | * Print out the various links at the bottom of the image page, e.g. reupload, |
562 | 558 | * external editing (and instructions link) etc. |
563 | 559 | */ |
564 | | - function uploadLinksBox() { |
| 560 | + protected function uploadLinksBox() { |
565 | 561 | global $wgUser, $wgOut; |
566 | 562 | |
567 | 563 | $this->loadFile(); |
— | — | @@ -588,21 +584,18 @@ |
589 | 585 | $wgOut->addHTML( '</ul>' ); |
590 | 586 | } |
591 | 587 | |
592 | | - function closeShowImage() |
593 | | - { |
594 | | - # For overloading |
| 588 | + protected function closeShowImage() {} # For overloading |
595 | 589 | |
596 | | - } |
597 | | - |
598 | 590 | /** |
599 | 591 | * If the page we've just displayed is in the "Image" namespace, |
600 | 592 | * we follow it with an upload history of the image and its usage. |
601 | 593 | */ |
602 | | - function imageHistory() { |
| 594 | + protected function imageHistory() { |
603 | 595 | global $wgOut, $wgUseExternalEditor; |
604 | 596 | |
605 | 597 | $this->loadFile(); |
606 | | - if ( $this->img->exists() ) { |
| 598 | + $s = ''; |
| 599 | + if( $this->img->exists() ) { |
607 | 600 | $list = new ImageHistoryList( $this ); |
608 | 601 | $file = $this->img; |
609 | 602 | $s = $list->beginImageHistoryList(); |
— | — | @@ -613,7 +606,7 @@ |
614 | 607 | $s .= $list->imageHistoryLine( false, $file ); |
615 | 608 | } |
616 | 609 | $s .= $list->endImageHistoryList(); |
617 | | - } else { $s=''; } |
| 610 | + } |
618 | 611 | $wgOut->addHTML( $s ); |
619 | 612 | |
620 | 613 | $this->img->resetHistory(); // free db resources |
— | — | @@ -623,10 +616,9 @@ |
624 | 617 | if( $wgUseExternalEditor && $this->img->exists() ) { |
625 | 618 | $this->uploadLinksBox(); |
626 | 619 | } |
627 | | - |
628 | 620 | } |
629 | 621 | |
630 | | - function imageLinks() { |
| 622 | + protected function imageLinks() { |
631 | 623 | global $wgUser, $wgOut, $wgLang; |
632 | 624 | |
633 | 625 | $limit = 100; |
— | — | @@ -641,7 +633,7 @@ |
642 | 634 | array( 'LIMIT' => $limit + 1) |
643 | 635 | ); |
644 | 636 | $count = $dbr->numRows( $res ); |
645 | | - if ( $count == 0 ) { |
| 637 | + if( $count == 0 ) { |
646 | 638 | $wgOut->addHTML( "<div id='mw-imagepage-nolinkstoimage'>\n" ); |
647 | 639 | $wgOut->addWikiMsg( 'nolinkstoimage' ); |
648 | 640 | $wgOut->addHTML( "</div>\n" ); |
— | — | @@ -649,7 +641,7 @@ |
650 | 642 | } |
651 | 643 | |
652 | 644 | $wgOut->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" ); |
653 | | - if ( $count <= $limit - 1 ) { |
| 645 | + if( $count <= $limit - 1 ) { |
654 | 646 | $wgOut->addWikiMsg( 'linkstoimage', $count ); |
655 | 647 | } else { |
656 | 648 | // More links than the limit. Add a link to [[Special:Whatlinkshere]] |
— | — | @@ -664,7 +656,7 @@ |
665 | 657 | $count = 0; |
666 | 658 | while ( $s = $res->fetchObject() ) { |
667 | 659 | $count++; |
668 | | - if ( $count <= $limit ) { |
| 660 | + if( $count <= $limit ) { |
669 | 661 | // We have not yet reached the extra one that tells us there is more to fetch |
670 | 662 | $name = Title::makeTitle( $s->page_namespace, $s->page_title ); |
671 | 663 | $link = $sk->makeKnownLinkObj( $name, "" ); |
— | — | @@ -675,15 +667,15 @@ |
676 | 668 | $res->free(); |
677 | 669 | |
678 | 670 | // Add a links to [[Special:Whatlinkshere]] |
679 | | - if ( $count > $limit ) |
| 671 | + if( $count > $limit ) |
680 | 672 | $wgOut->addWikiMsg( 'morelinkstoimage', $this->mTitle->getPrefixedDBkey() ); |
681 | 673 | } |
682 | 674 | |
683 | | - function imageRedirects() { |
| 675 | + protected function imageRedirects() { |
684 | 676 | global $wgUser, $wgOut, $wgLang; |
685 | 677 | |
686 | 678 | $redirects = $this->getTitle()->getRedirectsHere( NS_IMAGE ); |
687 | | - if ( count( $redirects ) == 0 ) return; |
| 679 | + if( count( $redirects ) == 0 ) return; |
688 | 680 | |
689 | 681 | $wgOut->addHTML( "<div id='mw-imagepage-section-redirectstofile'>\n" ); |
690 | 682 | $wgOut->addWikiMsg( 'redirectstofile', |
— | — | @@ -700,13 +692,13 @@ |
701 | 693 | |
702 | 694 | } |
703 | 695 | |
704 | | - function imageDupes() { |
| 696 | + protected function imageDupes() { |
705 | 697 | global $wgOut, $wgUser, $wgLang; |
706 | 698 | |
707 | 699 | $this->loadFile(); |
708 | 700 | |
709 | 701 | $dupes = $this->getDuplicates(); |
710 | | - if ( count( $dupes ) == 0 ) return; |
| 702 | + if( count( $dupes ) == 0 ) return; |
711 | 703 | |
712 | 704 | $wgOut->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" ); |
713 | 705 | $wgOut->addWikiMsg( 'duplicatesoffile', |
— | — | @@ -716,7 +708,7 @@ |
717 | 709 | |
718 | 710 | $sk = $wgUser->getSkin(); |
719 | 711 | foreach ( $dupes as $file ) { |
720 | | - if ( $file->isLocal() ) |
| 712 | + if( $file->isLocal() ) |
721 | 713 | $link = $sk->makeKnownLinkObj( $file->getTitle(), "" ); |
722 | 714 | else { |
723 | 715 | $link = $sk->makeExternalLink( $file->getDescriptionUrl(), |
— | — | @@ -753,7 +745,7 @@ |
754 | 746 | /** |
755 | 747 | * Override handling of action=purge |
756 | 748 | */ |
757 | | - function doPurge() { |
| 749 | + public function doPurge() { |
758 | 750 | $this->loadFile(); |
759 | 751 | if( $this->img->exists() ) { |
760 | 752 | wfDebug( "ImagePage::doPurge purging " . $this->img->getName() . "\n" ); |
— | — | @@ -799,15 +791,15 @@ |
800 | 792 | $this->imagePage = $imagePage; |
801 | 793 | } |
802 | 794 | |
803 | | - function getImagePage() { |
| 795 | + public function getImagePage() { |
804 | 796 | return $this->imagePage; |
805 | 797 | } |
806 | 798 | |
807 | | - function getSkin() { |
| 799 | + public function getSkin() { |
808 | 800 | return $this->skin; |
809 | 801 | } |
810 | 802 | |
811 | | - function getFile() { |
| 803 | + public function getFile() { |
812 | 804 | return $this->img; |
813 | 805 | } |
814 | 806 | |
— | — | @@ -961,7 +953,7 @@ |
962 | 954 | $row .= '</td><td>'; |
963 | 955 | |
964 | 956 | // Don't show deleted descriptions |
965 | | - if ( $file->isDeleted(File::DELETED_COMMENT) ) { |
| 957 | + if( $file->isDeleted(File::DELETED_COMMENT) ) { |
966 | 958 | $row .= '<span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>'; |
967 | 959 | } else { |
968 | 960 | $row .= $this->skin->commentBlock( $description, $this->title ); |