r46937 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46936‎ | r46937 | r46938 >
Date:20:55, 6 February 2009
Author:ashley
Status:deferred
Tags:
Comment:
EditSimilar: code cleanup
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
@@ -2,6 +2,7 @@
33 /**
44 * Internationalisation file for the EditSimilar extension
55 *
 6+ * @file
67 * @ingroup Extensions
78 */
89
@@ -12,18 +13,18 @@
1314 * @author Łukasz 'TOR' Garczewski
1415 */
1516 $messages['en'] = array(
16 - 'editsimilar-desc' => 'Encourages users to edit a similar page after saving a page',
17 - 'editsimilar-thanks' => 'Thank you for your contribution.
 17+ 'editsimilar-desc' => 'Encourages users to edit a similar page after saving a page',
 18+ 'editsimilar-thanks' => 'Thank you for your contribution.
1819 Check out these related pages: $1.',
19 - 'editsimilar-thanks-singleresult' => 'Thank you for your contribution.
 20+ 'editsimilar-thanks-singleresult' => 'Thank you for your contribution.
2021 Check out this related page: $1.',
21 - 'editsimilar-thanks-notsimilar' => 'Thank you for your contribution.
 22+ 'editsimilar-thanks-notsimilar' => 'Thank you for your contribution.
2223 These pages could also use your help: $1.',
2324 'editsimilar-thanks-notsimilar-singleresult' => 'Thank you for your contribution.
2425 This page could also use your help: $1.',
25 - 'editsimilar-thankyou' => 'Thank you for your contribution, $1!',
26 - 'editsimilar-link-disable' => 'set preferences',
27 - 'tog-edit-similar' => 'Enable similar pages suggestions',
 26+ 'editsimilar-thankyou' => 'Thank you for your contribution, $1!',
 27+ 'editsimilar-link-disable' => 'set preferences',
 28+ 'tog-edit-similar' => 'Enable similar pages suggestions',
2829 );
2930
3031 /** Message documentation (Message documentation)
Index: trunk/extensions/EditSimilar/EditSimilar.php
@@ -1,48 +1,40 @@
22 <?php
3 -
43 /**
5 -* Extension that suggest editing of similar articles upon saving an article
6 -*
7 -* @package MediaWiki
8 -* @subpackage Extensions
9 -*
10 -* @author Bartek Łapiński <bartek@wikia.com>
11 -* @copyright Copyright © 2008, Wikia Inc.
12 -* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
13 -*/
 4+ * Extension that suggests editing of similar articles upon saving an article
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ * @author Bartek Łapiński <bartek@wikia-inc.com>
 9+ * @copyright Copyright © 2008, Wikia Inc.
 10+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 11+ */
1412
15 -if (!defined('MEDIAWIKI'))
16 - exit;
 13+if( !defined( 'MEDIAWIKI' ) )
 14+ die( "This is not a valid entry point.\n" );
1715
1816 global $wgExtensionFunctions;
1917
2018 $dir = dirname(__FILE__);
2119 $wgExtensionMessagesFiles['EditSimilar'] = $dir . '/EditSimilar.i18n.php';
2220
23 -if (empty ($wgEditSimilarMaxResultsPool ) ) {
24 - // maximum number of results to choose from
25 - $wgEditSimilarMaxResultsPool = 50;
26 -}
 21+// maximum number of results to choose from
 22+$wgEditSimilarMaxResultsPool = 50;
2723
28 -if (empty ($wgEditSimilarMaxResultsToDisplay)) {
29 - // maximum number of results to display in text
30 - $wgEditSimilarMaxResultsToDisplay = 3;
31 -}
 24+// maximum number of results to display in text
 25+$wgEditSimilarMaxResultsToDisplay = 3;
3226
33 -if (empty ($wgEditSimilarCounterValue)) {
34 - // show message per specified number of edits
35 - $wgEditSimilarCounterValue = 1;
36 -}
 27+// show message per specified number of edits
 28+$wgEditSimilarCounterValue = 1;
