r12192 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12191‎ | r12192 | r12193 >
Date:10:45, 21 December 2005
Author:magnus_manske
Status:old
Tags:
Comment:
fixes, separation of translation
Modified paths:
  • /trunk/extensions/StableVersion/StableVersion.php (modified) (history)
  • /trunk/extensions/StableVersion/language (added) (history)
  • /trunk/extensions/StableVersion/language/en.php (added) (history)

Diff [purge]

Index: trunk/extensions/StableVersion/language/en.php
@@ -0,0 +1,32 @@
 2+<?
 3+/**
 4+ * English language file for the 'StableVErsion' extension
 5+ */
 6+
 7+// We will add messages to the global cache
 8+global $wgMessageCache;
 9+
 10+// Add messages
 11+$wgMessageCache->addMessages(
 12+ array(
 13+ 'stableversion_this_is_stable' => 'This is the stable version of this article. You can also look at the <a href="$1">latest draft version</a>.',
 14+ 'stableversion_this_is_draft_no_stable' => 'You are looking at a draft version of this article; there is no stable version of this article yet.',
 15+ 'stableversion_this_is_draft' => 'This is a draft version of this article. You can also look at the <a href="$1">stable version</a>.',
 16+ 'stableversion_reset_stable_version' => 'Click <a href="$1">here</a> to remove this as stable version!',
 17+ 'stableversion_set_stable_version' => 'Click <a href="$1">here</a> to set this as stable version!',
 18+ 'stableversion_set_ok' => 'The stable version has been successfully set.',
 19+ 'stableversion_reset_ok' => 'The stable version has been successfully removed. This article has no stable version right now.',
 20+ 'stableversion_return' => 'Return to <a href="$1">$2</a>',
 21+
 22+ 'stableversion_reset_log' => 'Stable version has been removed.',
 23+ 'stableversion_logpage' => 'Stable version log',
 24+ 'stableversion_logpagetext' => 'This is a log of changes to stable versions',
 25+ 'stableversion_logentry' => '',
 26+ 'stableversion_log' => 'Revision #$1 is now the stable version.',
 27+ 'stableversion_before_no' => 'There was no stable revision before.',
 28+ 'stableversion_before_yes' => 'The last stable revision was #$1.',
 29+ 'stableversion_this_is_stable_and_current' => "This is both the stable and the latest version.",
 30+ )
 31+);
 32+
 33+?>
\ No newline at end of file
Property changes on: trunk/extensions/StableVersion/language/en.php
___________________________________________________________________
Added: svn:keywords
134 + Author Date Id Revision
Added: svn:eol-style
235 + native
Index: trunk/extensions/StableVersion/StableVersion.php
@@ -71,26 +71,14 @@
7272 global $wgMessageCache , $wgStableVersionAddCache ;
7373 if ( $wgStableVersionAddCache ) return ;
7474 $wgStableVersionAddCache = true ;
75 - $wgMessageCache->addMessages(
76 - array(
77 - 'stableversion_this_is_stable' => 'This is the stable version of this article. You can also look at the <a href="$1">latest draft version</a>.',
78 - 'stableversion_this_is_draft_no_stable' => 'You are looking at a draft version of this article; there is no stable version of this article yet.',
79 - 'stableversion_this_is_draft' => 'This is a draft version of this article. You can also look at the <a href="$1">stable version</a>.',
80 - 'stableversion_reset_stable_version' => 'Click <a href="$1">here</a> to remove this as stable version!',
81 - 'stableversion_set_stable_version' => 'Click <a href="$1">here</a> to set this as stable version!',
82 - 'stableversion_set_ok' => 'The stable version has been successfully set.',
83 - 'stableversion_reset_ok' => 'The stable version has been successfully removed. This article has no stable version right now.',
84 - 'stableversion_return' => 'Return to <a href="$1">$2</a>',
85 -
86 - 'stableversion_reset_log' => 'Stable version has been removed.',
87 - 'stableversion_logpage' => 'Stable version log',
88 - 'stableversion_logpagetext' => 'This is a log of changes to stable versions',
89 - 'stableversion_logentry' => '',
90 - 'stableversion_log' => 'Revision #$1 is now the stable version.',
91 - 'stableversion_before_no' => 'There was no stable revision before.',
92 - 'stableversion_before_yes' => 'The last stable revision was #$1.',
93 - )
94 - );
 75+
 76+ // Default language is english
 77+ require_once('language/en.php');
 78+
 79+ global $wgLanguageCode;
 80+ $filename = 'language/' . addslashes($wgLanguageCode) . '.php' ;
 81+ // inclusion might fail :p
 82+ include( $filename );
9583 }
9684
9785 /**
@@ -120,10 +108,11 @@
121109 $res = $dbr->select(
122110 /* FROM */ 'stableversions',
123111 /* SELECT */ '*',
124 - /* WHERE */ array( 'sv_page_id' => $title->getArticleID() , 'sv_page_rev' => $article->mRevision ) ,
 112+ /* WHERE */ array( 'sv_page_id' => $title->getArticleID() ) ,
 113+ $fname,
125114 array ( "ORDER BY" => "sv_page_rev DESC" )
126115 );
127 -
 116+
128117 $article->mIsStable = false ;
129118 $article->mLastStable = 0 ;
130119 while ( $o = $dbr->fetchObject( $res ) ) {
@@ -164,8 +153,12 @@
165154 $st = "" ; # Subtitle
166155
167156 if ( $article->mIsStable ) { # This is the stable version
168 - $url = $wgTitle->getFullURL () ;
169 - $st = wfMsg ( 'stableversion_this_is_stable' , $url ) ;
 157+ if ( $article->mLatest == $article->mLastStable ) {
 158+ $st .= wfMsg ( 'stableversion_this_is_stable_and_current' ) ;
 159+ } else {
 160+ $url = $wgTitle->getFullURL () ;
 161+ $st .= wfMsg ( 'stableversion_this_is_stable' , $url ) ;
 162+ }
170163 } else if ( $article->mLastStable == "0" ) { # There is no spoon, er, stable version
171164 $st = wfMsg ( 'stableversion_this_is_draft_no_stable' ) ;
172165 } else { # This is not the stable version, recommend it
@@ -212,7 +205,7 @@
213206 * main()
214207 */
215208 function execute( $par = null ) {
216 - global $wgOut , $wgRequest , $wgUser ;
 209+ global $wgOut , $wgRequest , $wgUser , $wgArticle ;
217210
218211 # Sanity checks
219212 $mode = $wgRequest->getText('mode', "") ;
@@ -237,11 +230,13 @@
238231 }
239232
240233 # Get old stable version
241 - $dbr =& wfGetDB( DB_SLAVE );
 234+/* $dbr =& wfGetDB( DB_SLAVE );
242235 $fname = "SpecialStableVersion:execute" ;
243236 $row = $dbr->selectRow( 'page', array( 'page_stable' ),
244237 array( 'page_id' => $id ), $fname );
245238 $oldstable = $row->page_stable ;
 239+*/
 240+ $oldstable = isset ( $wgArticle->mLastStable ) ? $wgArticle->mLastStable : 0 ;
246241 if ( $oldstable == 0 ) $before = wfMsg ( 'stableversion_before_no' ) ;
247242 else $before = wfMsg ( 'stableversion_before_yes' , $oldstable ) ;
248243 $act .= " " . $before ;

Status & tagging log