@@ -72,7 +72,6 @@ discard block |
||
72 | 72 | |
73 | 73 | /** |
74 | 74 | * Get a link to the given user's userpage, or to Special:Contribs if $username is an IP |
75 | - * @param string $username Username |
|
76 | 75 | * @param string $projectUrl Project domain and protocol such as https://en.wikipedia.org |
77 | 76 | * @param string [$label] The link text, defaults to $username |
78 | 77 | * @return string Markup |
@@ -176,7 +175,7 @@ discard block |
||
176 | 175 | /** |
177 | 176 | * Get links to pageviews tools for the given page |
178 | 177 | * @param string $title Title of page |
179 | - * @param string $projectUrl Project domain such as en.wikipedia.org |
|
178 | + * @param string $project Project domain such as en.wikipedia.org |
|
180 | 179 | * @return string Markup |
181 | 180 | */ |
182 | 181 | public function pageviewsLinks($title, $project) |
@@ -14,23 +14,23 @@ discard block |
||
14 | 14 | |
15 | 15 | public function intuitionMessage($message = "", $vars = []) |
16 | 16 | { |
17 | - return $this->getIntuition()->msg($message, [ "domain" => "xtools", "variables" => $vars ]); |
|
17 | + return $this->getIntuition()->msg($message, ["domain" => "xtools", "variables" => $vars]); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /*********************************** FUNCTIONS ***********************************/ |
21 | 21 | |
22 | 22 | public function getFunctions() |
23 | 23 | { |
24 | - $options = [ 'is_safe' => [ 'html']]; |
|
24 | + $options = ['is_safe' => ['html']]; |
|
25 | 25 | return [ |
26 | - new Twig_SimpleFunction('wiki_link', [ $this, 'wikiLink' ], $options), |
|
27 | - new Twig_SimpleFunction('user_link', [ $this, 'userLink' ], $options), |
|
28 | - new Twig_SimpleFunction('group_link', [ $this, 'groupLink' ], $options), |
|
29 | - new Twig_SimpleFunction('wiki_history_link', [ $this, 'wikiHistoryLink' ], $options), |
|
30 | - new Twig_SimpleFunction('wiki_log_link', [ $this, 'wikiLogLink' ], $options), |
|
31 | - new Twig_SimpleFunction('pageviews_links', [ $this, 'pageviewsLinks' ], $options), |
|
32 | - new Twig_SimpleFunction('diff_link', [ $this, 'diffLink' ], $options), |
|
33 | - new Twig_SimpleFunction('perma_link', [ $this, 'permaLink' ], $options), |
|
26 | + new Twig_SimpleFunction('wiki_link', [$this, 'wikiLink'], $options), |
|
27 | + new Twig_SimpleFunction('user_link', [$this, 'userLink'], $options), |
|
28 | + new Twig_SimpleFunction('group_link', [$this, 'groupLink'], $options), |
|
29 | + new Twig_SimpleFunction('wiki_history_link', [$this, 'wikiHistoryLink'], $options), |
|
30 | + new Twig_SimpleFunction('wiki_log_link', [$this, 'wikiLogLink'], $options), |
|
31 | + new Twig_SimpleFunction('pageviews_links', [$this, 'pageviewsLinks'], $options), |
|
32 | + new Twig_SimpleFunction('diff_link', [$this, 'diffLink'], $options), |
|
33 | + new Twig_SimpleFunction('perma_link', [$this, 'permaLink'], $options), |
|
34 | 34 | ]; |
35 | 35 | } |
36 | 36 | |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | public function getFilters() |
200 | 200 | { |
201 | 201 | return [ |
202 | - new \Twig_SimpleFilter('percent_format', [ $this, 'percentFormat' ]), |
|
203 | - new \Twig_SimpleFilter('diff_format', [ $this, 'diffFormat' ], [ 'is_safe' => [ 'html' ] ]), |
|
204 | - new \Twig_SimpleFilter('wikify_comment', [ $this, 'wikifyComment' ], [ 'is_safe' => [ 'html' ] ]), |
|
202 | + new \Twig_SimpleFilter('percent_format', [$this, 'percentFormat']), |
|
203 | + new \Twig_SimpleFilter('diff_format', [$this, 'diffFormat'], ['is_safe' => ['html']]), |
|
204 | + new \Twig_SimpleFilter('wikify_comment', [$this, 'wikifyComment'], ['is_safe' => ['html']]), |
|
205 | 205 | ]; |
206 | 206 | } |
207 | 207 | |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | if (!$denominator) { |
238 | 238 | $quotient = 0; |
239 | 239 | } else { |
240 | - $quotient = ( $numerator / $denominator ) * 100; |
|
240 | + $quotient = ($numerator / $denominator) * 100; |
|
241 | 241 | } |
242 | 242 | |
243 | - return round($quotient, $precision) . '%'; |
|
243 | + return round($quotient, $precision).'%'; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | if ($isSection) { |
259 | 259 | $sectionTitle = $sectionMatch[1][0]; |
260 | 260 | $sectionTitleLink = str_replace(' ', '_', $sectionTitle); |
261 | - $sectionWikitext = "<a target='_blank' href='$projectUrl/wiki/$title#$sectionTitleLink'>→</a>" . |
|
261 | + $sectionWikitext = "<a target='_blank' href='$projectUrl/wiki/$title#$sectionTitleLink'>→</a>". |
|
262 | 262 | "<em class='text-muted'>$sectionTitle:</em> "; |
263 | 263 | $wikitext = str_replace($sectionMatch[0][0], $sectionWikitext, $wikitext); |
264 | 264 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | // Iterate over query results, loading each user id into the array |
182 | 182 | while ($row = $res->fetch()) { |
183 | - $adminIdArr[] = $row["user_id"] ; |
|
183 | + $adminIdArr[] = $row["user_id"]; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | // Set the query results to be useful in a sql statement. |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | } |
234 | 234 | |
235 | 235 | if ($adminCount > 0) { |
236 | - $adminsWithoutActionPct = $adminsWithoutAction/$adminCount; |
|
236 | + $adminsWithoutActionPct = $adminsWithoutAction / $adminCount; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | // Combine the two arrays. We can't use array_merge here because |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | { |
57 | 57 | |
58 | 58 | $this->setUp($project); |
59 | - $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ]; |
|
59 | + $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"]; |
|
60 | 60 | $query = new SimpleRequest('query', $params); |
61 | 61 | $result = []; |
62 | 62 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | |
78 | 78 | $this->setUp($project); |
79 | - $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
79 | + $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"]; |
|
80 | 80 | $query = new SimpleRequest('query', $params); |
81 | 81 | $result = []; |
82 | 82 | |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | public function namespaces($project) |
102 | 102 | { |
103 | 103 | // Use cache if possible. |
104 | - $cacheItem = $this->cache->getItem('api.namespaces.' . $project); |
|
104 | + $cacheItem = $this->cache->getItem('api.namespaces.'.$project); |
|
105 | 105 | if ($cacheItem->isHit()) { |
106 | 106 | return $cacheItem->get(); |
107 | 107 | } |
108 | 108 | |
109 | 109 | $this->setUp($project); |
110 | - $query = new SimpleRequest('query', [ "meta"=>"siteinfo", "siprop"=>"namespaces" ]); |
|
110 | + $query = new SimpleRequest('query', ["meta"=>"siteinfo", "siprop"=>"namespaces"]); |
|
111 | 111 | $result = []; |
112 | 112 | |
113 | 113 | try { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | try { |
156 | 156 | $continue = true; |
157 | - $i=0; |
|
157 | + $i = 0; |
|
158 | 158 | while ($continue) { |
159 | 159 | $query = new SimpleRequest( |
160 | 160 | 'query', |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | } |
175 | 175 | if (is_array($apiret2)) { |
176 | 176 | foreach ($apiret2 as $u => $obj) { |
177 | - $groups= array(); |
|
177 | + $groups = array(); |
|
178 | 178 | if (in_array("sysop", $obj["groups"])) { |
179 | 179 | $groups[] = "A"; |
180 | 180 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $groups[] = "B"; |
183 | 183 | } |
184 | 184 | if (in_array("steward", $obj["groups"])) { |
185 | - $groups[] = "S" ; |
|
185 | + $groups[] = "S"; |
|
186 | 186 | } |
187 | 187 | if (in_array("checkuser", $obj["groups"])) { |
188 | 188 | $groups[] = "CU"; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | if (in_array("bot", $obj["groups"])) { |
194 | 194 | $groups[] = "Bot"; |
195 | 195 | } |
196 | - $result[ $obj["name"] ] = array( |
|
196 | + $result[$obj["name"]] = array( |
|
197 | 197 | "editcount" => $obj["editcount"], |
198 | 198 | "groups" => implode('/', $groups) |
199 | 199 | ); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | $i++; |
204 | - if ($i>20) { |
|
204 | + if ($i > 20) { |
|
205 | 205 | break; |
206 | 206 | } |
207 | 207 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $normalized = []; |
280 | 280 | if (isset($result['query']['normalized'])) { |
281 | 281 | array_map( |
282 | - function ($e) use (&$normalized) { |
|
282 | + function($e) use (&$normalized) { |
|
283 | 283 | $normalized[$e['to']] = $e['from']; |
284 | 284 | }, |
285 | 285 | $result['query']['normalized'] |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | ]; |
323 | 323 | |
324 | 324 | // get assessments for this page from the API |
325 | - $assessments = $this->massApi($params, $project, function ($data) { |
|
325 | + $assessments = $this->massApi($params, $project, function($data) { |
|
326 | 326 | return isset($data['pages'][0]['pageassessments']) ? $data['pages'][0]['pageassessments'] : []; |
327 | 327 | }, 'pacontinue')['pages']; |
328 | 328 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | $classAttrs = $config['class']['Unknown']; |
350 | 350 | $assessment['class']['value'] = '???'; |
351 | 351 | $assessment['class']['category'] = $classAttrs['category']; |
352 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". $classAttrs['badge']; |
|
352 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/".$classAttrs['badge']; |
|
353 | 353 | } else { |
354 | 354 | $classAttrs = $config['class'][$classValue]; |
355 | 355 | $assessment['class'] = [ |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | |
361 | 361 | // add full URL to badge icon |
362 | 362 | if ($classAttrs['badge'] !== '') { |
363 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/" . |
|
363 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". |
|
364 | 364 | $classAttrs['badge']; |
365 | 365 | } |
366 | 366 | |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | $query = FluentRequest::factory()->setAction('query')->setParams($requestData); |
485 | 485 | $innerPromise = $this->api->getRequestAsync($query); |
486 | 486 | |
487 | - $innerPromise->then(function ($result) use (&$data) { |
|
487 | + $innerPromise->then(function($result) use (&$data) { |
|
488 | 488 | // some failures come back as 200s, so we still resolve and let the outer function handle it |
489 | 489 | if (isset($result['error']) || !isset($result['query'])) { |
490 | 490 | return $data['promise']->resolve($data); |