r35863 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35862‎ | r35863 | r35864 >
Date:14:58, 4 June 2008
Author:siebrand
Status:old
Tags:
Comment:
* updates to messages for consistency
* indentation and consistency fixes
Modified paths:
  • /trunk/extensions/EditSimilar/EditSimilar.i18n.php (modified) (history)
  • /trunk/extensions/EditSimilar/EditSimilar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EditSimilar/EditSimilar.i18n.php
@@ -1,21 +1,36 @@
22 <?php
 3+/**
 4+ * Internationalisation file for extension EditSimilar
 5+ *
 6+ * @addtogroup Extensions
 7+ */
 8+
39 $messages = array();
 10+
411 $messages['en'] = array(
5 - 'editsimilar-thanks' => 'Thanks for your edit. Check out these related articles: $1.' ,
6 - 'editsimilar-thanks-singleresult' => 'Thanks for your edit. Check out this related article: $1.' ,
7 - 'editsimilar-thanks-notsimilar' => 'Thank you for your edit. These articles could also use your help: $1.',
8 - 'editsimilar-thanks-notsimilar-singleresult' => 'Thank you for your edit. This article could also use your help: $1.',
9 - 'editsimilar-thankyou' => 'Thanks for your edit, $1!' ,
10 - 'editsimilar-link-disable' => 'set preferences' ,
11 - 'tog-edit-similar' => 'Enable similar articles suggestions' ,
12 -) ;
 12+ 'editsimilar-thanks' => 'Thank you for your contribution.
 13+Check out these related pages: $1.' ,
 14+ 'editsimilar-thanks-singleresult' => 'Thank you for your contribution.
 15+Check out this related page: $1.' ,
 16+ 'editsimilar-thanks-notsimilar' => 'Thank you for your contribution.
 17+These pages could also use your help: $1.',
 18+ 'editsimilar-thanks-notsimilar-singleresult' => 'Thank you for your contribution.
 19+This page could also use your help: $1.',
 20+ 'editsimilar-thankyou' => 'Thank you for your contribution, $1!' ,
 21+ 'editsimilar-link-disable' => 'set preferences' ,
 22+ 'tog-edit-similar' => 'Enable similar pages suggestions' ,
 23+);
1324
1425 $messages['pl'] = array(
15 - 'editsimilar-thanks' => 'Dzięki za edycję! Zerknij też na podobne artykuły: $1.' ,
16 - 'editsimilar-thanks-singleresult' => 'Dzięki za edycję! Zerknij też na ten podobny artykuł: $1.' ,
17 - 'editsimilar-thanks-notsimilar' => 'Dzięki za edycję! Te artykuły również mogą potrzebować twojej pomocy: $1.',
18 - 'editsimilar-thanks-notsimilar-singleresult' => 'Dzięki za edycję! Ten artykuł również może potrzebować twojej pomocy: $1.',
19 - 'editsimilar-thankyou' => 'Dzięki za Twoją edycję, $1!' ,
20 - 'editsimilar-link-disable' => 'zmień ustawienia' ,
21 - 'tog-edit-similar'=> 'Włącz sugestie edycji podobnych artykułów' ,
22 -) ;
 26+ 'editsimilar-thanks' => 'Dzięki za edycję!
 27+Zerknij też na podobne artykuły: $1.' ,
 28+ 'editsimilar-thanks-singleresult' => 'Dzięki za edycję!
 29+Zerknij też na ten podobny artykuł: $1.' ,
 30+ 'editsimilar-thanks-notsimilar' => 'Dzięki za edycję!
 31+Te artykuły również mogą potrzebować twojej pomocy: $1.',
 32+ 'editsimilar-thanks-notsimilar-singleresult' => 'Dzięki za edycję!
 33+Ten artykuł również może potrzebować twojej pomocy: $1.',
 34+ 'editsimilar-thankyou' => 'Dzięki za Twoją edycję, $1!' ,
 35+ 'editsimilar-link-disable' => 'zmień ustawienia' ,
 36+ 'tog-edit-similar' => 'Włącz sugestie edycji podobnych artykułów' ,
 37+);
