r35873 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35872‎ | r35873 | r35874 >
Date:18:53, 4 June 2008
Author:ashley
Status:old
Tags:
Comment:
EditSimilar:
*standard coding style
*remove some unused globals
*tweak extension credits
*add Finnish i18n
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,36 +1,61 @@
22 <?php
33 /**
4 - * Internationalisation file for extension EditSimilar
 4+ * Internationalisation file for the EditSimilar extension
55 *
6 - * @addtogroup Extensions
 6+ * @ingroup Extensions
77 */
88
99 $messages = array();
1010
 11+/** English
 12+ * @author Bartek Łapiński
 13+ * @author Łukasz 'TOR' Garczewski
 14+ */
1115 $messages['en'] = array(
1216 'editsimilar-thanks' => 'Thank you for your contribution.
13 -Check out these related pages: $1.' ,
 17+Check out these related pages: $1.',
1418 'editsimilar-thanks-singleresult' => 'Thank you for your contribution.
15 -Check out this related page: $1.' ,
 19+Check out this related page: $1.',
1620 'editsimilar-thanks-notsimilar' => 'Thank you for your contribution.
1721 These pages could also use your help: $1.',
1822 'editsimilar-thanks-notsimilar-singleresult' => 'Thank you for your contribution.
1923 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' ,
 24+ 'editsimilar-thankyou' => 'Thank you for your contribution, $1!',
 25+ 'editsimilar-link-disable' => 'set preferences',
 26+ 'tog-edit-similar' => 'Enable similar pages suggestions',
2327 );
2428
 29+/** Finnish (Suomi)
 30+ * @author Jack Phoenix
 31+ */
 32+$messages['fi'] = array(
 33+ 'editsimilar-thanks' => 'Kiitos muokkauksestasi.
 34+Katso nämä aiheeseen liittyvät sivut: $1.',
 35+ 'editsimilar-thanks-singleresult' => 'Kiitos muokkauksestasi.
 36+Katso tämä aiheeseen liittyvä sivu: $1.',
 37+ 'editsimilar-thanks-notsimilar' => 'Kiitos muokkauksestasi.
 38+Nämä sivut voisivat myös kaivata apuasi: $1.',
 39+ 'editsimilar-thanks-notsimilar-singleresult' => 'Kiitos muokkauksestasi.
 40+Tämä sivu voisi myös kaivata apuasi: $1.',
 41+ 'editsimilar-thankyou' => 'Kiitos muokkauksestasi, $1!',
 42+ 'editsimilar-link-disable' => 'aseta asetukset',
 43+ 'tog-edit-similar' => 'Ota käyttöön samanlaisten sivujen ehdotukset',
 44+);
 45+
 46+/** Polish (Polski)
 47+ * @author Bartek Łapiński
 48+ * @author Łukasz 'TOR' Garczewski
 49+ */
2550 $messages['pl'] = array(
2651 'editsimilar-thanks' => 'Dzięki za edycję!
27 -Zerknij też na podobne artykuły: $1.' ,
 52+Zerknij też na podobne artykuły: $1.',
2853 'editsimilar-thanks-singleresult' => 'Dzięki za edycję!
29 -Zerknij też na ten podobny artykuł: $1.' ,
 54+Zerknij też na ten podobny artykuł: $1.',
3055 'editsimilar-thanks-notsimilar' => 'Dzięki za edycję!
3156 Te artykuły również mogą potrzebować twojej pomocy: $1.',
3257 'editsimilar-thanks-notsimilar-singleresult' => 'Dzięki za edycję!
3358 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' ,
 59+ 'editsimilar-thankyou' => 'Dzięki za Twoją edycję, $1!',
 60+ 'editsimilar-link-disable' => 'zmień ustawienia',
 61+ 'tog-edit-similar' => 'Włącz sugestie edycji podobnych artykułów',
3762 );
Index: trunk/extensions/EditSimilar/EditSimilar.php
@@ -7,40 +7,40 @@
88 * @subpackage Extensions
99 *
1010 * @author Bartek Łapiński <bartek@wikia.com>
11 -* @copyright Copyright (C) 2008, Wikia Inc.
 11+* @copyright Copyright © 2008, Wikia Inc.
