@@ -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,24 +14,24 @@ 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('user_log_link', [ $this, 'userLogLink' ], $options), |
|
29 | - new Twig_SimpleFunction('group_link', [ $this, 'groupLink' ], $options), |
|
30 | - new Twig_SimpleFunction('wiki_history_link', [ $this, 'wikiHistoryLink' ], $options), |
|
31 | - new Twig_SimpleFunction('wiki_log_link', [ $this, 'wikiLogLink' ], $options), |
|
32 | - new Twig_SimpleFunction('pageviews_links', [ $this, 'pageviewsLinks' ], $options), |
|
33 | - new Twig_SimpleFunction('diff_link', [ $this, 'diffLink' ], $options), |
|
34 | - 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('user_log_link', [$this, 'userLogLink'], $options), |
|
29 | + new Twig_SimpleFunction('group_link', [$this, 'groupLink'], $options), |
|
30 | + new Twig_SimpleFunction('wiki_history_link', [$this, 'wikiHistoryLink'], $options), |
|
31 | + new Twig_SimpleFunction('wiki_log_link', [$this, 'wikiLogLink'], $options), |
|
32 | + new Twig_SimpleFunction('pageviews_links', [$this, 'pageviewsLinks'], $options), |
|
33 | + new Twig_SimpleFunction('diff_link', [$this, 'diffLink'], $options), |
|
34 | + new Twig_SimpleFunction('perma_link', [$this, 'permaLink'], $options), |
|
35 | 35 | ]; |
36 | 36 | } |
37 | 37 | |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | public function getFilters() |
224 | 224 | { |
225 | 225 | return [ |
226 | - new \Twig_SimpleFilter('percent_format', [ $this, 'percentFormat' ]), |
|
227 | - new \Twig_SimpleFilter('diff_format', [ $this, 'diffFormat' ], [ 'is_safe' => [ 'html' ] ]), |
|
228 | - new \Twig_SimpleFilter('wikify_comment', [ $this, 'wikifyComment' ], [ 'is_safe' => [ 'html' ] ]), |
|
226 | + new \Twig_SimpleFilter('percent_format', [$this, 'percentFormat']), |
|
227 | + new \Twig_SimpleFilter('diff_format', [$this, 'diffFormat'], ['is_safe' => ['html']]), |
|
228 | + new \Twig_SimpleFilter('wikify_comment', [$this, 'wikifyComment'], ['is_safe' => ['html']]), |
|
229 | 229 | ]; |
230 | 230 | } |
231 | 231 | |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | if (!$denominator) { |
262 | 262 | $quotient = $numerator; |
263 | 263 | } else { |
264 | - $quotient = ( $numerator / $denominator ) * 100; |
|
264 | + $quotient = ($numerator / $denominator) * 100; |
|
265 | 265 | } |
266 | 266 | |
267 | - return round($quotient, $precision) . '%'; |
|
267 | + return round($quotient, $precision).'%'; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | if ($isSection) { |
283 | 283 | $sectionTitle = $sectionMatch[1][0]; |
284 | 284 | $sectionTitleLink = str_replace(' ', '_', $sectionTitle); |
285 | - $sectionWikitext = "<a target='_blank' href='$projectUrl/wiki/$title#$sectionTitleLink'>→</a>" . |
|
285 | + $sectionWikitext = "<a target='_blank' href='$projectUrl/wiki/$title#$sectionTitleLink'>→</a>". |
|
286 | 286 | "<em class='text-muted'>$sectionTitle:</em> "; |
287 | 287 | $wikitext = str_replace($sectionMatch[0][0], $sectionWikitext, $wikitext); |
288 | 288 | } |
@@ -52,6 +52,9 @@ discard block |
||
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | + /** |
|
56 | + * @param string $username |
|
57 | + */ |
|
55 | 58 | public function groups($project, $username) |
56 | 59 | { |
57 | 60 | |
@@ -72,6 +75,9 @@ discard block |
||
72 | 75 | return $result; |
73 | 76 | } |
74 | 77 | |
78 | + /** |
|
79 | + * @param string $username |
|
80 | + */ |
|
75 | 81 | public function globalGroups($project, $username) |
76 | 82 | { |
77 | 83 |
@@ -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 { |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $groups[] = "B"; |
167 | 167 | } |
168 | 168 | if (in_array("steward", $admin["groups"])) { |
169 | - $groups[] = "S" ; |
|
169 | + $groups[] = "S"; |
|
170 | 170 | } |
171 | 171 | if (in_array("checkuser", $admin["groups"])) { |
172 | 172 | $groups[] = "CU"; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | if (in_array("bot", $admin["groups"])) { |
178 | 178 | $groups[] = "Bot"; |
179 | 179 | } |
180 | - $result[ $admin["name"] ] = [ |
|
180 | + $result[$admin["name"]] = [ |
|
181 | 181 | "editcount" => $admin["editcount"], |
182 | 182 | "groups" => implode('/', $groups) |
183 | 183 | ]; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $normalized = []; |
254 | 254 | if (isset($result['query']['normalized'])) { |
255 | 255 | array_map( |
256 | - function ($e) use (&$normalized) { |
|
256 | + function($e) use (&$normalized) { |
|
257 | 257 | $normalized[$e['to']] = $e['from']; |
258 | 258 | }, |
259 | 259 | $result['query']['normalized'] |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | ]; |
297 | 297 | |
298 | 298 | // get assessments for this page from the API |
299 | - $assessments = $this->massApi($params, $project, function ($data) { |
|
299 | + $assessments = $this->massApi($params, $project, function($data) { |
|
300 | 300 | return isset($data['pages'][0]['pageassessments']) ? $data['pages'][0]['pageassessments'] : []; |
301 | 301 | }, 'pacontinue')['pages']; |
302 | 302 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $classAttrs = $config['class']['Unknown']; |
324 | 324 | $assessment['class']['value'] = '???'; |
325 | 325 | $assessment['class']['category'] = $classAttrs['category']; |
326 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". $classAttrs['badge']; |
|
326 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/".$classAttrs['badge']; |
|
327 | 327 | } else { |
328 | 328 | $classAttrs = $config['class'][$classValue]; |
329 | 329 | $assessment['class'] = [ |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | |
335 | 335 | // add full URL to badge icon |
336 | 336 | if ($classAttrs['badge'] !== '') { |
337 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/" . |
|
337 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". |
|
338 | 338 | $classAttrs['badge']; |
339 | 339 | } |
340 | 340 | |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | $query = FluentRequest::factory()->setAction('query')->setParams($requestData); |
459 | 459 | $innerPromise = $this->api->getRequestAsync($query); |
460 | 460 | |
461 | - $innerPromise->then(function ($result) use (&$data) { |
|
461 | + $innerPromise->then(function($result) use (&$data) { |
|
462 | 462 | // some failures come back as 200s, so we still resolve and let the outer function handle it |
463 | 463 | if (isset($result['error']) || !isset($result['query'])) { |
464 | 464 | return $data['promise']->resolve($data); |
@@ -176,7 +176,7 @@ |
||
176 | 176 | |
177 | 177 | // Iterate over query results, loading each user id into the array |
178 | 178 | while ($row = $res->fetch()) { |
179 | - $adminIdArr[] = $row["user_id"] ; |
|
179 | + $adminIdArr[] = $row["user_id"]; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | // Set the query results to be useful in a sql statement. |