Index: trunk/extensions/EditSimilar/EditSimilar.php
@@ -11,12 +11,13 @@
1212 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1313 */
1414
15 -if ( defined( 'MEDIAWIKI' ) ) {
 15+if (!defined('MEDIAWIKI'))
 16+ exit;
1617
1718 global $wgExtensionFunctions, $wgGroupPermissions;
1819
19 -$dir = dirname(__FILE__);
20 -$wgExtensionMessagesFiles ['EditSimilar'] = $dir . '/EditSimilar.i18n.php' ;
 20+$dir = dirname(__FILE__);
 21+$wgExtensionMessagesFiles ['EditSimilar'] = $dir . '/EditSimilar.i18n.php' ;
2122
2223 if (empty ($wgEditSimilarMaxResultsPool ) ) {
2324 // maximum number of results to choose from
@@ -37,7 +38,7 @@
3839
3940 $wgExtensionCredits['other'][] = array(
4041 'name' => 'EditSimilar',
41 - 'version' => 1.16 ,
 42+ 'version' => '1.16',
4243 'author' => 'Bartek Łapiński, [http://inside.wikia.com/wiki/User:TOR Łukasz \'TOR\' Garczewski]',
4344 'url' => 'http://help.wikia.com/wiki/Help:EditSimilar',
4445 'description' => 'Encourages users to edit an article similar (by categories) to the one they just had edited.',
@@ -59,7 +60,7 @@
6061 * Chosen Stub Category 2
6162 etc. (separated by stars)
6263
63 - insert '-' if you want to disable the extension without blanking the commanding article
 64+ insert '-' if you want to disable the extension without blanking the commanding article
6465
6566 */
6667
@@ -68,7 +69,7 @@
6970 var $mBaseArticle ; // the article from which we hail in our quest for similiarities, this is its title
7071 var $mMarkerType ; // how do we mark articles that need attention? currently, by category only
7172 var $mAttentionMarkers ; // the marker array (for now it contains categories)
72 - var $mMatchType ; // how do we match articles as a secondary
 73+ var $mMatchType ; // how do we match articles as a secondary
7374 var $mPoolLimit ; // limit up the pool of 'stubs' to choose from
7475 var $mBaseCategories ; // extracted categories that this saved article is in
7576 var $mSimilarArticles ; // to differentiate between really similar results or just needing attention
@@ -79,10 +80,10 @@
8081 $this->mBaseArticle = $article ;
8182 $this->mMarkerType = $markertype ;
8283 $this->mAttentionMarkers = $this->getStubCategories () ;
83 - $this->mPoolLimit = $wgEditSimilarMaxResultsPool ;
 84+ $this->mPoolLimit = $wgEditSimilarMaxResultsPool ;
8485 $this->mBaseCategories = $this->getBaseCategories () ;
85 - $this->mSimilarArticles = true ;
86 - }
 86+ $this->mSimilarArticles = true ;
 87+ }
8788
8889 // fetch categories marked as 'stub categories'
8990 function getStubCategories () {
@@ -100,7 +101,7 @@
101102 }
102103 }
103104
104 - // this is the main function that returns articles we deem similar or worth showing
 105+ // this is the main function that returns articles we deem similar or worth showing
105106 function getSimilarArticles () {
106107 global $wgUser, $wgEditSimilarMarker ;
107108 global $wgEditSimilarMaxResultsToDisplay ;
@@ -113,7 +114,7 @@
114115 $x = 0 ;
115116
116117 while ( (count ($articles) < $wgEditSimilarMaxResultsToDisplay) && ($x < count ($this->mAttentionMarkers)) ) {
117 - $articles = array_merge ($articles, $this->getResults ($this->mAttentionMarkers [$x]) ) ;
 118+ $articles = array_merge ($articles, $this->getResults ($this->mAttentionMarkers [$x]) ) ;
118119 if (!empty ($articles)) {
119120 $articles = array_unique ($articles) ;
120121 }
@@ -129,7 +130,7 @@
130131 $articles = array_unique ($articles) ;
131132 $this->mSimilarArticles = false ;
132133 }
133 -
 134+
134135 if (1 == count ($articles)) { // in this case, array_rand returns a single element, not an array
135136 $rand_articles = array (0) ;
136137 } else {
@@ -147,15 +148,15 @@
148149 foreach ($rand_articles as $r_key => $rand_article_key) {
149150 $translated_titles [] = $articles [$rand_article_key] ;
150151 }
151 - $translated_titles = $this->idsToTitles ($translated_titles) ;
152 -
 152+ $translated_titles = $this->idsToTitles ($translated_titles) ;
 153+
153154 foreach ($translated_titles as $link_title) {
154155 $article_link = $sk->makeKnownLinkObj ($link_title) ;
155 - $real_rand_values [] = $article_link ;
 156+ $real_rand_values [] = $article_link ;
156157 }
157 -
 158+
158159 return $real_rand_values;
159 - }
 160+ }