1212 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1313 */
1414
1515 if (!defined('MEDIAWIKI'))
1616 exit;
1717
18 -global $wgExtensionFunctions, $wgGroupPermissions;
 18+global $wgExtensionFunctions;
1919
2020 $dir = dirname(__FILE__);
21 -$wgExtensionMessagesFiles ['EditSimilar'] = $dir . '/EditSimilar.i18n.php' ;
 21+$wgExtensionMessagesFiles['EditSimilar'] = $dir . '/EditSimilar.i18n.php';
2222
2323 if (empty ($wgEditSimilarMaxResultsPool ) ) {
2424 // maximum number of results to choose from
25 - $wgEditSimilarMaxResultsPool = 50 ;
 25+ $wgEditSimilarMaxResultsPool = 50;
2626 }
2727
2828 if (empty ($wgEditSimilarMaxResultsToDisplay)) {
2929 // maximum number of results to display in text
30 - $wgEditSimilarMaxResultsToDisplay = 3 ;
 30+ $wgEditSimilarMaxResultsToDisplay = 3;
3131 }
3232
3333 if (empty ($wgEditSimilarCounterValue)) {
3434 // show message per specified number of edits
35 - $wgEditSimilarCounterValue = 1 ;
 35+ $wgEditSimilarCounterValue = 1;
3636 }
3737
38 -$wgExtensionFunctions [] = 'wfEditSimilarSetup' ;
 38+$wgExtensionFunctions[] = 'wfEditSimilarSetup';
