@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | 'username' => $username, |
69 | 69 | ]); |
70 | 70 | } elseif ($project != "") { |
71 | - return $this->redirectToRoute("TopEditsResults", [ 'project'=>$project ]); |
|
71 | + return $this->redirectToRoute("TopEditsResults", ['project'=>$project]); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // set default wiki so we can populate the namespace selector |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | // Get page info about these 100 pages, so we can use their display title. |
146 | - $titles = array_map(function ($e) { |
|
146 | + $titles = array_map(function($e) { |
|
147 | 147 | return $e['page_title']; |
148 | 148 | }, $editData); |
149 | 149 | /** @var ApiHelper $apiHelper */ |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $apiPath = $this->container->getParameter('api_path'); |
40 | 40 | |
41 | 41 | try { |
42 | - $this->api = MediawikiApi::newFromApiEndpoint($normalizedProject . $apiPath); |
|
42 | + $this->api = MediawikiApi::newFromApiEndpoint($normalizedProject.$apiPath); |
|
43 | 43 | } catch (Exception $e) { |
44 | 44 | // Do nothing... |
45 | 45 | } catch (FatalErrorException $e) { |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | throw new Exception("Unable to find project '$project'"); |
69 | 69 | } |
70 | 70 | |
71 | - $cacheKey = "siteinfo." . str_replace('/', '_', $normalizedProject); |
|
71 | + $cacheKey = "siteinfo.".str_replace('/', '_', $normalizedProject); |
|
72 | 72 | if ($this->cacheHas($cacheKey)) { |
73 | 73 | return $this->cacheGet($cacheKey); |
74 | 74 | } |
75 | 75 | |
76 | 76 | $this->setUp($normalizedProject); |
77 | - $params = [ 'meta'=>'siteinfo', 'siprop'=>'general|namespaces' ]; |
|
77 | + $params = ['meta'=>'siteinfo', 'siprop'=>'general|namespaces']; |
|
78 | 78 | $query = new SimpleRequest('query', $params); |
79 | 79 | |
80 | 80 | $result = [ |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | public function groups($project, $username) |
139 | 139 | { |
140 | 140 | $this->setUp($project); |
141 | - $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ]; |
|
141 | + $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"]; |
|
142 | 142 | $query = new SimpleRequest('query', $params); |
143 | 143 | $result = []; |
144 | 144 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | public function globalGroups($project, $username) |
158 | 158 | { |
159 | 159 | $this->setUp($project); |
160 | - $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
160 | + $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"]; |
|
161 | 161 | $query = new SimpleRequest('query', $params); |
162 | 162 | $result = []; |
163 | 163 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $groups[] = "B"; |
206 | 206 | } |
207 | 207 | if (in_array("steward", $admin["groups"])) { |
208 | - $groups[] = "S" ; |
|
208 | + $groups[] = "S"; |
|
209 | 209 | } |
210 | 210 | if (in_array("checkuser", $admin["groups"])) { |
211 | 211 | $groups[] = "CU"; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | if (in_array("bot", $admin["groups"])) { |
217 | 217 | $groups[] = "Bot"; |
218 | 218 | } |
219 | - $result[ $admin["name"] ] = [ |
|
219 | + $result[$admin["name"]] = [ |
|
220 | 220 | "groups" => implode('/', $groups) |
221 | 221 | ]; |
222 | 222 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $normalized = []; |
292 | 292 | if (isset($result['query']['normalized'])) { |
293 | 293 | array_map( |
294 | - function ($e) use (&$normalized) { |
|
294 | + function($e) use (&$normalized) { |
|
295 | 295 | $normalized[$e['to']] = $e['from']; |
296 | 296 | }, |
297 | 297 | $result['query']['normalized'] |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | ]; |
338 | 338 | |
339 | 339 | // get assessments for this page from the API |
340 | - $assessments = $this->massApi($params, $project, function ($data) { |
|
340 | + $assessments = $this->massApi($params, $project, function($data) { |
|
341 | 341 | return isset($data['pages'][0]['pageassessments']) ? $data['pages'][0]['pageassessments'] : []; |
342 | 342 | }, 'pacontinue')['pages']; |
343 | 343 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | $classAttrs = $config['class']['Unknown']; |
362 | 362 | $assessment['class']['value'] = '???'; |
363 | 363 | $assessment['class']['category'] = $classAttrs['category']; |
364 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". $classAttrs['badge']; |
|
364 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/".$classAttrs['badge']; |
|
365 | 365 | } else { |
366 | 366 | $classAttrs = $config['class'][$classValue]; |
367 | 367 | $assessment['class'] = [ |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | |
373 | 373 | // add full URL to badge icon |
374 | 374 | if ($classAttrs['badge'] !== '') { |
375 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/" . |
|
375 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". |
|
376 | 376 | $classAttrs['badge']; |
377 | 377 | } |
378 | 378 | |
@@ -421,9 +421,9 @@ discard block |
||
421 | 421 | $config = $this->getAssessmentsConfig(); |
422 | 422 | |
423 | 423 | if (isset($config[$project]['class'][$class])) { |
424 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class'][$class]['badge']; |
|
424 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class'][$class]['badge']; |
|
425 | 425 | } elseif (isset($config[$project]['class']['Unknown'])) { |
426 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class']['Unknown']['badge']; |
|
426 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class']['Unknown']['badge']; |
|
427 | 427 | } else { |
428 | 428 | return ""; |
429 | 429 | } |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | $query = FluentRequest::factory()->setAction('query')->setParams($requestData); |
517 | 517 | $innerPromise = $this->api->getRequestAsync($query); |
518 | 518 | |
519 | - $innerPromise->then(function ($result) use (&$data) { |
|
519 | + $innerPromise->then(function($result) use (&$data) { |
|
520 | 520 | // some failures come back as 200s, so we still resolve and let the outer function handle it |
521 | 521 | if (isset($result['error']) || !isset($result['query'])) { |
522 | 522 | return $data['promise']->resolve($data); |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | $username = $request->query->get('username'); |
28 | 28 | |
29 | 29 | if ($projectQuery != "" && $username != "") { |
30 | - return $this->redirectToRoute("AdminScoreResult", [ 'project'=>$projectQuery, 'username' => $username ]); |
|
30 | + return $this->redirectToRoute("AdminScoreResult", ['project'=>$projectQuery, 'username' => $username]); |
|
31 | 31 | } elseif ($projectQuery != "") { |
32 | - return $this->redirectToRoute("AdminScoreProject", [ 'project'=>$projectQuery ]); |
|
32 | + return $this->redirectToRoute("AdminScoreProject", ['project'=>$projectQuery]); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | // Otherwise fall through. |
@@ -67,20 +67,20 @@ discard block |
||
67 | 67 | $archiveTable = $lh->getTable("archive", $dbName); |
68 | 68 | |
69 | 69 | // MULTIPLIERS (to review) |
70 | - $ACCT_AGE_MULT = 1.25; # 0 if = 365 jours |
|
71 | - $EDIT_COUNT_MULT = 1.25; # 0 if = 10 000 |
|
72 | - $USER_PAGE_MULT = 0.1; # 0 if = |
|
70 | + $ACCT_AGE_MULT = 1.25; # 0 if = 365 jours |
|
71 | + $EDIT_COUNT_MULT = 1.25; # 0 if = 10 000 |
|
72 | + $USER_PAGE_MULT = 0.1; # 0 if = |
|
73 | 73 | $PATROLS_MULT = 1; # 0 if = |
74 | - $BLOCKS_MULT = 1.4; # 0 if = 10 |
|
74 | + $BLOCKS_MULT = 1.4; # 0 if = 10 |
|
75 | 75 | $AFD_MULT = 1.15; |
76 | - $RECENT_ACTIVITY_MULT = 0.9; # 0 if = |
|
76 | + $RECENT_ACTIVITY_MULT = 0.9; # 0 if = |
|
77 | 77 | $AIV_MULT = 1.15; |
78 | - $EDIT_SUMMARIES_MULT = 0.8; # 0 if = |
|
79 | - $NAMESPACES_MULT = 1.0; # 0 if = |
|
78 | + $EDIT_SUMMARIES_MULT = 0.8; # 0 if = |
|
79 | + $NAMESPACES_MULT = 1.0; # 0 if = |
|
80 | 80 | $PAGES_CREATED_LIVE_MULT = 1.4; # 0 if = |
81 | 81 | $PAGES_CREATED_ARCHIVE_MULT = 1.4; # 0 if = |
82 | - $RPP_MULT = 1.15; # 0 if = |
|
83 | - $USERRIGHTS_MULT = 0.75; # 0 if = |
|
82 | + $RPP_MULT = 1.15; # 0 if = |
|
83 | + $USERRIGHTS_MULT = 0.75; # 0 if = |
|
84 | 84 | |
85 | 85 | // Grab the connection to the replica database (which is separate from the above) |
86 | 86 | $conn = $this->get('doctrine')->getManager("replicas")->getConnection(); |
@@ -156,15 +156,15 @@ discard block |
||
156 | 156 | $now = new DateTime(); |
157 | 157 | $date = new DateTime($value); |
158 | 158 | $diff = $date->diff($now); |
159 | - $formula = 365*$diff->format("%y")+30*$diff->format("%m")+$diff->format("%d"); |
|
159 | + $formula = 365 * $diff->format("%y")+30 * $diff->format("%m")+$diff->format("%d"); |
|
160 | 160 | $value = $formula-365; |
161 | 161 | } |
162 | 162 | |
163 | 163 | if ($key == "id") { |
164 | 164 | $id = $value; |
165 | 165 | } else { |
166 | - $multiplierKey = strtoupper($row["source"] . "_MULT"); |
|
167 | - $multiplier = ( isset($$multiplierKey) ? $$multiplierKey : 1 ); |
|
166 | + $multiplierKey = strtoupper($row["source"]."_MULT"); |
|
167 | + $multiplier = (isset($$multiplierKey) ? $$multiplierKey : 1); |
|
168 | 168 | $score = max(min($value * $multiplier, 100), -100); |
169 | 169 | $master[$key]["mult"] = $multiplier; |
170 | 170 | $master[$key]["value"] = $value; |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | if ($id == 0) { |
177 | - $this->addFlash("notice", [ "noresult", $username ]); |
|
178 | - return $this->redirectToRoute("AdminScore", [ "project"=>$project ]); |
|
177 | + $this->addFlash("notice", ["noresult", $username]); |
|
178 | + return $this->redirectToRoute("AdminScore", ["project"=>$project]); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | return $this->render('adminscore/result.html.twig', [ |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | $article = $request->query->get('article'); |
56 | 56 | |
57 | 57 | if ($projectQuery != '' && $article != '') { |
58 | - return $this->redirectToRoute('ArticleInfoResult', [ 'project'=>$projectQuery, 'article' => $article ]); |
|
58 | + return $this->redirectToRoute('ArticleInfoResult', ['project'=>$projectQuery, 'article' => $article]); |
|
59 | 59 | } elseif ($article != '') { |
60 | - return $this->redirectToRoute('ArticleInfoProject', [ 'project'=>$projectQuery ]); |
|
60 | + return $this->redirectToRoute('ArticleInfoProject', ['project'=>$projectQuery]); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | return $this->render('articleInfo/index.html.twig', [ |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | 'url' => $basicInfo['fullurl'] |
103 | 103 | ]; |
104 | 104 | |
105 | - $this->pageInfo['watchers'] = ( isset($basicInfo['watchers']) ) ? $basicInfo['watchers'] : "< 30"; |
|
105 | + $this->pageInfo['watchers'] = (isset($basicInfo['watchers'])) ? $basicInfo['watchers'] : "< 30"; |
|
106 | 106 | |
107 | 107 | $pageProps = isset($basicInfo['pageprops']) ? $basicInfo['pageprops'] : []; |
108 | 108 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | */ |
165 | 165 | private function getRevCount() |
166 | 166 | { |
167 | - $query = "SELECT COUNT(*) AS count FROM " . $this->revisionTable |
|
168 | - . " WHERE rev_page = '" . $this->pageInfo['id'] . "'"; |
|
167 | + $query = "SELECT COUNT(*) AS count FROM ".$this->revisionTable |
|
168 | + . " WHERE rev_page = '".$this->pageInfo['id']."'"; |
|
169 | 169 | $res = $this->conn->query($query)->fetchAll(); |
170 | 170 | return $res[0]['count']; |
171 | 171 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | FROM $this->revisionTable |
198 | 198 | LEFT JOIN $userGroupsTable ON rev_user = ug_user |
199 | 199 | LEFT JOIN $userFromerGroupsTable ON rev_user = ufg_user |
200 | - WHERE rev_page = " . $this->pageInfo['id'] . " AND (ug_group = 'bot' OR ufg_group = 'bot') |
|
200 | + WHERE rev_page = ".$this->pageInfo['id']." AND (ug_group = 'bot' OR ufg_group = 'bot') |
|
201 | 201 | GROUP BY rev_user_text"; |
202 | 202 | $res = $this->conn->query($query)->fetchAll(); |
203 | 203 | |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | $sum = 0; |
207 | 207 | foreach ($res as $bot) { |
208 | 208 | $bots[$bot['username']] = [ |
209 | - 'count' => (int) $bot['count'], |
|
209 | + 'count' => (int)$bot['count'], |
|
210 | 210 | 'current' => $bot['current'] === 'bot' |
211 | 211 | ]; |
212 | 212 | $sum += $bot['count']; |
213 | 213 | } |
214 | 214 | |
215 | - uasort($bots, function ($a, $b) { |
|
216 | - return $b['count'] - $a['count']; |
|
215 | + uasort($bots, function($a, $b) { |
|
216 | + return $b['count']-$a['count']; |
|
217 | 217 | }); |
218 | 218 | |
219 | 219 | $this->pageInfo['general']['bot_revision_count'] = $sum; |
@@ -249,10 +249,10 @@ discard block |
||
249 | 249 | |
250 | 250 | if ($info['all'] > 1) { |
251 | 251 | // Number of seconds between first and last edit |
252 | - $secs = intval(strtotime($info['last']) - strtotime($info['first']) / $info['all']); |
|
252 | + $secs = intval(strtotime($info['last'])-strtotime($info['first']) / $info['all']); |
|
253 | 253 | |
254 | 254 | // Average time between edits (in days) |
255 | - $this->pageInfo['editors'][$editor]['atbe'] = $secs / ( 60 * 60 * 24 ); |
|
255 | + $this->pageInfo['editors'][$editor]['atbe'] = $secs / (60 * 60 * 24); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | if (count($info['sizes'])) { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | |
299 | 299 | // Transform to associative array by 'type' |
300 | 300 | foreach ($res as $row) { |
301 | - $data[$row['type'] . '_count'] = $row['value']; |
|
301 | + $data[$row['type'].'_count'] = $row['value']; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | return $data; |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $title = str_replace(' ', '_', $this->pageInfo['title']); |
315 | 315 | $query = "SELECT log_action, log_type, log_timestamp AS timestamp |
316 | 316 | FROM $loggingTable |
317 | - WHERE log_namespace = '" . $this->pageInfo['namespace'] . "' |
|
317 | + WHERE log_namespace = '".$this->pageInfo['namespace']."' |
|
318 | 318 | AND log_title = '$title' AND log_timestamp > 1 |
319 | 319 | AND log_type IN ('delete', 'move', 'protect', 'stable')"; |
320 | 320 | $events = $this->conn->query($query)->fetchAll(); |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | $conn = $this->container->get('doctrine')->getManager('replicas')->getConnection(); |
400 | 400 | $res = $conn->query($query)->fetchAll(); |
401 | 401 | |
402 | - $terms = array_map(function ($entry) { |
|
402 | + $terms = array_map(function($entry) { |
|
403 | 403 | return $entry['term']; |
404 | 404 | }, $res); |
405 | 405 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | 'prio' => 2, |
411 | 411 | 'name' => 'Wikidata', |
412 | 412 | 'notice' => "Label for language <em>$lang</em> is missing", // FIXME: i18n |
413 | - 'explanation' => "See: <a target='_blank' " . |
|
413 | + 'explanation' => "See: <a target='_blank' ". |
|
414 | 414 | "href='//www.wikidata.org/wiki/Help:Label'>Help:Label</a>", |
415 | 415 | ]; |
416 | 416 | } |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | 'prio' => 3, |
420 | 420 | 'name' => 'Wikidata', |
421 | 421 | 'notice' => "Description for language <em>$lang</em> is missing", // FIXME: i18n |
422 | - 'explanation' => "See: <a target='_blank' " . |
|
422 | + 'explanation' => "See: <a target='_blank' ". |
|
423 | 423 | "href='//www.wikidata.org/wiki/Help:Description'>Help:Description</a>", |
424 | 424 | ]; |
425 | 425 | } |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | $query = "SELECT rev_id, rev_parent_id, rev_user_text, rev_user, rev_timestamp, |
437 | 437 | rev_minor_edit, rev_len, rev_comment |
438 | 438 | FROM $this->revisionTable |
439 | - WHERE rev_page = '" . $this->pageInfo['id'] . "' AND rev_timestamp > 1 |
|
439 | + WHERE rev_page = '".$this->pageInfo['id']."' AND rev_timestamp > 1 |
|
440 | 440 | ORDER BY rev_timestamp"; |
441 | 441 | |
442 | 442 | $res = $this->conn->query($query)->fetchAll(); |
@@ -456,14 +456,14 @@ discard block |
||
456 | 456 | return $rev['rev_len']; |
457 | 457 | } |
458 | 458 | |
459 | - $lastRev = $this->pageHistory[$revIndex - 1]; |
|
459 | + $lastRev = $this->pageHistory[$revIndex-1]; |
|
460 | 460 | |
461 | 461 | // TODO: Remove once T101631 is resolved |
462 | 462 | // Treat as zero change in size if rev_len of previous edit is missing |
463 | 463 | if ($lastRev['rev_len'] === null) { |
464 | 464 | return 0; |
465 | 465 | } else { |
466 | - return $rev['rev_len'] - $lastRev['rev_len']; |
|
466 | + return $rev['rev_len']-$lastRev['rev_len']; |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | // The month of the first edit. Used as a comparison when building the per-month data |
485 | 485 | $firstEditMonth = strtotime(date('Y-m-01, 00:00', strtotime($firstEdit['rev_timestamp']))); |
486 | 486 | |
487 | - $lastEdit = $this->pageHistory[ $revisionCount - 1 ]; |
|
488 | - $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[ $revisionCount - 2 ]; |
|
487 | + $lastEdit = $this->pageHistory[$revisionCount-1]; |
|
488 | + $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[$revisionCount-2]; |
|
489 | 489 | |
490 | 490 | // Now we can start our master array. This one will be HUGE! |
491 | 491 | $lastEditSize = ($revisionCount > 1) |
492 | - ? $lastEdit['rev_len'] - $secondLastEdit['rev_len'] |
|
492 | + ? $lastEdit['rev_len']-$secondLastEdit['rev_len'] |
|
493 | 493 | : $lastEdit['rev_len']; |
494 | 494 | $data = [ |
495 | 495 | 'general' => [ |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | // Increment year and month counts for all edits |
587 | 587 | $data['year_count'][$timestamp['year']]['all']++; |
588 | 588 | $data['year_count'][$timestamp['year']]['months'][$timestamp['month']]['all']++; |
589 | - $data['year_count'][$timestamp['year']]['size'] = (int) $rev['rev_len']; |
|
589 | + $data['year_count'][$timestamp['year']]['size'] = (int)$rev['rev_len']; |
|
590 | 590 | |
591 | 591 | $editsThisMonth = $data['year_count'][$timestamp['year']]['months'][$timestamp['month']]['all']; |
592 | 592 | if ($editsThisMonth > $data['max_edits_per_month']) { |
@@ -630,9 +630,9 @@ discard block |
||
630 | 630 | } |
631 | 631 | |
632 | 632 | // determine if the next revision was a revert |
633 | - $nextRevision = isset($this->pageHistory[$i + 1]) ? $this->pageHistory[$i + 1] : null; |
|
633 | + $nextRevision = isset($this->pageHistory[$i+1]) ? $this->pageHistory[$i+1] : null; |
|
634 | 634 | $nextRevisionIsRevert = $nextRevision && |
635 | - $this->getDiffSize($i + 1) === -$diffSize && |
|
635 | + $this->getDiffSize($i+1) === -$diffSize && |
|
636 | 636 | $this->aeh->isRevert($nextRevision['rev_comment']); |
637 | 637 | |
638 | 638 | // don't count this edit as content removal if the next edit reverted it |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'quote/all.html.twig', |
112 | 112 | [ |
113 | 113 | 'base_dir' => realpath( |
114 | - $this->getParameter('kernel.root_dir') . '/..' |
|
114 | + $this->getParameter('kernel.root_dir').'/..' |
|
115 | 115 | ), |
116 | 116 | 'xtPage' => 'bash', |
117 | 117 | 'quotes' => $quotes, |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | 'quote/view.html.twig', |
161 | 161 | [ |
162 | 162 | 'base_dir' => realpath( |
163 | - $this->getParameter('kernel.root_dir') . '/..' |
|
163 | + $this->getParameter('kernel.root_dir').'/..' |
|
164 | 164 | ), |
165 | 165 | "xtPage" => "bash", |
166 | 166 | "text" => $text, |
@@ -155,7 +155,7 @@ |
||
155 | 155 | $archiveTable = $lh->getTable("archive", $dbName); |
156 | 156 | |
157 | 157 | $cond_begin = $start ? " AND rev_timestamp > :start " : null; |
158 | - $cond_end = $end ? " AND rev_timestamp < :end ": null; |
|
158 | + $cond_end = $end ? " AND rev_timestamp < :end " : null; |
|
159 | 159 | |
160 | 160 | foreach ($AEBTypes as $toolname => $check) { |
161 | 161 | $toolname = $dbh->quote($toolname, \PDO::PARAM_STR); |
@@ -14,25 +14,25 @@ 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), |
|
35 | - new Twig_SimpleFunction('edit_link', [ $this, 'editLink' ], $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 | + new Twig_SimpleFunction('edit_link', [$this, 'editLink'], $options), |
|
36 | 36 | ]; |
37 | 37 | } |
38 | 38 | |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | public function getFilters() |
245 | 245 | { |
246 | 246 | return [ |
247 | - new \Twig_SimpleFilter('diff_format', [ $this, 'diffFormat' ], [ 'is_safe' => [ 'html' ] ]), |
|
248 | - new \Twig_SimpleFilter('wikify_comment', [ $this, 'wikifyComment' ], [ 'is_safe' => [ 'html' ] ]), |
|
247 | + new \Twig_SimpleFilter('diff_format', [$this, 'diffFormat'], ['is_safe' => ['html']]), |
|
248 | + new \Twig_SimpleFilter('wikify_comment', [$this, 'wikifyComment'], ['is_safe' => ['html']]), |
|
249 | 249 | ]; |
250 | 250 | } |
251 | 251 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | if ($isSection) { |
285 | 285 | $sectionTitle = $sectionMatch[1][0]; |
286 | 286 | $sectionTitleLink = str_replace(' ', '_', $sectionTitle); |
287 | - $sectionWikitext = "<a target='_blank' href='$projectUrl/wiki/$title#$sectionTitleLink'>→</a>" . |
|
287 | + $sectionWikitext = "<a target='_blank' href='$projectUrl/wiki/$title#$sectionTitleLink'>→</a>". |
|
288 | 288 | "<em class='text-muted'>$sectionTitle:</em> "; |
289 | 289 | $wikitext = str_replace($sectionMatch[0][0], $sectionWikitext, $wikitext); |
290 | 290 | } |
@@ -16,37 +16,37 @@ 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('msgPrintExists', [ $this, 'intuitionMessagePrintExists' ], $options), |
|
23 | - new \Twig_SimpleFunction('msgExists', [ $this, 'intuitionMessageExists' ], $options), |
|
24 | - new \Twig_SimpleFunction('msg', [ $this, 'intuitionMessage' ], $options), |
|
25 | - new \Twig_SimpleFunction('lang', [ $this, 'getLang' ], $options), |
|
26 | - new \Twig_SimpleFunction('langName', [ $this, 'getLangName' ], $options), |
|
27 | - new \Twig_SimpleFunction('allLangs', [ $this, 'getAllLangs' ]), |
|
28 | - new \Twig_SimpleFunction('isRTL', [ $this, 'intuitionIsRTL' ]), |
|
29 | - new \Twig_SimpleFunction('isRTLLang', [ $this, 'intuitionIsRTLLang' ]), |
|
30 | - new \Twig_SimpleFunction('shortHash', [ $this, 'gitShortHash' ]), |
|
31 | - new \Twig_SimpleFunction('hash', [ $this, 'gitHash' ]), |
|
32 | - new \Twig_SimpleFunction('enabled', [ $this, 'tabEnabled' ]), |
|
33 | - new \Twig_SimpleFunction('tools', [ $this, 'allTools' ]), |
|
34 | - new \Twig_SimpleFunction('color', [ $this, 'getColorList' ]), |
|
35 | - new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]), |
|
36 | - new \Twig_SimpleFunction('isSingleWiki', [ $this, 'isSingleWiki' ]), |
|
37 | - new \Twig_SimpleFunction('getReplagThreshold', [ $this, 'getReplagThreshold' ]), |
|
38 | - new \Twig_SimpleFunction('loadStylesheetsFromCDN', [ $this, 'loadStylesheetsFromCDN' ]), |
|
39 | - new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]), |
|
40 | - new \Twig_SimpleFunction('replag', [ $this, 'replag' ]), |
|
41 | - new \Twig_SimpleFunction('link', [ $this, 'link' ]), |
|
42 | - new \Twig_SimpleFunction('quote', [ $this, 'quote' ]), |
|
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('msgPrintExists', [$this, 'intuitionMessagePrintExists'], $options), |
|
23 | + new \Twig_SimpleFunction('msgExists', [$this, 'intuitionMessageExists'], $options), |
|
24 | + new \Twig_SimpleFunction('msg', [$this, 'intuitionMessage'], $options), |
|
25 | + new \Twig_SimpleFunction('lang', [$this, 'getLang'], $options), |
|
26 | + new \Twig_SimpleFunction('langName', [$this, 'getLangName'], $options), |
|
27 | + new \Twig_SimpleFunction('allLangs', [$this, 'getAllLangs']), |
|
28 | + new \Twig_SimpleFunction('isRTL', [$this, 'intuitionIsRTL']), |
|
29 | + new \Twig_SimpleFunction('isRTLLang', [$this, 'intuitionIsRTLLang']), |
|
30 | + new \Twig_SimpleFunction('shortHash', [$this, 'gitShortHash']), |
|
31 | + new \Twig_SimpleFunction('hash', [$this, 'gitHash']), |
|
32 | + new \Twig_SimpleFunction('enabled', [$this, 'tabEnabled']), |
|
33 | + new \Twig_SimpleFunction('tools', [$this, 'allTools']), |
|
34 | + new \Twig_SimpleFunction('color', [$this, 'getColorList']), |
|
35 | + new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']), |
|
36 | + new \Twig_SimpleFunction('isSingleWiki', [$this, 'isSingleWiki']), |
|
37 | + new \Twig_SimpleFunction('getReplagThreshold', [$this, 'getReplagThreshold']), |
|
38 | + new \Twig_SimpleFunction('loadStylesheetsFromCDN', [$this, 'loadStylesheetsFromCDN']), |
|
39 | + new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']), |
|
40 | + new \Twig_SimpleFunction('replag', [$this, 'replag']), |
|
41 | + new \Twig_SimpleFunction('link', [$this, 'link']), |
|
42 | + new \Twig_SimpleFunction('quote', [$this, 'quote']), |
|
43 | 43 | ]; |
44 | 44 | } |
45 | 45 | |
46 | 46 | public function requestTime($decimals = 3) |
47 | 47 | { |
48 | 48 | |
49 | - return number_format(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], $decimals); |
|
49 | + return number_format(microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'], $decimals); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public function requestMemory() |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function linkToWiki($url, $page, $secondary = "") |
74 | 74 | { |
75 | - $link = $url . "/"; |
|
75 | + $link = $url."/"; |
|
76 | 76 | |
77 | 77 | if ($this->isWMFLabs()) { |
78 | 78 | $link .= "wiki/"; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | public function linkToWikiScript($url, $secondary) |
91 | 91 | { |
92 | - $link = $url . "/"; |
|
92 | + $link = $url."/"; |
|
93 | 93 | |
94 | 94 | if ($this->isWMFLabs()) { |
95 | 95 | $link .= "w/"; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | // TODO: refactor all intuition stuff so it can be used anywhere |
106 | 106 | public function intuitionMessageExists($message = "") |
107 | 107 | { |
108 | - return $this->getIntuition()->msgExists($message, [ "domain" => "xtools" ]); |
|
108 | + return $this->getIntuition()->msgExists($message, ["domain" => "xtools"]); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | public function intuitionMessagePrintExists($message = "", $vars = []) |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | public function intuitionMessage($message = "", $vars = []) |
126 | 126 | { |
127 | - return $this->getIntuition()->msg($message, [ "domain" => "xtools", "variables" => $vars ]); |
|
127 | + return $this->getIntuition()->msg($message, ["domain" => "xtools", "variables" => $vars]); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | public function getLang() |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function getAllLangs() |
147 | 147 | { |
148 | - $messageFiles = glob($this->container->getParameter("kernel.root_dir") . '/../i18n/*.json'); |
|
148 | + $messageFiles = glob($this->container->getParameter("kernel.root_dir").'/../i18n/*.json'); |
|
149 | 149 | |
150 | 150 | $languages = array_values(array_unique(array_map( |
151 | - function ($filename) { |
|
151 | + function($filename) { |
|
152 | 152 | return basename($filename, '.json'); |
153 | 153 | }, |
154 | 154 | $messageFiles |
@@ -205,41 +205,41 @@ discard block |
||
205 | 205 | public static function getColorList($num = false) |
206 | 206 | { |
207 | 207 | $colors = [ |
208 | - 0 => '#Cc0000',# '#FF005A', #red '#FF5555', |
|
208 | + 0 => '#Cc0000', # '#FF005A', #red '#FF5555', |
|
209 | 209 | 1 => '#F7b7b7', |
210 | - 2 => '#5c8d20',# '#008800', #green'#55FF55', |
|
210 | + 2 => '#5c8d20', # '#008800', #green'#55FF55', |
|
211 | 211 | 3 => '#85eD82', |
212 | 212 | 4 => '#2E97E0', # blue |
213 | 213 | 5 => '#B9E3F9', |
214 | - 6 => '#e1711d', # orange |
|
214 | + 6 => '#e1711d', # orange |
|
215 | 215 | 7 => '#ffc04c', |
216 | 216 | 8 => '#FDFF98', # yellow |
217 | 217 | 9 => '#5555FF', |
218 | 218 | 10 => '#55FFFF', |
219 | - 11 => '#0000C0', # |
|
220 | - 12 => '#008800', # green |
|
219 | + 11 => '#0000C0', # |
|
220 | + 12 => '#008800', # green |
|
221 | 221 | 13 => '#00C0C0', |
222 | - 14 => '#FFAFAF', # rosé |
|
223 | - 15 => '#808080', # gray |
|
222 | + 14 => '#FFAFAF', # rosé |
|
223 | + 15 => '#808080', # gray |
|
224 | 224 | 16 => '#00C000', |
225 | 225 | 17 => '#404040', |
226 | - 18 => '#C0C000', # green |
|
226 | + 18 => '#C0C000', # green |
|
227 | 227 | 19 => '#C000C0', |
228 | - 100 => '#75A3D1', # blue |
|
229 | - 101 => '#A679D2', # purple |
|
228 | + 100 => '#75A3D1', # blue |
|
229 | + 101 => '#A679D2', # purple |
|
230 | 230 | 102 => '#660000', |
231 | 231 | 103 => '#000066', |
232 | - 104 => '#FAFFAF', # caramel |
|
232 | + 104 => '#FAFFAF', # caramel |
|
233 | 233 | 105 => '#408345', |
234 | 234 | 106 => '#5c8d20', |
235 | - 107 => '#e1711d', # red |
|
236 | - 108 => '#94ef2b', # light green |
|
237 | - 109 => '#756a4a', # brown |
|
235 | + 107 => '#e1711d', # red |
|
236 | + 108 => '#94ef2b', # light green |
|
237 | + 109 => '#756a4a', # brown |
|
238 | 238 | 110 => '#6f1dab', |
239 | 239 | 111 => '#301e30', |
240 | 240 | 112 => '#5c9d96', |
241 | - 113 => '#a8cd8c', # earth green |
|
242 | - 114 => '#f2b3f1', # light purple |
|
241 | + 113 => '#a8cd8c', # earth green |
|
242 | + 114 => '#f2b3f1', # light purple |
|
243 | 243 | 115 => '#9b5828', |
244 | 244 | 118 => '#99FFFF', |
245 | 245 | 119 => '#99BBFF', |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | 446 => '#06DCFB', |
261 | 261 | 447 => '#892EE4', |
262 | 262 | 460 => '#99FF66', |
263 | - 461 => '#99CC66', # green |
|
264 | - 470 => '#CCCC33', # ocker |
|
263 | + 461 => '#99CC66', # green |
|
264 | + 470 => '#CCCC33', # ocker |
|
265 | 265 | 471 => '#CCFF33', |
266 | 266 | 480 => '#6699FF', |
267 | 267 | 481 => '#66FFFF', |
@@ -276,18 +276,18 @@ discard block |
||
276 | 276 | 1198 => '#FF34B3', |
277 | 277 | 1199 => '#8B1C62', |
278 | 278 | |
279 | - '#61a9f3',# blue |
|
280 | - '#f381b9',# pink |
|
279 | + '#61a9f3', # blue |
|
280 | + '#f381b9', # pink |
|
281 | 281 | '#61E3A9', |
282 | 282 | '#D56DE2', |
283 | 283 | '#85eD82', |
284 | 284 | '#F7b7b7', |
285 | 285 | '#CFDF49', |
286 | 286 | '#88d8f2', |
287 | - '#07AF7B',# green |
|
287 | + '#07AF7B', # green |
|
288 | 288 | '#B9E3F9', |
289 | 289 | '#FFF3AD', |
290 | - '#EF606A',# red |
|
290 | + '#EF606A', # red |
|
291 | 291 | '#EC8833', |
292 | 292 | '#FFF100', |
293 | 293 | '#87C9A5', |
@@ -414,8 +414,8 @@ discard block |
||
414 | 414 | public function getFilters() |
415 | 415 | { |
416 | 416 | return [ |
417 | - new \Twig_SimpleFilter('capitalize_first', [ $this, 'capitalizeFirst' ]), |
|
418 | - new \Twig_SimpleFilter('percent_format', [ $this, 'percentFormat' ]), |
|
417 | + new \Twig_SimpleFilter('capitalize_first', [$this, 'capitalizeFirst']), |
|
418 | + new \Twig_SimpleFilter('percent_format', [$this, 'percentFormat']), |
|
419 | 419 | ]; |
420 | 420 | } |
421 | 421 | |
@@ -442,9 +442,9 @@ discard block |
||
442 | 442 | if (!$denominator) { |
443 | 443 | $quotient = $numerator; |
444 | 444 | } else { |
445 | - $quotient = ( $numerator / $denominator ) * 100; |
|
445 | + $quotient = ($numerator / $denominator) * 100; |
|
446 | 446 | } |
447 | 447 | |
448 | - return round($quotient, $precision) . '%'; |
|
448 | + return round($quotient, $precision).'%'; |
|
449 | 449 | } |
450 | 450 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function getRevisionCounts(Project $project, User $user) |
42 | 42 | { |
43 | 43 | // Set up cache. |
44 | - $cacheKey = 'revisioncounts.' . $user->getId($project); |
|
44 | + $cacheKey = 'revisioncounts.'.$user->getId($project); |
|
45 | 45 | if ($this->cache->hasItem($cacheKey)) { |
46 | 46 | return $this->cache->getItem($cacheKey)->get(); |
47 | 47 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | public function getTopProjectsEditCounts($projectUrl, $username, $numProjects = 10) |
133 | 133 | { |
134 | 134 | $this->debug("Getting top project edit counts for $username"); |
135 | - $cacheKey = 'topprojectseditcounts.' . $username; |
|
135 | + $cacheKey = 'topprojectseditcounts.'.$username; |
|
136 | 136 | if ($this->cacheHas($cacheKey)) { |
137 | 137 | return $this->cacheGet($cacheKey); |
138 | 138 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | if (false === $topEditCounts) { |
145 | 145 | // If no CentralAuth, fall back to querying each database in turn. |
146 | 146 | foreach ($this->labsHelper->getProjectsInfo() as $project) { |
147 | - $this->container->get('logger')->debug('Getting edit count for ' . $project['url']); |
|
147 | + $this->container->get('logger')->debug('Getting edit count for '.$project['url']); |
|
148 | 148 | $revisionTableName = $this->labsHelper->getTable('revision', $project['dbName']); |
149 | 149 | $sql = "SELECT COUNT(rev_id) FROM $revisionTableName WHERE rev_user_text=:username"; |
150 | 150 | $stmt = $this->replicas->prepare($sql); |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | $topEditCounts[$project['dbName']] = array_merge($project, ['total' => $total]); |
155 | 155 | } |
156 | 156 | } |
157 | - uasort($topEditCounts, function ($a, $b) { |
|
158 | - return $b['total'] - $a['total']; |
|
157 | + uasort($topEditCounts, function($a, $b) { |
|
158 | + return $b['total']-$a['total']; |
|
159 | 159 | }); |
160 | 160 | $out = array_slice($topEditCounts, 0, $numProjects); |
161 | 161 | |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | $results = $resultQuery->fetchAll(); |
198 | 198 | |
199 | 199 | $pageCounts = array_combine( |
200 | - array_map(function ($e) { |
|
200 | + array_map(function($e) { |
|
201 | 201 | return $e['source']; |
202 | 202 | }, $results), |
203 | - array_map(function ($e) { |
|
203 | + array_map(function($e) { |
|
204 | 204 | return $e['value']; |
205 | 205 | }, $results) |
206 | 206 | ); |
@@ -216,16 +216,16 @@ discard block |
||
216 | 216 | public function getLogCounts($userId) |
217 | 217 | { |
218 | 218 | $sql = "SELECT CONCAT(log_type, '-', log_action) AS source, COUNT(log_id) AS value |
219 | - FROM " . $this->labsHelper->getTable('logging') . " |
|
219 | + FROM " . $this->labsHelper->getTable('logging')." |
|
220 | 220 | WHERE log_user = :userId |
221 | 221 | GROUP BY log_type, log_action"; |
222 | 222 | $resultQuery = $this->replicas->prepare($sql); |
223 | 223 | $resultQuery->bindParam('userId', $userId); |
224 | 224 | $resultQuery->execute(); |
225 | 225 | $results = $resultQuery->fetchAll(); |
226 | - $logCounts = array_combine(array_map(function ($e) { |
|
226 | + $logCounts = array_combine(array_map(function($e) { |
|
227 | 227 | return $e['source']; |
228 | - }, $results), array_map(function ($e) { |
|
228 | + }, $results), array_map(function($e) { |
|
229 | 229 | return $e['value']; |
230 | 230 | }, $results)); |
231 | 231 | |
@@ -253,9 +253,9 @@ discard block |
||
253 | 253 | |
254 | 254 | // Merge approvals together. |
255 | 255 | $logCounts['review-approve'] = |
256 | - $logCounts['review-approve'] + |
|
257 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + |
|
258 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
256 | + $logCounts['review-approve']+ |
|
257 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ |
|
258 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
259 | 259 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); |
260 | 260 | |
261 | 261 | // Add Commons upload count, if applicable. |
@@ -281,16 +281,16 @@ discard block |
||
281 | 281 | { |
282 | 282 | $userId = $this->getUserId($username); |
283 | 283 | $sql = "SELECT page_namespace, count(rev_id) AS total |
284 | - FROM " . $this->labsHelper->getTable('revision') . " r |
|
285 | - JOIN " . $this->labsHelper->getTable('page') . " p on r.rev_page = p.page_id |
|
284 | + FROM " . $this->labsHelper->getTable('revision')." r |
|
285 | + JOIN " . $this->labsHelper->getTable('page')." p on r.rev_page = p.page_id |
|
286 | 286 | WHERE r.rev_user = :id GROUP BY page_namespace"; |
287 | 287 | $resultQuery = $this->replicas->prepare($sql); |
288 | 288 | $resultQuery->bindParam(":id", $userId); |
289 | 289 | $resultQuery->execute(); |
290 | 290 | $results = $resultQuery->fetchAll(); |
291 | - $namespaceTotals = array_combine(array_map(function ($e) { |
|
291 | + $namespaceTotals = array_combine(array_map(function($e) { |
|
292 | 292 | return $e['page_namespace']; |
293 | - }, $results), array_map(function ($e) { |
|
293 | + }, $results), array_map(function($e) { |
|
294 | 294 | return $e['total']; |
295 | 295 | }, $results)); |
296 | 296 | |
@@ -313,14 +313,14 @@ discard block |
||
313 | 313 | $revisions = $this->cacheGet($cacheKey); |
314 | 314 | } else { |
315 | 315 | $sql = |
316 | - "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, " . |
|
317 | - " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, " . |
|
318 | - " page_title, page_namespace " . " FROM " . |
|
319 | - $this->labsHelper->getTable('revision', $project['dbName']) . " JOIN " . |
|
320 | - $this->labsHelper->getTable('page', $project['dbName']) . |
|
321 | - " ON (rev_page = page_id)" . |
|
322 | - " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username" . |
|
323 | - " ORDER BY rev_timestamp DESC" . " LIMIT 10"; |
|
316 | + "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, ". |
|
317 | + " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, ". |
|
318 | + " page_title, page_namespace "." FROM ". |
|
319 | + $this->labsHelper->getTable('revision', $project['dbName'])." JOIN ". |
|
320 | + $this->labsHelper->getTable('page', $project['dbName']). |
|
321 | + " ON (rev_page = page_id)". |
|
322 | + " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username". |
|
323 | + " ORDER BY rev_timestamp DESC"." LIMIT 10"; |
|
324 | 324 | $resultQuery = $this->replicas->prepare($sql); |
325 | 325 | $resultQuery->bindParam(":username", $username); |
326 | 326 | $resultQuery->execute(); |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | if (count($revisions) === 0) { |
331 | 331 | continue; |
332 | 332 | } |
333 | - $revsWithProject = array_map(function (&$item) use ($project) { |
|
333 | + $revsWithProject = array_map(function(&$item) use ($project) { |
|
334 | 334 | $item['project_name'] = $project['wikiName']; |
335 | 335 | $item['project_url'] = $project['url']; |
336 | 336 | $item['project_db_name'] = $project['dbName']; |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | }, $revisions); |
341 | 341 | $allRevisions = array_merge($allRevisions, $revsWithProject); |
342 | 342 | } |
343 | - usort($allRevisions, function ($a, $b) { |
|
344 | - return $b['rev_timestamp'] - $a['rev_timestamp']; |
|
343 | + usort($allRevisions, function($a, $b) { |
|
344 | + return $b['rev_timestamp']-$a['rev_timestamp']; |
|
345 | 345 | }); |
346 | 346 | |
347 | 347 | return array_slice($allRevisions, 0, $topN); |
@@ -360,12 +360,12 @@ discard block |
||
360 | 360 | } |
361 | 361 | |
362 | 362 | $sql = |
363 | - "SELECT " . " YEAR(rev_timestamp) AS `year`," . |
|
364 | - " MONTH(rev_timestamp) AS `month`," . " page_namespace," . |
|
365 | - " COUNT(rev_id) AS `count` " . " FROM " . $this->labsHelper->getTable('revision') . |
|
366 | - " JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" . |
|
367 | - " WHERE rev_user_text = :username" . |
|
368 | - " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace " . |
|
363 | + "SELECT "." YEAR(rev_timestamp) AS `year`,". |
|
364 | + " MONTH(rev_timestamp) AS `month`,"." page_namespace,". |
|
365 | + " COUNT(rev_id) AS `count` "." FROM ".$this->labsHelper->getTable('revision'). |
|
366 | + " JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)". |
|
367 | + " WHERE rev_user_text = :username". |
|
368 | + " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace ". |
|
369 | 369 | " ORDER BY rev_timestamp DESC"; |
370 | 370 | $resultQuery = $this->replicas->prepare($sql); |
371 | 371 | $resultQuery->bindParam(":username", $username); |
@@ -387,14 +387,14 @@ discard block |
||
387 | 387 | if (!isset($out['totals'][$ns])) { |
388 | 388 | $out['totals'][$ns] = []; |
389 | 389 | } |
390 | - $out['totals'][$ns][$total['year'] . $total['month']] = $total['count']; |
|
390 | + $out['totals'][$ns][$total['year'].$total['month']] = $total['count']; |
|
391 | 391 | } |
392 | 392 | // Fill in the blanks (where no edits were made in a given month for a namespace). |
393 | 393 | for ($y = $out['min_year']; $y <= $out['max_year']; $y++) { |
394 | 394 | for ($m = 1; $m <= 12; $m++) { |
395 | 395 | foreach ($out['totals'] as $nsId => &$total) { |
396 | - if (!isset($total[$y . $m])) { |
|
397 | - $total[$y . $m] = 0; |
|
396 | + if (!isset($total[$y.$m])) { |
|
397 | + $total[$y.$m] = 0; |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | } |
@@ -417,12 +417,12 @@ discard block |
||
417 | 417 | } |
418 | 418 | |
419 | 419 | $sql = |
420 | - "SELECT " . " SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4) AS `year`," . |
|
421 | - " page_namespace," . " COUNT(rev_id) AS `count` " . " FROM " . |
|
422 | - $this->labsHelper->getTable('revision') . " JOIN " . |
|
423 | - $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" . |
|
424 | - " WHERE rev_user_text = :username" . |
|
425 | - " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace " . |
|
420 | + "SELECT "." SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4) AS `year`,". |
|
421 | + " page_namespace,"." COUNT(rev_id) AS `count` "." FROM ". |
|
422 | + $this->labsHelper->getTable('revision')." JOIN ". |
|
423 | + $this->labsHelper->getTable('page')." ON (rev_page = page_id)". |
|
424 | + " WHERE rev_user_text = :username". |
|
425 | + " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace ". |
|
426 | 426 | " ORDER BY rev_timestamp DESC "; |
427 | 427 | $resultQuery = $this->replicas->prepare($sql); |
428 | 428 | $resultQuery->bindParam(":username", $username); |
@@ -461,9 +461,9 @@ discard block |
||
461 | 461 | $hourInterval = 2; |
462 | 462 | $xCalc = "ROUND(HOUR(rev_timestamp)/$hourInterval)*$hourInterval"; |
463 | 463 | $sql = |
464 | - "SELECT " . " DAYOFWEEK(rev_timestamp) AS `y`, " . " $xCalc AS `x`, " . |
|
465 | - " COUNT(rev_id) AS `r` " . " FROM " . $this->labsHelper->getTable('revision') . |
|
466 | - " WHERE rev_user_text = :username" . " GROUP BY DAYOFWEEK(rev_timestamp), $xCalc " . |
|
464 | + "SELECT "." DAYOFWEEK(rev_timestamp) AS `y`, "." $xCalc AS `x`, ". |
|
465 | + " COUNT(rev_id) AS `r` "." FROM ".$this->labsHelper->getTable('revision'). |
|
466 | + " WHERE rev_user_text = :username"." GROUP BY DAYOFWEEK(rev_timestamp), $xCalc ". |
|
467 | 467 | " "; |
468 | 468 | $resultQuery = $this->replicas->prepare($sql); |
469 | 469 | $resultQuery->bindParam(":username", $username); |