@@ -16,39 +16,39 @@ discard block |
||
16 | 16 | { |
17 | 17 | $options = ['is_safe' => ['html']]; |
18 | 18 | return [ |
19 | - new \Twig_SimpleFunction('request_time', [ $this, 'requestTime' ], $options), |
|
20 | - new \Twig_SimpleFunction('memory_usage', [ $this, 'requestMemory' ], $options), |
|
21 | - new \Twig_SimpleFunction('year', [ $this, 'generateYear' ], $options), |
|
22 | - new \Twig_SimpleFunction('linkWiki', [ $this, 'linkToWiki' ], $options), |
|
23 | - new \Twig_SimpleFunction('linkWikiScript', [ $this, 'linkToWikiScript' ], $options), |
|
24 | - new \Twig_SimpleFunction('msgPrintExists', [ $this, 'intuitionMessagePrintExists' ], $options), |
|
25 | - new \Twig_SimpleFunction('msgExists', [ $this, 'intuitionMessageExists' ], $options), |
|
26 | - new \Twig_SimpleFunction('msg', [ $this, 'intuitionMessage' ], $options), |
|
27 | - new \Twig_SimpleFunction('msg_footer', [ $this, 'intuitionMessageFooter' ], $options), |
|
28 | - new \Twig_SimpleFunction('lang', [ $this, 'getLang' ], $options), |
|
29 | - new \Twig_SimpleFunction('langName', [ $this, 'getLangName' ], $options), |
|
30 | - new \Twig_SimpleFunction('allLangs', [ $this, 'getAllLangs' ]), |
|
31 | - new \Twig_SimpleFunction('isRTL', [ $this, 'intuitionIsRTL' ]), |
|
32 | - new \Twig_SimpleFunction('isRTLLang', [ $this, 'intuitionIsRTLLang' ]), |
|
33 | - new \Twig_SimpleFunction('shortHash', [ $this, 'gitShortHash' ]), |
|
34 | - new \Twig_SimpleFunction('hash', [ $this, 'gitHash' ]), |
|
35 | - new \Twig_SimpleFunction('enabled', [ $this, 'tabEnabled' ]), |
|
36 | - new \Twig_SimpleFunction('tools', [ $this, 'allTools' ]), |
|
37 | - new \Twig_SimpleFunction('color', [ $this, 'getColorList' ]), |
|
38 | - new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]), |
|
39 | - new \Twig_SimpleFunction('isSingleWiki', [ $this, 'isSingleWiki' ]), |
|
40 | - new \Twig_SimpleFunction('getReplagThreshold', [ $this, 'getReplagThreshold' ]), |
|
41 | - new \Twig_SimpleFunction('loadStylesheetsFromCDN', [ $this, 'loadStylesheetsFromCDN' ]), |
|
42 | - new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]), |
|
43 | - new \Twig_SimpleFunction('replag', [ $this, 'replag' ]), |
|
44 | - new \Twig_SimpleFunction('link', [ $this, 'link' ]), |
|
19 | + new \Twig_SimpleFunction('request_time', [$this, 'requestTime'], $options), |
|
20 | + new \Twig_SimpleFunction('memory_usage', [$this, 'requestMemory'], $options), |
|
21 | + new \Twig_SimpleFunction('year', [$this, 'generateYear'], $options), |
|
22 | + new \Twig_SimpleFunction('linkWiki', [$this, 'linkToWiki'], $options), |
|
23 | + new \Twig_SimpleFunction('linkWikiScript', [$this, 'linkToWikiScript'], $options), |
|
24 | + new \Twig_SimpleFunction('msgPrintExists', [$this, 'intuitionMessagePrintExists'], $options), |
|
25 | + new \Twig_SimpleFunction('msgExists', [$this, 'intuitionMessageExists'], $options), |
|
26 | + new \Twig_SimpleFunction('msg', [$this, 'intuitionMessage'], $options), |
|
27 | + new \Twig_SimpleFunction('msg_footer', [$this, 'intuitionMessageFooter'], $options), |
|
28 | + new \Twig_SimpleFunction('lang', [$this, 'getLang'], $options), |
|
29 | + new \Twig_SimpleFunction('langName', [$this, 'getLangName'], $options), |
|
30 | + new \Twig_SimpleFunction('allLangs', [$this, 'getAllLangs']), |
|
31 | + new \Twig_SimpleFunction('isRTL', [$this, 'intuitionIsRTL']), |
|
32 | + new \Twig_SimpleFunction('isRTLLang', [$this, 'intuitionIsRTLLang']), |
|
33 | + new \Twig_SimpleFunction('shortHash', [$this, 'gitShortHash']), |
|
34 | + new \Twig_SimpleFunction('hash', [$this, 'gitHash']), |
|
35 | + new \Twig_SimpleFunction('enabled', [$this, 'tabEnabled']), |
|
36 | + new \Twig_SimpleFunction('tools', [$this, 'allTools']), |
|
37 | + new \Twig_SimpleFunction('color', [$this, 'getColorList']), |
|
38 | + new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']), |
|
39 | + new \Twig_SimpleFunction('isSingleWiki', [$this, 'isSingleWiki']), |
|
40 | + new \Twig_SimpleFunction('getReplagThreshold', [$this, 'getReplagThreshold']), |
|
41 | + new \Twig_SimpleFunction('loadStylesheetsFromCDN', [$this, 'loadStylesheetsFromCDN']), |
|
42 | + new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']), |
|
43 | + new \Twig_SimpleFunction('replag', [$this, 'replag']), |
|
44 | + new \Twig_SimpleFunction('link', [$this, 'link']), |
|
45 | 45 | ]; |
46 | 46 | } |
47 | 47 | |
48 | 48 | public function requestTime($decimals = 3) |
49 | 49 | { |
50 | 50 | |
51 | - return number_format(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], $decimals); |
|
51 | + return number_format(microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'], $decimals); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function requestMemory() |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function linkToWiki($url, $page, $secondary = "") |
76 | 76 | { |
77 | - $link = $url . "/"; |
|
77 | + $link = $url."/"; |
|
78 | 78 | |
79 | 79 | if ($this->isWMFLabs()) { |
80 | 80 | $link .= "wiki/"; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | public function linkToWikiScript($url, $secondary) |
93 | 93 | { |
94 | - $link = $url . "/"; |
|
94 | + $link = $url."/"; |
|
95 | 95 | |
96 | 96 | if ($this->isWMFLabs()) { |
97 | 97 | $link .= "w/"; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | // TODO: refactor all intuition stuff so it can be used anywhere |
108 | 108 | public function intuitionMessageExists($message = "") |
109 | 109 | { |
110 | - return $this->getIntuition()->msgExists($message, [ "domain" => "xtools" ]); |
|
110 | + return $this->getIntuition()->msgExists($message, ["domain" => "xtools"]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | public function intuitionMessagePrintExists($message = "", $vars = []) |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | public function intuitionMessage($message = "", $vars = []) |
128 | 128 | { |
129 | - return $this->getIntuition()->msg($message, [ "domain" => "xtools", "variables" => $vars ]); |
|
129 | + return $this->getIntuition()->msg($message, ["domain" => "xtools", "variables" => $vars]); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | public function intuitionMessageFooter() |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function getAllLangs() |
156 | 156 | { |
157 | - $messageFiles = glob($this->container->getParameter("kernel.root_dir") . '/../i18n/*.json'); |
|
157 | + $messageFiles = glob($this->container->getParameter("kernel.root_dir").'/../i18n/*.json'); |
|
158 | 158 | |
159 | 159 | $languages = array_values(array_unique(array_map( |
160 | - function ($filename) { |
|
160 | + function($filename) { |
|
161 | 161 | return basename($filename, '.json'); |
162 | 162 | }, |
163 | 163 | $messageFiles |
@@ -214,41 +214,41 @@ discard block |
||
214 | 214 | public static function getColorList($num = false) |
215 | 215 | { |
216 | 216 | $colors = [ |
217 | - 0 => '#Cc0000',# '#FF005A', #red '#FF5555', |
|
217 | + 0 => '#Cc0000', # '#FF005A', #red '#FF5555', |
|
218 | 218 | 1 => '#F7b7b7', |
219 | - 2 => '#5c8d20',# '#008800', #green'#55FF55', |
|
219 | + 2 => '#5c8d20', # '#008800', #green'#55FF55', |
|
220 | 220 | 3 => '#85eD82', |
221 | 221 | 4 => '#2E97E0', # blue |
222 | 222 | 5 => '#B9E3F9', |
223 | - 6 => '#e1711d', # orange |
|
223 | + 6 => '#e1711d', # orange |
|
224 | 224 | 7 => '#ffc04c', |
225 | 225 | 8 => '#FDFF98', # yellow |
226 | 226 | 9 => '#5555FF', |
227 | 227 | 10 => '#55FFFF', |
228 | - 11 => '#0000C0', # |
|
229 | - 12 => '#008800', # green |
|
228 | + 11 => '#0000C0', # |
|
229 | + 12 => '#008800', # green |
|
230 | 230 | 13 => '#00C0C0', |
231 | - 14 => '#FFAFAF', # rosé |
|
232 | - 15 => '#808080', # gray |
|
231 | + 14 => '#FFAFAF', # rosé |
|
232 | + 15 => '#808080', # gray |
|
233 | 233 | 16 => '#00C000', |
234 | 234 | 17 => '#404040', |
235 | - 18 => '#C0C000', # green |
|
235 | + 18 => '#C0C000', # green |
|
236 | 236 | 19 => '#C000C0', |
237 | - 100 => '#75A3D1', # blue |
|
238 | - 101 => '#A679D2', # purple |
|
237 | + 100 => '#75A3D1', # blue |
|
238 | + 101 => '#A679D2', # purple |
|
239 | 239 | 102 => '#660000', |
240 | 240 | 103 => '#000066', |
241 | - 104 => '#FAFFAF', # caramel |
|
241 | + 104 => '#FAFFAF', # caramel |
|
242 | 242 | 105 => '#408345', |
243 | 243 | 106 => '#5c8d20', |
244 | - 107 => '#e1711d', # red |
|
245 | - 108 => '#94ef2b', # light green |
|
246 | - 109 => '#756a4a', # brown |
|
244 | + 107 => '#e1711d', # red |
|
245 | + 108 => '#94ef2b', # light green |
|
246 | + 109 => '#756a4a', # brown |
|
247 | 247 | 110 => '#6f1dab', |
248 | 248 | 111 => '#301e30', |
249 | 249 | 112 => '#5c9d96', |
250 | - 113 => '#a8cd8c', # earth green |
|
251 | - 114 => '#f2b3f1', # light purple |
|
250 | + 113 => '#a8cd8c', # earth green |
|
251 | + 114 => '#f2b3f1', # light purple |
|
252 | 252 | 115 => '#9b5828', |
253 | 253 | 118 => '#99FFFF', |
254 | 254 | 119 => '#99BBFF', |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | 446 => '#06DCFB', |
270 | 270 | 447 => '#892EE4', |
271 | 271 | 460 => '#99FF66', |
272 | - 461 => '#99CC66', # green |
|
273 | - 470 => '#CCCC33', # ocker |
|
272 | + 461 => '#99CC66', # green |
|
273 | + 470 => '#CCCC33', # ocker |
|
274 | 274 | 471 => '#CCFF33', |
275 | 275 | 480 => '#6699FF', |
276 | 276 | 481 => '#66FFFF', |
@@ -285,18 +285,18 @@ discard block |
||
285 | 285 | 1198 => '#FF34B3', |
286 | 286 | 1199 => '#8B1C62', |
287 | 287 | |
288 | - '#61a9f3',# blue |
|
289 | - '#f381b9',# pink |
|
288 | + '#61a9f3', # blue |
|
289 | + '#f381b9', # pink |
|
290 | 290 | '#61E3A9', |
291 | 291 | '#D56DE2', |
292 | 292 | '#85eD82', |
293 | 293 | '#F7b7b7', |
294 | 294 | '#CFDF49', |
295 | 295 | '#88d8f2', |
296 | - '#07AF7B',# green |
|
296 | + '#07AF7B', # green |
|
297 | 297 | '#B9E3F9', |
298 | 298 | '#FFF3AD', |
299 | - '#EF606A',# red |
|
299 | + '#EF606A', # red |
|
300 | 300 | '#EC8833', |
301 | 301 | '#FFF100', |
302 | 302 | '#87C9A5', |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | public function getFilters() |
414 | 414 | { |
415 | 415 | return [ |
416 | - new \Twig_SimpleFilter('capitalize_first', [ $this, 'capitalizeFirst' ]), |
|
416 | + new \Twig_SimpleFilter('capitalize_first', [$this, 'capitalizeFirst']), |
|
417 | 417 | ]; |
418 | 418 | } |
419 | 419 |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | 'username' => $username, |
57 | 57 | ]); |
58 | 58 | } elseif ($projectQuery != "") { |
59 | - return $this->redirectToRoute("PagesProject", [ 'project'=>$projectQuery ]); |
|
59 | + return $this->redirectToRoute("PagesProject", ['project'=>$projectQuery]); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // set default wiki so we can populate the namespace selector |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | // show error message and redirect back to default project |
75 | 75 | $this->addFlash("notice", [$e->getMessage()]); |
76 | 76 | $project = $this->container->getParameter('default_project'); |
77 | - return $this->redirectToRoute("PagesProject", [ 'project'=>$project ]); |
|
77 | + return $this->redirectToRoute("PagesProject", ['project'=>$project]); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Otherwise fall through. |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | JOIN $revisionTable ON page_id = rev_page |
184 | 184 | $paJoin |
185 | 185 | WHERE $whereRev AND rev_parent_id = '0' $namespaceConditionRev $redirectCondition |
186 | - " . ($hasPageAssessments ? "GROUP BY rev_page" : "") . " |
|
186 | + ".($hasPageAssessments ? "GROUP BY rev_page" : "")." |
|
187 | 187 | ) |
188 | 188 | |
189 | 189 | UNION |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | if ($total < 1) { |
270 | - $this->addFlash("notice", [ "noresult", $username ]); |
|
271 | - return $this->redirectToRoute("PagesProject", [ "project"=>$project ]); |
|
270 | + $this->addFlash("notice", ["noresult", $username]); |
|
271 | + return $this->redirectToRoute("PagesProject", ["project"=>$project]); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | ksort($pagesByNamespaceByDate); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'username' => $username, |
49 | 49 | ]); |
50 | 50 | } elseif ($project != "") { |
51 | - return $this->redirectToRoute("TopEditsResults", [ 'project'=>$project ]); |
|
51 | + return $this->redirectToRoute("TopEditsResults", ['project'=>$project]); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | // set default wiki so we can populate the namespace selector |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // show error message and redirect back to default project |
67 | 67 | $this->addFlash("notice", [$e->getMessage()]); |
68 | 68 | $project = $this->container->getParameter('default_project'); |
69 | - return $this->redirectToRoute("PagesProject", [ 'project'=>$project ]); |
|
69 | + return $this->redirectToRoute("PagesProject", ['project'=>$project]); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | return $this->render('topedits/index.html.twig', [ |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $editData = $conn->executeQuery($query, $params)->fetchAll(); |
120 | 120 | |
121 | 121 | // Get page info about these 100 pages, so we can use their display title. |
122 | - $titles = array_map(function ($e) { |
|
122 | + $titles = array_map(function($e) { |
|
123 | 123 | return $e['page_title']; |
124 | 124 | }, $editData); |
125 | 125 | /** @var ApiHelper $apiHelper */ |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | public function groups($project, $username) |
56 | 56 | { |
57 | 57 | $this->setUp($project); |
58 | - $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ]; |
|
58 | + $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"]; |
|
59 | 59 | $query = new SimpleRequest('query', $params); |
60 | 60 | $result = []; |
61 | 61 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function globalGroups($project, $username) |
75 | 75 | { |
76 | 76 | $this->setUp($project); |
77 | - $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
77 | + $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"]; |
|
78 | 78 | $query = new SimpleRequest('query', $params); |
79 | 79 | $result = []; |
80 | 80 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | $this->setUp($project); |
107 | - $query = new SimpleRequest('query', [ "meta"=>"siteinfo", "siprop"=>"namespaces" ]); |
|
107 | + $query = new SimpleRequest('query', ["meta"=>"siteinfo", "siprop"=>"namespaces"]); |
|
108 | 108 | $namespaces = []; |
109 | 109 | |
110 | 110 | try { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $groups[] = "B"; |
161 | 161 | } |
162 | 162 | if (in_array("steward", $admin["groups"])) { |
163 | - $groups[] = "S" ; |
|
163 | + $groups[] = "S"; |
|
164 | 164 | } |
165 | 165 | if (in_array("checkuser", $admin["groups"])) { |
166 | 166 | $groups[] = "CU"; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | if (in_array("bot", $admin["groups"])) { |
172 | 172 | $groups[] = "Bot"; |
173 | 173 | } |
174 | - $result[ $admin["name"] ] = [ |
|
174 | + $result[$admin["name"]] = [ |
|
175 | 175 | "groups" => implode('/', $groups) |
176 | 176 | ]; |
177 | 177 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $normalized = []; |
247 | 247 | if (isset($result['query']['normalized'])) { |
248 | 248 | array_map( |
249 | - function ($e) use (&$normalized) { |
|
249 | + function($e) use (&$normalized) { |
|
250 | 250 | $normalized[$e['to']] = $e['from']; |
251 | 251 | }, |
252 | 252 | $result['query']['normalized'] |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | ]; |
293 | 293 | |
294 | 294 | // get assessments for this page from the API |
295 | - $assessments = $this->massApi($params, $project, function ($data) { |
|
295 | + $assessments = $this->massApi($params, $project, function($data) { |
|
296 | 296 | return isset($data['pages'][0]['pageassessments']) ? $data['pages'][0]['pageassessments'] : []; |
297 | 297 | }, 'pacontinue')['pages']; |
298 | 298 | |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | $classAttrs = $config['class']['Unknown']; |
317 | 317 | $assessment['class']['value'] = '???'; |
318 | 318 | $assessment['class']['category'] = $classAttrs['category']; |
319 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". $classAttrs['badge']; |
|
319 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/".$classAttrs['badge']; |
|
320 | 320 | } else { |
321 | 321 | $classAttrs = $config['class'][$classValue]; |
322 | 322 | $assessment['class'] = [ |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | |
328 | 328 | // add full URL to badge icon |
329 | 329 | if ($classAttrs['badge'] !== '') { |
330 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/" . |
|
330 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". |
|
331 | 331 | $classAttrs['badge']; |
332 | 332 | } |
333 | 333 | |
@@ -376,9 +376,9 @@ discard block |
||
376 | 376 | $config = $this->getAssessmentsConfig(); |
377 | 377 | |
378 | 378 | if (isset($config[$project]['class'][$class])) { |
379 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class'][$class]['badge']; |
|
379 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class'][$class]['badge']; |
|
380 | 380 | } elseif (isset($config[$project]['class']['Unknown'])) { |
381 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class']['Unknown']['badge']; |
|
381 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class']['Unknown']['badge']; |
|
382 | 382 | } else { |
383 | 383 | return ""; |
384 | 384 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | $query = FluentRequest::factory()->setAction('query')->setParams($requestData); |
472 | 472 | $innerPromise = $this->api->getRequestAsync($query); |
473 | 473 | |
474 | - $innerPromise->then(function ($result) use (&$data) { |
|
474 | + $innerPromise->then(function($result) use (&$data) { |
|
475 | 475 | // some failures come back as 200s, so we still resolve and let the outer function handle it |
476 | 476 | if (isset($result['error']) || !isset($result['query'])) { |
477 | 477 | return $data['promise']->resolve($data); |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | $username = $request->query->get('username'); |
64 | 64 | |
65 | 65 | if (($project || $queryProject) && $username) { |
66 | - $routeParams = [ 'project'=>($project ?: $queryProject), 'username' => $username ]; |
|
66 | + $routeParams = ['project'=>($project ?: $queryProject), 'username' => $username]; |
|
67 | 67 | return $this->redirectToRoute("EditCounterResult", $routeParams); |
68 | 68 | } elseif (!$project && $queryProject) { |
69 | - return $this->redirectToRoute("EditCounterProject", [ 'project'=>$queryProject ]); |
|
69 | + return $this->redirectToRoute("EditCounterProject", ['project'=>$queryProject]); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $this->init($project); |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | 'rev_small' => $revisionCounts['small'], |
172 | 172 | 'rev_large' => $revisionCounts['large'], |
173 | 173 | 'with_comments' => $revisionCounts['with_comments'], |
174 | - 'without_comments' => $revisionCounts['live'] - $revisionCounts['with_comments'], |
|
174 | + 'without_comments' => $revisionCounts['live']-$revisionCounts['with_comments'], |
|
175 | 175 | 'minor_edits' => $revisionCounts['minor_edits'], |
176 | - 'nonminor_edits' => $revisionCounts['live'] - $revisionCounts['minor_edits'], |
|
176 | + 'nonminor_edits' => $revisionCounts['live']-$revisionCounts['minor_edits'], |
|
177 | 177 | 'auto_edits_total' => array_sum($automatedEditsSummary), |
178 | 178 | |
179 | 179 | // Page counts. |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | // Create the query we're going to run against the meta database |
62 | 62 | $wikiQuery = $this->client->createQueryBuilder(); |
63 | 63 | $wikiQuery |
64 | - ->select([ 'dbName', 'name', 'url', 'lang' ]) |
|
64 | + ->select(['dbName', 'name', 'url', 'lang']) |
|
65 | 65 | ->from('wiki') |
66 | 66 | ->where($wikiQuery->expr()->eq('dbname', ':project')) |
67 | 67 | // The meta database will have the project's URL stored as https://en.wikipedia.org |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $this->dbName = $dbName; |
98 | 98 | $this->url = $url; |
99 | 99 | |
100 | - return [ 'dbName' => $dbName, 'wikiName' => $wikiName, 'url' => $url, 'lang' => $lang ]; |
|
100 | + return ['dbName' => $dbName, 'wikiName' => $wikiName, 'url' => $url, 'lang' => $lang]; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | public function allProjects() |
107 | 107 | { |
108 | 108 | $wikiQuery = $this->client->createQueryBuilder(); |
109 | - $wikiQuery->select([ 'dbName', 'name', 'url' ])->from('wiki'); |
|
109 | + $wikiQuery->select(['dbName', 'name', 'url'])->from('wiki'); |
|
110 | 110 | $stmt = $wikiQuery->execute(); |
111 | 111 | $out = $stmt->fetchAll(); |
112 | 112 | return $out; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function allProjects() |
119 | 119 | { |
120 | 120 | $wikiQuery = $this->client->createQueryBuilder(); |
121 | - $wikiQuery->select([ 'dbName', 'name', 'url' ])->from('wiki'); |
|
121 | + $wikiQuery->select(['dbName', 'name', 'url'])->from('wiki'); |
|
122 | 122 | $stmt = $wikiQuery->execute(); |
123 | 123 | $out = $stmt->fetchAll(); |
124 | 124 | return $out; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | { |
60 | 60 | $topEditCounts = []; |
61 | 61 | foreach ($this->labsHelper->allProjects() as $project) { |
62 | - $cacheKey = 'topprojects.' . $project['dbName'] . '.' . $username; |
|
62 | + $cacheKey = 'topprojects.'.$project['dbName'].'.'.$username; |
|
63 | 63 | if ($this->cacheHas($cacheKey)) { |
64 | 64 | $total = $this->cacheGet($cacheKey); |
65 | 65 | } else { |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | } |
76 | 76 | $topEditCounts[$project['dbName']] = array_merge($project, ['total' => $total]); |
77 | 77 | } |
78 | - uasort($topEditCounts, function ($a, $b) { |
|
79 | - return $b['total'] - $a['total']; |
|
78 | + uasort($topEditCounts, function($a, $b) { |
|
79 | + return $b['total']-$a['total']; |
|
80 | 80 | }); |
81 | 81 | return array_slice($topEditCounts, 0, $numProjects); |
82 | 82 | } |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | $revisionCounts = array_combine( |
149 | - array_map(function ($e) { |
|
149 | + array_map(function($e) { |
|
150 | 150 | return $e['source']; |
151 | 151 | }, $results), |
152 | - array_map(function ($e) { |
|
152 | + array_map(function($e) { |
|
153 | 153 | return $e['value']; |
154 | 154 | }, $results) |
155 | 155 | ); |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | // Count the number of days, accounting for when there's zero or one edit. |
158 | 158 | $revisionCounts['days'] = 0; |
159 | 159 | if (isset($revisionCounts['first']) && isset($revisionCounts['last'])) { |
160 | - $editingTimeInSeconds = ceil($revisionCounts['last'] - $revisionCounts['first']); |
|
161 | - $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds/(60*60*24) : 1; |
|
160 | + $editingTimeInSeconds = ceil($revisionCounts['last']-$revisionCounts['first']); |
|
161 | + $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds / (60 * 60 * 24) : 1; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Format the first and last dates. |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | : 0; |
171 | 171 | |
172 | 172 | // Sum deleted and live to make the total. |
173 | - $revisionCounts['total'] = $revisionCounts['deleted'] + $revisionCounts['live']; |
|
173 | + $revisionCounts['total'] = $revisionCounts['deleted']+$revisionCounts['live']; |
|
174 | 174 | |
175 | 175 | // Calculate the average number of live edits per day. |
176 | 176 | $revisionCounts['avg_per_day'] = round( |
@@ -214,16 +214,16 @@ discard block |
||
214 | 214 | $results = $resultQuery->fetchAll(); |
215 | 215 | |
216 | 216 | $pageCounts = array_combine( |
217 | - array_map(function ($e) { |
|
217 | + array_map(function($e) { |
|
218 | 218 | return $e['source']; |
219 | 219 | }, $results), |
220 | - array_map(function ($e) { |
|
220 | + array_map(function($e) { |
|
221 | 221 | return $e['value']; |
222 | 222 | }, $results) |
223 | 223 | ); |
224 | 224 | |
225 | 225 | // Total created. |
226 | - $pageCounts['created'] = $pageCounts['created-live'] + $pageCounts['created-deleted']; |
|
226 | + $pageCounts['created'] = $pageCounts['created-live']+$pageCounts['created-deleted']; |
|
227 | 227 | |
228 | 228 | // Calculate the average number of edits per page. |
229 | 229 | $pageCounts['edits_per_page'] = 0; |
@@ -252,17 +252,17 @@ discard block |
||
252 | 252 | $resultQuery->execute(); |
253 | 253 | $results = $resultQuery->fetchAll(); |
254 | 254 | $logCounts = array_combine( |
255 | - array_map(function ($e) { |
|
255 | + array_map(function($e) { |
|
256 | 256 | return $e['source']; |
257 | 257 | }, $results), |
258 | - array_map(function ($e) { |
|
258 | + array_map(function($e) { |
|
259 | 259 | return $e['value']; |
260 | 260 | }, $results) |
261 | 261 | ); |
262 | 262 | |
263 | 263 | // Make sure there is some value for each of the wanted counts. |
264 | 264 | $requiredCounts = [ |
265 | - 'thanks-thank', 'review-approve', 'patrol-patrol','block-block', 'block-unblock', |
|
265 | + 'thanks-thank', 'review-approve', 'patrol-patrol', 'block-block', 'block-unblock', |
|
266 | 266 | 'protect-protect', 'protect-unprotect', 'delete-delete', 'delete-revision', |
267 | 267 | 'delete-restore', 'import-import', 'upload-upload', 'upload-overwrite', |
268 | 268 | ]; |
@@ -273,9 +273,9 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | // Merge approvals together. |
276 | - $logCounts['review-approve'] = $logCounts['review-approve'] + |
|
277 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + |
|
278 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
276 | + $logCounts['review-approve'] = $logCounts['review-approve']+ |
|
277 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ |
|
278 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
279 | 279 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); |
280 | 280 | |
281 | 281 | // Add Commons upload count, if applicable. |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | { |
302 | 302 | $userId = $this->getUserId($username); |
303 | 303 | $sql = "SELECT page_namespace, count(rev_id) AS total |
304 | - FROM ".$this->labsHelper->getTable('revision') ." r |
|
304 | + FROM ".$this->labsHelper->getTable('revision')." r |
|
305 | 305 | JOIN ".$this->labsHelper->getTable('page')." p on r.rev_page = p.page_id |
306 | 306 | WHERE r.rev_user = :id GROUP BY page_namespace"; |
307 | 307 | $resultQuery = $this->replicas->prepare($sql); |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | $resultQuery->execute(); |
310 | 310 | $results = $resultQuery->fetchAll(); |
311 | 311 | $namespaceTotals = array_combine( |
312 | - array_map(function ($e) { |
|
312 | + array_map(function($e) { |
|
313 | 313 | return $e['page_namespace']; |
314 | 314 | }, $results), |
315 | - array_map(function ($e) { |
|
315 | + array_map(function($e) { |
|
316 | 316 | return $e['total']; |
317 | 317 | }, $results) |
318 | 318 | ); |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | $sql = |
338 | 338 | "SELECT rev_id, rev_comment, rev_timestamp, rev_minor_edit, rev_deleted, " |
339 | 339 | . " rev_len, rev_parent_id, page_title " |
340 | - . " FROM " . $this->labsHelper->getTable('revision', $project['dbName']) |
|
341 | - . " JOIN " . $this->labsHelper->getTable('page', $project['dbName']) |
|
340 | + . " FROM ".$this->labsHelper->getTable('revision', $project['dbName']) |
|
341 | + . " JOIN ".$this->labsHelper->getTable('page', $project['dbName']) |
|
342 | 342 | . " ON (rev_page = page_id)" |
343 | 343 | . " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username" |
344 | 344 | . " ORDER BY rev_timestamp DESC" |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | continue; |
354 | 354 | } |
355 | 355 | $revsWithProject = array_map( |
356 | - function (&$item) use ($project) { |
|
356 | + function(&$item) use ($project) { |
|
357 | 357 | $item['project_name'] = $project['name']; |
358 | 358 | $item['project_url'] = $project['url']; |
359 | 359 | $item['project_db_name'] = $project['dbName']; |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | ); |
364 | 364 | $allRevisions = array_merge($allRevisions, $revsWithProject); |
365 | 365 | } |
366 | - usort($allRevisions, function ($a, $b) { |
|
367 | - return $b['rev_timestamp'] - $a['rev_timestamp']; |
|
366 | + usort($allRevisions, function($a, $b) { |
|
367 | + return $b['rev_timestamp']-$a['rev_timestamp']; |
|
368 | 368 | }); |
369 | 369 | return array_slice($allRevisions, 0, $contribCount); |
370 | 370 | } |
@@ -386,8 +386,8 @@ discard block |
||
386 | 386 | . " MONTH(rev_timestamp) AS `month`," |
387 | 387 | . " page_namespace," |
388 | 388 | . " COUNT(rev_id) AS `count` " |
389 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
390 | - . " JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" |
|
389 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
390 | + . " JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)" |
|
391 | 391 | . " WHERE rev_user_text = :username" |
392 | 392 | . " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace " |
393 | 393 | . " ORDER BY rev_timestamp DESC"; |
@@ -443,10 +443,10 @@ discard block |
||
443 | 443 | . " SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4) AS `year`," |
444 | 444 | . " page_namespace," |
445 | 445 | . " COUNT(rev_id) AS `count` " |
446 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
447 | - . " JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" . |
|
448 | - " WHERE rev_user_text = :username" . |
|
449 | - " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace " . |
|
446 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
447 | + . " JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)". |
|
448 | + " WHERE rev_user_text = :username". |
|
449 | + " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace ". |
|
450 | 450 | " ORDER BY rev_timestamp DESC "; |
451 | 451 | $resultQuery = $this->replicas->prepare($sql); |
452 | 452 | $resultQuery->bindParam(":username", $username); |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | . " DAYOFWEEK(rev_timestamp) AS `y`, " |
488 | 488 | . " $xCalc AS `x`, " |
489 | 489 | . " COUNT(rev_id) AS `r` " |
490 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
490 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
491 | 491 | . " WHERE rev_user_text = :username" |
492 | 492 | . " GROUP BY DAYOFWEEK(rev_timestamp), $xCalc " |
493 | 493 | . " "; |