@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | FROM $pageTable |
263 | 263 | JOIN $revisionTable ON page_id = rev_page |
264 | 264 | $paJoin |
265 | - WHERE $whereRev AND rev_parent_id = '0' $namespaceConditionRev $redirectCondition" . |
|
266 | - ($hasPageAssessments ? 'GROUP BY rev_page' : '') . " |
|
265 | + WHERE $whereRev AND rev_parent_id = '0' $namespaceConditionRev $redirectCondition". |
|
266 | + ($hasPageAssessments ? 'GROUP BY rev_page' : '')." |
|
267 | 267 | ) |
268 | 268 | |
269 | 269 | UNION |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $tagJoin = $tags != '' ? "LEFT OUTER JOIN $tagTable ON ct_rev_id = rev_id" : ''; |
376 | 376 | $condTools[] = "ct_tag IN ($tags)"; |
377 | 377 | } |
378 | - $condTool = 'AND (' . implode(' OR ', $condTools) . ')'; |
|
378 | + $condTool = 'AND ('.implode(' OR ', $condTools).')'; |
|
379 | 379 | |
380 | 380 | $sql = "SELECT COUNT(DISTINCT(rev_id)) |
381 | 381 | FROM $revisionTable |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $condEnd"; |
389 | 389 | |
390 | 390 | $resultQuery = $this->executeQuery($sql, $user, $namespace, $start, $end); |
391 | - $result = (int) $resultQuery->fetchColumn(); |
|
391 | + $result = (int)$resultQuery->fetchColumn(); |
|
392 | 392 | |
393 | 393 | // Cache for 10 minutes, and return. |
394 | 394 | $cacheItem = $this->cache->getItem($cacheKey) |
@@ -524,8 +524,8 @@ discard block |
||
524 | 524 | } |
525 | 525 | |
526 | 526 | // Sort the array by count |
527 | - uasort($results, function ($a, $b) { |
|
528 | - return $b['count'] - $a['count']; |
|
527 | + uasort($results, function($a, $b) { |
|
528 | + return $b['count']-$a['count']; |
|
529 | 529 | }); |
530 | 530 | |
531 | 531 | // Cache for 10 minutes, and return. |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | |
575 | 575 | // Developer error, no regex or tag provided for this tool. |
576 | 576 | if ($condTool === '') { |
577 | - throw new Exception("No regex or tag found for the tool $toolname. " . |
|
577 | + throw new Exception("No regex or tag found for the tool $toolname. ". |
|
578 | 578 | "Please verify this entry in semi_automated.yml"); |
579 | 579 | } |
580 | 580 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | if ($condTool === '') { |
623 | 623 | $condTool = "ct_tag = $tag"; |
624 | 624 | } else { |
625 | - $condTool = '(' . $condTool . " OR ct_tag = $tag)"; |
|
625 | + $condTool = '('.$condTool." OR ct_tag = $tag)"; |
|
626 | 626 | } |
627 | 627 | } |
628 | 628 |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | $promises[] = $promise; |
118 | 118 | |
119 | 119 | // Handle response of $promise asynchronously. |
120 | - $promise->then(function ($response) use ($key, $endpoint) { |
|
121 | - $result = (array) json_decode($response->getBody()->getContents()); |
|
120 | + $promise->then(function($response) use ($key, $endpoint) { |
|
121 | + $result = (array)json_decode($response->getBody()->getContents()); |
|
122 | 122 | |
123 | 123 | $this->getRepository() |
124 | 124 | ->getLog() |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | // We'll log this to see how often it happens. |
136 | 136 | $this->getRepository() |
137 | 137 | ->getLog() |
138 | - ->error("Failed to fetch data for $endpoint via async, " . |
|
138 | + ->error("Failed to fetch data for $endpoint via async, ". |
|
139 | 139 | "re-attempting synchoronously."); |
140 | 140 | } |
141 | 141 | }); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | // Filter out unblocks unless requested. |
193 | 193 | if ($blocksOnly) { |
194 | - $blocks = array_filter($blocks, function ($block) { |
|
194 | + $blocks = array_filter($blocks, function($block) { |
|
195 | 195 | return $block['log_action'] === 'block'; |
196 | 196 | }); |
197 | 197 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function countAllRevisions() |
227 | 227 | { |
228 | - return $this->countLiveRevisions() + $this->countDeletedRevisions(); |
|
228 | + return $this->countLiveRevisions()+$this->countDeletedRevisions(); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function countRevisionsWithoutComments() |
246 | 246 | { |
247 | - return $this->countLiveRevisions() - $this->countRevisionsWithComments(); |
|
247 | + return $this->countLiveRevisions()-$this->countRevisionsWithComments(); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | */ |
284 | 284 | public function countAllPagesEdited() |
285 | 285 | { |
286 | - return $this->countLivePagesEdited() + $this->countDeletedPagesEdited(); |
|
286 | + return $this->countLivePagesEdited()+$this->countDeletedPagesEdited(); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | */ |
294 | 294 | public function countPagesCreated() |
295 | 295 | { |
296 | - return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted(); |
|
296 | + return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted(); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | } elseif ($block['log_action'] === 'unblock') { |
434 | 434 | // The last block was lifted. So the duration will be the time from when the |
435 | 435 | // last block was set to the time of the unblock. |
436 | - $timeSinceLastBlock = $timestamp - $lastBlock[0]; |
|
436 | + $timeSinceLastBlock = $timestamp-$lastBlock[0]; |
|
437 | 437 | if ($timeSinceLastBlock > $this->longestBlockSeconds) { |
438 | 438 | $this->longestBlockSeconds = $timeSinceLastBlock; |
439 | 439 | |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | // The last block was modified. So we will adjust $lastBlock to include |
445 | 445 | // the difference of the duration of the new reblock, and time since the last block. |
446 | 446 | // $lastBlock is left unchanged if its duration was indefinite. |
447 | - $timeSinceLastBlock = $timestamp - $lastBlock[0]; |
|
448 | - $lastBlock[1] = $timeSinceLastBlock + $duration; |
|
447 | + $timeSinceLastBlock = $timestamp-$lastBlock[0]; |
|
448 | + $lastBlock[1] = $timeSinceLastBlock+$duration; |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | } |
456 | 456 | |
457 | 457 | // Test if the last block is still active, and if so use the expiry as the duration. |
458 | - $lastBlockExpiry = $lastBlock[0] + $lastBlock[1]; |
|
458 | + $lastBlockExpiry = $lastBlock[0]+$lastBlock[1]; |
|
459 | 459 | if ($lastBlockExpiry > time() && $lastBlockExpiry > $this->longestBlockSeconds) { |
460 | 460 | $this->longestBlockSeconds = $lastBlock[1]; |
461 | 461 | // Otherwise, test if the duration of the last block is now the longest overall. |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | // If invalid, $duration is left as null. |
497 | 497 | if (strtotime($durationStr)) { |
498 | 498 | $expiry = strtotime($durationStr, $timestamp); |
499 | - $duration = $expiry - $timestamp; |
|
499 | + $duration = $expiry-$timestamp; |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | return [$timestamp, $duration]; |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0; |
574 | 574 | $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0; |
575 | 575 | $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0; |
576 | - return $import + $interwiki + $upload; |
|
576 | + return $import+$interwiki+$upload; |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | /** |
@@ -697,9 +697,9 @@ discard block |
||
697 | 697 | public function approvals() |
698 | 698 | { |
699 | 699 | $logCounts = $this->getLogCounts(); |
700 | - $total = $logCounts['review-approve'] + |
|
701 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + |
|
702 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
700 | + $total = $logCounts['review-approve']+ |
|
701 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ |
|
702 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
703 | 703 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); |
704 | 704 | return $total; |
705 | 705 | } |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | $logCounts = $this->getLogCounts(); |
724 | 724 | $create2 = $logCounts['newusers-create2'] ?: 0; |
725 | 725 | $byemail = $logCounts['newusers-byemail'] ?: 0; |
726 | - return $create2 + $byemail; |
|
726 | + return $create2+$byemail; |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | /** |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | |
776 | 776 | $totals = $this->getRepository()->getMonthCounts($this->project, $this->user); |
777 | 777 | $out = [ |
778 | - 'yearLabels' => [], // labels for years |
|
778 | + 'yearLabels' => [], // labels for years |
|
779 | 779 | 'monthLabels' => [], // labels for months |
780 | 780 | 'totals' => [], // actual totals, grouped by namespace, year and then month |
781 | 781 | ]; |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | $out['totals'][$ns][$total['year']] = []; |
843 | 843 | } |
844 | 844 | |
845 | - $out['totals'][$ns][$total['year']][$total['month']] = (int) $total['count']; |
|
845 | + $out['totals'][$ns][$total['year']][$total['month']] = (int)$total['count']; |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | return [$out, $firstEdit]; |
@@ -859,8 +859,8 @@ discard block |
||
859 | 859 | private function fillInMonthTotalsAndLabels($out, DatePeriod $dateRange) |
860 | 860 | { |
861 | 861 | foreach ($dateRange as $monthObj) { |
862 | - $year = (int) $monthObj->format('Y'); |
|
863 | - $month = (int) $monthObj->format('n'); |
|
862 | + $year = (int)$monthObj->format('Y'); |
|
863 | + $month = (int)$monthObj->format('n'); |
|
864 | 864 | |
865 | 865 | // Fill in labels |
866 | 866 | $out['monthLabels'][] = $monthObj->format('Y-m'); |
@@ -963,8 +963,8 @@ discard block |
||
963 | 963 | |
964 | 964 | if ($sorted) { |
965 | 965 | // Sort. |
966 | - uasort($this->globalEditCounts, function ($a, $b) { |
|
967 | - return $b['total'] - $a['total']; |
|
966 | + uasort($this->globalEditCounts, function($a, $b) { |
|
967 | + return $b['total']-$a['total']; |
|
968 | 968 | }); |
969 | 969 | } |
970 | 970 | |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | $nsName = $project->getNamespaces()[$revision['page_namespace']]; |
1001 | 1001 | } |
1002 | 1002 | $page = $project->getRepository() |
1003 | - ->getPage($project, $nsName . ':' . $revision['page_title']); |
|
1003 | + ->getPage($project, $nsName.':'.$revision['page_title']); |
|
1004 | 1004 | $edit = new Edit($page, $revision); |
1005 | 1005 | $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit; |
1006 | 1006 | } |
@@ -1041,7 +1041,7 @@ discard block |
||
1041 | 1041 | public function countSmallEdits() |
1042 | 1042 | { |
1043 | 1043 | $editSizeData = $this->getEditSizeData(); |
1044 | - return isset($editSizeData['small_edits']) ? (int) $editSizeData['small_edits'] : 0; |
|
1044 | + return isset($editSizeData['small_edits']) ? (int)$editSizeData['small_edits'] : 0; |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | /** |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | public function countLargeEdits() |
1052 | 1052 | { |
1053 | 1053 | $editSizeData = $this->getEditSizeData(); |
1054 | - return isset($editSizeData['large_edits']) ? (int) $editSizeData['large_edits'] : 0; |
|
1054 | + return isset($editSizeData['large_edits']) ? (int)$editSizeData['large_edits'] : 0; |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | public function loginAction() |
90 | 90 | { |
91 | 91 | try { |
92 | - list( $next, $token ) = $this->getOauthClient()->initiate(); |
|
92 | + list($next, $token) = $this->getOauthClient()->initiate(); |
|
93 | 93 | } catch (Exception $oauthException) { |
94 | 94 | throw $oauthException; |
95 | 95 | // @TODO Make this work. |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | . '?title=Special:OAuth'; |
157 | 157 | $conf = new ClientConfig($endpoint); |
158 | 158 | $consumerKey = $this->getParameter('oauth_key'); |
159 | - $consumerSecret = $this->getParameter('oauth_secret'); |
|
159 | + $consumerSecret = $this->getParameter('oauth_secret'); |
|
160 | 160 | $conf->setConsumer(new Consumer($consumerKey, $consumerSecret)); |
161 | 161 | $this->oauthClient = new Client($conf); |
162 | 162 | // Callback URL is hardcoded in the consumer registration. |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $normalized = []; |
77 | 77 | if (isset($result['query']['normalized'])) { |
78 | 78 | array_map( |
79 | - function ($e) use (&$normalized) { |
|
79 | + function($e) use (&$normalized) { |
|
80 | 80 | $normalized[$e['to']] = $e['from']; |
81 | 81 | }, |
82 | 82 | $result['query']['normalized'] |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $query = FluentRequest::factory()->setAction('query')->setParams($requestData); |
162 | 162 | $innerPromise = $this->api->getRequestAsync($query); |
163 | 163 | |
164 | - $innerPromise->then(function ($result) use (&$data) { |
|
164 | + $innerPromise->then(function($result) use (&$data) { |
|
165 | 165 | // some failures come back as 200s, so we still resolve and let the outer function handle it |
166 | 166 | if (isset($result['error']) || !isset($result['query'])) { |
167 | 167 | return $data['promise']->resolve($data); |
@@ -44,32 +44,32 @@ discard block |
||
44 | 44 | { |
45 | 45 | $options = ['is_safe' => ['html']]; |
46 | 46 | return [ |
47 | - new \Twig_SimpleFunction('request_time', [ $this, 'requestTime' ], $options), |
|
48 | - new \Twig_SimpleFunction('memory_usage', [ $this, 'requestMemory' ], $options), |
|
49 | - new \Twig_SimpleFunction('year', [ $this, 'generateYear' ], $options), |
|
50 | - new \Twig_SimpleFunction('msgPrintExists', [ $this, 'intuitionMessagePrintExists' ], $options), |
|
51 | - new \Twig_SimpleFunction('msgExists', [ $this, 'intuitionMessageExists' ], $options), |
|
52 | - new \Twig_SimpleFunction('msg', [ $this, 'intuitionMessage' ], $options), |
|
53 | - new \Twig_SimpleFunction('lang', [ $this, 'getLang' ], $options), |
|
54 | - new \Twig_SimpleFunction('langName', [ $this, 'getLangName' ], $options), |
|
55 | - new \Twig_SimpleFunction('allLangs', [ $this, 'getAllLangs' ]), |
|
56 | - new \Twig_SimpleFunction('isRTL', [ $this, 'intuitionIsRTL' ]), |
|
57 | - new \Twig_SimpleFunction('isRTLLang', [ $this, 'intuitionIsRTLLang' ]), |
|
58 | - new \Twig_SimpleFunction('shortHash', [ $this, 'gitShortHash' ]), |
|
59 | - new \Twig_SimpleFunction('hash', [ $this, 'gitHash' ]), |
|
60 | - new \Twig_SimpleFunction('releaseDate', [ $this, 'gitDate' ]), |
|
61 | - new \Twig_SimpleFunction('enabled', [ $this, 'tabEnabled' ]), |
|
62 | - new \Twig_SimpleFunction('tools', [ $this, 'allTools' ]), |
|
63 | - new \Twig_SimpleFunction('color', [ $this, 'getColorList' ]), |
|
64 | - new \Twig_SimpleFunction('chartColor', [ $this, 'chartColor' ]), |
|
65 | - new \Twig_SimpleFunction('isSingleWiki', [ $this, 'isSingleWiki' ]), |
|
66 | - new \Twig_SimpleFunction('getReplagThreshold', [ $this, 'getReplagThreshold' ]), |
|
67 | - new \Twig_SimpleFunction('loadStylesheetsFromCDN', [ $this, 'loadStylesheetsFromCDN' ]), |
|
68 | - new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]), |
|
69 | - new \Twig_SimpleFunction('replag', [ $this, 'replag' ]), |
|
70 | - new \Twig_SimpleFunction('link', [ $this, 'link' ]), |
|
71 | - new \Twig_SimpleFunction('quote', [ $this, 'quote' ]), |
|
72 | - new \Twig_SimpleFunction('bugReportURL', [ $this, 'bugReportURL' ]), |
|
47 | + new \Twig_SimpleFunction('request_time', [$this, 'requestTime'], $options), |
|
48 | + new \Twig_SimpleFunction('memory_usage', [$this, 'requestMemory'], $options), |
|
49 | + new \Twig_SimpleFunction('year', [$this, 'generateYear'], $options), |
|
50 | + new \Twig_SimpleFunction('msgPrintExists', [$this, 'intuitionMessagePrintExists'], $options), |
|
51 | + new \Twig_SimpleFunction('msgExists', [$this, 'intuitionMessageExists'], $options), |
|
52 | + new \Twig_SimpleFunction('msg', [$this, 'intuitionMessage'], $options), |
|
53 | + new \Twig_SimpleFunction('lang', [$this, 'getLang'], $options), |
|
54 | + new \Twig_SimpleFunction('langName', [$this, 'getLangName'], $options), |
|
55 | + new \Twig_SimpleFunction('allLangs', [$this, 'getAllLangs']), |
|
56 | + new \Twig_SimpleFunction('isRTL', [$this, 'intuitionIsRTL']), |
|
57 | + new \Twig_SimpleFunction('isRTLLang', [$this, 'intuitionIsRTLLang']), |
|
58 | + new \Twig_SimpleFunction('shortHash', [$this, 'gitShortHash']), |
|
59 | + new \Twig_SimpleFunction('hash', [$this, 'gitHash']), |
|
60 | + new \Twig_SimpleFunction('releaseDate', [$this, 'gitDate']), |
|
61 | + new \Twig_SimpleFunction('enabled', [$this, 'tabEnabled']), |
|
62 | + new \Twig_SimpleFunction('tools', [$this, 'allTools']), |
|
63 | + new \Twig_SimpleFunction('color', [$this, 'getColorList']), |
|
64 | + new \Twig_SimpleFunction('chartColor', [$this, 'chartColor']), |
|
65 | + new \Twig_SimpleFunction('isSingleWiki', [$this, 'isSingleWiki']), |
|
66 | + new \Twig_SimpleFunction('getReplagThreshold', [$this, 'getReplagThreshold']), |
|
67 | + new \Twig_SimpleFunction('loadStylesheetsFromCDN', [$this, 'loadStylesheetsFromCDN']), |
|
68 | + new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']), |
|
69 | + new \Twig_SimpleFunction('replag', [$this, 'replag']), |
|
70 | + new \Twig_SimpleFunction('link', [$this, 'link']), |
|
71 | + new \Twig_SimpleFunction('quote', [$this, 'quote']), |
|
72 | + new \Twig_SimpleFunction('bugReportURL', [$this, 'bugReportURL']), |
|
73 | 73 | new \Twig_SimpleFunction('logged_in_user', [$this, 'functionLoggedInUser']), |
74 | 74 | new \Twig_SimpleFunction('isUserAnon', [$this, 'isUserAnon']), |
75 | 75 | new \Twig_SimpleFunction('nsName', [$this, 'nsName']), |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | public function requestTime() |
88 | 88 | { |
89 | 89 | if (!isset($this->requestTime)) { |
90 | - $this->requestTime = microtime(true) - $this->getCurrentRequest()->server->get('REQUEST_TIME_FLOAT'); |
|
90 | + $this->requestTime = microtime(true)-$this->getCurrentRequest()->server->get('REQUEST_TIME_FLOAT'); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | return $this->requestTime; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function intuitionMessage($message = "", $vars = []) |
162 | 162 | { |
163 | - return $this->getIntuition()->msg($message, [ "domain" => "xtools", "variables" => $vars ]); |
|
163 | + return $this->getIntuition()->msg($message, ["domain" => "xtools", "variables" => $vars]); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function getAllLangs() |
191 | 191 | { |
192 | - $messageFiles = glob($this->container->getParameter("kernel.root_dir") . '/../i18n/*.json'); |
|
192 | + $messageFiles = glob($this->container->getParameter("kernel.root_dir").'/../i18n/*.json'); |
|
193 | 193 | |
194 | 194 | $languages = array_values(array_unique(array_map( |
195 | - function ($filename) { |
|
195 | + function($filename) { |
|
196 | 196 | return basename($filename, '.json'); |
197 | 197 | }, |
198 | 198 | $messageFiles |
@@ -540,9 +540,9 @@ discard block |
||
540 | 540 | public function getFilters() |
541 | 541 | { |
542 | 542 | return [ |
543 | - new \Twig_SimpleFilter('capitalize_first', [ $this, 'capitalizeFirst' ]), |
|
544 | - new \Twig_SimpleFilter('percent_format', [ $this, 'percentFormat' ]), |
|
545 | - new \Twig_SimpleFilter('diff_format', [ $this, 'diffFormat' ], [ 'is_safe' => [ 'html' ] ]), |
|
543 | + new \Twig_SimpleFilter('capitalize_first', [$this, 'capitalizeFirst']), |
|
544 | + new \Twig_SimpleFilter('percent_format', [$this, 'percentFormat']), |
|
545 | + new \Twig_SimpleFilter('diff_format', [$this, 'diffFormat'], ['is_safe' => ['html']]), |
|
546 | 546 | new \Twig_SimpleFilter('num_format', [$this, 'numberFormat']), |
547 | 547 | new \Twig_SimpleFilter('date_format', [$this, 'dateFormat']), |
548 | 548 | ]; |
@@ -616,10 +616,10 @@ discard block |
||
616 | 616 | if (!$denominator) { |
617 | 617 | $quotient = $numerator; |
618 | 618 | } else { |
619 | - $quotient = ( $numerator / $denominator ) * 100; |
|
619 | + $quotient = ($numerator / $denominator) * 100; |
|
620 | 620 | } |
621 | 621 | |
622 | - return $this->numberFormat($quotient, $precision) . '%'; |
|
622 | + return $this->numberFormat($quotient, $precision).'%'; |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | /** |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | list($val, $key) = $this->getDurationMessageKey($seconds); |
690 | 690 | |
691 | 691 | if ($translate) { |
692 | - return $this->numberFormat($val) . ' ' . $this->intuitionMessage("num-$key", [$val]); |
|
692 | + return $this->numberFormat($val).' '.$this->intuitionMessage("num-$key", [$val]); |
|
693 | 693 | } else { |
694 | 694 | return [$this->numberFormat($val), "num-$key"]; |
695 | 695 | } |
@@ -710,15 +710,15 @@ discard block |
||
710 | 710 | |
711 | 711 | if ($seconds >= 86400) { |
712 | 712 | // Over a day |
713 | - $val = (int) floor($seconds / 86400); |
|
713 | + $val = (int)floor($seconds / 86400); |
|
714 | 714 | $key = 'days'; |
715 | 715 | } elseif ($seconds >= 3600) { |
716 | 716 | // Over an hour, less than a day |
717 | - $val = (int) floor($seconds / 3600); |
|
717 | + $val = (int)floor($seconds / 3600); |
|
718 | 718 | $key = 'hours'; |
719 | 719 | } elseif ($seconds >= 60) { |
720 | 720 | // Over a minute, less than an hour |
721 | - $val = (int) floor($seconds / 60); |
|
721 | + $val = (int)floor($seconds / 60); |
|
722 | 722 | $key = 'minutes'; |
723 | 723 | } |
724 | 724 |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | public function getMaxRevisions() |
157 | 157 | { |
158 | 158 | if (!isset($this->maxRevisions)) { |
159 | - $this->maxRevisions = (int) $this->container->getParameter('app.max_page_revisions'); |
|
159 | + $this->maxRevisions = (int)$this->container->getParameter('app.max_page_revisions'); |
|
160 | 160 | } |
161 | 161 | return $this->maxRevisions; |
162 | 162 | } |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | $this->yearMonthCounts[$editYear]['all']++; |
820 | 820 | $this->yearMonthCounts[$editYear]['months'][$editMonth]['all']++; |
821 | 821 | // This will ultimately be the size of the page by the end of the year |
822 | - $this->yearMonthCounts[$editYear]['size'] = (int) $edit->getLength(); |
|
822 | + $this->yearMonthCounts[$editYear]['size'] = (int)$edit->getLength(); |
|
823 | 823 | |
824 | 824 | // Keep track of which month had the most edits |
825 | 825 | $editsThisMonth = $this->yearMonthCounts[$editYear]['months'][$editMonth]['all']; |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | $editYear = $edit->getYear(); |
839 | 839 | |
840 | 840 | // Beginning of the month at 00:00:00. |
841 | - $firstEditTime = mktime(0, 0, 0, (int) $this->firstEdit->getMonth(), 1, $this->firstEdit->getYear()); |
|
841 | + $firstEditTime = mktime(0, 0, 0, (int)$this->firstEdit->getMonth(), 1, $this->firstEdit->getYear()); |
|
842 | 842 | |
843 | 843 | $this->yearMonthCounts[$editYear] = [ |
844 | 844 | 'all' => 0, |
@@ -973,14 +973,14 @@ discard block |
||
973 | 973 | $botData = $this->getRepository()->getBotData($this->page); |
974 | 974 | while ($bot = $botData->fetch()) { |
975 | 975 | $bots[$bot['username']] = [ |
976 | - 'count' => (int) $bot['count'], |
|
976 | + 'count' => (int)$bot['count'], |
|
977 | 977 | 'current' => $bot['current'] === 'bot', |
978 | 978 | ]; |
979 | 979 | } |
980 | 980 | |
981 | 981 | // Sort by edit count. |
982 | - uasort($bots, function ($a, $b) { |
|
983 | - return $b['count'] - $a['count']; |
|
982 | + uasort($bots, function($a, $b) { |
|
983 | + return $b['count']-$a['count']; |
|
984 | 984 | }); |
985 | 985 | |
986 | 986 | $this->bots = $bots; |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | |
1092 | 1092 | if ($info['all'] > 1) { |
1093 | 1093 | // Number of seconds/days between first and last edit. |
1094 | - $secs = $info['last']->getTimestamp() - $info['first']->getTimestamp(); |
|
1094 | + $secs = $info['last']->getTimestamp()-$info['first']->getTimestamp(); |
|
1095 | 1095 | $days = $secs / (60 * 60 * 24); |
1096 | 1096 | |
1097 | 1097 | // Average time between edits (in days). |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | |
1111 | 1111 | // First sort editors array by the amount of text they added. |
1112 | 1112 | $topTenEditorsByAdded = $this->editors; |
1113 | - uasort($topTenEditorsByAdded, function ($a, $b) { |
|
1113 | + uasort($topTenEditorsByAdded, function($a, $b) { |
|
1114 | 1114 | if ($a['added'] === $b['added']) { |
1115 | 1115 | return 0; |
1116 | 1116 | } |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | |
1120 | 1120 | // Then build a new array of top 10 editors by added text, |
1121 | 1121 | // in the data structure needed for the chart. |
1122 | - $this->topTenEditorsByAdded = array_map(function ($editor) { |
|
1122 | + $this->topTenEditorsByAdded = array_map(function($editor) { |
|
1123 | 1123 | $added = $this->editors[$editor]['added']; |
1124 | 1124 | return [ |
1125 | 1125 | 'label' => $editor, |
@@ -90,20 +90,20 @@ discard block |
||
90 | 90 | |
91 | 91 | // MULTIPLIERS (to review) |
92 | 92 | $multipliers = [ |
93 | - 'account-age-mult' => 1.25, # 0 if = 365 jours |
|
94 | - 'edit-count-mult' => 1.25, # 0 if = 10 000 |
|
95 | - 'user-page-mult' => 0.1, # 0 if = |
|
96 | - 'patrols-mult' => 1, # 0 if = |
|
97 | - 'blocks-mult' => 1.4, # 0 if = 10 |
|
93 | + 'account-age-mult' => 1.25, # 0 if = 365 jours |
|
94 | + 'edit-count-mult' => 1.25, # 0 if = 10 000 |
|
95 | + 'user-page-mult' => 0.1, # 0 if = |
|
96 | + 'patrols-mult' => 1, # 0 if = |
|
97 | + 'blocks-mult' => 1.4, # 0 if = 10 |
|
98 | 98 | 'afd-mult' => 1.15, |
99 | - 'recent-activity-mult' => 0.9, # 0 if = |
|
99 | + 'recent-activity-mult' => 0.9, # 0 if = |
|
100 | 100 | 'aiv-mult' => 1.15, |
101 | - 'edit-summaries-mult' => 0.8, # 0 if = |
|
102 | - 'namespaces-mult' => 1.0, # 0 if = |
|
103 | - 'pages-created-live-mult' => 1.4, # 0 if = |
|
104 | - 'pages-created-deleted-mult' => 1.4, # 0 if = |
|
105 | - 'rpp-mult' => 1.15, # 0 if = |
|
106 | - 'user-rights-mult' => 0.75, # 0 if = |
|
101 | + 'edit-summaries-mult' => 0.8, # 0 if = |
|
102 | + 'namespaces-mult' => 1.0, # 0 if = |
|
103 | + 'pages-created-live-mult' => 1.4, # 0 if = |
|
104 | + 'pages-created-deleted-mult' => 1.4, # 0 if = |
|
105 | + 'rpp-mult' => 1.15, # 0 if = |
|
106 | + 'user-rights-mult' => 0.75, # 0 if = |
|
107 | 107 | ]; |
108 | 108 | |
109 | 109 | // Grab the connection to the replica database (which is separate from the above) |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | $now = new DateTime(); |
186 | 186 | $date = new DateTime($value); |
187 | 187 | $diff = $date->diff($now); |
188 | - $formula = 365 * $diff->format('%y') + 30 * $diff->format('%m') + $diff->format('%d'); |
|
189 | - $value = $formula - 365; |
|
188 | + $formula = 365 * $diff->format('%y')+30 * $diff->format('%m')+$diff->format('%d'); |
|
189 | + $value = $formula-365; |
|
190 | 190 | |
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | - $multiplierKey = $row['source'] . '-mult'; |
|
194 | + $multiplierKey = $row['source'].'-mult'; |
|
195 | 195 | $multiplier = isset($multipliers[$multiplierKey]) ? $multipliers[$multiplierKey] : 1; |
196 | 196 | $score = max(min($value * $multiplier, 100), -100); |
197 | 197 | $master[$key]['mult'] = $multiplier; |