160161
161162 // extract all categories our base article is in
162163 function getBaseCategories () {
@@ -163,13 +164,13 @@
164165 if (empty ($this->mAttentionMarkers) || !$this->mAttentionMarkers) {
165166 return false ;
166167 }
167 -
 168+
168169 $dbr = wfGetDB( DB_SLAVE );
169 - $result_array = array () ;
 170+ $result_array = array () ;
170171 $res = $dbr->select (
171172 array ('categorylinks') ,
172173 array ('cl_to') ,
173 - array ( 'cl_from' => $this->mBaseArticle ) ,
 174+ array ( 'cl_from' => $this->mBaseArticle ) ,
174175 __METHOD__ ,
175176 array ( 'ORDER_BY' => 'cl_from' ,
176177 'USE_INDEX' => 'cl_from'
@@ -177,7 +178,7 @@
178179 ) ;
179180 while( $x = $dbr->fetchObject ( $res ) ) {
180181 if (!in_array ($x->cl_to, $this->mAttentionMarkers) ) {
181 - $result_array [] = $x->cl_to ;
 182+ $result_array [] = $x->cl_to ;
182183 }
183184 }
184185
@@ -192,7 +193,7 @@
193194 latest addition: if we got no results at all (indicating that:
194195 A - the article had no categories,
195196 B - the article had no relevant results for its categories)
196 -
 197+
197198 this is to ensure we can get always (well, almost - if "marker" categories get no results, it's dead in the water anyway)
198199 some results
199200 */
@@ -202,11 +203,11 @@
203204 $query = "SELECT cl_from
204205 FROM categorylinks
205206 WHERE cl_to IN (" ;
206 -
207 - $fixed_names = array () ;
 207+
 208+ $fixed_names = array () ;
208209 foreach ($this->mAttentionMarkers as $category) {
209210 $fixed_names [] = $dbr->addQuotes ($category) ;
210 - }
 211+ }
211212 $stringed_names = implode (",", $fixed_names) ;
212213 $query .= $stringed_names . ")" ;
213214
@@ -214,7 +215,7 @@
215216 $result_array = array () ;
216217 while( $x = $dbr->fetchObject ( $res ) ) {
217218 if ($this->mBaseArticle != $x->cl_from) {
218 - $result_array [] = $x->cl_from ;
 219+ $result_array [] = $x->cl_from ;
219220 }
220221 }
221222 $dbr->freeResult( $res );
@@ -237,13 +238,13 @@
238239 $res = $dbr->query ($query, __METHOD__) ;
239240 $result_array = array () ;
240241
241 - // so for now, to speed things up, just discard results from other namespaces (and subpages)
242 - while( ($x = $dbr->fetchObject ( $res ))
 242+ // so for now, to speed things up, just discard results from other namespaces (and subpages)
 243+ while( ($x = $dbr->fetchObject ( $res ))
243244 && (in_array ($x->page_namespace, $wgContentNamespaces))
244245 && false === strpos ($x->page_title, "/") ) {
245246 $result_array [] = Title::makeTitle ($x->page_namespace, $x->page_title ) ;
246247 }
247 -
 248+
248249 $dbr->freeResult( $res );
249250 return $result_array ;
250251 }
@@ -256,25 +257,25 @@
257258
258259 if (empty ($this->mBaseCategories)) {
259260 return $result_array ;
260 - }
 261+ }
261262
262263 $query = "SELECT c1.cl_from
263 - FROM categorylinks as c1, categorylinks as c2
264 - WHERE c1.cl_from = c2.cl_from
265 - AND c1.cl_to = " .$dbr->addQuotes ($title->getDBKey ()) . "
 264+ FROM categorylinks as c1, categorylinks as c2
 265+ WHERE c1.cl_from = c2.cl_from
 266+ AND c1.cl_to = " .$dbr->addQuotes ($title->getDBKey ()) . "
266267 AND c2.cl_to IN (" ;
267 -
268 - $fixed_names = array () ;
 268+
 269+ $fixed_names = array () ;
269270 foreach ($this->mBaseCategories as $category) {
270271 $fixed_names [] = $dbr->addQuotes ($category) ;
271 - }
 272+ }
272273 $stringed_names = implode (",", $fixed_names) ;
273274 $query .= $stringed_names . ")" ;
274275
275276 $res = $dbr->query ($query, __METHOD__) ;
276277 while( $x = $dbr->fetchObject ( $res ) ) {
277278 if ($this->mBaseArticle != $x->cl_from) {
278 - $result_array [] = $x->cl_from ;
 279+ $result_array [] = $x->cl_from ;
279280 }
280281 }
281282 $dbr->freeResult( $res );
@@ -298,7 +299,7 @@
299300 }
300301 </style>
301302 ") ;
302 - if ($wgUser->isLoggedIn () ) {
 303+ if ($wgUser->isLoggedIn () ) {
303304 $link = "<div class=\"editsimilar_dismiss\">[<span class=\"plainlinks\"><a href=\"" . $wgScript . "?title=Special:Preferences#prefsection-4\" id=\"editsimilar_preferences\">" . wfMsg('editsimilar-link-disable') . "</a></span>]</div><div style=\"display:block\">&nbsp;</div>" ;
304305 } else {
305306 $link = '' ;
@@ -316,7 +317,7 @@
317318 return false ;
318319 } else {
319320 $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue ;
320 - return true ;
 321+ return true ;
321322 }
322323 } else {
323324 $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue ;
@@ -327,10 +328,10 @@
328329
329330 function wfEditSimilarSetup () {
330331 global $wgHooks, $wgMessageCache, $wgUser ;
331 - $wgHooks ['ArticleSaveComplete'][] = 'wfEditSimilarCheck' ;
332 - $wgHooks ['OutputPageBeforeHTML'][] = 'wfEditSimilarViewMesg' ;
 332+ $wgHooks ['ArticleSaveComplete'][] = 'wfEditSimilarCheck' ;
 333+ $wgHooks ['OutputPageBeforeHTML'][] = 'wfEditSimilarViewMesg' ;
333334 if ( $wgUser->isLoggedIn ()) {
334 - $wgHooks ['getEditingPreferencesCustomHtml'][] = 'wfEditSimilarPrefCustomHtml' ;
 335+ $wgHooks ['getEditingPreferencesCustomHtml'][] = 'wfEditSimilarPrefCustomHtml' ;
335336 $wgHooks ['UserToggles'][] = 'wfEditSimilarToggle' ;
336337 }
337338 }
@@ -338,7 +339,7 @@
339340 // check if we had the extension enabled at all and if this is in a content namespace
340341 function wfEditSimilarCheck ($article) {
341342 global $wgOut, $wgUser, $wgContentNamespaces ;
342 -
 343+
343344 $namespace = $article->getTitle()->getNamespace() ;
344345 if ( (1 == $wgUser->getOption ('edit-similar', 1)) && (in_array ($namespace, $wgContentNamespaces)) ) {
345346 $_SESSION ['ES_saved'] = 'yes' ;
@@ -351,12 +352,12 @@
352353 global $wgTitle, $wgUser, $wgEditSimilarAlwaysShowThanks ;
353354 wfLoadExtensionMessages ('EditSimilar') ;
354355 if ( !empty ($_SESSION ['ES_saved']) && (1 == $wgUser->getOption ('edit-similar', 1) ) && $out->isArticle ()) {
355 - if (EditSimilar::checkCounter ()) {
 356+ if (EditSimilar::checkCounter ()) {
356357 $message_text = '' ;
357358 $article_title = $wgTitle->getText() ;
358359 // here we'll populate the similar articles and links
359360 $SInstance = new EditSimilar ($wgTitle->getArticleId(), 'category') ;
360 - $similarities = $SInstance->getSimilarArticles () ;
 361+ $similarities = $SInstance->getSimilarArticles () ;
361362 if (!empty($similarities)) {
362363 if ($SInstance->mSimilarArticles) {
363364 if (count($similarities) > 1) {
@@ -397,9 +398,9 @@
398399 $ttext = $wgLang->getUserToggle ($tname) ;
399400 // the catch lies here
400401 $checked = $wgUser->getOption ($tname, 1) == 1 ? ' checked="checked"' : '';
401 -
 402+
402403 $wgOut->addHTML ("<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked />" .
403 - " <span class='toggletext'><label for=\"$tname\">$ttext</label></span></div>\n") ;
 404+ " <span class='toggletext'><label for=\"$tname\">$ttext</label></span></div>\n") ;
404405 return true ;
405406 }
406407
@@ -408,6 +409,3 @@
409410 $toggles ['edit-similar'] = 'edit-similar' ;
410411 return true ;
411412 }
412 -
413 -}
414 -?>

Status & tagging log