3729
3830 $wgExtensionFunctions[] = 'wfEditSimilarSetup';
3931
4032 $wgExtensionCredits['other'][] = array(
41 - 'name' => 'EditSimilar',
42 - 'version' => '1.17',
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',
45 - 'description' => 'Encourages users to edit an article similar (by categories) to the one they just had edited.',
46 - 'descriptionmsg' => 'editsimilar-desc',
 33+ 'name' => 'EditSimilar',
 34+ 'version' => '1.17',
 35+ 'author' => array( 'Bartek Łapiński', "Łukasz 'TOR' Garczewski" ),
 36+ 'url' => 'http://www.mediawiki.org/wiki/Extension:EditSimilar',
 37+ 'description' => 'Encourages users to edit an article similar (by categories) to the one they just had edited.',
 38+ 'descriptionmsg' => 'editsimilar-desc',
4739 );
4840
4941 /*
@@ -76,7 +68,7 @@
7769 var $mSimilarArticles; // to differentiate between really similar results or just needing attention
7870
7971 // constructor
80 - function __construct ($article, $markertype = 'category') {
 72+ function __construct( $article, $markertype = 'category' ) {
8173 global $wgEditSimilarMaxResultsPool;
8274 $this->mBaseArticle = $article;
8375 $this->mMarkerType = $markertype;
@@ -87,72 +79,71 @@
8880 }
8981
9082 // fetch categories marked as 'stub categories'
91 - function getStubCategories () {
92 - $stub_categories = wfMsgForContent('EditSimilar-Categories');
 83+ function getStubCategories() {
 84+ $stub_categories = wfMsgForContent( 'EditSimilar-Categories' );
9385 if ( ('&lt;EditSimilar-Categories&gt;' == $stub_categories) || ('' == $stub_categories) || ('-' == $stub_categories) ) {
9486 return false;
9587 } else {
96 - $lines = preg_split ("/\*/", $stub_categories);
 88+ $lines = preg_split( "/\*/", $stub_categories );
