r86244 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86243‎ | r86244 | r86245 >
Date:22:44, 16 April 2011
Author:happy-melon
Status:ok
Tags:
Comment:
Clean up some uses and abuses of the SpecialPage:: static methods in extensions
Modified paths:
  • /trunk/extensions/ApprovedRevs/SpecialApprovedRevs.php (modified) (history)
  • /trunk/extensions/MassEditRegex/MassEditRegex.class.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php (modified) (history)
  • /trunk/extensions/UserOptionStats/SpecialUserOptionStats.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MassEditRegex/MassEditRegex.class.php
@@ -100,7 +100,7 @@
101101 }
102102
103103 $wgOut->addWikiMsg( 'masseditregextext' );
104 - $titleObj = SpecialPage::getTitle( 'MassEditRegex' );
 104+ $titleObj = SpecialPage::getTitleFor( 'MassEditRegex' );
105105
106106 $wgOut->addHTML(
107107 Xml::openElement('form', array(
Index: trunk/extensions/UserOptionStats/SpecialUserOptionStats.php
@@ -40,9 +40,9 @@
4141
4242 if ( !$par ) {
4343 $opts = array();
44 - $name = SpecialPage::getLocalNameFor( 'UserOptionStats' );
 44+ $name = SpecialPage::getTitleFor( 'UserOptionStats' )->getPrefixedText();
4545 foreach ( $this->getOptions() as $k ) {
46 - $opts[] = "[[Special:$name/$k|$k]]";
 46+ $opts[] = "[[$name/$k|$k]]";
4747 }
4848 $wgOut->addWikiMsg( 'uos-choose', $wgLang->commaList( $opts ) );
4949 return;
Index: trunk/extensions/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php
@@ -101,7 +101,7 @@
102102 // add the search placeholder
103103 // $wgOut->addWikiText( wfMsg( 'searchresulttext' ) );
104104 $sk = $wgUser->getSkin();
105 - $title = Title :: MakeTitle( NS_SPECIAL, 'Search' );
 105+ $title = Title::MakeTitle( NS_SPECIAL, 'Search' );
106106
107107 // check if the skin already includes the dynamicSearchControl
108108 global $wgUser;
@@ -127,7 +127,7 @@
128128 }
129129 }
130130 function dynamicSearchControl() {
131 - $title = SpecialPage :: getTitleFor( 'MediaSearch' );
 131+ $title = SpecialPage::getTitleFor( 'MediaSearch' );
132132 $action = $title->escapeLocalURL();
133133
134134 $o = "<div id=\"msms_form_search_row\" class=\"form_search_row\">
@@ -352,13 +352,13 @@
353353 $prevnext = '';
354354 // pagging
355355 if ( $this->numResultsFound > $this->limit ) {
356 - $prevnext = mvViewPrevNext( $this->offset, $this->limit, SpecialPage :: getTitleFor( 'MediaSearch' ), $this->get_httpd_filters_query(), ( $this->num < $this->limit ) );
 356+ $prevnext = mvViewPrevNext( $this->offset, $this->limit, SpecialPage::getTitleFor( 'MediaSearch' ), $this->get_httpd_filters_query(), ( $this->num < $this->limit ) );
357357 $o .= '<li class="prevnext">' . $prevnext . '</li>';
358358 }
359359 $br = '<br />';
360360 $enddash = '';
361361
362 - $sTitle = Title :: MakeTitle( NS_SPECIAL, 'MvExportSearch' );
 362+ $sTitle = Title::MakeTitle( NS_SPECIAL, 'MvExportSearch' );
363363
364364 // force host for script (should be a better way to do this)
365365 if ( !isset( $_SERVER['HTTP_HOST'] ) )
@@ -383,7 +383,7 @@
384384 if ( $wgRequest->getVal( 'limit' ) != '' || $wgRequest->getVal( 'order' ) != '' )
385385 $q_req .= '&' . http_build_query( array( 'limit' => $this->limit, 'offset' => $this->offset ) );
386386 $q_req .= '&order=' . $type;
387 - $o .= $enddash . '<li class="relevant">' . $sk->makeKnownLinkObj( SpecialPage :: getTitleFor( 'MediaSearch' ),
 387+ $o .= $enddash . '<li class="relevant">' . $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'MediaSearch' ),
388388 wfMsg( 'mv_most_' . $type ), $q_req ) . '</li>';
389389 }
390390 $br = '';
@@ -413,10 +413,10 @@
414414
415415 if( $pmvd->wiki_title ){
416416 $pMvTitle = new MV_Title( $pmvd->wiki_title );
417 - $pAnnoStreamLink = Title :: MakeTitle( MV_NS_STREAM, $pMvTitle->getNearStreamName( 0 ) );
 417+ $pAnnoStreamLink = Title::MakeTitle( MV_NS_STREAM, $pMvTitle->getNearStreamName( 0 ) );
418418 $clip_desc_txt = 'Segment';
419419 if($pmvd->Speech_by){
420 - $personTitle = Title :: newFromText( $pmvd->Speech_by );
 420+ $personTitle = Title::newFromText( $pmvd->Speech_by );
421421 $clip_desc_txt = 'Speech By ' . $personTitle->getText();
422422 }
423423
@@ -427,7 +427,7 @@
428428 $pmeta_out.='<br />Covering: ';
429429 $coma='';
430430 foreach($pmvd->category as $cat_titlekey ){
431 - $cTitle = $cTitle = Title :: MakeTitle( NS_CATEGORY, $cat_titlekey );
 431+ $cTitle = $cTitle = Title::MakeTitle( NS_CATEGORY, $cat_titlekey );
432432 $pmeta_out .= $coma . $sk->makeKnownLinkObj( $cTitle, $cTitle->getText() );
433433 $coma=', ';
434434 assoc_array_increment( $sideBarLinkBucket, 'category', $cat_titlekey );
@@ -435,7 +435,7 @@
436436 }
437437 if($pmvd->Bill){
438438 $pmeta_out.='<br />Bill: ';
439 - $bTitle = Title :: newFromText( $pmvd->Bill );
 439+ $bTitle = Title::newFromText( $pmvd->Bill );
440440 $pmeta_out .= $sk->makeKnownLinkObj( $bTitle, $bTitle->getText() );
441441 assoc_array_increment( $sideBarLinkBucket, 'bill', $pmvd->Bill );
442442 }
@@ -443,7 +443,7 @@
444444 }
445445 $mvd_cnt_links = '';
446446 if ( isset ( $mvd->spoken_by ) ) {
447 - $ptitle = Title :: MakeTitle( NS_MAIN, $mvd->spoken_by );
 447+ $ptitle = Title::MakeTitle( NS_MAIN, $mvd->spoken_by );
448448 $mvd_cnt_links .= wfMsg( 'mv_search_spoken_by' ) . ': ' . $sk->makeKnownLinkObj( $ptitle );
449449 $mvd_cnt_links .= '<br />';
450450 assoc_array_increment( $sideBarLinkBucket, 'person', $mvd->spoken_by );
@@ -452,7 +452,7 @@
453453 $coma = '';
454454 if ( isset ( $mvd->categories ) ) {
455455 foreach ( $mvd->categories as $cat_id => $na ) {
456 - $cTitle = Title :: MakeTitle( NS_CATEGORY, $cat_id );
 456+ $cTitle = Title::MakeTitle( NS_CATEGORY, $cat_id );
457457 if ( $mvd_cat_links == '' )
458458 $mvd_cat_links .= wfMsg( 'mv_search_categories' ) .
459459 ': ';
@@ -464,7 +464,7 @@
465465 $coma = '';
466466 if ( isset ( $mvd->bills ) ) {
467467 foreach ( $mvd->bills as $bill_id => $na ) {
468 - $bTitle = Title :: newFromText( $bill_id );
 468+ $bTitle = Title:: newFromText( $bill_id );
469469 if ( $mvd_bill_links == '' )
470470 $mvd_bill_links .= wfMsg( 'mv_search_bills' ) .
471471 ': ';
@@ -477,9 +477,9 @@
478478 //if the clip length is < $mvDefaultClipLength get range:
479479 global $mvDefaultClipLength;
480480 if( $mvTitle->getSegmentDuration() < $mvDefaultClipLength){
481 - $mvStreamTitle = Title :: MakeTitle( MV_NS_STREAM, $mvTitle->getNearStreamName( $mvDefaultClipRange ) );
 481+ $mvStreamTitle = Title::MakeTitle( MV_NS_STREAM, $mvTitle->getNearStreamName( $mvDefaultClipRange ) );
482482 }else{
483 - $mvStreamTitle = Title :: MakeTitle( MV_NS_STREAM, $mvTitle->getNearStreamName( 0 ) );
 483+ $mvStreamTitle = Title::MakeTitle( MV_NS_STREAM, $mvTitle->getNearStreamName( 0 ) );
484484 }
485485 // $mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() );
486486
@@ -527,7 +527,7 @@
528528 $first_block = ' first_block';
529529 $matches = 0;
530530 $person_out_ary = array();
531 - $person_out = MV_SpecialMediaSearch :: auto_complete_person( $this->unified_term_search, 3, 'person_html', $matches, $person_out_ary );
 531+ $person_out = MV_SpecialMediaSearch::auto_complete_person( $this->unified_term_search, 3, 'person_html', $matches, $person_out_ary );
532532 if ( $person_out != '' || count( $sideBarLinkBucket['person'] ) != 0 ) {
533533 // for now don't include({$matches})
534534 $o .= "<div class=\"block{$first_block}\">
@@ -543,7 +543,7 @@
544544 if ( in_array( $person_name, $person_out_ary ) )continue;
545545 if ( $i == $perSectionCount )
546546 break;
547 - $o .= MV_SpecialMediaSearch :: format_ac_line( $person_name, '', '', MV_SpecialMediaSearch :: getPersonImageURL( $person_name ), $format = 'person_html' );
 547+ $o .= MV_SpecialMediaSearch::format_ac_line( $person_name, '', '', MV_SpecialMediaSearch::getPersonImageURL( $person_name ), $format = 'person_html' );
548548 $i++;
549549 }
550550 }
@@ -551,7 +551,7 @@
552552 $first_block = '';
553553 }
554554 // get categories
555 - $category_out = MV_SpecialMediaSearch :: auto_complete_search_categories( $this->unified_term_search, 3, 'block_html', $matches );
 555+ $category_out = MV_SpecialMediaSearch::auto_complete_search_categories( $this->unified_term_search, 3, 'block_html', $matches );
556556 if ( $category_out != '' || count( $sideBarLinkBucket['category'] ) != 0 ) {
557557 $o .= '<div class="block' . htmlspecialchars( $first_block ) . '\">
558558 <h6>' . wfMsg( 'mv_category_results' ) . '</h6>
@@ -565,7 +565,7 @@
566566 foreach ( $cAry as $cat_name => $count ) {
567567 if ( $i == $perSectionCount )
568568 break;
569 - $o .= MV_SpecialMediaSearch :: format_ac_line( $cat_name, '', $catNStxt . ':', 'no_image', $format = 'block_html' );
 569+ $o .= MV_SpecialMediaSearch::format_ac_line( $cat_name, '', $catNStxt . ':', 'no_image', $format = 'block_html' );
570570 $i++;
571571 }
572572 }
@@ -573,7 +573,7 @@
574574 $first_block = '';
575575 }
576576 // get bills:
577 - $bill_out = MV_SpecialMediaSearch :: auto_complete_category( 'Bill', $this->unified_term_search, 3, 'block_html', $matches );
 577+ $bill_out = MV_SpecialMediaSearch::auto_complete_category( 'Bill', $this->unified_term_search, 3, 'block_html', $matches );
578578 if ( $bill_out != '' || count( $sideBarLinkBucket['bill'] ) != 0 ) {
579579 global $wgContLang;
580580 $o .= '<div class=\"block ' . htmlspecialchars( $first_block ) . '">
@@ -587,7 +587,7 @@
588588 foreach ( $bAry as $bill_name => $count ) {
589589 if ( $i == $perSectionCount )
590590 break;
591 - $o .= MV_SpecialMediaSearch :: format_ac_line( $bill_name, '', '', 'no_image', $format = 'block_html' );
 591+ $o .= MV_SpecialMediaSearch::format_ac_line( $bill_name, '', '', 'no_image', $format = 'block_html' );
592592 $i++;
593593 }
594594 }
@@ -595,7 +595,7 @@
596596 $first_block = '';
597597 }
598598 // intrest out is just simple title matching (for now)
599 - $intrest_out = MV_SpecialMediaSearch :: auto_complete_category( 'Interest_Group', $this->unified_term_search, 3, 'block_html', $matches );
 599+ $intrest_out = MV_SpecialMediaSearch::auto_complete_category( 'Interest_Group', $this->unified_term_search, 3, 'block_html', $matches );
600600 if ( $intrest_out != '' ) {
601601 $o .= "<div class=\"block{$first_block}\">
602602 <h6>" . wfMsg( 'mv_intrest_group_results' ) . "</h6>
@@ -705,7 +705,7 @@
706706 global $wgOut, $mvgIP;
707707 global $mvDefaultSearchVideoPlaybackRes;
708708
709 - $mvd = MV_Index :: getMVDbyId( $mvd_id );
 709+ $mvd = MV_Index::getMVDbyId( $mvd_id );
710710 if ( count( $mvd ) != 0 ) {
711711 $mvTitle = new MV_Title( $mvd->wiki_title );
712712 // validate title and load stream ref:
@@ -846,7 +846,7 @@
847847 return $o;
848848 }
849849 function getSearchLink() {
850 - return SpecialPage :: getTitleFor( 'MediaSearch' ) .
 850+ return SpecialPage::getTitleFor( 'MediaSearch' ) .
851851 $this->get_httpd_filters_query();
852852 }
853853 /*
@@ -883,9 +883,9 @@
884884 $disp = 'none';
885885 }
886886 // make the missing person image ref:
887 - $imgTitle = Title :: makeTitle( NS_IMAGE, $person_name . '.jpg' );
 887+ $imgTitle = Title::makeTitle( NS_IMAGE, $person_name . '.jpg' );
888888 if ( !$imgTitle->exists() ) {
889 - $imgTitle = Title :: makeTitle( NS_IMAGE, MV_MISSING_PERSON_IMG );
 889+ $imgTitle = Title::makeTitle( NS_IMAGE, MV_MISSING_PERSON_IMG );
890890 }
891891
892892 $img = wfFindFile( $imgTitle );
@@ -945,25 +945,25 @@
946946 // make sure people know they can "search" too (formated by
947947 $out = 'do_search|' . wfMsg( 'mv_search_transcripts_for', '<B>$1</B>' ) . '|no_image' . "\n";
948948 // get keywords
949 - $category_out = MV_SpecialMediaSearch :: auto_complete_search_categories( $val, 3 );
 949+ $category_out = MV_SpecialMediaSearch::auto_complete_search_categories( $val, 3 );
950950 if ( $category_out != '' ) {
951951 $out .= $catNStxt . ':Categories|<h6>' . wfMsg( 'mv_category_matches' ) . '</h6>|no_image' . "\n";
952952 $out .= $category_out;
953953 }
954954 // get people
955 - $person_out = MV_SpecialMediaSearch :: auto_complete_person( $val, 3 );
 955+ $person_out = MV_SpecialMediaSearch::auto_complete_person( $val, 3 );
956956 if ( $person_out != '' ) {
957957 $out .= $catNStxt . ':Person|<h6>' . wfMsg( 'mv_people_matches' ) . '</h6>|no_image' . "\n";
958958 $out .= $person_out;
959959 }
960960 // get bills
961 - $bill_out = MV_SpecialMediaSearch :: auto_complete_category( 'Bill', $val, 3 );
 961+ $bill_out = MV_SpecialMediaSearch::auto_complete_category( 'Bill', $val, 3 );
962962 if ( $bill_out != '' ) {
963963 $out .= $catNStxt . ':Bill|<h6>' . wfMsg( 'mv_bill_matches' ) . '</h6>|no_image' . "\n";
964964 $out .= $bill_out;
965965 }
966966 // get interests
967 - $intrest_out = MV_SpecialMediaSearch :: auto_complete_category( 'Interest_Group', $val, 3 );
 967+ $intrest_out = MV_SpecialMediaSearch::auto_complete_category( 'Interest_Group', $val, 3 );
968968 if ( $intrest_out != '' ) {
969969 $out .= $catNStxt . ':Interest Group|<h6>' . wfMsg( 'mv_interest_group_matches' ) . '</h6>|no_image' . "\n";
970970 $out .= $intrest_out;
@@ -985,7 +985,7 @@
986986 $out = '';
987987 $catNStxt = $wgContLang->getNsText( NS_CATEGORY );
988988 while ( $row = $dbr->fetchObject( $result ) ) {
989 - $out .= MV_SpecialMediaSearch :: format_ac_line( $row->page_title, $val, $catNStxt . ':', 'no_image', $format );
 989+ $out .= MV_SpecialMediaSearch::format_ac_line( $row->page_title, $val, $catNStxt . ':', 'no_image', $format );
990990 }
991991 return $out;
992992 }
@@ -1008,7 +1008,7 @@
10091009 return '';
10101010 $out = '';
10111011 while ( $row = $dbr->fetchObject( $result ) ) {
1012 - $out .= MV_SpecialMediaSearch :: format_ac_line( $row->cl_sortkey, $val, '', 'no_image', $format );
 1012+ $out .= MV_SpecialMediaSearch::format_ac_line( $row->cl_sortkey, $val, '', 'no_image', $format );
10131013 }
10141014 return $out;
10151015 }
@@ -1040,12 +1040,12 @@
10411041
10421042 foreach($person_ary as $person_name=>$na){
10431043 // make sure the person page exists:
1044 - $personTitle = Title :: makeTitle( NS_MAIN, $person_name );
 1044+ $personTitle = Title::makeTitle( NS_MAIN, $person_name );
10451045 if ( $personTitle->exists() ) {
10461046 // dont try and get person full name from semantic table if available
10471047 $person_full_name = $person_name;
10481048 // format and output the line:
1049 - $out .= MV_SpecialMediaSearch :: format_ac_line( $person_full_name, $val, '', MV_SpecialMediaSearch :: getPersonImageURL( $person_name ), $format );
 1049+ $out .= MV_SpecialMediaSearch::format_ac_line( $person_full_name, $val, '', MV_SpecialMediaSearch::getPersonImageURL( $person_name ), $format );
10501050 }
10511051 }
10521052 // $out.='</ul>';
@@ -1080,9 +1080,9 @@
10811081 }
10821082 function getPersonImageURL( $person_name ) {
10831083 // make the missing person image ref:
1084 - $imgTitle = Title :: makeTitle( NS_IMAGE, $person_name . '.jpg' );
 1084+ $imgTitle = Title::makeTitle( NS_IMAGE, $person_name . '.jpg' );
10851085 if ( !$imgTitle->exists() ) {
1086 - $imgTitle = Title :: makeTitle( NS_IMAGE, MV_MISSING_PERSON_IMG );
 1086+ $imgTitle = Title::makeTitle( NS_IMAGE, MV_MISSING_PERSON_IMG );
10871087 }
10881088 $img = wfFindFile( $imgTitle );
10891089 if ( !$img ) {
@@ -1113,7 +1113,7 @@
11141114 if ( $format == 'block_html' || $format == 'person_html' ) {
11151115 global $wgUser;
11161116 $sk = $wgUser->getSkin();
1117 - $title = Title :: newFromText( $prefix . $page_title );
 1117+ $title = Title::newFromText( $prefix . $page_title );
11181118
11191119 if ( $format == 'block_html' )
11201120 return "<p class=\"normal_match\">" . $sk->makeKnownLinkObj( $title, '<span>' .
Index: trunk/extensions/ApprovedRevs/SpecialApprovedRevs.php
@@ -57,8 +57,7 @@
5858 function getPageHeader() {
5959 // show the names of the three lists of pages, with the one
6060 // corresponding to the current "mode" not being linked
61 - $approvedPagesPage = SpecialPage::getPage( 'ApprovedRevs' );
62 - $approvedPagesTitle = SpecialPage::getPage( 'ApprovedRevs' )->getTitle();
 61+ $approvedPagesTitle = SpecialPage::getTitleFor( 'ApprovedRevs' );
6362 $navLine = wfMsg( 'approvedrevs-view' ) . ' ';
6463
6564 if ( $this->mMode == '' ) {

Status & tagging log