Index: trunk/extensions/EditSimilar/EditSimilar.i18n.php |
— | — | @@ -1,21 +1,36 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * Internationalisation file for extension EditSimilar |
| 5 | + * |
| 6 | + * @addtogroup Extensions |
| 7 | + */ |
| 8 | + |
3 | 9 | $messages = array(); |
| 10 | + |
4 | 11 | $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 | +); |
13 | 24 | |
14 | 25 | $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 @@ |
12 | 12 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
13 | 13 | */ |
14 | 14 | |
15 | | -if ( defined( 'MEDIAWIKI' ) ) { |
| 15 | +if (!defined('MEDIAWIKI')) |
| 16 | + exit; |
16 | 17 | |
17 | 18 | global $wgExtensionFunctions, $wgGroupPermissions; |
18 | 19 | |
19 | | -$dir = dirname(__FILE__); |
20 | | -$wgExtensionMessagesFiles ['EditSimilar'] = $dir . '/EditSimilar.i18n.php' ; |
| 20 | +$dir = dirname(__FILE__); |
| 21 | +$wgExtensionMessagesFiles ['EditSimilar'] = $dir . '/EditSimilar.i18n.php' ; |
21 | 22 | |
22 | 23 | if (empty ($wgEditSimilarMaxResultsPool ) ) { |
23 | 24 | // maximum number of results to choose from |
— | — | @@ -37,7 +38,7 @@ |
38 | 39 | |
39 | 40 | $wgExtensionCredits['other'][] = array( |
40 | 41 | 'name' => 'EditSimilar', |
41 | | - 'version' => 1.16 , |
| 42 | + 'version' => '1.16', |
42 | 43 | 'author' => 'Bartek Łapiński, [http://inside.wikia.com/wiki/User:TOR Łukasz \'TOR\' Garczewski]', |
43 | 44 | 'url' => 'http://help.wikia.com/wiki/Help:EditSimilar', |
44 | 45 | 'description' => 'Encourages users to edit an article similar (by categories) to the one they just had edited.', |
— | — | @@ -59,7 +60,7 @@ |
60 | 61 | * Chosen Stub Category 2 |
61 | 62 | etc. (separated by stars) |
62 | 63 | |
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 |
64 | 65 | |
65 | 66 | */ |
66 | 67 | |
— | — | @@ -68,7 +69,7 @@ |
69 | 70 | var $mBaseArticle ; // the article from which we hail in our quest for similiarities, this is its title |
70 | 71 | var $mMarkerType ; // how do we mark articles that need attention? currently, by category only |
71 | 72 | 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 |
73 | 74 | var $mPoolLimit ; // limit up the pool of 'stubs' to choose from |
74 | 75 | var $mBaseCategories ; // extracted categories that this saved article is in |
75 | 76 | var $mSimilarArticles ; // to differentiate between really similar results or just needing attention |
— | — | @@ -79,10 +80,10 @@ |
80 | 81 | $this->mBaseArticle = $article ; |
81 | 82 | $this->mMarkerType = $markertype ; |
82 | 83 | $this->mAttentionMarkers = $this->getStubCategories () ; |
83 | | - $this->mPoolLimit = $wgEditSimilarMaxResultsPool ; |
| 84 | + $this->mPoolLimit = $wgEditSimilarMaxResultsPool ; |
84 | 85 | $this->mBaseCategories = $this->getBaseCategories () ; |
85 | | - $this->mSimilarArticles = true ; |
86 | | - } |
| 86 | + $this->mSimilarArticles = true ; |
| 87 | + } |
87 | 88 | |
88 | 89 | // fetch categories marked as 'stub categories' |
89 | 90 | function getStubCategories () { |
— | — | @@ -100,7 +101,7 @@ |
101 | 102 | } |
102 | 103 | } |
103 | 104 | |
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 |
105 | 106 | function getSimilarArticles () { |
106 | 107 | global $wgUser, $wgEditSimilarMarker ; |
107 | 108 | global $wgEditSimilarMaxResultsToDisplay ; |
— | — | @@ -113,7 +114,7 @@ |
114 | 115 | $x = 0 ; |
115 | 116 | |
116 | 117 | 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]) ) ; |
118 | 119 | if (!empty ($articles)) { |
119 | 120 | $articles = array_unique ($articles) ; |
120 | 121 | } |
— | — | @@ -129,7 +130,7 @@ |
130 | 131 | $articles = array_unique ($articles) ; |
131 | 132 | $this->mSimilarArticles = false ; |
132 | 133 | } |
133 | | - |
| 134 | + |
134 | 135 | if (1 == count ($articles)) { // in this case, array_rand returns a single element, not an array |
135 | 136 | $rand_articles = array (0) ; |
136 | 137 | } else { |
— | — | @@ -147,15 +148,15 @@ |
148 | 149 | foreach ($rand_articles as $r_key => $rand_article_key) { |
149 | 150 | $translated_titles [] = $articles [$rand_article_key] ; |
150 | 151 | } |
151 | | - $translated_titles = $this->idsToTitles ($translated_titles) ; |
152 | | - |
| 152 | + $translated_titles = $this->idsToTitles ($translated_titles) ; |
| 153 | + |
153 | 154 | foreach ($translated_titles as $link_title) { |
154 | 155 | $article_link = $sk->makeKnownLinkObj ($link_title) ; |
155 | | - $real_rand_values [] = $article_link ; |
| 156 | + $real_rand_values [] = $article_link ; |
156 | 157 | } |
157 | | - |
| 158 | + |
158 | 159 | return $real_rand_values; |
159 | | - } |
| 160 | + } |
160 | 161 | |
161 | 162 | // extract all categories our base article is in |
162 | 163 | function getBaseCategories () { |
— | — | @@ -163,13 +164,13 @@ |
164 | 165 | if (empty ($this->mAttentionMarkers) || !$this->mAttentionMarkers) { |
165 | 166 | return false ; |
166 | 167 | } |
167 | | - |
| 168 | + |
168 | 169 | $dbr = wfGetDB( DB_SLAVE ); |
169 | | - $result_array = array () ; |
| 170 | + $result_array = array () ; |
170 | 171 | $res = $dbr->select ( |
171 | 172 | array ('categorylinks') , |
172 | 173 | array ('cl_to') , |
173 | | - array ( 'cl_from' => $this->mBaseArticle ) , |
| 174 | + array ( 'cl_from' => $this->mBaseArticle ) , |
174 | 175 | __METHOD__ , |
175 | 176 | array ( 'ORDER_BY' => 'cl_from' , |
176 | 177 | 'USE_INDEX' => 'cl_from' |
— | — | @@ -177,7 +178,7 @@ |
178 | 179 | ) ; |
179 | 180 | while( $x = $dbr->fetchObject ( $res ) ) { |
180 | 181 | if (!in_array ($x->cl_to, $this->mAttentionMarkers) ) { |
181 | | - $result_array [] = $x->cl_to ; |
| 182 | + $result_array [] = $x->cl_to ; |
182 | 183 | } |
183 | 184 | } |
184 | 185 | |
— | — | @@ -192,7 +193,7 @@ |
193 | 194 | latest addition: if we got no results at all (indicating that: |
194 | 195 | A - the article had no categories, |
195 | 196 | B - the article had no relevant results for its categories) |
196 | | - |
| 197 | + |
197 | 198 | this is to ensure we can get always (well, almost - if "marker" categories get no results, it's dead in the water anyway) |
198 | 199 | some results |
199 | 200 | */ |
— | — | @@ -202,11 +203,11 @@ |
203 | 204 | $query = "SELECT cl_from |
204 | 205 | FROM categorylinks |
205 | 206 | WHERE cl_to IN (" ; |
206 | | - |
207 | | - $fixed_names = array () ; |
| 207 | + |
| 208 | + $fixed_names = array () ; |
208 | 209 | foreach ($this->mAttentionMarkers as $category) { |
209 | 210 | $fixed_names [] = $dbr->addQuotes ($category) ; |
210 | | - } |
| 211 | + } |
211 | 212 | $stringed_names = implode (",", $fixed_names) ; |
212 | 213 | $query .= $stringed_names . ")" ; |
213 | 214 | |
— | — | @@ -214,7 +215,7 @@ |
215 | 216 | $result_array = array () ; |
216 | 217 | while( $x = $dbr->fetchObject ( $res ) ) { |
217 | 218 | if ($this->mBaseArticle != $x->cl_from) { |
218 | | - $result_array [] = $x->cl_from ; |
| 219 | + $result_array [] = $x->cl_from ; |
219 | 220 | } |
220 | 221 | } |
221 | 222 | $dbr->freeResult( $res ); |
— | — | @@ -237,13 +238,13 @@ |
238 | 239 | $res = $dbr->query ($query, __METHOD__) ; |
239 | 240 | $result_array = array () ; |
240 | 241 | |
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 )) |
243 | 244 | && (in_array ($x->page_namespace, $wgContentNamespaces)) |
244 | 245 | && false === strpos ($x->page_title, "/") ) { |
245 | 246 | $result_array [] = Title::makeTitle ($x->page_namespace, $x->page_title ) ; |
246 | 247 | } |
247 | | - |
| 248 | + |
248 | 249 | $dbr->freeResult( $res ); |
249 | 250 | return $result_array ; |
250 | 251 | } |
— | — | @@ -256,25 +257,25 @@ |
257 | 258 | |
258 | 259 | if (empty ($this->mBaseCategories)) { |
259 | 260 | return $result_array ; |
260 | | - } |
| 261 | + } |
261 | 262 | |
262 | 263 | $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 ()) . " |
266 | 267 | AND c2.cl_to IN (" ; |
267 | | - |
268 | | - $fixed_names = array () ; |
| 268 | + |
| 269 | + $fixed_names = array () ; |
269 | 270 | foreach ($this->mBaseCategories as $category) { |
270 | 271 | $fixed_names [] = $dbr->addQuotes ($category) ; |
271 | | - } |
| 272 | + } |
272 | 273 | $stringed_names = implode (",", $fixed_names) ; |
273 | 274 | $query .= $stringed_names . ")" ; |
274 | 275 | |
275 | 276 | $res = $dbr->query ($query, __METHOD__) ; |
276 | 277 | while( $x = $dbr->fetchObject ( $res ) ) { |
277 | 278 | if ($this->mBaseArticle != $x->cl_from) { |
278 | | - $result_array [] = $x->cl_from ; |
| 279 | + $result_array [] = $x->cl_from ; |
279 | 280 | } |
280 | 281 | } |
281 | 282 | $dbr->freeResult( $res ); |
— | — | @@ -298,7 +299,7 @@ |
299 | 300 | } |
300 | 301 | </style> |
301 | 302 | ") ; |
302 | | - if ($wgUser->isLoggedIn () ) { |
| 303 | + if ($wgUser->isLoggedIn () ) { |
303 | 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\"> </div>" ; |
304 | 305 | } else { |
305 | 306 | $link = '' ; |
— | — | @@ -316,7 +317,7 @@ |
317 | 318 | return false ; |
318 | 319 | } else { |
319 | 320 | $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue ; |
320 | | - return true ; |
| 321 | + return true ; |
321 | 322 | } |
322 | 323 | } else { |
323 | 324 | $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue ; |
— | — | @@ -327,10 +328,10 @@ |
328 | 329 | |
329 | 330 | function wfEditSimilarSetup () { |
330 | 331 | global $wgHooks, $wgMessageCache, $wgUser ; |
331 | | - $wgHooks ['ArticleSaveComplete'][] = 'wfEditSimilarCheck' ; |
332 | | - $wgHooks ['OutputPageBeforeHTML'][] = 'wfEditSimilarViewMesg' ; |
| 332 | + $wgHooks ['ArticleSaveComplete'][] = 'wfEditSimilarCheck' ; |
| 333 | + $wgHooks ['OutputPageBeforeHTML'][] = 'wfEditSimilarViewMesg' ; |
333 | 334 | if ( $wgUser->isLoggedIn ()) { |
334 | | - $wgHooks ['getEditingPreferencesCustomHtml'][] = 'wfEditSimilarPrefCustomHtml' ; |
| 335 | + $wgHooks ['getEditingPreferencesCustomHtml'][] = 'wfEditSimilarPrefCustomHtml' ; |
335 | 336 | $wgHooks ['UserToggles'][] = 'wfEditSimilarToggle' ; |
336 | 337 | } |
337 | 338 | } |
— | — | @@ -338,7 +339,7 @@ |
339 | 340 | // check if we had the extension enabled at all and if this is in a content namespace |
340 | 341 | function wfEditSimilarCheck ($article) { |
341 | 342 | global $wgOut, $wgUser, $wgContentNamespaces ; |
342 | | - |
| 343 | + |
343 | 344 | $namespace = $article->getTitle()->getNamespace() ; |
344 | 345 | if ( (1 == $wgUser->getOption ('edit-similar', 1)) && (in_array ($namespace, $wgContentNamespaces)) ) { |
345 | 346 | $_SESSION ['ES_saved'] = 'yes' ; |
— | — | @@ -351,12 +352,12 @@ |
352 | 353 | global $wgTitle, $wgUser, $wgEditSimilarAlwaysShowThanks ; |
353 | 354 | wfLoadExtensionMessages ('EditSimilar') ; |
354 | 355 | if ( !empty ($_SESSION ['ES_saved']) && (1 == $wgUser->getOption ('edit-similar', 1) ) && $out->isArticle ()) { |
355 | | - if (EditSimilar::checkCounter ()) { |
| 356 | + if (EditSimilar::checkCounter ()) { |
356 | 357 | $message_text = '' ; |
357 | 358 | $article_title = $wgTitle->getText() ; |
358 | 359 | // here we'll populate the similar articles and links |
359 | 360 | $SInstance = new EditSimilar ($wgTitle->getArticleId(), 'category') ; |
360 | | - $similarities = $SInstance->getSimilarArticles () ; |
| 361 | + $similarities = $SInstance->getSimilarArticles () ; |
361 | 362 | if (!empty($similarities)) { |
362 | 363 | if ($SInstance->mSimilarArticles) { |
363 | 364 | if (count($similarities) > 1) { |
— | — | @@ -397,9 +398,9 @@ |
398 | 399 | $ttext = $wgLang->getUserToggle ($tname) ; |
399 | 400 | // the catch lies here |
400 | 401 | $checked = $wgUser->getOption ($tname, 1) == 1 ? ' checked="checked"' : ''; |
401 | | - |
| 402 | + |
402 | 403 | $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") ; |
404 | 405 | return true ; |
405 | 406 | } |
406 | 407 | |
— | — | @@ -408,6 +409,3 @@ |
409 | 410 | $toggles ['edit-similar'] = 'edit-similar' ; |
410 | 411 | return true ; |
411 | 412 | } |
412 | | - |
413 | | -} |
414 | | -?> |