3939
4040 $wgExtensionCredits['other'][] = array(
4141 'name' => 'EditSimilar',
4242 'version' => '1.16',
43 - 'author' => 'Bartek Łapiński, [http://inside.wikia.com/wiki/User:TOR Łukasz \'TOR\' Garczewski]',
44 - 'url' => 'http://help.wikia.com/wiki/Help:EditSimilar',
 43+ 'author' => array('Bartek Łapiński', '[http://inside.wikia.com/wiki/User:TOR Łukasz \'TOR\' Garczewski]'),
 44+ 'url' => 'http://www.mediawiki.org/wiki/Extension:EditSimilar',
4545 'description' => 'Encourages users to edit an article similar (by categories) to the one they just had edited.',
4646 );
4747
@@ -66,93 +66,93 @@
6767
6868 // base class for this extension
6969 class EditSimilar {
70 - var $mBaseArticle ; // the article from which we hail in our quest for similiarities, this is its title
71 - var $mMarkerType ; // how do we mark articles that need attention? currently, by category only
72 - var $mAttentionMarkers ; // the marker array (for now it contains categories)
73 - var $mMatchType ; // how do we match articles as a secondary
74 - var $mPoolLimit ; // limit up the pool of 'stubs' to choose from
75 - var $mBaseCategories ; // extracted categories that this saved article is in
76 - var $mSimilarArticles ; // to differentiate between really similar results or just needing attention
 70+ var $mBaseArticle; // the article from which we hail in our quest for similiarities, this is its title
 71+ var $mMarkerType; // how do we mark articles that need attention? currently, by category only
 72+ var $mAttentionMarkers; // the marker array (for now it contains categories)
 73+ var $mMatchType; // how do we match articles as a secondary
 74+ var $mPoolLimit; // limit up the pool of 'stubs' to choose from
 75+ var $mBaseCategories; // extracted categories that this saved article is in
 76+ var $mSimilarArticles; // to differentiate between really similar results or just needing attention
7777
7878 // constructor
7979 function __construct ($article, $markertype = 'category') {
80 - global $wgEditSimilarMaxResultsPool ;
81 - $this->mBaseArticle = $article ;
82 - $this->mMarkerType = $markertype ;
83 - $this->mAttentionMarkers = $this->getStubCategories () ;
84 - $this->mPoolLimit = $wgEditSimilarMaxResultsPool ;
85 - $this->mBaseCategories = $this->getBaseCategories () ;
86 - $this->mSimilarArticles = true ;
 80+ global $wgEditSimilarMaxResultsPool;
 81+ $this->mBaseArticle = $article;
 82+ $this->mMarkerType = $markertype;
 83+ $this->mAttentionMarkers = $this->getStubCategories();
 84+ $this->mPoolLimit = $wgEditSimilarMaxResultsPool;
 85+ $this->mBaseCategories = $this->getBaseCategories();
 86+ $this->mSimilarArticles = true;
8787 }
8888
8989 // fetch categories marked as 'stub categories'
9090 function getStubCategories () {
91 - $stub_categories = wfMsgForContent ('EditSimilar-Categories') ;
 91+ $stub_categories = wfMsgForContent('EditSimilar-Categories');
9292 if ( ('&lt;EditSimilar-Categories&gt;' == $stub_categories) || ('' == $stub_categories) || ('-' == $stub_categories) ) {
93 - return false ;
 93+ return false;
9494 } else {
95 - $lines = preg_split ("/\*/", $stub_categories) ;
96 - $normalised_lines = array () ;
97 - array_shift ($lines) ;
 95+ $lines = preg_split ("/\*/", $stub_categories);
 96+ $normalised_lines = array();
 97+ array_shift($lines);
9898 foreach ($lines as $line) {
99 - $normalised_lines [] = str_replace(" ", "_", trim ($line)) ;
 99+ $normalised_lines[] = str_replace(" ", "_", trim ($line));
100100 }
101 - return $normalised_lines ;
 101+ return $normalised_lines;
102102 }
103103 }
104104
105105 // this is the main function that returns articles we deem similar or worth showing
106106 function getSimilarArticles () {
107 - global $wgUser, $wgEditSimilarMarker ;
108 - global $wgEditSimilarMaxResultsToDisplay ;
 107+ global $wgUser, $wgEditSimilarMarker;
 108+ global $wgEditSimilarMaxResultsToDisplay;
109109
110110 if (empty ($this->mAttentionMarkers) || !$this->mAttentionMarkers) {
111 - return false ;
 111+ return false;
112112 }
113 - $text = '' ;
114 - $articles = array () ;
115 - $x = 0 ;
 113+ $text = '';
 114+ $articles = array();
 115+ $x = 0;
116116
117117 while ( (count ($articles) < $wgEditSimilarMaxResultsToDisplay) && ($x < count ($this->mAttentionMarkers)) ) {
118 - $articles = array_merge ($articles, $this->getResults ($this->mAttentionMarkers [$x]) ) ;
 118+ $articles = array_merge ($articles, $this->getResults ($this->mAttentionMarkers [$x]) );
119119 if (!empty ($articles)) {
120 - $articles = array_unique ($articles) ;
 120+ $articles = array_unique($articles);
121121 }
122 - $x++ ;
 122+ $x++;
123123 }
124124
125125 if (empty ($articles) ) {
126 - $articles = $this->getAdditionalCheck () ;
 126+ $articles = $this->getAdditionalCheck();
127127 // second check to make sure we have anything to display
128128 if (empty ($articles) ) {
129129 return false;
130130 }
131 - $articles = array_unique ($articles) ;
132 - $this->mSimilarArticles = false ;
 131+ $articles = array_unique($articles);
 132+ $this->mSimilarArticles = false;
133133 }
134134
135135 if (1 == count ($articles)) { // in this case, array_rand returns a single element, not an array
136 - $rand_articles = array (0) ;
 136+ $rand_articles = array(0);
137137 } else {
138 - $rand_articles = array_rand ($articles, min ($wgEditSimilarMaxResultsToDisplay, count ($articles)) ) ;
 138+ $rand_articles = array_rand ($articles, min ($wgEditSimilarMaxResultsToDisplay, count ($articles)) );
139139 }
140 - $sk = $wgUser->getSkin () ;
141 - $skinname = get_class ($sk) ;
142 - $skinname = strtolower ( substr ($skinname, 4) ) ;
143 - $real_rand_values = array () ;
 140+ $sk = $wgUser->getSkin();
 141+ $skinname = get_class($sk);
 142+ $skinname = strtolower( substr($skinname, 4) );
 143+ $real_rand_values = array();
144144 if (empty ($rand_articles)) {
145 - return false ;
 145+ return false;
146146 }
147147
148 - $translated_titles = array () ;
 148+ $translated_titles = array();
149149 foreach ($rand_articles as $r_key => $rand_article_key) {
150 - $translated_titles [] = $articles [$rand_article_key] ;
 150+ $translated_titles[] = $articles [$rand_article_key];
151151 }
152 - $translated_titles = $this->idsToTitles ($translated_titles) ;
 152+ $translated_titles = $this->idsToTitles($translated_titles);
153153
154154 foreach ($translated_titles as $link_title) {
155 - $article_link = $sk->makeKnownLinkObj ($link_title) ;
156 - $real_rand_values [] = $article_link ;
 155+ $article_link = $sk->makeKnownLinkObj($link_title);
 156+ $real_rand_values[] = $article_link;
157157 }
158158
159159 return $real_rand_values;
@@ -160,32 +160,32 @@
161161
162162 // extract all categories our base article is in
163163 function getBaseCategories () {
164 - global $wgEditSimilarMaxResultsToDisplay ;
 164+ global $wgEditSimilarMaxResultsToDisplay;
165165 if (empty ($this->mAttentionMarkers) || !$this->mAttentionMarkers) {
166 - return false ;
 166+ return false;
167167 }
168168
169 - $dbr = wfGetDB( DB_SLAVE );
170 - $result_array = array () ;
 169+ $dbr = wfGetDB( DB_SLAVE );
 170+ $result_array = array();
171171 $res = $dbr->select (
172 - array ('categorylinks') ,
173 - array ('cl_to') ,
174 - array ( 'cl_from' => $this->mBaseArticle ) ,
175 - __METHOD__ ,
176 - array ( 'ORDER_BY' => 'cl_from' ,
 172+ array ('categorylinks'),
 173+ array ('cl_to'),
 174+ array ( 'cl_from' => $this->mBaseArticle ),
 175+ __METHOD__,
 176+ array ( 'ORDER_BY' => 'cl_from',
177177 'USE_INDEX' => 'cl_from'
178178 )
179179 ) ;
180 - while( $x = $dbr->fetchObject ( $res ) ) {
181 - if (!in_array ($x->cl_to, $this->mAttentionMarkers) ) {
182 - $result_array [] = $x->cl_to ;
 180+ while( $x = $dbr->fetchObject ( $res ) ) {
 181+ if (!in_array ($x->cl_to, $this->mAttentionMarkers) ) {
 182+ $result_array [] = $x->cl_to;
 183+ }
183184 }
184 - }
185185
186186 if (!empty ($result_array) ) {
187 - return $result_array ;
 187+ return $result_array;
188188 } else {
189 - return false ;
 189+ return false;
190190 }
191191 }
192192
@@ -198,94 +198,94 @@
199199 some results
200200 */
201201 function getAdditionalCheck () {
202 - $dbr = wfGetDB( DB_SLAVE );
 202+ $dbr = wfGetDB( DB_SLAVE );
203203
204204 $query = "SELECT cl_from
205205 FROM categorylinks
206 - WHERE cl_to IN (" ;
 206+ WHERE cl_to IN (";
207207
208 - $fixed_names = array () ;
 208+ $fixed_names = array();
209209 foreach ($this->mAttentionMarkers as $category) {
210 - $fixed_names [] = $dbr->addQuotes ($category) ;
 210+ $fixed_names[] = $dbr->addQuotes($category);
211211 }
212 - $stringed_names = implode (",", $fixed_names) ;
213 - $query .= $stringed_names . ")" ;
 212+ $stringed_names = implode (",", $fixed_names);
 213+ $query .= $stringed_names . ")";
214214
215 - $res = $dbr->query ($query, __METHOD__) ;
216 - $result_array = array () ;
217 - while( $x = $dbr->fetchObject ( $res ) ) {
218 - if ($this->mBaseArticle != $x->cl_from) {
219 - $result_array [] = $x->cl_from ;
220 - }
221 - }
222 - $dbr->freeResult( $res );
 215+ $res = $dbr->query($query, __METHOD__);
 216+ $result_array = array();
 217+ while( $x = $dbr->fetchObject ( $res ) ) {
 218+ if ($this->mBaseArticle != $x->cl_from) {
 219+ $result_array[] = $x->cl_from;
 220+ }
 221+ }
 222+ $dbr->freeResult( $res );
223223
224 - return $result_array ;
 224+ return $result_array;
225225
226226 }
227227
228228 // one function to turn result ids into titles in one query rather than multiple ones
229229 function idsToTitles ($id_array) {
230 - global $wgContentNamespaces ;
 230+ global $wgContentNamespaces;
231231 $dbr = wfGetDB( DB_SLAVE );
232232 $query = "SELECT page_namespace, page_title
233233 FROM page
234 - WHERE page_id IN (" ;
 234+ WHERE page_id IN (";
235235
236 - $stringed_names = implode (",", $id_array) ;
237 - $query .= $stringed_names . ")" ;
 236+ $stringed_names = implode (",", $id_array);
 237+ $query .= $stringed_names . ")";
238238
239 - $res = $dbr->query ($query, __METHOD__) ;
240 - $result_array = array () ;
 239+ $res = $dbr->query ($query, __METHOD__);
 240+ $result_array = array();
241241
242242 // so for now, to speed things up, just discard results from other namespaces (and subpages)
243243 while( ($x = $dbr->fetchObject ( $res ))
244244 && (in_array ($x->page_namespace, $wgContentNamespaces))
245245 && false === strpos ($x->page_title, "/") ) {
246 - $result_array [] = Title::makeTitle ($x->page_namespace, $x->page_title ) ;
 246+ $result_array[] = Title::makeTitle($x->page_namespace, $x->page_title);
247247 }
248248
249249 $dbr->freeResult( $res );
250 - return $result_array ;
 250+ return $result_array;
251251 }
252252
253253 // get categories from the 'stub' or 'attention needed' category
254254 function getResults ($marker_category) {
255255 $dbr = wfGetDB( DB_SLAVE );
256 - $title = Title::makeTitle (NS_CATEGORY, $marker_category );
257 - $result_array = array () ;
 256+ $title = Title::makeTitle(NS_CATEGORY, $marker_category);
 257+ $result_array = array();
258258
259259 if (empty ($this->mBaseCategories)) {
260 - return $result_array ;
 260+ return $result_array;
261261 }
262262
263263 $query = "SELECT c1.cl_from
264264 FROM categorylinks as c1, categorylinks as c2
265265 WHERE c1.cl_from = c2.cl_from
266266 AND c1.cl_to = " .$dbr->addQuotes ($title->getDBKey ()) . "
267 - AND c2.cl_to IN (" ;
 267+ AND c2.cl_to IN (";
268268
269 - $fixed_names = array () ;
 269+ $fixed_names = array();
270270 foreach ($this->mBaseCategories as $category) {
271 - $fixed_names [] = $dbr->addQuotes ($category) ;
 271+ $fixed_names[] = $dbr->addQuotes($category);
272272 }
273 - $stringed_names = implode (",", $fixed_names) ;
274 - $query .= $stringed_names . ")" ;
 273+ $stringed_names = implode (",", $fixed_names);
 274+ $query .= $stringed_names . ")";
275275
276 - $res = $dbr->query ($query, __METHOD__) ;
 276+ $res = $dbr->query ($query, __METHOD__);
277277 while( $x = $dbr->fetchObject ( $res ) ) {
278278 if ($this->mBaseArticle != $x->cl_from) {
279 - $result_array [] = $x->cl_from ;
 279+ $result_array[] = $x->cl_from;
280280 }
281281 }
282282 $dbr->freeResult( $res );
283283
284 - return $result_array ;
 284+ return $result_array;
285285 }
286286
287287 // message box wrapper
288288 static public function showMessage ($text) {
289 - global $wgOut, $wgUser, $wgScript ;
 289+ global $wgOut, $wgUser, $wgScript;
290290 $wgOut->addHTML ("
291291 <style type=\"text/css\">
292292 .editsimilar {
@@ -300,112 +300,112 @@
301301 </style>
302302 ") ;
303303 if ($wgUser->isLoggedIn () ) {
304 - $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>" ;
 304+ $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>";
305305 } else {
306 - $link = '' ;
 306+ $link = '';
307307 }
308 - $wgOut->addHTML ("<div id=\"editsimilar_links\" class=\"usermessage editsimilar\"><div>" . $text . "</div>" . $link . "</div>") ;
 308+ $wgOut->addHTML ("<div id=\"editsimilar_links\" class=\"usermessage editsimilar\"><div>" . $text . "</div>" . $link . "</div>");
309309 }
310310
311311
312312 // this is for determining whether to display the message or not
313313 static public function checkCounter () {
314 - global $wgEditSimilarCounterValue ;
 314+ global $wgEditSimilarCounterValue;
315315 if (isset ($_SESSION ['ES_counter'])) {
316 - $_SESSION ['ES_counter'] -- ;
 316+ $_SESSION ['ES_counter'] --;
317317 if ($_SESSION ['ES_counter'] > 0) {
318 - return false ;
 318+ return false;
319319 } else {
320 - $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue ;
321 - return true ;
 320+ $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue;
 321+ return true;
322322 }
323323 } else {
324 - $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue ;
325 - return true ;
 324+ $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue;
 325+ return true;
326326 }
327327 }
328328 }
329329
330330 function wfEditSimilarSetup () {
331 - global $wgHooks, $wgMessageCache, $wgUser ;
332 - $wgHooks ['ArticleSaveComplete'][] = 'wfEditSimilarCheck' ;
333 - $wgHooks ['OutputPageBeforeHTML'][] = 'wfEditSimilarViewMesg' ;
 331+ global $wgHooks, $wgUser;
 332+ $wgHooks['ArticleSaveComplete'][] = 'wfEditSimilarCheck';
 333+ $wgHooks['OutputPageBeforeHTML'][] = 'wfEditSimilarViewMesg';
334334 if ( $wgUser->isLoggedIn ()) {
335 - $wgHooks ['getEditingPreferencesCustomHtml'][] = 'wfEditSimilarPrefCustomHtml' ;
336 - $wgHooks ['UserToggles'][] = 'wfEditSimilarToggle' ;
 335+ $wgHooks['getEditingPreferencesCustomHtml'][] = 'wfEditSimilarPrefCustomHtml';
 336+ $wgHooks['UserToggles'][] = 'wfEditSimilarToggle';
337337 }
338338 }
339339
340340 // check if we had the extension enabled at all and if this is in a content namespace
341341 function wfEditSimilarCheck ($article) {
342 - global $wgOut, $wgUser, $wgContentNamespaces ;
 342+ global $wgOut, $wgUser, $wgContentNamespaces;
343343
344 - $namespace = $article->getTitle()->getNamespace() ;
345 - if ( (1 == $wgUser->getOption ('edit-similar', 1)) && (in_array ($namespace, $wgContentNamespaces)) ) {
346 - $_SESSION ['ES_saved'] = 'yes' ;
 344+ $namespace = $article->getTitle()->getNamespace();
 345+ if ( (1 == $wgUser->getOption('edit-similar', 1)) && (in_array ($namespace, $wgContentNamespaces)) ) {
 346+ $_SESSION ['ES_saved'] = 'yes';
347347 }
348 - return true ;
 348+ return true;
349349 }
350350
351351 //view message depending on settings and the relevancy of the results
352352 function wfEditSimilarViewMesg (&$out) {
353 - global $wgTitle, $wgUser, $wgEditSimilarAlwaysShowThanks ;
354 - wfLoadExtensionMessages ('EditSimilar') ;
 353+ global $wgTitle, $wgUser, $wgEditSimilarAlwaysShowThanks;
 354+ wfLoadExtensionMessages('EditSimilar');
355355 if ( !empty ($_SESSION ['ES_saved']) && (1 == $wgUser->getOption ('edit-similar', 1) ) && $out->isArticle ()) {
356356 if (EditSimilar::checkCounter ()) {
357 - $message_text = '' ;
358 - $article_title = $wgTitle->getText() ;
 357+ $message_text = '';
 358+ $article_title = $wgTitle->getText();
359359 // here we'll populate the similar articles and links
360 - $SInstance = new EditSimilar ($wgTitle->getArticleId(), 'category') ;
361 - $similarities = $SInstance->getSimilarArticles () ;
 360+ $SInstance = new EditSimilar ($wgTitle->getArticleId(), 'category');
 361+ $similarities = $SInstance->getSimilarArticles();
362362 if (!empty($similarities)) {
363363 if ($SInstance->mSimilarArticles) {
364364 if (count($similarities) > 1) {
365 - $message_text = wfMsg ('editsimilar-thanks', implode (", ", $similarities));
 365+ $message_text = wfMsg('editsimilar-thanks', implode (", ", $similarities));
366366 } else {
367 - $message_text = wfMsg ('editsimilar-thanks-singleresult', implode (", ", $similarities));
 367+ $message_text = wfMsg('editsimilar-thanks-singleresult', implode (", ", $similarities));
368368 }
369369 } else { // the articles we found were rather just articles needing attention
370370 if (count($similarities) > 1) {
371 - $message_text = wfMsg ('editsimilar-thanks-notsimilar', implode (", ", $similarities));
 371+ $message_text = wfMsg('editsimilar-thanks-notsimilar', implode (", ", $similarities));
372372 } else {
373 - $message_text = wfMsg ('editsimilar-thanks-notsimilar-singleresult', implode (", ", $similarities));
 373+ $message_text = wfMsg('editsimilar-thanks-notsimilar-singleresult', implode (", ", $similarities));
374374 }
375375 }
376376 } else {
377377 if ($wgUser->isLoggedIn () && !empty ($wgEditSimilarAlwaysShowThanks)) {
378 - $message_text = wfMsg ('editsimilar-thankyou', $wgUser->getName ()) ;
 378+ $message_text = wfMsg ('editsimilar-thankyou', $wgUser->getName ());
379379 }
380380 }
381381
382382 if ('' != $message_text) {
383 - EditSimilar::showMessage ($message_text, $article_title) ;
 383+ EditSimilar::showMessage($message_text, $article_title);
384384 }
385385 }
386386 //display that only once
387 - $_SESSION ['ES_saved'] = '' ;
 387+ $_SESSION ['ES_saved'] = '';
388388 }
389 - return true ;
 389+ return true;
390390 }
391391
392392 // a customized version of getToggle from SpecialPreferences
393393 // this one uses getOption with a default - so we can have it checked if unset
394394 function wfEditSimilarPrefCustomHtml ($prefsForm) {
395 - wfLoadExtensionMessages ('EditSimilar') ;
396 - global $wgOut, $wgUser, $wgLang ;
397 - $tname = 'edit-similar' ;
398 - $prefsForm->mUsedToggles [$tname] = true ;
399 - $ttext = $wgLang->getUserToggle ($tname) ;
 395+ wfLoadExtensionMessages('EditSimilar');
 396+ global $wgOut, $wgUser, $wgLang;
 397+ $tname = 'edit-similar';
 398+ $prefsForm->mUsedToggles [$tname] = true;
 399+ $ttext = $wgLang->getUserToggle($tname);
400400 // the catch lies here
401 - $checked = $wgUser->getOption ($tname, 1) == 1 ? ' checked="checked"' : '';
 401+ $checked = $wgUser->getOption($tname, 1) == 1 ? ' checked="checked"' : '';
402402
403403 $wgOut->addHTML ("<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked />" .
404 - " <span class='toggletext'><label for=\"$tname\">$ttext</label></span></div>\n") ;
405 - return true ;
 404+ " <span class='toggletext'><label for=\"$tname\">$ttext</label></span></div>\n");
 405+ return true;
406406 }
407407
408408 function wfEditSimilarToggle ($toggles) {
409 - wfLoadExtensionMessages ('EditSimilar') ;
410 - $toggles ['edit-similar'] = 'edit-similar' ;
411 - return true ;
412 -}
 409+ wfLoadExtensionMessages('EditSimilar');
 410+ $toggles['edit-similar'] = 'edit-similar';
 411+ return true;
 412+}
\ No newline at end of file

Status & tagging log