Index: trunk/extensions/EditSimilar/EditSimilar.i18n.php |
— | — | @@ -1,36 +1,61 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Internationalisation file for extension EditSimilar |
| 4 | + * Internationalisation file for the EditSimilar extension |
5 | 5 | * |
6 | | - * @addtogroup Extensions |
| 6 | + * @ingroup Extensions |
7 | 7 | */ |
8 | 8 | |
9 | 9 | $messages = array(); |
10 | 10 | |
| 11 | +/** English |
| 12 | + * @author Bartek Łapiński |
| 13 | + * @author Łukasz 'TOR' Garczewski |
| 14 | + */ |
11 | 15 | $messages['en'] = array( |
12 | 16 | 'editsimilar-thanks' => 'Thank you for your contribution. |
13 | | -Check out these related pages: $1.' , |
| 17 | +Check out these related pages: $1.', |
14 | 18 | 'editsimilar-thanks-singleresult' => 'Thank you for your contribution. |
15 | | -Check out this related page: $1.' , |
| 19 | +Check out this related page: $1.', |
16 | 20 | 'editsimilar-thanks-notsimilar' => 'Thank you for your contribution. |
17 | 21 | These pages could also use your help: $1.', |
18 | 22 | 'editsimilar-thanks-notsimilar-singleresult' => 'Thank you for your contribution. |
19 | 23 | 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', |
23 | 27 | ); |
24 | 28 | |
| 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 | + */ |
25 | 50 | $messages['pl'] = array( |
26 | 51 | 'editsimilar-thanks' => 'Dzięki za edycję! |
27 | | -Zerknij też na podobne artykuły: $1.' , |
| 52 | +Zerknij też na podobne artykuły: $1.', |
28 | 53 | 'editsimilar-thanks-singleresult' => 'Dzięki za edycję! |
29 | | -Zerknij też na ten podobny artykuł: $1.' , |
| 54 | +Zerknij też na ten podobny artykuł: $1.', |
30 | 55 | 'editsimilar-thanks-notsimilar' => 'Dzięki za edycję! |
31 | 56 | Te artykuły również mogą potrzebować twojej pomocy: $1.', |
32 | 57 | 'editsimilar-thanks-notsimilar-singleresult' => 'Dzięki za edycję! |
33 | 58 | 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', |
37 | 62 | ); |
Index: trunk/extensions/EditSimilar/EditSimilar.php |
— | — | @@ -7,40 +7,40 @@ |
8 | 8 | * @subpackage Extensions |
9 | 9 | * |
10 | 10 | * @author Bartek Łapiński <bartek@wikia.com> |
11 | | -* @copyright Copyright (C) 2008, Wikia Inc. |
| 11 | +* @copyright Copyright © 2008, Wikia Inc. |
12 | 12 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
13 | 13 | */ |
14 | 14 | |
15 | 15 | if (!defined('MEDIAWIKI')) |
16 | 16 | exit; |
17 | 17 | |
18 | | -global $wgExtensionFunctions, $wgGroupPermissions; |
| 18 | +global $wgExtensionFunctions; |
19 | 19 | |
20 | 20 | $dir = dirname(__FILE__); |
21 | | -$wgExtensionMessagesFiles ['EditSimilar'] = $dir . '/EditSimilar.i18n.php' ; |
| 21 | +$wgExtensionMessagesFiles['EditSimilar'] = $dir . '/EditSimilar.i18n.php'; |
22 | 22 | |
23 | 23 | if (empty ($wgEditSimilarMaxResultsPool ) ) { |
24 | 24 | // maximum number of results to choose from |
25 | | - $wgEditSimilarMaxResultsPool = 50 ; |
| 25 | + $wgEditSimilarMaxResultsPool = 50; |
26 | 26 | } |
27 | 27 | |
28 | 28 | if (empty ($wgEditSimilarMaxResultsToDisplay)) { |
29 | 29 | // maximum number of results to display in text |
30 | | - $wgEditSimilarMaxResultsToDisplay = 3 ; |
| 30 | + $wgEditSimilarMaxResultsToDisplay = 3; |
31 | 31 | } |
32 | 32 | |
33 | 33 | if (empty ($wgEditSimilarCounterValue)) { |
34 | 34 | // show message per specified number of edits |
35 | | - $wgEditSimilarCounterValue = 1 ; |
| 35 | + $wgEditSimilarCounterValue = 1; |
36 | 36 | } |
37 | 37 | |
38 | | -$wgExtensionFunctions [] = 'wfEditSimilarSetup' ; |
| 38 | +$wgExtensionFunctions[] = 'wfEditSimilarSetup'; |
39 | 39 | |
40 | 40 | $wgExtensionCredits['other'][] = array( |
41 | 41 | 'name' => 'EditSimilar', |
42 | 42 | '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', |
45 | 45 | 'description' => 'Encourages users to edit an article similar (by categories) to the one they just had edited.', |
46 | 46 | ); |
47 | 47 | |
— | — | @@ -66,93 +66,93 @@ |
67 | 67 | |
68 | 68 | // base class for this extension |
69 | 69 | 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 |
77 | 77 | |
78 | 78 | // constructor |
79 | 79 | 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; |
87 | 87 | } |
88 | 88 | |
89 | 89 | // fetch categories marked as 'stub categories' |
90 | 90 | function getStubCategories () { |
91 | | - $stub_categories = wfMsgForContent ('EditSimilar-Categories') ; |
| 91 | + $stub_categories = wfMsgForContent('EditSimilar-Categories'); |
92 | 92 | if ( ('<EditSimilar-Categories>' == $stub_categories) || ('' == $stub_categories) || ('-' == $stub_categories) ) { |
93 | | - return false ; |
| 93 | + return false; |
94 | 94 | } 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); |
98 | 98 | foreach ($lines as $line) { |
99 | | - $normalised_lines [] = str_replace(" ", "_", trim ($line)) ; |
| 99 | + $normalised_lines[] = str_replace(" ", "_", trim ($line)); |
100 | 100 | } |
101 | | - return $normalised_lines ; |
| 101 | + return $normalised_lines; |
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | 105 | // this is the main function that returns articles we deem similar or worth showing |
106 | 106 | function getSimilarArticles () { |
107 | | - global $wgUser, $wgEditSimilarMarker ; |
108 | | - global $wgEditSimilarMaxResultsToDisplay ; |
| 107 | + global $wgUser, $wgEditSimilarMarker; |
| 108 | + global $wgEditSimilarMaxResultsToDisplay; |
109 | 109 | |
110 | 110 | if (empty ($this->mAttentionMarkers) || !$this->mAttentionMarkers) { |
111 | | - return false ; |
| 111 | + return false; |
112 | 112 | } |
113 | | - $text = '' ; |
114 | | - $articles = array () ; |
115 | | - $x = 0 ; |
| 113 | + $text = ''; |
| 114 | + $articles = array(); |
| 115 | + $x = 0; |
116 | 116 | |
117 | 117 | 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]) ); |
119 | 119 | if (!empty ($articles)) { |
120 | | - $articles = array_unique ($articles) ; |
| 120 | + $articles = array_unique($articles); |
121 | 121 | } |
122 | | - $x++ ; |
| 122 | + $x++; |
123 | 123 | } |
124 | 124 | |
125 | 125 | if (empty ($articles) ) { |
126 | | - $articles = $this->getAdditionalCheck () ; |
| 126 | + $articles = $this->getAdditionalCheck(); |
127 | 127 | // second check to make sure we have anything to display |
128 | 128 | if (empty ($articles) ) { |
129 | 129 | return false; |
130 | 130 | } |
131 | | - $articles = array_unique ($articles) ; |
132 | | - $this->mSimilarArticles = false ; |
| 131 | + $articles = array_unique($articles); |
| 132 | + $this->mSimilarArticles = false; |
133 | 133 | } |
134 | 134 | |
135 | 135 | 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); |
137 | 137 | } else { |
138 | | - $rand_articles = array_rand ($articles, min ($wgEditSimilarMaxResultsToDisplay, count ($articles)) ) ; |
| 138 | + $rand_articles = array_rand ($articles, min ($wgEditSimilarMaxResultsToDisplay, count ($articles)) ); |
139 | 139 | } |
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(); |
144 | 144 | if (empty ($rand_articles)) { |
145 | | - return false ; |
| 145 | + return false; |
146 | 146 | } |
147 | 147 | |
148 | | - $translated_titles = array () ; |
| 148 | + $translated_titles = array(); |
149 | 149 | foreach ($rand_articles as $r_key => $rand_article_key) { |
150 | | - $translated_titles [] = $articles [$rand_article_key] ; |
| 150 | + $translated_titles[] = $articles [$rand_article_key]; |
151 | 151 | } |
152 | | - $translated_titles = $this->idsToTitles ($translated_titles) ; |
| 152 | + $translated_titles = $this->idsToTitles($translated_titles); |
153 | 153 | |
154 | 154 | 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; |
157 | 157 | } |
158 | 158 | |
159 | 159 | return $real_rand_values; |
— | — | @@ -160,32 +160,32 @@ |
161 | 161 | |
162 | 162 | // extract all categories our base article is in |
163 | 163 | function getBaseCategories () { |
164 | | - global $wgEditSimilarMaxResultsToDisplay ; |
| 164 | + global $wgEditSimilarMaxResultsToDisplay; |
165 | 165 | if (empty ($this->mAttentionMarkers) || !$this->mAttentionMarkers) { |
166 | | - return false ; |
| 166 | + return false; |
167 | 167 | } |
168 | 168 | |
169 | | - $dbr = wfGetDB( DB_SLAVE ); |
170 | | - $result_array = array () ; |
| 169 | + $dbr = wfGetDB( DB_SLAVE ); |
| 170 | + $result_array = array(); |
171 | 171 | $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', |
177 | 177 | 'USE_INDEX' => 'cl_from' |
178 | 178 | ) |
179 | 179 | ) ; |
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 | + } |
183 | 184 | } |
184 | | - } |
185 | 185 | |
186 | 186 | if (!empty ($result_array) ) { |
187 | | - return $result_array ; |
| 187 | + return $result_array; |
188 | 188 | } else { |
189 | | - return false ; |
| 189 | + return false; |
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
— | — | @@ -198,94 +198,94 @@ |
199 | 199 | some results |
200 | 200 | */ |
201 | 201 | function getAdditionalCheck () { |
202 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 202 | + $dbr = wfGetDB( DB_SLAVE ); |
203 | 203 | |
204 | 204 | $query = "SELECT cl_from |
205 | 205 | FROM categorylinks |
206 | | - WHERE cl_to IN (" ; |
| 206 | + WHERE cl_to IN ("; |
207 | 207 | |
208 | | - $fixed_names = array () ; |
| 208 | + $fixed_names = array(); |
209 | 209 | foreach ($this->mAttentionMarkers as $category) { |
210 | | - $fixed_names [] = $dbr->addQuotes ($category) ; |
| 210 | + $fixed_names[] = $dbr->addQuotes($category); |
211 | 211 | } |
212 | | - $stringed_names = implode (",", $fixed_names) ; |
213 | | - $query .= $stringed_names . ")" ; |
| 212 | + $stringed_names = implode (",", $fixed_names); |
| 213 | + $query .= $stringed_names . ")"; |
214 | 214 | |
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 ); |
223 | 223 | |
224 | | - return $result_array ; |
| 224 | + return $result_array; |
225 | 225 | |
226 | 226 | } |
227 | 227 | |
228 | 228 | // one function to turn result ids into titles in one query rather than multiple ones |
229 | 229 | function idsToTitles ($id_array) { |
230 | | - global $wgContentNamespaces ; |
| 230 | + global $wgContentNamespaces; |
231 | 231 | $dbr = wfGetDB( DB_SLAVE ); |
232 | 232 | $query = "SELECT page_namespace, page_title |
233 | 233 | FROM page |
234 | | - WHERE page_id IN (" ; |
| 234 | + WHERE page_id IN ("; |
235 | 235 | |
236 | | - $stringed_names = implode (",", $id_array) ; |
237 | | - $query .= $stringed_names . ")" ; |
| 236 | + $stringed_names = implode (",", $id_array); |
| 237 | + $query .= $stringed_names . ")"; |
238 | 238 | |
239 | | - $res = $dbr->query ($query, __METHOD__) ; |
240 | | - $result_array = array () ; |
| 239 | + $res = $dbr->query ($query, __METHOD__); |
| 240 | + $result_array = array(); |
241 | 241 | |
242 | 242 | // so for now, to speed things up, just discard results from other namespaces (and subpages) |
243 | 243 | while( ($x = $dbr->fetchObject ( $res )) |
244 | 244 | && (in_array ($x->page_namespace, $wgContentNamespaces)) |
245 | 245 | && 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); |
247 | 247 | } |
248 | 248 | |
249 | 249 | $dbr->freeResult( $res ); |
250 | | - return $result_array ; |
| 250 | + return $result_array; |
251 | 251 | } |
252 | 252 | |
253 | 253 | // get categories from the 'stub' or 'attention needed' category |
254 | 254 | function getResults ($marker_category) { |
255 | 255 | $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(); |
258 | 258 | |
259 | 259 | if (empty ($this->mBaseCategories)) { |
260 | | - return $result_array ; |
| 260 | + return $result_array; |
261 | 261 | } |
262 | 262 | |
263 | 263 | $query = "SELECT c1.cl_from |
264 | 264 | FROM categorylinks as c1, categorylinks as c2 |
265 | 265 | WHERE c1.cl_from = c2.cl_from |
266 | 266 | AND c1.cl_to = " .$dbr->addQuotes ($title->getDBKey ()) . " |
267 | | - AND c2.cl_to IN (" ; |
| 267 | + AND c2.cl_to IN ("; |
268 | 268 | |
269 | | - $fixed_names = array () ; |
| 269 | + $fixed_names = array(); |
270 | 270 | foreach ($this->mBaseCategories as $category) { |
271 | | - $fixed_names [] = $dbr->addQuotes ($category) ; |
| 271 | + $fixed_names[] = $dbr->addQuotes($category); |
272 | 272 | } |
273 | | - $stringed_names = implode (",", $fixed_names) ; |
274 | | - $query .= $stringed_names . ")" ; |
| 273 | + $stringed_names = implode (",", $fixed_names); |
| 274 | + $query .= $stringed_names . ")"; |
275 | 275 | |
276 | | - $res = $dbr->query ($query, __METHOD__) ; |
| 276 | + $res = $dbr->query ($query, __METHOD__); |
277 | 277 | while( $x = $dbr->fetchObject ( $res ) ) { |
278 | 278 | if ($this->mBaseArticle != $x->cl_from) { |
279 | | - $result_array [] = $x->cl_from ; |
| 279 | + $result_array[] = $x->cl_from; |
280 | 280 | } |
281 | 281 | } |
282 | 282 | $dbr->freeResult( $res ); |
283 | 283 | |
284 | | - return $result_array ; |
| 284 | + return $result_array; |
285 | 285 | } |
286 | 286 | |
287 | 287 | // message box wrapper |
288 | 288 | static public function showMessage ($text) { |
289 | | - global $wgOut, $wgUser, $wgScript ; |
| 289 | + global $wgOut, $wgUser, $wgScript; |
290 | 290 | $wgOut->addHTML (" |
291 | 291 | <style type=\"text/css\"> |
292 | 292 | .editsimilar { |
— | — | @@ -300,112 +300,112 @@ |
301 | 301 | </style> |
302 | 302 | ") ; |
303 | 303 | 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\"> </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\"> </div>"; |
305 | 305 | } else { |
306 | | - $link = '' ; |
| 306 | + $link = ''; |
307 | 307 | } |
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>"); |
309 | 309 | } |
310 | 310 | |
311 | 311 | |
312 | 312 | // this is for determining whether to display the message or not |
313 | 313 | static public function checkCounter () { |
314 | | - global $wgEditSimilarCounterValue ; |
| 314 | + global $wgEditSimilarCounterValue; |
315 | 315 | if (isset ($_SESSION ['ES_counter'])) { |
316 | | - $_SESSION ['ES_counter'] -- ; |
| 316 | + $_SESSION ['ES_counter'] --; |
317 | 317 | if ($_SESSION ['ES_counter'] > 0) { |
318 | | - return false ; |
| 318 | + return false; |
319 | 319 | } else { |
320 | | - $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue ; |
321 | | - return true ; |
| 320 | + $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue; |
| 321 | + return true; |
322 | 322 | } |
323 | 323 | } else { |
324 | | - $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue ; |
325 | | - return true ; |
| 324 | + $_SESSION ['ES_counter'] = $wgEditSimilarCounterValue; |
| 325 | + return true; |
326 | 326 | } |
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
330 | 330 | 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'; |
334 | 334 | if ( $wgUser->isLoggedIn ()) { |
335 | | - $wgHooks ['getEditingPreferencesCustomHtml'][] = 'wfEditSimilarPrefCustomHtml' ; |
336 | | - $wgHooks ['UserToggles'][] = 'wfEditSimilarToggle' ; |
| 335 | + $wgHooks['getEditingPreferencesCustomHtml'][] = 'wfEditSimilarPrefCustomHtml'; |
| 336 | + $wgHooks['UserToggles'][] = 'wfEditSimilarToggle'; |
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | 340 | // check if we had the extension enabled at all and if this is in a content namespace |
341 | 341 | function wfEditSimilarCheck ($article) { |
342 | | - global $wgOut, $wgUser, $wgContentNamespaces ; |
| 342 | + global $wgOut, $wgUser, $wgContentNamespaces; |
343 | 343 | |
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'; |
347 | 347 | } |
348 | | - return true ; |
| 348 | + return true; |
349 | 349 | } |
350 | 350 | |
351 | 351 | //view message depending on settings and the relevancy of the results |
352 | 352 | function wfEditSimilarViewMesg (&$out) { |
353 | | - global $wgTitle, $wgUser, $wgEditSimilarAlwaysShowThanks ; |
354 | | - wfLoadExtensionMessages ('EditSimilar') ; |
| 353 | + global $wgTitle, $wgUser, $wgEditSimilarAlwaysShowThanks; |
| 354 | + wfLoadExtensionMessages('EditSimilar'); |
355 | 355 | if ( !empty ($_SESSION ['ES_saved']) && (1 == $wgUser->getOption ('edit-similar', 1) ) && $out->isArticle ()) { |
356 | 356 | if (EditSimilar::checkCounter ()) { |
357 | | - $message_text = '' ; |
358 | | - $article_title = $wgTitle->getText() ; |
| 357 | + $message_text = ''; |
| 358 | + $article_title = $wgTitle->getText(); |
359 | 359 | // 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(); |
362 | 362 | if (!empty($similarities)) { |
363 | 363 | if ($SInstance->mSimilarArticles) { |
364 | 364 | if (count($similarities) > 1) { |
365 | | - $message_text = wfMsg ('editsimilar-thanks', implode (", ", $similarities)); |
| 365 | + $message_text = wfMsg('editsimilar-thanks', implode (", ", $similarities)); |
366 | 366 | } else { |
367 | | - $message_text = wfMsg ('editsimilar-thanks-singleresult', implode (", ", $similarities)); |
| 367 | + $message_text = wfMsg('editsimilar-thanks-singleresult', implode (", ", $similarities)); |
368 | 368 | } |
369 | 369 | } else { // the articles we found were rather just articles needing attention |
370 | 370 | if (count($similarities) > 1) { |
371 | | - $message_text = wfMsg ('editsimilar-thanks-notsimilar', implode (", ", $similarities)); |
| 371 | + $message_text = wfMsg('editsimilar-thanks-notsimilar', implode (", ", $similarities)); |
372 | 372 | } else { |
373 | | - $message_text = wfMsg ('editsimilar-thanks-notsimilar-singleresult', implode (", ", $similarities)); |
| 373 | + $message_text = wfMsg('editsimilar-thanks-notsimilar-singleresult', implode (", ", $similarities)); |
374 | 374 | } |
375 | 375 | } |
376 | 376 | } else { |
377 | 377 | if ($wgUser->isLoggedIn () && !empty ($wgEditSimilarAlwaysShowThanks)) { |
378 | | - $message_text = wfMsg ('editsimilar-thankyou', $wgUser->getName ()) ; |
| 378 | + $message_text = wfMsg ('editsimilar-thankyou', $wgUser->getName ()); |
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
382 | 382 | if ('' != $message_text) { |
383 | | - EditSimilar::showMessage ($message_text, $article_title) ; |
| 383 | + EditSimilar::showMessage($message_text, $article_title); |
384 | 384 | } |
385 | 385 | } |
386 | 386 | //display that only once |
387 | | - $_SESSION ['ES_saved'] = '' ; |
| 387 | + $_SESSION ['ES_saved'] = ''; |
388 | 388 | } |
389 | | - return true ; |
| 389 | + return true; |
390 | 390 | } |
391 | 391 | |
392 | 392 | // a customized version of getToggle from SpecialPreferences |
393 | 393 | // this one uses getOption with a default - so we can have it checked if unset |
394 | 394 | 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); |
400 | 400 | // the catch lies here |
401 | | - $checked = $wgUser->getOption ($tname, 1) == 1 ? ' checked="checked"' : ''; |
| 401 | + $checked = $wgUser->getOption($tname, 1) == 1 ? ' checked="checked"' : ''; |
402 | 402 | |
403 | 403 | $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; |
406 | 406 | } |
407 | 407 | |
408 | 408 | 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 |