9789 $normalised_lines = array();
98 - array_shift($lines);
99 - foreach ($lines as $line) {
100 - $normalised_lines[] = str_replace(" ", "_", trim ($line));
 90+ array_shift( $lines );
 91+ foreach( $lines as $line ) {
 92+ $normalised_lines[] = str_replace( ' ', '_', trim( $line ) );
10193 }
10294 return $normalised_lines;
10395 }
10496 }
10597
10698 // this is the main function that returns articles we deem similar or worth showing
107 - function getSimilarArticles () {
108 - global $wgUser, $wgEditSimilarMarker;
109 - global $wgEditSimilarMaxResultsToDisplay;
 99+ function getSimilarArticles() {
 100+ global $wgUser, $wgEditSimilarMaxResultsToDisplay;
110101
111 - if (empty ($this->mAttentionMarkers) || !$this->mAttentionMarkers) {
 102+ if( empty( $this->mAttentionMarkers ) || !$this->mAttentionMarkers ) {
112103 return false;
113104 }
114105 $text = '';
115106 $articles = array();
116107 $x = 0;
117108
118 - while ( (count ($articles) < $wgEditSimilarMaxResultsToDisplay) && ($x < count ($this->mAttentionMarkers)) ) {
119 - $articles = array_merge ($articles, $this->getResults ($this->mAttentionMarkers [$x]) );
120 - if (!empty ($articles)) {
121 - $articles = array_unique($articles);
 109+ while ( ( count( $articles ) < $wgEditSimilarMaxResultsToDisplay ) && ( $x < count( $this->mAttentionMarkers ) ) ) {
 110+ $articles = array_merge( $articles, $this->getResults( $this->mAttentionMarkers[$x] ) );
 111+ if( !empty( $articles ) ) {
 112+ $articles = array_unique( $articles );
122113 }
123114 $x++;
124115 }
125116
126 - if (empty ($articles) ) {
 117+ if( empty( $articles ) ) {
127118 $articles = $this->getAdditionalCheck();
128119 // second check to make sure we have anything to display
129 - if (empty ($articles) ) {
 120+ if( empty( $articles ) ) {
130121 return false;
131122 }
132 - $articles = array_unique($articles);
 123+ $articles = array_unique( $articles );
133124 $this->mSimilarArticles = false;
134125 }
135126
136 - if (1 == count ($articles)) { // in this case, array_rand returns a single element, not an array
137 - $rand_articles = array(0);
 127+ if( 1 == count( $articles ) ) { // in this case, array_rand returns a single element, not an array
 128+ $rand_articles = array( 0 );
138129 } else {
139 - $rand_articles = array_rand ($articles, min ($wgEditSimilarMaxResultsToDisplay, count ($articles)) );
 130+ $rand_articles = array_rand( $articles, min( $wgEditSimilarMaxResultsToDisplay, count( $articles ) ) );
140131 }
141132 $sk = $wgUser->getSkin();
142 - $skinname = get_class($sk);
143 - $skinname = strtolower( substr($skinname, 4) );
 133+ $skinname = get_class( $sk );
 134+ $skinname = strtolower( substr( $skinname, 4 ) );
144135 $real_rand_values = array();
145 - if (empty ($rand_articles)) {
 136+ if( empty( $rand_articles ) ) {
146137 return false;
147138 }
148139
149140 $translated_titles = array();
150 - foreach ($rand_articles as $r_key => $rand_article_key) {
 141+ foreach( $rand_articles as $r_key => $rand_article_key ) {
151142 $translated_titles[] = $articles [$rand_article_key];
152143 }
153 - $translated_titles = $this->idsToTitles($translated_titles);
 144+ $translated_titles = $this->idsToTitles( $translated_titles );
154145
155 - foreach ($translated_titles as $link_title) {
156 - $article_link = $sk->makeKnownLinkObj($link_title);
 146+ foreach( $translated_titles as $link_title ) {
 147+ $article_link = $sk->makeKnownLinkObj( $link_title );
157148 $real_rand_values[] = $article_link;
158149 }
159150
@@ -160,30 +151,31 @@
161152 }
162153
163154 // extract all categories our base article is in
164 - function getBaseCategories () {
 155+ function getBaseCategories() {
165156 global $wgEditSimilarMaxResultsToDisplay;
166 - if (empty ($this->mAttentionMarkers) || !$this->mAttentionMarkers) {
 157+ if( empty( $this->mAttentionMarkers ) || !$this->mAttentionMarkers ) {
167158 return false;
168159 }
169160
170161 $dbr = wfGetDB( DB_SLAVE );
171162 $result_array = array();
172 - $res = $dbr->select (
173 - array ('categorylinks'),
174 - array ('cl_to'),
175 - array ( 'cl_from' => $this->mBaseArticle ),
 163+ $res = $dbr->select(
 164+ array( 'categorylinks' ),
 165+ array( 'cl_to' ),
 166+ array( 'cl_from' => $this->mBaseArticle ),
176167 __METHOD__,
177 - array ( 'ORDER_BY' => 'cl_from',
 168+ array(
 169+ 'ORDER_BY' => 'cl_from',
178170 'USE_INDEX' => 'cl_from'
179171 )
180 - ) ;
181 - while( $x = $dbr->fetchObject ( $res ) ) {
182 - if (!in_array ($x->cl_to, $this->mAttentionMarkers) ) {
183 - $result_array [] = $x->cl_to;
184 - }
 172+ );
 173+ while( $x = $dbr->fetchObject( $res ) ) {
 174+ if( !in_array( $x->cl_to, $this->mAttentionMarkers ) ) {
 175+ $result_array [] = $x->cl_to;
185176 }
 177+ }
186178
187 - if (!empty ($result_array) ) {
 179+ if( !empty( $result_array ) ) {
188180 return $result_array;
189181 } else {
190182 return false;
@@ -198,96 +190,96 @@
199191 this is to ensure we can get always (well, almost - if "marker" categories get no results, it's dead in the water anyway)
200192 some results
201193 */
202 - function getAdditionalCheck () {
 194+ function getAdditionalCheck() {
203195 $dbr = wfGetDB( DB_SLAVE );
204196
205 - $query = "SELECT cl_from
206 - FROM categorylinks
207 - WHERE cl_to IN (";
208 -
209197 $fixed_names = array();
210 - foreach ($this->mAttentionMarkers as $category) {
211 - $fixed_names[] = $dbr->addQuotes($category);
 198+ foreach( $this->mAttentionMarkers as $category ) {
 199+ $fixed_names[] = $dbr->addQuotes( $category );
212200 }
213 - $stringed_names = implode (",", $fixed_names);
214 - $query .= $stringed_names . ")";
 201+ $stringed_names = implode( ",", $fixed_names );
215202
216 - $res = $dbr->query($query, __METHOD__);
 203+ $res = $dbr->select(
 204+ 'categorylinks',
 205+ array( 'cl_from' ),
 206+ array( "cl_to IN ($stringed_names)" ),
 207+ __METHOD__
 208+ );
 209+
217210 $result_array = array();
218 - while( $x = $dbr->fetchObject ( $res ) ) {
219 - if ($this->mBaseArticle != $x->cl_from) {
220 - $result_array[] = $x->cl_from;
221 - }
222 - }
223 - $dbr->freeResult( $res );
 211+ while( $x = $dbr->fetchObject( $res ) ) {
 212+ if( $this->mBaseArticle != $x->cl_from ) {
 213+ $result_array[] = $x->cl_from;
 214+ }
 215+ }
 216+ $dbr->freeResult( $res );
224217
225218 return $result_array;
226 -
227219 }
228220
229221 // one function to turn result ids into titles in one query rather than multiple ones
230 - function idsToTitles ($id_array) {
 222+ function idsToTitles( $id_array ) {
231223 global $wgContentNamespaces;
232 - $dbr = wfGetDB( DB_SLAVE );
233 - $query = "SELECT page_namespace, page_title
234 - FROM page
235 - WHERE page_id IN (";
 224+ $dbr = wfGetDB( DB_SLAVE );
 225+ $stringed_names = implode( ",", $id_array );
 226+ $res = $dbr->select(
 227+ 'page',
 228+ array( 'page_namespace', 'page_title' ),
 229+ array( "page_id IN ($stringed_names)" ),
 230+ __METHOD__
 231+ );
236232
237 - $stringed_names = implode (",", $id_array);
238 - $query .= $stringed_names . ")";
 233+ $result_array = array();
239234
240 - $res = $dbr->query ($query, __METHOD__);
241 - $result_array = array();
242 -
243235 // so for now, to speed things up, just discard results from other namespaces (and subpages)
244 - while( ($x = $dbr->fetchObject ( $res ))
245 - && (in_array ($x->page_namespace, $wgContentNamespaces))
246 - && false === strpos ($x->page_title, "/") ) {
247 - $result_array[] = Title::makeTitle($x->page_namespace, $x->page_title);
248 - }
 236+ while( ( $x = $dbr->fetchObject( $res ) )
 237+ && ( in_array( $x->page_namespace, $wgContentNamespaces ) )
 238+ && false === strpos( $x->page_title, "/" ) ) {
 239+ $result_array[] = Title::makeTitle( $x->page_namespace, $x->page_title );
 240+ }
249241
250 - $dbr->freeResult( $res );
251 - return $result_array;
 242+ $dbr->freeResult( $res );
 243+ return $result_array;
252244 }
253245
254246 // get categories from the 'stub' or 'attention needed' category
255 - function getResults ($marker_category) {
256 - $dbr = wfGetDB( DB_SLAVE );
257 - $title = Title::makeTitle(NS_CATEGORY, $marker_category);
 247+ function getResults( $marker_category ) {
 248+ $dbr = wfGetDB( DB_SLAVE );
 249+ $title = Title::makeTitle( NS_CATEGORY, $marker_category );
258250 $result_array = array();
259251
260 - if (empty ($this->mBaseCategories)) {
 252+ if( empty( $this->mBaseCategories ) ) {
261253 return $result_array;
262254 }
263255
264256 $query = "SELECT c1.cl_from
265 - FROM categorylinks as c1, categorylinks as c2
266 - WHERE c1.cl_from = c2.cl_from
267 - AND c1.cl_to = " .$dbr->addQuotes ($title->getDBKey ()) . "
 257+ FROM {$dbr->tableName( 'categorylinks' )} AS c1, {$dbr->tableName( 'categorylinks' )} AS c2
 258+ WHERE c1.cl_from = c2.cl_from
 259+ AND c1.cl_to = " .$dbr->addQuotes( $title->getDBkey() ) . "
268260 AND c2.cl_to IN (";
269261
270262 $fixed_names = array();
271 - foreach ($this->mBaseCategories as $category) {
272 - $fixed_names[] = $dbr->addQuotes($category);
 263+ foreach( $this->mBaseCategories as $category ) {
 264+ $fixed_names[] = $dbr->addQuotes( $category );
273265 }
274 - $stringed_names = implode (",", $fixed_names);
 266+ $stringed_names = implode( ",", $fixed_names );
275267 $query .= $stringed_names . ")";
276268
277 - $res = $dbr->query ($query, __METHOD__);
278 - while( $x = $dbr->fetchObject ( $res ) ) {
279 - if ($this->mBaseArticle != $x->cl_from) {
 269+ $res = $dbr->query( $query, __METHOD__ );
 270+ while( $x = $dbr->fetchObject( $res ) ) {
 271+ if( $this->mBaseArticle != $x->cl_from ) {
280272 $result_array[] = $x->cl_from;
281273 }
282 - }
283 - $dbr->freeResult( $res );
 274+ }
 275+ $dbr->freeResult( $res );
284276
285277 return $result_array;
286278 }
287279
288280 // message box wrapper
289 - static public function showMessage ($text) {
 281+ static public function showMessage( $text ) {
290282 global $wgOut, $wgUser, $wgScript;
291 - $wgOut->addHTML ("
 283+ $wgOut->addHTML( "
292284 <style type=\"text/css\">
293285 .editsimilar {
294286 background-color: #c0fec0;
@@ -299,114 +291,113 @@
300292 font-size:0.9em;
301293 }
302294 </style>
303 - ") ;
304 - if ($wgUser->isLoggedIn () ) {
305 - $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>";
 295+ ");
 296+ if( $wgUser->isLoggedIn() ) {
 297+ $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>';
306298 } else {
307299 $link = '';
308300 }
309 - $wgOut->addHTML ("<div id=\"editsimilar_links\" class=\"usermessage editsimilar\"><div>" . $text . "</div>" . $link . "</div>");
 301+ $wgOut->addHTML( '<div id="editsimilar_links" class="usermessage editsimilar"><div>' . $text . '</div>' . $link . '</div>' );
310302 }
311303
312 -
313304 // this is for determining whether to display the message or not
314 - static public function checkCounter () {
 305+ static public function checkCounter() {
315306 global $wgEditSimilarCounterValue;
316 - if (isset ($_SESSION ['ES_counter'])) {
317 - $_SESSION ['ES_counter'] --;
318 - if ($_SESSION ['ES_counter'] > 0) {
 307+ if( isset( $_SESSION['ES_counter'] ) ) {
 308+ $_SESSION['ES_counter']--;
 309+ if( $_SESSION['ES_counter'] > 0 ) {
319310 return false;
320311 } else {
321 - $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue;
 312+ $_SESSION['ES_counter'] = $wgEditSimilarCounterValue;
322313 return true;
323314 }
324315 } else {
325 - $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue;
 316+ $_SESSION['ES_counter'] = $wgEditSimilarCounterValue;
326317 return true;
327318 }
328319 }
329320 }
330321
331 -function wfEditSimilarSetup () {
 322+function wfEditSimilarSetup() {
332323 global $wgHooks, $wgUser;
333324 $wgHooks['ArticleSaveComplete'][] = 'wfEditSimilarCheck';
334325 $wgHooks['OutputPageBeforeHTML'][] = 'wfEditSimilarViewMesg';
335 - if ( $wgUser->isLoggedIn ()) {
 326+ if ( $wgUser->isLoggedIn() ) {
336327 $wgHooks['getEditingPreferencesCustomHtml'][] = 'wfEditSimilarPrefCustomHtml';
337328 $wgHooks['UserToggles'][] = 'wfEditSimilarToggle';
338329 }
339330 }
340331
341332 // check if we had the extension enabled at all and if this is in a content namespace
342 -function wfEditSimilarCheck ($article) {
 333+function wfEditSimilarCheck( $article ) {
343334 global $wgOut, $wgUser, $wgContentNamespaces;
344335
345336 $namespace = $article->getTitle()->getNamespace();
346 - if ( (1 == $wgUser->getOption('edit-similar', 1)) && (in_array ($namespace, $wgContentNamespaces)) ) {
 337+ if ( ( 1 == $wgUser->getOption( 'edit-similar', 1 ) ) && ( in_array( $namespace, $wgContentNamespaces ) ) ) {
347338 $_SESSION ['ES_saved'] = 'yes';
348339 }
349340 return true;
350341 }
351342
352343 //view message depending on settings and the relevancy of the results
353 -function wfEditSimilarViewMesg (&$out) {
 344+function wfEditSimilarViewMesg( &$out ) {
354345 global $wgTitle, $wgUser, $wgEditSimilarAlwaysShowThanks;
355 - wfLoadExtensionMessages('EditSimilar');
356 - if ( !empty ($_SESSION ['ES_saved']) && (1 == $wgUser->getOption ('edit-similar', 1) ) && $out->isArticle ()) {
357 - if (EditSimilar::checkCounter ()) {
 346+ wfLoadExtensionMessages( 'EditSimilar' );
 347+ if ( !empty( $_SESSION['ES_saved'] ) && ( 1 == $wgUser->getOption( 'edit-similar', 1 ) ) && $out->isArticle() ) {
 348+ if( EditSimilar::checkCounter() ) {
358349 $message_text = '';
359350 $article_title = $wgTitle->getText();
360351 // here we'll populate the similar articles and links
361 - $SInstance = new EditSimilar ($wgTitle->getArticleId(), 'category');
 352+ $SInstance = new EditSimilar( $wgTitle->getArticleId(), 'category' );
362353 $similarities = $SInstance->getSimilarArticles();
363 - if (!empty($similarities)) {
364 - if ($SInstance->mSimilarArticles) {
365 - if (count($similarities) > 1) {
366 - $message_text = wfMsg('editsimilar-thanks', implode (", ", $similarities));
 354+ if( !empty( $similarities ) ) {
 355+ if( $SInstance->mSimilarArticles ) {
 356+ if( count( $similarities ) > 1 ) {
 357+ $message_text = wfMsg( 'editsimilar-thanks', implode( ", ", $similarities ) );
367358 } else {
368 - $message_text = wfMsg('editsimilar-thanks-singleresult', implode (", ", $similarities));
 359+ $message_text = wfMsg( 'editsimilar-thanks-singleresult', implode( ", ", $similarities ) );
369360 }
370361 } else { // the articles we found were rather just articles needing attention
371 - if (count($similarities) > 1) {
372 - $message_text = wfMsg('editsimilar-thanks-notsimilar', implode (", ", $similarities));
 362+ if( count( $similarities ) > 1 ) {
 363+ $message_text = wfMsg( 'editsimilar-thanks-notsimilar', implode( ", ", $similarities ) );
373364 } else {
374 - $message_text = wfMsg('editsimilar-thanks-notsimilar-singleresult', implode (", ", $similarities));
 365+ $message_text = wfMsg( 'editsimilar-thanks-notsimilar-singleresult', implode( ", ", $similarities ) );
375366 }
376367 }
377368 } else {
378 - if ($wgUser->isLoggedIn () && !empty ($wgEditSimilarAlwaysShowThanks)) {
379 - $message_text = wfMsg ('editsimilar-thankyou', $wgUser->getName ());
 369+ if( $wgUser->isLoggedIn() && !empty( $wgEditSimilarAlwaysShowThanks ) ) {
 370+ $message_text = wfMsg( 'editsimilar-thankyou', $wgUser->getName() );
380371 }
381372 }
382373
383 - if ('' != $message_text) {
384 - EditSimilar::showMessage($message_text, $article_title);
 374+ if( '' != $message_text ) {
 375+ EditSimilar::showMessage( $message_text, $article_title );
385376 }
386377 }
387 - //display that only once
388 - $_SESSION ['ES_saved'] = '';
 378+ // display that only once
 379+ $_SESSION['ES_saved'] = '';
389380 }
390381 return true;
391382 }
392383
393384 // a customized version of getToggle from SpecialPreferences
394385 // this one uses getOption with a default - so we can have it checked if unset
395 -function wfEditSimilarPrefCustomHtml ($prefsForm) {
396 - wfLoadExtensionMessages('EditSimilar');
 386+function wfEditSimilarPrefCustomHtml( $prefsForm ) {
 387+ wfLoadExtensionMessages( 'EditSimilar' );
397388 global $wgOut, $wgUser, $wgLang;
398389 $tname = 'edit-similar';
399 - $prefsForm->mUsedToggles [$tname] = true;
400 - $ttext = $wgLang->getUserToggle($tname);
 390+ $prefsForm->mUsedToggles[$tname] = true;
 391+ $ttext = $wgLang->getUserToggle( $tname );
401392 // the catch lies here
402 - $checked = $wgUser->getOption($tname, 1) == 1 ? ' checked="checked"' : '';
 393+ $checked = $wgUser->getOption( $tname, 1 ) == 1 ? ' checked="checked"' : '';
403394
404 - $wgOut->addHTML ("<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked />" .
405 - " <span class='toggletext'><label for=\"$tname\">$ttext</label></span></div>\n");
 395+ $wgOut->addHTML( "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked />" .
 396+ " <span class='toggletext'><label for=\"$tname\">$ttext</label></span></div>\n" );
406397 return true;
407398 }
408399
409 -function wfEditSimilarToggle ($toggles) {
410 - wfLoadExtensionMessages('EditSimilar');
 400+function wfEditSimilarToggle( $toggles ) {
 401+ wfLoadExtensionMessages( 'EditSimilar' );
411402 $toggles['edit-similar'] = 'edit-similar';
412 - return true;
 403+ return true;
413404 }
\ No newline at end of file

Status & tagging log