jenkins-bot has submitted this change and it was merged. Change subject: Remove use of wfMsg and friends ......................................................................
Remove use of wfMsg and friends The function changes in this change only to get a testable, fatal, warning and notice free test environment with MW 1.20. Bug: 68750 Change-Id: Ic60108036805dd203f51a6d291957fa1323fb3b0 --- M BlogHooks.php M BlogPage.php M SpecialArticleLists.php M SpecialArticlesHome.php M SpecialCreateBlogPost.php M TagCloudClass.php M i18n/en.json 7 files changed, 176 insertions(+), 183 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/BlogHooks.php b/BlogHooks.php index 9b056d6..8a9995c 100644 --- a/BlogHooks.php +++ b/BlogHooks.php @@ -65,7 +65,7 @@ } if ( !$wgUser->isAllowed( 'edit' ) || $wgUser->isBlocked() ) { - $wgOut->addHTML( wfMsg( 'blog-permission-required' ) ); + $wgOut->addWikiMsg( 'blog-permission-required' ); return false; } } @@ -107,8 +107,7 @@ foreach ( $res as $row ) { $ctg = Title::makeTitle( NS_CATEGORY, $row->cl_to ); $ctgname = $ctg->getText(); - $blogCat = wfMsgForContent( 'blog-category' ); - $userBlogCat = wfMsgForContent( 'blog-by-user-category', $blogCat ); + $userBlogCat = wfMessage( 'blog-by-user-category' )->inContentLanguage()->text(); if( strpos( $ctgname, $userBlogCat ) !== false ) { $user_name = trim( str_replace( $userBlogCat, '', $ctgname ) ); @@ -116,6 +115,8 @@ if( $u ) { $stats = new UserStatsTrack( $u, $user_name ); + $userBlogCat = wfMessage( 'blog-by-user-category', $stats->user_name ) + ->inContentLanguage()->text(); // Copied from UserStatsTrack::updateCreatedOpinionsCount() // Throughout this code, we could use $u and $user_name // instead of $stats->user_id and $stats->user_name but @@ -211,10 +212,10 @@ "Got UserProfile articles for user {$user_name} from DB\n" ); $categoryTitle = Title::newFromText( - wfMsgForContent( + wfMessage( 'blog-by-user-category', - wfMsgForContent( 'blog-category' ) - ) . " {$user_name}" + $user_name + )->inContentLanguage()->text() ); $dbr = wfGetDB( DB_SLAVE ); @@ -256,30 +257,28 @@ $articleLink = Title::makeTitle( NS_CATEGORY, - wfMsgForContent( + wfMessage( 'blog-by-user-category', - wfMsgForContent( 'blog-category' ) - ) . " {$user_name}" + $user_name + )->inContentLanguage()->text() ); if ( count( $articles ) > 0 ) { $output .= '<div class="user-section-heading"> <div class="user-section-title">' . - wfMsg( 'blog-user-articles-title' ) . + wfMessae( 'blog-user-articles-title' )->escaped() . '</div> <div class="user-section-actions"> <div class="action-right">'; if( $articleCount > 5 ) { $output .= '<a href="' . htmlspecialchars( $articleLink->getFullURL() ) . - '" rel="nofollow">' . wfMsg( 'user-view-all' ) . '</a>'; + '" rel="nofollow">' . wfMessage( 'user-view-all' )->escaped(). '</a>'; } $output .= '</div> - <div class="action-left">' . wfMsgExt( - 'user-count-separator', - 'parsemag', - count( $articles ), - $articleCount - ) . '</div> + <div class="action-left">' . + wfMessage( 'user-count-separator') + ->numParams( $articleCount, count( $articles ) ) + ->escaped() . '</div> <div class="cleared"></div> </div> </div> @@ -305,22 +304,18 @@ <div class=\"number-of-votes\"> <div class=\"vote-number\">{$voteCount}</div> <div class=\"vote-text\">" . - wfMsgExt( - 'blog-user-articles-votes', - 'parsemag', - $voteCount - ) . + wfMessage( 'blog-user-articles-votes' ) + ->numParams( $voteCount ) + ->escaped() . '</div> </div> <div class="article-title"> <a href="' . htmlspecialchars( $articleTitle->getFullURL() ) . "\">{$articleTitle->getText()}</a> <span class=\"item-small\">" . - wfMsgExt( - 'blog-user-article-comment', - 'parsemag', - $commentCount - ) . '</span> + wfMsgExt( 'blog-user-article-comment' ) + ->num-Params( $commentCount ) + ->escaped() . '</span> </div> <div class="cleared"></div> </div>'; diff --git a/BlogPage.php b/BlogPage.php index 0456ee7..47ad774 100644 --- a/BlogPage.php +++ b/BlogPage.php @@ -63,10 +63,10 @@ $wgOut->addHTML( "\t\t\t\t" . '<div class="blog-left-units">' . "\n" ); $wgOut->addHTML( - "\t\t\t\t\t" . '<h2>' . wfMsgExt( - 'blog-author-title', - 'parsemag', - count( $this->authors ) ) . '</h2>' . "\n" + "\t\t\t\t\t" . '<h2>' . + wfMessage( 'blog-author-title' ) + ->numParams( count( $this->authors ) ) + ->escaped() . '</h2>' . "\n" ); // Why was this commented out? --ashley, 11 July 2011 if( count( $this->authors ) > 1 ) { @@ -137,14 +137,13 @@ $articleText = $this->pageContent; $categoryName = $wgContLang->getNsText( NS_CATEGORY ); - $blogCat = wfMsgForContent( 'blog-category' ); // This unbelievably weak and hacky regex is used to find out the // author's name from the category. See also getBlurb(), which uses a // similar regex. preg_match_all( "/\[\[(?:(?:c|C)ategory|{$categoryName}):\s?" . - wfMsgForContent( 'blog-by-user-category', $blogCat ) . + wfMessage( 'blog-by-user-category' )->inContentLanguage()->escaped() . " (.*)\]\]/", $articleText, $matches @@ -207,15 +206,18 @@ $count = 0; // Get date of last edit - $edit_date = $wgLang->timeanddate( $this->getTimestamp(), true ); + $timestamp = $this->getTimestamp(); + $edit_time['date'] = $wgLang->date( $timestamp, true ); + $edit_time['time'] = $wgLang->time( $timestamp, true ); + $edit_time['datetime'] = $wgLang->timeanddate( $timestamp, true ); // Get date of when article was created - $create_date = $wgLang->timeanddate( - self::getCreateDate( $this->getId() ), - true - ); + $timestamp = self::getCreateDate( $this->getId() ); + $create_time['date'] = $wgLang->date( $timestamp, true ); + $create_time['time'] = $wgLang->time( $timestamp, true ); + $create_time['datetime'] = $wgLang->timeanddate( $timestamp, true ); - $output = '<div class="blog-byline">' . wfMsg( 'blog-by' ) . ' '; + $output = '<div class="blog-byline">' . wfMessage( 'blog-by' )->escaped() . ' '; $authors = ''; foreach( $this->authors as $author ) { @@ -225,8 +227,9 @@ $authors .= ', '; } if ( $count == count( $this->authors ) && $count != 1 ) { - $authors .= wfMsg( 'word-separator' ) . wfMsg( 'blog-and' ) . - wfMsg( 'word-separator' ); + $authors .= wfMessage( 'word-separator' )->escaped() . + wfMessage( 'blog-and' )-escaped() . + wfMessage( 'word-separator' )->escaped(); } $authors .= "<a href=\"{htmlspecialchars( $userTitle->getFullURL() )}\">{$author['user_name']}</a>"; } @@ -236,12 +239,23 @@ $output .= '</div>'; $edit_text = ''; - if( $create_date != $edit_date ) { - $edit_text = ', ' . wfMsg( 'blog-last-edited', $edit_date ); + if( $create_time['datetime'] != $edit_time['datetime'] ) { + $edit_text = ', ' . + wfMessage( + 'blog-last-edited', + $edit_time['datetime'], + $edit_time['date'], + $edit_time['time'] + )->escaped(); } $output .= "\n" . '<div class="blog-byline-last-edited">' . - wfMsg( 'blog-created', $create_date ) . " {$edit_text}</div>"; - + wfMessage( + 'blog-created', + $create_time['datetime'], + $create_time['date'], + $create_time['time'] + )->escaped() . + " {$edit_text}</div>"; return $output; } @@ -256,14 +270,15 @@ $authors .= ', '; } if ( $count == count( $this->authors ) ) { - $authors .= wfMsg( 'word-separator' ) . wfMsg( 'blog-and' ) . - wfMsg( 'word-separator' ); + $authors .= wfMessage( 'word-separator' )->escaped() . + wfMessage( 'blog-and' )->escaped() . + wfMessage( 'word-separator' )->escaped(); } $authors .= "<a href=\"{htmlspecialchars( $userTitle->getFullURL() )}\">{$author['user_name']}</a>"; } $output = '<div class="multiple-authors-message">' . - wfMsg( 'blog-multiple-authors', $authors ) . + wfMessage( 'blog-multiple-authors', $authors )->escaped() . '</div>'; return $output; @@ -341,11 +356,10 @@ $user_name = $this->authors[$author_index]['user_name']; $user_id = $this->authors[$author_index]['user_id']; - $blogCat = wfMsgForContent( 'blog-category' ); $archiveLink = Title::makeTitle( NS_CATEGORY, - wfMsg( 'blog-by-user-category', $blogCat ) . " {$user_name}" + wfMessage( 'blog-by-user-category', $user_name )->text() ); $articles = array(); @@ -361,7 +375,7 @@ wfDebugLog( 'BlogPage', "Got blog author articles for user {$user_name} from DB" ); $dbr = wfGetDB( DB_SLAVE ); $categoryTitle = Title::newFromText( - wfMsg( 'blog-by-user-category', $blogCat ) . " {$user_name}" + wfMessage( 'blog-by-user-category', $user_name )->text() ); $res = $dbr->select( array( 'page', 'categorylinks'), @@ -410,7 +424,7 @@ } $output .= "<div class=\"more-container{$css_fix}\"> - <h3>" . wfMsg( 'blog-author-more-by', $user_name ) . '</h3>'; + <h3>" . wfMessage( 'blog-author-more-by', $user_name )->escaped() . '</h3>'; $x = 1; @@ -420,16 +434,15 @@ $output .= '<div class="author-article-item"> <a href="' . htmlspecialchars( $articleTitle->getFullURL() ) . "\">{$articleTitle->getText()}</a> <div class=\"author-item-small\">" . - wfMsgExt( + wfMessage( 'blog-author-votes', - 'parsemag', BlogPage::getVotesForPage( $article['page_id'] ) - ) . ', ' . - wfMsgExt( - 'blog-author-comments', - 'parsemag', - BlogPage::getCommentsForPage( $article['page_id'] ) - ) . + )->escaped() . + ', ' . + wfMessage( + 'blog-author-comments', + BlogPage::getCommentsForPage( $article['page_id'] ) + )->escaped() . '</div> </div>'; @@ -438,7 +451,7 @@ $output .= '<div class="author-archive-link"> <a href="' . htmlspecialchars( $archiveLink->getFullURL() ) . '">' . - wfMsg( 'blog-view-archive-link' ) . + wfMessage( 'blog-view-archive-link' )->escaped() . '</a> </div> </div>'; @@ -521,8 +534,8 @@ if ( count( $editors ) > 0 ) { $output .= '<div class="recent-container"> - <h2>' . wfMsg( 'blog-recent-editors' ) . '</h2> - <div>' . wfMsg( 'blog-recent-editors-message' ) . '</div>'; + <h2>' . wfMessage( 'blog-recent-editors' )->escaped() . '</h2> + <div>' . wfMessage( 'blog-recent-editors-message' )->escaped() . '</div>'; foreach( $editors as $editor ) { $avatar = new wAvatar( $editor['user_id'], 'm' ); @@ -613,8 +626,8 @@ if( count( $voters ) > 0 ) { $output .= '<div class="recent-container bottom-fix"> - <h2>' . wfMsg( 'blog-recent-voters' ) . '</h2> - <div>' . wfMsg( 'blog-recent-voters-message' ) . '</div>'; + <h2>' . wfMessage( 'blog-recent-voters' )->escaped() . '</h2> + <div>' . wfMessage( 'blog-recent-voters-message' )->escaped() . '</div>'; foreach( $voters as $voter ) { $userTitle = Title::makeTitle( NS_USER, $voter['user_name'] ); @@ -651,7 +664,7 @@ $output = ''; $output .= '<div class="recent-container bottom-fix"><h2>' . - wfMsg( 'blog-embed-title' ) . '</h2>'; + wfMessage( 'blog-embed-title' )->escaped() . '</h2>'; $output .= '<div class="blog-widget-embed">'; $output .= "<p><input type='text' size='20' onclick='this.select();' value='" . '<object width="300" height="450" id="content_widget" align="middle"> <param name="movie" value="content_widget.swf" /><embed src="' . @@ -696,12 +709,12 @@ } $output = ''; - $message = wfMsgForContent( 'inthenews' ); - if ( !wfEmptyMsg( 'inthenews', $message ) ) { - $newsArray = explode( "\n\n", $message ); + $message = wfMessage( 'inthenews' )->inContentLanguage(); + if ( !$message->isDisabled() ) { + $newsArray = explode( "\n\n", $message->plain() ); $newsItem = $newsArray[array_rand( $newsArray )]; $output = '<div class="blog-container"> - <h2>' . wfMsg( 'blog-in-the-news' ) . '</h2> + <h2>' . wfMessage( 'blog-in-the-news' )->escaped() . '</h2> <div>' . $wgOut->parse( $newsItem, false ) . '</div> </div>'; } @@ -731,7 +744,6 @@ $popularBlogPosts = $data; } else { wfDebugLog( 'BlogPage', 'Got popular articles from DB' ); - $blogCat = wfMsgForContent( 'blog-category' ); $dbr = wfGetDB( DB_SLAVE ); // Code sporked from Rob Church's NewestPages extension // @todo FIXME: adding categorylinks table and that one where @@ -750,7 +762,6 @@ 'page_is_redirect' => 0, 'page_id = Comment_Page_ID', 'page_id = vote_page_id', - #'cl_to ' . $dbr->buildLike( /*$dbr->anyString(), */$blogCat, $dbr->anyString() ), // If you can figure out how to do this without a subquery, // please let me know. Until that... "((SELECT COUNT(*) FROM $voteTable WHERE vote_page_id = page_id) >= 5 OR @@ -792,7 +803,7 @@ $html .= '</div>'; // .listpages-container $output = '<div class="blog-container"> - <h2>' . wfMsg( 'blog-popular-articles' ) . '</h2> + <h2>' . wfMessage( 'blog-popular-articles' )->escaped() . '</h2> <div>' . $html . '</div> </div>'; @@ -824,7 +835,6 @@ // We could do complicated LIKE stuff with the categorylinks table, // but I think we can safely assume that stuff in the NS_BLOG NS // is blog-related :) - //$blogCat = wfMsgForContent( 'blog-category' ); $dbr = wfGetDB( DB_SLAVE ); // Code sporked from Rob Church's NewestPages extension $res = $dbr->select( @@ -859,7 +869,7 @@ $html .= '</div>'; // .listpages-container $output = '<div class="blog-container bottom-fix"> - <h2>' . wfMsg( 'blog-new-articles' ) . '</h2> + <h2>' . wfMessage( 'blog-new-articles' )->escaped() . '</h2> <div>' . $html . '</div> </div>'; @@ -953,7 +963,7 @@ if( $comment['user_id'] != 0 ) { $commentPosterDisplay = $comment['user_name']; } else { - $commentPosterDisplay = wfMsg( 'blog-anonymous-name' ); + $commentPosterDisplay = wfMessage( 'blog-anonymous-name' )->escaped(); } $comment['comment_text'] = strip_tags( $comment['comment_text'] ); @@ -970,7 +980,7 @@ if ( count( $comments ) > 0 ) { $output = '<div class="blog-container"> - <h2>' . wfMsg( 'blog-comments-of-day' ) . '</h2>' . + <h2>' . wfMessage( 'blog-comments-of-day' )->escaped() . '</h2>' . $output . '</div>'; } @@ -1126,7 +1136,7 @@ $blurbText = preg_replace( '/[\n\r\t]/', ' ', $blurbText ); // replace any non-space whitespace with a space return $blurbFont . $blurbText. '. . . <a href="' . - htmlspecialchars( $title->getFullURL() ) . '">' . wfMsg( 'blog-more' ) . + htmlspecialchars( $title->getFullURL() ) . '">' . wfMessage( 'blog-more' )->escaped() . '</a></span>'; } @@ -1182,7 +1192,7 @@ static function getTimeOffset( $time, $timeabrv, $timename ) { $timeStr = ''; if( $time[$timeabrv] > 0 ) { - $timeStr = wfMsgExt( "blog-time-{$timename}", 'parsemag', $time[$timeabrv] ); + $timeStr = wfMessage( "blog-time-$timename", $time[$timeabrv] )->text(); } if( $timeStr ) { $timeStr .= ' '; @@ -1206,7 +1216,7 @@ } } if( !$timeStr ) { - $timeStr = wfMsgExt( 'blog-time-seconds', 'parsemag', 1 ); + $timeStr = wfMessage( 'blog-time-seconds' )->umParams( 1 )->text(); } return $timeStr; } diff --git a/SpecialArticleLists.php b/SpecialArticleLists.php index b7deff1..151e4e4 100644 --- a/SpecialArticleLists.php +++ b/SpecialArticleLists.php @@ -22,7 +22,7 @@ public function execute( $limit ) { global $wgMemc, $wgOut, $wgScriptPath; - $wgOut->setPageTitle( wfMsg( 'ah-new-articles' ) ); + $wgOut->setPageTitle( $this->msg( 'ah-new-articles' ) ); if ( empty( $limit ) ) { $limit = 25; @@ -40,7 +40,7 @@ $output = '<div class="left-articles">'; if ( !$this->including() ) { - $output .= '<h2>' . wfMsg( 'ah-new-articles' ) . '</h2>'; + $output .= '<h2>' . $this->msg( 'ah-new-articles' )->escaped() . '</h2>'; } // Try cache first @@ -81,7 +81,7 @@ $output .= '<div class="listpages-container">' . "\n"; if ( empty( $newBlogPosts ) ) { - $output .= wfMsg( 'ah-no-results' ); + $output .= $this->msg( 'ah-no-results' )->escaped(); } else { foreach( $newBlogPosts as $newBlogPost ) { $titleObj = Title::makeTitle( NS_BLOG, $newBlogPost['title'] ); @@ -110,17 +110,15 @@ '</div><!-- .listpages-blurb --> <div class="listpages-stats">' . "\n"; $output .= "<img src=\"{$imgPath}voteIcon.gif\" alt=\"\" border=\"0\" /> " . - wfMsgExt( + $this->msg( 'blog-author-votes', - 'parsemag', BlogPage::getVotesForPage( $newBlogPost['id'] ) - ); + )->escaped(); $output .= " <img src=\"{$imgPath}comment.gif\" alt=\"\" border=\"0\" /> " . - wfMsgExt( + $this->msg( 'blog-author-comments', - 'parsemag', BlogPage::getCommentsForPage( $newBlogPost['id'] ) - ) . '</div><!-- . listpages-stats --> + )->escaped() . '</div><!-- . listpages-stats --> </div><!-- .listpages-item --> <div class="cleared"></div>' . "\n"; } diff --git a/SpecialArticlesHome.php b/SpecialArticlesHome.php index 771052a..7e57b72 100644 --- a/SpecialArticlesHome.php +++ b/SpecialArticlesHome.php @@ -48,11 +48,11 @@ // Determine the page title and set it if ( $type == 'popular' ) { - $name = wfMsg( 'ah-popular-articles' ); - $name_right = wfMsg( 'ah-new-articles' ); + $name = $this->msg( 'ah-popular-articles' ); + $name_right = $this->msg( 'ah-new-articles' )->escaped(); } else { - $name = wfMsg( 'ah-new-articles' ); - $name_right = wfMsg( 'ah-popular-articles' ); + $name = $this->msg( 'ah-new-articles' ); + $name_right = $this->msg( 'ah-popular-articles' )->escaped(); } $wgOut->setPageTitle( $name ); @@ -62,17 +62,16 @@ // Start building the HTML output $output = '<div class="main-page-left">'; $output .= '<div class="logged-in-articles">'; - $output .= '<h2>' . $name . '</h2>'; - //$output .= '<h2>' . $name . ' <span class="rss-feed"><a href="http://feeds.feedburner.com/Armchairgm"><img src="http://www.armchairgm.com/images/a/a7/Rss-icon.gif" border="0" alt="RSS" /></a> ' . wfMsg( 'ah-feed-rss' ) . '</span></h2>'; + $output .= '<h2>' . $name->escaped() . '</h2>'; $output .= '<p class="main-page-sub-links"><a href="' . htmlspecialchars( SpecialPage::getTitleFor( 'CreateBlogPost' )->getFullURL() ) . '">' . - wfMsg( 'ah-write-article' ) . '</a> - <a href="' . + $this->msg( 'ah-write-article' )->escaped() . '</a> - <a href="' . // original used date( 'F j, Y' ) which returned something like // December 5, 2008 htmlspecialchars( Title::makeTitle( NS_CATEGORY, $today )->getFullURL() ) . '">' . - wfMsg( 'ah-todays-articles' ) . '</a> - <a href="' . + $this->msg( 'ah-todays-articles' )->escaped() . '</a> - <a href="' . htmlspecialchars( Title::newMainPage()->getFullURL() ) . '">' . - wfMsg( 'mainpage' ) . '</a></p>' . "\n\n"; + $this->msg( 'mainpage' )->escaped() . '</a></p>' . "\n\n"; if ( $type == 'popular' ) { $output .= $this->getPopularPosts(); @@ -100,13 +99,13 @@ // Most Votes $output .= '<div class="side-articles">'; - $output .= '<h2>' . wfMsg( 'ah-most-votes' ) . '</h2>'; + $output .= '<h2>' . $this->msg( 'ah-most-votes' )->escaped() . '</h2>'; $output .= $this->displayMostVotedPages( $date_categories ); $output .= '</div>'; // Most Comments $output .= '<div class="side-articles">'; - $output .= '<h2>' . wfMsg( 'ah-what-talking-about' ) . '</h2>'; + $output .= '<h2>' . $this->msg( 'ah-what-talking-about' )->escaped() . '</h2>'; $output .= $this->displayMostCommentedPages( $date_categories ); $output .= '</div>'; @@ -199,7 +198,7 @@ $output = '<div class="listpages-container">'; if ( empty( $popularBlogPosts ) ) { - $output .= wfMsg( 'ah-no-results' ); + $output .= $this->msg( 'ah-no-results' )->escaped(); } else { foreach( $popularBlogPosts as $popularBlogPost ) { $titleObj = Title::makeTitle( NS_BLOG, $popularBlogPost['title'] ); @@ -220,14 +219,17 @@ $titleObj->getText() . '</a> <div class="listpages-date">'; - $output .= '(' . wfMsg( 'blog-created-ago', - BlogPage::getTimeAgo( - // need to strtotime() it because getCreateDate() now - // returns the raw timestamp from the database; in the past - // it converted it to UNIX timestamp via the SQL function - // UNIX_TIMESTAMP but that was no good for our purposes - strtotime( BlogPage::getCreateDate( $popularBlogPost['id'] ) ) - ) ) . ')'; + $output .= '(' . + $this->msg( + 'blog-created-ago', + BlogPage::getTimeAgo( + // need to strtotime() it because getCreateDate() now + // returns the raw timestamp from the database; in the past + // it converted it to UNIX timestamp via the SQL function + // UNIX_TIMESTAMP but that was no good for our purposes + strtotime( BlogPage::getCreateDate( $popularBlogPost['id'] ) ) + ) + )->escaped() . ')'; $output .= "</div> <div class=\"listpages-blurb\">\n" . BlogPage::getBlurb( @@ -238,17 +240,15 @@ '</div><!-- .listpages-blurb --> <div class="listpages-stats">' . "\n"; $output .= "<img src=\"{$imgPath}voteIcon.gif\" alt=\"\" border=\"0\" /> " . - wfMsgExt( + $this->msg( 'blog-author-votes', - 'parsemag', BlogPage::getVotesForPage( $popularBlogPost['id'] ) - ); + )->escaaped(); $output .= " <img src=\"{$imgPath}comment.gif\" alt=\"\" border=\"0\" /> " . - wfMsgExt( + $this->msg( 'blog-author-comments', - 'parsemag', BlogPage::getCommentsForPage( $popularBlogPost['id'] ) - ) . '</div><!-- . listpages-stats --> + )->escaped() . '</div><!-- . listpages-stats --> </div><!-- .listpages-item --> <div class="cleared"></div>' . "\n"; } @@ -324,7 +324,7 @@ $output = '<div class="listpages-container">' . "\n"; if ( empty( $votedBlogPosts ) ) { - $output .= wfMsg( 'ah-no-results' ); + $output .= $this->msg( 'ah-no-results' )->escaped(); } else { foreach ( $votedBlogPosts as $votedBlogPost ) { $titleObj = Title::makeTitle( NS_BLOG, $votedBlogPost['title'] ); @@ -334,11 +334,9 @@ $output .= '<div class="listpages-votebox-number">' . $votes . "</div>\n"; $output .= '<div class="listpages-votebox-text">' . - wfMsgExt( - 'blog-author-votes', - 'parsemag', - $votes - ) . "</div>\n"; // .listpages-votebox-text + $this->msg( 'blog-author-votes' ) + ->numParams( $votes ) + ->escaped() . "</div>\n"; // .listpages-votebox-text $output .= '</div>' . "\n"; // .listpages-votebox $output .= '</div>' . "\n"; // .listpages-item $output .= '<a href="' . htmlspecialchars( $titleObj->getFullURL() ) . '">' . @@ -416,7 +414,7 @@ $output = '<div class="listpages-container">'; if ( empty( $commentedBlogPosts ) ) { - $output .= wfMsg( 'ah-no-results' ); + $output .= $this->msg( 'ah-no-results' )->escaped(); } else { foreach( $commentedBlogPosts as $commentedBlogPost ) { $titleObj = Title::makeTitle( NS_BLOG, $commentedBlogPost['title'] ); @@ -485,7 +483,7 @@ $output = '<div class="listpages-container">' . "\n"; if ( empty( $newBlogPosts ) ) { - $output .= wfMsg( 'ah-no-results' ); + $output .= $this->msg( 'ah-no-results' )->escaped(); } else { foreach( $newBlogPosts as $newBlogPost ) { $titleObj = Title::makeTitle( NS_BLOG, $newBlogPost['title'] ); @@ -496,11 +494,9 @@ $votes . "</div>\n"; // .listpages-votebox-number $output .= '<div class="listpages-votebox-text">' . - wfMsgExt( - 'blog-author-votes', - 'parsemag', - $votes - ) . "</div>\n"; // .listpages-votebox-text + $this->msg( 'blog-author-votes' ) + ->numParams( $votes ) + ->escaped() . "</div>\n"; // .listpages-votebox-text $output .= "</div>\n"; // .listpages-votebox $output .= '<a href="' . htmlspecialchars( $titleObj->getFullURL() ) . '">' . $titleObj->getText() . @@ -567,7 +563,7 @@ $output = '<div class="listpages-container">'; if ( empty( $newestBlogPosts ) ) { - $output .= wfMsg( 'ah-no-results' ); + $output .= $this->msg( 'ah-no-results' )->escaped(); } else { foreach( $newestBlogPosts as $newestBlogPost ) { $titleObj = Title::makeTitle( NS_BLOG, $newestBlogPost['title'] ); @@ -588,14 +584,16 @@ $titleObj->getText() . '</a> <div class="listpages-date">'; - $output .= '(' . wfMsg( 'blog-created-ago', - BlogPage::getTimeAgo( - // need to strtotime() it because getCreateDate() now - // returns the raw timestamp from the database; in the past - // it converted it to UNIX timestamp via the SQL function - // UNIX_TIMESTAMP but that was no good for our purposes - strtotime( BlogPage::getCreateDate( $newestBlogPost['id'] ) ) - ) ) . ')'; + $output .= '(' . + $this->msg( 'blog-created-ago', + BlogPage::getTimeAgo( + // need to strtotime() it because getCreateDate() now + // returns the raw timestamp from the database; in the past + // it converted it to UNIX timestamp via the SQL function + // UNIX_TIMESTAMP but that was no good for our purposes + strtotime( BlogPage::getCreateDate( $newestBlogPost['id'] ) ) + ) + )->escaped() . ')'; $output .= "</div> <div class=\"listpages-blurb\">\n" . BlogPage::getBlurb( @@ -606,17 +604,13 @@ '</div><!-- .listpages-blurb --> <div class="listpages-stats">' . "\n"; $output .= "<img src=\"{$imgPath}voteIcon.gif\" alt=\"\" border=\"0\" /> " . - wfMsgExt( - 'blog-author-votes', - 'parsemag', - BlogPage::getVotesForPage( $newestBlogPost['id'] ) - ); + $this->msg( 'blog-author-votes' ) + ->numParams( BlogPage::getVotesForPage( $newestBlogPost['id'] ) ) + ->escaped(); $output .= " <img src=\"{$imgPath}comment.gif\" alt=\"\" border=\"0\" /> " . - wfMsgExt( - 'blog-author-comments', - 'parsemag', - BlogPage::getCommentsForPage( $newestBlogPost['id'] ) - ) . '</div><!-- . listpages-stats --> + $this->msg( 'blog-author-comments' ) + ->numParams( BlogPage::getCommentsForPage( $newestBlogPost['id'] ) ) + ->escaped() . '</div><!-- . listpages-stats --> </div><!-- .listpages-item --> <div class="cleared"></div>' . "\n"; } @@ -696,7 +690,7 @@ $output = '<div class="listpages-container">'; if ( empty( $popularBlogPosts ) ) { - $output .= wfMsg( 'ah-no-results' ); + $output .= $this->msg( 'ah-no-results' )->escaped(); } else { foreach( $popularBlogPosts as $popularBlogPost ) { $titleObj = Title::makeTitle( NS_BLOG, $popularBlogPost['title'] ); @@ -706,11 +700,9 @@ $output .= '<div class="listpages-votebox-number">' . $votes . "</div>\n"; $output .= '<div class="listpages-votebox-text">' . - wfMsgExt( - 'blog-author-votes', - 'parsemag', - $votes - ) . "</div>\n"; // .listpages-votebox-text + $this->msg( 'blog-author-votes' ) + ->numParams( $votes ) + ->escaped() . "</div>\n"; // .listpages-votebox-text $output .= '</div>' . "\n"; // .listpages-votebox $output .= '<a href="' . htmlspecialchars( $titleObj->getFullURL() ) . '">' . $titleObj->getText() . diff --git a/SpecialCreateBlogPost.php b/SpecialCreateBlogPost.php index f385055..2a190b1 100644 --- a/SpecialCreateBlogPost.php +++ b/SpecialCreateBlogPost.php @@ -62,7 +62,7 @@ // Protect against cross-site request forgery (CSRF) if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { - $wgOut->addHTML( wfMsg( 'sessionfailure' ) ); + $wgOut->addWikiMsg( 'sessionfailure' ); return; } @@ -75,7 +75,7 @@ // The user didn't supply a title? Ask them to supply one. if ( !$userSuppliedTitle ) { - $wgOut->setPageTitle( wfMsg( 'errorpagetitle' ) ); + $wgOut->setPageTitle( $this->msg( 'errorpagetitle' ) ); $wgOut->addWikiMsg( 'blog-create-error-need-title' ); $wgOut->addReturnTo( $this->getPageTitle() ); return; @@ -83,7 +83,7 @@ // The user didn't supply the blog post text? Ask them to supply it. if ( !$wgRequest->getVal( 'pageBody' ) ) { - $wgOut->setPageTitle( wfMsg( 'errorpagetitle' ) ); + $wgOut->setPageTitle( $this->msg( 'errorpagetitle' ) ); $wgOut->addWikiMsg( 'blog-create-error-need-content' ); $wgOut->addReturnTo( $this->getPageTitle() ); return; @@ -96,7 +96,7 @@ // Create the blog page if it doesn't already exist $article = new Article( $title, 0 ); if ( $article->exists() ) { - $wgOut->setPageTitle( wfMsg( 'errorpagetitle' ) ); + $wgOut->setPageTitle( $this->msg( 'errorpagetitle' ) ); $wgOut->addWikiMsg( 'blog-create-error-page-exists' ); $wgOut->addReturnTo( $this->getPageTitle() ); return; @@ -107,11 +107,11 @@ // we need to take those into account, too. $categories = array( '[[' . $localizedCatNS . ':' . - wfMsgForContent( + $this->msg( 'blog-by-user-category', - wfMsgForContent( 'blog-category' ) - ) . wfMsgForContent( 'word-separator' ) . - $wgUser->getName() . ']]', + $this->getUser()->getName() + )->inContentLanguage()->text() . + ']]' . "[[{$localizedCatNS}:{$today}]]" ); @@ -140,7 +140,7 @@ $wgRequest->getVal( 'pageBody' ) . "\n\n" . '<comments />' . "\n\n" . $wikitextCategories . "\n__NOEDITSECTION__", - wfMsgForContent( 'blog-create-summary' ) + $this->msg( 'blog-create-summary' )->inContentLanguage()->text() ); $articleId = $article->getID(); @@ -179,10 +179,9 @@ $output = ''; // Show the blog rules, if the message containing them ain't empty - $message = trim( wfMsgExt( 'blog-create-rules', array( 'parse', 'content' ) ) ); - // Yes, the strlen() is needed, I dunno why wfEmptyMsg() won't work - if( !wfEmptyMsg( 'blog-create-rules', $message ) && strlen( $message ) > 0 ) { - $output .= $message . '<br />'; + $message = $this->msg( 'blog-create-rules' ); + if( !$message->isDisabled() ) { + $output .= $message->escaped() . '<br />'; } // Main form @@ -198,7 +197,7 @@ * @return String: HTML */ function displayFormPageTitle() { - $output = '<span class="create-title">' . wfMsg( 'blog-create-title' ) . + $output = '<span class="create-title">' . $this->msg( 'blog-create-title' )->escaped() . '</span><br /><input class="createbox" type="text" tabindex="' . $this->tabCounter . '" name="title2" id="title" style="width: 500px;"><br /><br />'; $this->tabCounter++; @@ -210,7 +209,7 @@ * @return String: HTML */ function displayFormPageText() { - $output = '<span class="create-title">' . wfMsg( 'blog-create-text' ) . + $output = '<span class="create-title">' . $this->msg( 'blog-create-text' )->escaped() . '</span><br />'; // The EditPage toolbar wasn't originally present here but I figured // that adding it might be more helpful than anything else. @@ -236,8 +235,7 @@ $tagnumber = 0; foreach ( $cloud->tags as $tag => $att ) { $tag = trim( $tag ); - $blogUserCat = wfMsgForContent( 'blog-by-user-category', - wfMsgForContent( 'blog-category' ) ); + $blogUserCat = $this->msg( 'blog-by-user-category' )->inContentLanguage()->text(); // Ignore "Articles by User X" categories if ( !preg_match( '/' . $blogUserCat . '/', $tag ) ) { $slashedTag = $tag; // define variable @@ -254,10 +252,10 @@ $tagcloud .= '</div>'; $output = '<div class="create-title">' . - wfMsg( 'blog-create-categories' ) . + $this->msg( 'blog-create-categories' )->escaped() . '</div> <div class="categorytext">' . - wfMsg( 'blog-create-category-help' ) . + $this->msg( 'blog-create-category-help' )->escaped() . '</div>' . "\n"; $output .= $tagcloud . "\n"; $output .= '<textarea class="createbox" tabindex="' . $this->tabCounter . @@ -278,17 +276,17 @@ if ( $wgRightsText ) { $copywarnMsg = 'copyrightwarning'; $copywarnMsgParams = array( - '[[' . wfMsgForContent( 'copyrightpage' ) . ']]', + '[[' . $this->msg( 'copyrightpage' )->inContentLanguage()->text() . ']]', $wgRightsText ); } else { $copywarnMsg = 'copyrightwarning2'; $copywarnMsgParams = array( - '[[' . wfMsgForContent( 'copyrightpage' ) . ']]' + '[[' . $this->msg( 'copyrightpage' )->inContentLanguage()->text() . ']]' ); } return '<div class="copyright-warning">' . - wfMsgExt( $copywarnMsg, 'parse', $copywarnMsgParams ) . + $this->msg( $copywarnMsg, $copywarnMsgParams )->parseAsBlock() . '</div>'; } @@ -300,15 +298,15 @@ global $wgUser; $output = '<form id="editform" name="editform" method="post" action="' . - htmlspecialchars( $this->getPageTitle()->getFullURL() ) . '" enctype="multipart/form-data">'; + htmlspecialchars( $this->getTitle()->getFullURL() ) . '" enctype="multipart/form-data">'; $output .= "\n" . $this->displayFormPageTitle() . "\n"; $output .= "\n" . $this->displayFormPageText() . "\n"; $output .= "\n" . $this->displayFormPageCategories() . "\n"; $output .= "\n" . $this->displayCopyrightWarning() . "\n"; - $output .= '<input type="button" value="' . wfMsg( 'blog-create-button' ) . + $output .= '<input type="button" value="' . $this->msg( 'blog-create-button' )->escaped() . '" name="wpSave" class="createsubmit site-button" accesskey="s" title="' . - wfMsg( 'tooltip-save' ) . ' [alt-s]" /> + $this->msg( 'tooltip-save' )->escaped() . ' [alt-s]" /> <input type="hidden" value="" name="wpSection" /> <input type="hidden" value="" name="wpEdittime" /> <input type="hidden" value="" name="wpTextbox1" id="wpTextbox1" /> diff --git a/TagCloudClass.php b/TagCloudClass.php index f530d12..c046fe0 100644 --- a/TagCloudClass.php +++ b/TagCloudClass.php @@ -9,6 +9,7 @@ public $tags_max_pts = 32; public $tags_highest_count = 0; public $tags_size_type = 'pt'; + public $tags = array(); public function __construct( $limit = 10 ) { $this->limit = $limit; @@ -29,11 +30,11 @@ ) ); - $message = trim( wfMsgForContent( 'blog-tagcloud-blacklist' ) ); + $message = wfMessage( 'blog-tagcloud-blacklist' ); $catsExcluded = array(); // Yes, the strlen() is needed, I dunno why wfEmptyMsg() won't work - if( !wfEmptyMsg( 'blog-tagcloud-blacklist', $message ) && strlen( $message ) > 0 ) { - $catsExcluded = explode( "\n* ", wfMsgForContent( 'blog-tagcloud-blacklist' ) ); + if( !$message->isDisabled() ) { + $catsExcluded = explode( "\n* ", $message->inContentLanguage()->text() ); } wfSuppressWarnings(); // prevent PHP from bitching about strtotime() diff --git a/i18n/en.json b/i18n/en.json index 82c7b35..a462b4e 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -12,8 +12,7 @@ "blog-author-title": "About the {{PLURAL:$1|Author|Authors}}", "blog-author-votes": "$1 {{PLURAL:$1|vote|votes}}", "blog-by": "by", - "blog-by-user-category": "$1 by User", - "blog-category": "Articles", + "blog-by-user-category": "Articles by User $1", "blog-comments-of-day": "Comments of the Day", "blog-created": "created $1", "blog-created-ago": "created $1 ago", -- To view, visit https://gerrit.wikimedia.org/r/151199 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic60108036805dd203f51a6d291957fa1323fb3b0 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/BlogPage Gerrit-Branch: master Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de> Gerrit-Reviewer: Alex Monk <kren...@wikimedia.org> Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de> Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Nemo bis <federicol...@tiscali.it> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits