Index: trunk/extensions/LiquidThreads/classes/Dispatch.php |
— | — | @@ -90,6 +90,10 @@ |
91 | 91 | return $view->show(); |
92 | 92 | } |
93 | 93 | |
| 94 | + /** |
| 95 | + * @param $title Title |
| 96 | + * @return bool|null |
| 97 | + */ |
94 | 98 | static function isLqtPage( $title ) { |
95 | 99 | // Ignore it if it's a thread or a summary, makes no sense to have LiquidThreads there. |
96 | 100 | if ( $title->getNamespace() == NS_LQT_THREAD || |
Index: trunk/extensions/LiquidThreads/classes/Hooks.php |
— | — | @@ -5,6 +5,10 @@ |
6 | 6 | public static $editType = null; |
7 | 7 | public static $editThread = null; |
8 | 8 | public static $editAppliesTo = null; |
| 9 | + |
| 10 | + /** |
| 11 | + * @var Article |
| 12 | + */ |
9 | 13 | public static $editArticle = null; |
10 | 14 | public static $editTalkpage = null; |
11 | 15 | public static $scriptVariables = array(); |
— | — | @@ -21,6 +25,12 @@ |
22 | 26 | Threads::TYPE_DELETED => 'deleted' |
23 | 27 | ); |
24 | 28 | |
| 29 | + /** |
| 30 | + * @param $changeslist ChangesList |
| 31 | + * @param $s string |
| 32 | + * @param $rc RecentChange |
| 33 | + * @return bool |
| 34 | + */ |
25 | 35 | static function customizeOldChangesList( &$changeslist, &$s, $rc ) { |
26 | 36 | if ( $rc->getTitle()->getNamespace() != NS_LQT_THREAD ) { |
27 | 37 | return true; |
— | — | @@ -158,15 +168,15 @@ |
159 | 169 | return true; |
160 | 170 | } |
161 | 171 | |
| 172 | + /** |
| 173 | + * @param $article Article |
| 174 | + * @return bool |
| 175 | + */ |
162 | 176 | static function updateNewtalkOnEdit( $article ) { |
163 | 177 | $title = $article->getTitle(); |
164 | 178 | |
165 | | - if ( LqtDispatch::isLqtPage( $title ) ) { |
166 | | - // They're only editing the header, don't update newtalk. |
167 | | - return false; |
168 | | - } |
169 | | - |
170 | | - return true; |
| 179 | + // They're only editing the header, don't update newtalk. |
| 180 | + return !LqtDispatch::isLqtPage( $title ); |
171 | 181 | } |
172 | 182 | |
173 | 183 | static function dumpThreadData( $writer, &$out, $row, $title ) { |
— | — | @@ -259,6 +269,12 @@ |
260 | 270 | return true; |
261 | 271 | } |
262 | 272 | |
| 273 | + /** |
| 274 | + * @param $editPage EditPage |
| 275 | + * @param $checkboxes |
| 276 | + * @param $tabIndex |
| 277 | + * @return bool |
| 278 | + */ |
263 | 279 | static function editCheckboxes( $editPage, &$checkboxes, &$tabIndex ) { |
264 | 280 | global $wgRequest, $wgLiquidThreadsShowBumpCheckbox; |
265 | 281 | |
— | — | @@ -317,60 +333,37 @@ |
318 | 334 | return true; |
319 | 335 | } |
320 | 336 | |
| 337 | + /** |
| 338 | + * @param $updater DatabaseUpdater |
| 339 | + * @return bool |
| 340 | + */ |
321 | 341 | public static function onLoadExtensionSchemaUpdates( $updater = null ) { |
322 | 342 | $dir = realpath( dirname( __FILE__ ) . '/..' ); |
323 | 343 | |
324 | | - if ( $updater === null ) { |
325 | | - // DB updates |
326 | | - $wgExtNewTables[] = array( 'thread', "$dir/lqt.sql" ); |
327 | | - $wgExtNewTables[] = array( 'user_message_state', "$dir/lqt.sql" ); |
328 | | - $wgExtNewTables[] = array( 'thread_history', "$dir/schema-changes/thread_history_table.sql" ); |
329 | | - $wgExtNewTables[] = array( 'thread_pending_relationship', "$dir/schema-changes/thread_pending_relationship.sql" ); |
330 | | - $wgExtNewTables[] = array( 'thread_reaction', "$dir/schema-changes/thread_reactions.sql" ); |
| 344 | + $updater->addExtensionUpdate( array( 'addTable', 'thread', "$dir/lqt.sql", true ) ); |
| 345 | + $updater->addExtensionUpdate( array( 'addTable', 'user_message_state', "$dir/lqt.sql", true ) ); |
| 346 | + $updater->addExtensionUpdate( array( 'addTable', 'thread_history', "$dir/schema-changes/thread_history_table.sql", true ) ); |
| 347 | + $updater->addExtensionUpdate( array( 'addTable', 'thread_pending_relationship', "$dir/schema-changes/thread_pending_relationship.sql", true ) ); |
| 348 | + $updater->addExtensionUpdate( array( 'addTable', 'thread_reaction', "$dir/schema-changes/thread_reactions.sql", true ) ); |
331 | 349 | |
332 | | - $wgExtNewFields[] = array( "thread", "thread_article_namespace", "$dir/schema-changes/split-thread_article.sql" ); |
333 | | - $wgExtNewFields[] = array( "thread", "thread_article_title", "$dir/schema-changes/split-thread_article.sql" ); |
334 | | - $wgExtNewFields[] = array( "thread", "thread_ancestor", "$dir/schema-changes/normalise-ancestry.sql" ); |
335 | | - $wgExtNewFields[] = array( "thread", "thread_parent", "$dir/schema-changes/normalise-ancestry.sql" ); |
336 | | - $wgExtNewFields[] = array( "thread", "thread_modified", "$dir/schema-changes/split-timestamps.sql" ); |
337 | | - $wgExtNewFields[] = array( "thread", "thread_created", "$dir/schema-changes/split-timestamps.sql" ); |
338 | | - $wgExtNewFields[] = array( "thread", "thread_editedness", "$dir/schema-changes/store-editedness.sql" ); |
339 | | - $wgExtNewFields[] = array( "thread", "thread_subject", "$dir/schema-changes/store_subject-author.sql" ); |
340 | | - $wgExtNewFields[] = array( "thread", "thread_author_id", "$dir/schema-changes/store_subject-author.sql" ); |
341 | | - $wgExtNewFields[] = array( "thread", "thread_author_name", "$dir/schema-changes/store_subject-author.sql" ); |
342 | | - $wgExtNewFields[] = array( "thread", "thread_sortkey", "$dir/schema-changes/new-sortkey.sql" ); |
343 | | - $wgExtNewFields[] = array( 'thread', 'thread_replies', "$dir/schema-changes/store_reply_count.sql" ); |
344 | | - $wgExtNewFields[] = array( 'thread', 'thread_article_id', "$dir/schema-changes/store_article_id.sql" ); |
345 | | - $wgExtNewFields[] = array( 'thread', 'thread_signature', "$dir/schema-changes/thread_signature.sql" ); |
346 | | - $wgExtNewFields[] = array( 'user_message_state', 'ums_conversation', "$dir/schema-changes/ums_conversation.sql" ); |
| 350 | + $updater->addExtensionUpdate( array( 'addField', "thread", "thread_article_namespace", "$dir/schema-changes/split-thread_article.sql", true ) ); |
| 351 | + $updater->addExtensionUpdate( array( 'addField', "thread", "thread_article_title", "$dir/schema-changes/split-thread_article.sql", true ) ); |
| 352 | + $updater->addExtensionUpdate( array( 'addField', "thread", "thread_ancestor", "$dir/schema-changes/normalise-ancestry.sql", true ) ); |
| 353 | + $updater->addExtensionUpdate( array( 'addField', "thread", "thread_parent", "$dir/schema-changes/normalise-ancestry.sql", true ) ); |
| 354 | + $updater->addExtensionUpdate( array( 'addField', "thread", "thread_modified", "$dir/schema-changes/split-timestamps.sql", true ) ); |
| 355 | + $updater->addExtensionUpdate( array( 'addField', "thread", "thread_created", "$dir/schema-changes/split-timestamps.sql", true ) ); |
| 356 | + $updater->addExtensionUpdate( array( 'addField', "thread", "thread_editedness", "$dir/schema-changes/store-editedness.sql", true ) ); |
| 357 | + $updater->addExtensionUpdate( array( 'addField', "thread", "thread_subject", "$dir/schema-changes/store_subject-author.sql", true ) ); |
| 358 | + $updater->addExtensionUpdate( array( 'addField', "thread", "thread_author_id", "$dir/schema-changes/store_subject-author.sql", true ) ); |
| 359 | + $updater->addExtensionUpdate( array( 'addField', "thread", "thread_author_name", "$dir/schema-changes/store_subject-author.sql", true ) ); |
| 360 | + $updater->addExtensionUpdate( array( 'addField', "thread", "thread_sortkey", "$dir/schema-changes/new-sortkey.sql", true ) ); |
| 361 | + $updater->addExtensionUpdate( array( 'addField', 'thread', 'thread_replies', "$dir/schema-changes/store_reply_count.sql", true ) ); |
| 362 | + $updater->addExtensionUpdate( array( 'addField', 'thread', 'thread_article_id', "$dir/schema-changes/store_article_id.sql", true ) ); |
| 363 | + $updater->addExtensionUpdate( array( 'addField', 'thread', 'thread_signature', "$dir/schema-changes/thread_signature.sql", true ) ); |
| 364 | + $updater->addExtensionUpdate( array( 'addField', 'user_message_state', 'ums_conversation', "$dir/schema-changes/ums_conversation.sql", true ) ); |
347 | 365 | |
348 | | - $wgExtNewIndexes[] = array( 'thread', 'thread_summary_page', '(thread_summary_page)' ); |
349 | | - } else { |
350 | | - $updater->addExtensionUpdate( array( 'addTable', 'thread', "$dir/lqt.sql", true ) ); |
351 | | - $updater->addExtensionUpdate( array( 'addTable', 'user_message_state', "$dir/lqt.sql", true ) ); |
352 | | - $updater->addExtensionUpdate( array( 'addTable', 'thread_history', "$dir/schema-changes/thread_history_table.sql", true ) ); |
353 | | - $updater->addExtensionUpdate( array( 'addTable', 'thread_pending_relationship', "$dir/schema-changes/thread_pending_relationship.sql", true ) ); |
354 | | - $updater->addExtensionUpdate( array( 'addTable', 'thread_reaction', "$dir/schema-changes/thread_reactions.sql", true ) ); |
| 366 | + $updater->addExtensionUpdate( array( 'addIndex', 'thread', 'thread_summary_page', '(thread_summary_page)' ) ); |
355 | 367 | |
356 | | - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_article_namespace", "$dir/schema-changes/split-thread_article.sql", true ) ); |
357 | | - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_article_title", "$dir/schema-changes/split-thread_article.sql", true ) ); |
358 | | - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_ancestor", "$dir/schema-changes/normalise-ancestry.sql", true ) ); |
359 | | - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_parent", "$dir/schema-changes/normalise-ancestry.sql", true ) ); |
360 | | - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_modified", "$dir/schema-changes/split-timestamps.sql", true ) ); |
361 | | - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_created", "$dir/schema-changes/split-timestamps.sql", true ) ); |
362 | | - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_editedness", "$dir/schema-changes/store-editedness.sql", true ) ); |
363 | | - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_subject", "$dir/schema-changes/store_subject-author.sql", true ) ); |
364 | | - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_author_id", "$dir/schema-changes/store_subject-author.sql", true ) ); |
365 | | - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_author_name", "$dir/schema-changes/store_subject-author.sql", true ) ); |
366 | | - $updater->addExtensionUpdate( array( 'addField', "thread", "thread_sortkey", "$dir/schema-changes/new-sortkey.sql", true ) ); |
367 | | - $updater->addExtensionUpdate( array( 'addField', 'thread', 'thread_replies', "$dir/schema-changes/store_reply_count.sql", true ) ); |
368 | | - $updater->addExtensionUpdate( array( 'addField', 'thread', 'thread_article_id', "$dir/schema-changes/store_article_id.sql", true ) ); |
369 | | - $updater->addExtensionUpdate( array( 'addField', 'thread', 'thread_signature', "$dir/schema-changes/thread_signature.sql", true ) ); |
370 | | - $updater->addExtensionUpdate( array( 'addField', 'user_message_state', 'ums_conversation', "$dir/schema-changes/ums_conversation.sql", true ) ); |
371 | | - |
372 | | - $updater->addExtensionUpdate( array( 'addIndex', 'thread', 'thread_summary_page', '(thread_summary_page)' ) ); |
373 | | - } |
374 | | - |
375 | 368 | return true; |
376 | 369 | } |
377 | 370 | |
— | — | @@ -395,6 +388,13 @@ |
396 | 389 | return true; |
397 | 390 | } |
398 | 391 | |
| 392 | + /** |
| 393 | + * @param $user User |
| 394 | + * @param $title Title |
| 395 | + * @param $isBlocked bool |
| 396 | + * @param $allowUserTalk bool |
| 397 | + * @return bool |
| 398 | + */ |
399 | 399 | static function userIsBlockedFrom( $user, $title, &$isBlocked, &$allowUserTalk ) { |
400 | 400 | // Limit applicability |
401 | 401 | if ( !( $isBlocked && $allowUserTalk && $title->getNamespace() == NS_LQT_THREAD ) ) { |
— | — | @@ -473,6 +473,20 @@ |
474 | 474 | return true; |
475 | 475 | } |
476 | 476 | |
| 477 | + /** |
| 478 | + * @param $article Article |
| 479 | + * @param $user User |
| 480 | + * @param $text |
| 481 | + * @param $summary |
| 482 | + * @param $minoredit |
| 483 | + * @param $watchthis |
| 484 | + * @param $sectionanchor |
| 485 | + * @param $flags |
| 486 | + * @param $revision |
| 487 | + * @param $status Status |
| 488 | + * @param $baseRevId |
| 489 | + * @return bool |
| 490 | + */ |
477 | 491 | static function onArticleSaveComplete( &$article, &$user, $text, $summary, |
478 | 492 | $minoredit, $watchthis, $sectionanchor, &$flags, $revision, |
479 | 493 | &$status, $baseRevId ) { |
— | — | @@ -510,6 +524,11 @@ |
511 | 525 | return true; |
512 | 526 | } |
513 | 527 | |
| 528 | + /** |
| 529 | + * @param $title Title |
| 530 | + * @param $types |
| 531 | + * @return bool |
| 532 | + */ |
514 | 533 | static function getProtectionTypes( $title, &$types ) { |
515 | 534 | $isLqtPage = LqtDispatch::isLqtPage( $title ); |
516 | 535 | $isThread = $title->getNamespace() == NS_LQT_THREAD; |
— | — | @@ -530,6 +549,10 @@ |
531 | 550 | return true; |
532 | 551 | } |
533 | 552 | |
| 553 | + /** |
| 554 | + * @param $vars sttsu |
| 555 | + * @return bool |
| 556 | + */ |
534 | 557 | public static function onMakeGlobalVariablesScript( &$vars ) { |
535 | 558 | $vars += self::$scriptVariables; |
536 | 559 | |
— | — | @@ -540,6 +563,7 @@ |
541 | 564 | * Returns the text contents of a template page set in given key contents |
542 | 565 | * Returns empty string if no text could be retrieved. |
543 | 566 | * @param $key String: message key that should contain a template page name |
| 567 | + * @return String |
544 | 568 | */ |
545 | 569 | private static function getTextForPageInKey( $key ) { |
546 | 570 | $templateTitleText = wfMsgForContent( $key ); |
— | — | @@ -564,7 +588,6 @@ |
565 | 589 | /** |
566 | 590 | * Handles tags in Page sections of XML dumps |
567 | 591 | */ |
568 | | - |
569 | 592 | public static function handlePageXMLTag( $reader, &$pageInfo ) { |
570 | 593 | if ( !isset( $reader->nodeType ) || !( $reader->nodeType == XmlReader::ELEMENT && |
571 | 594 | $reader->name == 'DiscussionThreading' ) ) { |
— | — | @@ -603,7 +626,16 @@ |
604 | 627 | return false; |
605 | 628 | } |
606 | 629 | |
607 | | - // Processes discussion threading data in XML dumps (extracted in handlePageXMLTag). |
| 630 | + /** |
| 631 | + * Processes discussion threading data in XML dumps (extracted in handlePageXMLTag). |
| 632 | + * |
| 633 | + * @param $title Title |
| 634 | + * @param $origTitle Title |
| 635 | + * @param $revCount |
| 636 | + * @param $sRevCount |
| 637 | + * @param $pageInfo |
| 638 | + * @return bool |
| 639 | + */ |
608 | 640 | public static function afterImportPage( $title, $origTitle, $revCount, $sRevCount, $pageInfo ) { |
609 | 641 | // in-process cache of pending thread relationships |
610 | 642 | static $pendingRelationships = null; |
— | — | @@ -695,6 +727,10 @@ |
696 | 728 | } |
697 | 729 | } |
698 | 730 | |
| 731 | + /** |
| 732 | + * @param $pendingRelationship |
| 733 | + * @param $title Title |
| 734 | + */ |
699 | 735 | public static function applyPendingArticleRelationship( $pendingRelationship, $title ) { |
700 | 736 | $articleID = $title->getArticleId(); |
701 | 737 | |
— | — | @@ -708,6 +744,9 @@ |
709 | 745 | array( 'tpr_title' => $pendingRelationship['title'] ), __METHOD__ ); |
710 | 746 | } |
711 | 747 | |
| 748 | + /** |
| 749 | + * @return array |
| 750 | + */ |
712 | 751 | public static function loadPendingRelationships() { |
713 | 752 | $dbr = wfGetDB( DB_MASTER ); |
714 | 753 | $arr = array(); |
— | — | @@ -756,7 +795,15 @@ |
757 | 796 | $array[$title][] = $entry; |
758 | 797 | } |
759 | 798 | |
760 | | - // Do not allow users to read threads on talkpages that they cannot read. |
| 799 | + /** |
| 800 | + * Do not allow users to read threads on talkpages that they cannot read. |
| 801 | + * |
| 802 | + * @param $title Title |
| 803 | + * @param $user |
| 804 | + * @param $action |
| 805 | + * @param $result |
| 806 | + * @return bool |
| 807 | + */ |
761 | 808 | public static function onGetUserPermissionsErrors( $title, $user, $action, &$result ) { |
762 | 809 | if ( $title->getNamespace() != NS_LQT_THREAD || $action != 'read' ) |
763 | 810 | return true; |
— | — | @@ -779,6 +826,10 @@ |
780 | 827 | } |
781 | 828 | } |
782 | 829 | |
| 830 | + /** |
| 831 | + * @param $parser Parser |
| 832 | + * @return bool |
| 833 | + */ |
783 | 834 | public static function onParserFirstCallInit( $parser ) { |
784 | 835 | $parser->setFunctionHook( |
785 | 836 | 'useliquidthreads', |
— | — | @@ -800,6 +851,10 @@ |
801 | 852 | return true; |
802 | 853 | } |
803 | 854 | |
| 855 | + /** |
| 856 | + * @param $list array |
| 857 | + * @return bool |
| 858 | + */ |
804 | 859 | public static function onCanonicalNamespaces( &$list ) { |
805 | 860 | $list[NS_LQT_THREAD] = 'Thread'; |
806 | 861 | $list[NS_LQT_THREAD_TALK] = 'Thread_talk'; |