@@ -150,7 +150,7 @@ |
||
| 150 | 150 | // $tableExtension in order to generate the new table name |
| 151 | 151 | if ($this->isLabs() && $tableExtension !== null) { |
| 152 | 152 | $mapped = true; |
| 153 | - $tableName = $tableName . '_' . $tableExtension; |
|
| 153 | + $tableName = $tableName.'_'.$tableExtension; |
|
| 154 | 154 | } elseif ($this->container->hasParameter("app.table.$tableName")) { |
| 155 | 155 | // Use the table specified in the table mapping configuration, if present. |
| 156 | 156 | $mapped = true; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $revTable = $project->getRepository()->getTableName($project->getDatabaseName(), 'revision'); |
| 127 | 127 | $pageTable = $project->getRepository()->getTableName($project->getDatabaseName(), 'page'); |
| 128 | 128 | |
| 129 | - $AEBTypes = array_map(function ($AEBType) { |
|
| 129 | + $AEBTypes = array_map(function($AEBType) { |
|
| 130 | 130 | return $AEBType['regex']; |
| 131 | 131 | }, $this->container->getParameter('automated_tools')); |
| 132 | 132 | |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Get diff sizes, based on length of each parent revision |
| 154 | - $parentRevIds = array_map(function ($edit) { |
|
| 154 | + $parentRevIds = array_map(function($edit) { |
|
| 155 | 155 | return $edit['rev_parent_id']; |
| 156 | 156 | }, $editData); |
| 157 | 157 | $query = "SELECT rev_len, rev_id |
| 158 | 158 | FROM revision |
| 159 | - WHERE rev_id IN (" . implode(',', $parentRevIds) . ")"; |
|
| 159 | + WHERE rev_id IN (" . implode(',', $parentRevIds).")"; |
|
| 160 | 160 | $diffSizeData = $conn->executeQuery($query)->fetchAll(); |
| 161 | 161 | |
| 162 | 162 | // reformat with rev_id as the key, rev_len as the value |
@@ -166,24 +166,24 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // Build our array of nonautomated edits |
| 169 | - $editData = array_map(function ($edit) use ($namespaces, $diffSizes) { |
|
| 169 | + $editData = array_map(function($edit) use ($namespaces, $diffSizes) { |
|
| 170 | 170 | $pageTitle = $edit['page_title']; |
| 171 | 171 | |
| 172 | 172 | if ($edit['page_namespace'] !== '0') { |
| 173 | - $pageTitle = $namespaces[$edit['page_namespace']] . ":$pageTitle"; |
|
| 173 | + $pageTitle = $namespaces[$edit['page_namespace']].":$pageTitle"; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $diffSize = $edit['rev_len']; |
| 177 | 177 | if ($edit['rev_parent_id'] > 0) { |
| 178 | - $diffSize = $edit['rev_len'] - $diffSizes[$edit['rev_parent_id']]; |
|
| 178 | + $diffSize = $edit['rev_len']-$diffSizes[$edit['rev_parent_id']]; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | return [ |
| 182 | 182 | 'page_title' => $pageTitle, |
| 183 | - 'namespace' => (int) $edit['page_namespace'], |
|
| 184 | - 'rev_id' => (int) $edit['rev_id'], |
|
| 183 | + 'namespace' => (int)$edit['page_namespace'], |
|
| 184 | + 'rev_id' => (int)$edit['rev_id'], |
|
| 185 | 185 | 'timestamp' => DateTime::createFromFormat('YmdHis', $edit['rev_timestamp']), |
| 186 | - 'minor_edit' => (bool) $edit['rev_minor_edit'], |
|
| 186 | + 'minor_edit' => (bool)$edit['rev_minor_edit'], |
|
| 187 | 187 | 'summary' => $edit['rev_comment'], |
| 188 | 188 | 'size' => $diffSize |
| 189 | 189 | ]; |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | $article = $request->query->get('article'); |
| 84 | 84 | |
| 85 | 85 | if ($projectQuery != '' && $article != '') { |
| 86 | - return $this->redirectToRoute('ArticleInfoResult', [ 'project'=>$projectQuery, 'article' => $article ]); |
|
| 86 | + return $this->redirectToRoute('ArticleInfoResult', ['project'=>$projectQuery, 'article' => $article]); |
|
| 87 | 87 | } elseif ($article != '') { |
| 88 | - return $this->redirectToRoute('ArticleInfoProject', [ 'project'=>$projectQuery ]); |
|
| 88 | + return $this->redirectToRoute('ArticleInfoProject', ['project'=>$projectQuery]); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | if ($projectQuery == '') { |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $this->pageInfo['firstEdit'] = new Edit($this->pageInfo['page'], $this->pageHistory[0]); |
| 154 | 154 | $this->pageInfo['lastEdit'] = new Edit( |
| 155 | 155 | $this->pageInfo['page'], |
| 156 | - $this->pageHistory[$page->getNumRevisions() - 1] |
|
| 156 | + $this->pageHistory[$page->getNumRevisions()-1] |
|
| 157 | 157 | ); |
| 158 | 158 | |
| 159 | 159 | // NOTE: bots are fetched first in case we want to restrict some stats to humans editors only |
@@ -215,10 +215,10 @@ discard block |
||
| 215 | 215 | $userGroupsTable = $this->projectRepo->getTableName($this->dbName, 'user_groups'); |
| 216 | 216 | $userFromerGroupsTable = $this->projectRepo->getTableName($this->dbName, 'user_former_groups'); |
| 217 | 217 | $query = "SELECT COUNT(rev_user_text) AS count, rev_user_text AS username, ug_group AS current |
| 218 | - FROM " . $this->projectRepo->getTableName($this->dbName, 'revision') . " |
|
| 218 | + FROM " . $this->projectRepo->getTableName($this->dbName, 'revision')." |
|
| 219 | 219 | LEFT JOIN $userGroupsTable ON rev_user = ug_user |
| 220 | 220 | LEFT JOIN $userFromerGroupsTable ON rev_user = ufg_user |
| 221 | - WHERE rev_page = " . $this->pageInfo['page']->getId() . " AND (ug_group = 'bot' OR ufg_group = 'bot') |
|
| 221 | + WHERE rev_page = ".$this->pageInfo['page']->getId()." AND (ug_group = 'bot' OR ufg_group = 'bot') |
|
| 222 | 222 | GROUP BY rev_user_text"; |
| 223 | 223 | $res = $this->conn->query($query)->fetchAll(); |
| 224 | 224 | |
@@ -227,14 +227,14 @@ discard block |
||
| 227 | 227 | $sum = 0; |
| 228 | 228 | foreach ($res as $bot) { |
| 229 | 229 | $bots[$bot['username']] = [ |
| 230 | - 'count' => (int) $bot['count'], |
|
| 230 | + 'count' => (int)$bot['count'], |
|
| 231 | 231 | 'current' => $bot['current'] === 'bot' |
| 232 | 232 | ]; |
| 233 | 233 | $sum += $bot['count']; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - uasort($bots, function ($a, $b) { |
|
| 237 | - return $b['count'] - $a['count']; |
|
| 236 | + uasort($bots, function($a, $b) { |
|
| 237 | + return $b['count']-$a['count']; |
|
| 238 | 238 | }); |
| 239 | 239 | |
| 240 | 240 | $this->pageInfo['general']['bot_revision_count'] = $sum; |
@@ -282,10 +282,10 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | if ($info['all'] > 1) { |
| 284 | 284 | // Number of seconds between first and last edit |
| 285 | - $secs = intval(strtotime($info['last']) - strtotime($info['first']) / $info['all']); |
|
| 285 | + $secs = intval(strtotime($info['last'])-strtotime($info['first']) / $info['all']); |
|
| 286 | 286 | |
| 287 | 287 | // Average time between edits (in days) |
| 288 | - $this->pageInfo['editors'][$editor]['atbe'] = $secs / ( 60 * 60 * 24 ); |
|
| 288 | + $this->pageInfo['editors'][$editor]['atbe'] = $secs / (60 * 60 * 24); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | if (count($info['sizes'])) { |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | // First sort editors array by the amount of text they added |
| 302 | 302 | $topTenEditorsByAdded = $this->pageInfo['editors']; |
| 303 | - uasort($topTenEditorsByAdded, function ($a, $b) { |
|
| 303 | + uasort($topTenEditorsByAdded, function($a, $b) { |
|
| 304 | 304 | if ($a['added'] === $b['added']) { |
| 305 | 305 | return 0; |
| 306 | 306 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | // Then build a new array of top 10 editors by added text, |
| 311 | 311 | // in the data structure needed for the chart |
| 312 | - $this->pageInfo['topTenEditorsByAdded'] = array_map(function ($editor) { |
|
| 312 | + $this->pageInfo['topTenEditorsByAdded'] = array_map(function($editor) { |
|
| 313 | 313 | $added = $this->pageInfo['editors'][$editor]['added']; |
| 314 | 314 | return [ |
| 315 | 315 | 'label' => $editor, |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | |
| 357 | 357 | // Transform to associative array by 'type' |
| 358 | 358 | foreach ($res as $row) { |
| 359 | - $data[$row['type'] . '_count'] = $row['value']; |
|
| 359 | + $data[$row['type'].'_count'] = $row['value']; |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | return $data; |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | $title = str_replace(' ', '_', $this->pageInfo['page']->getTitle()); |
| 373 | 373 | $query = "SELECT log_action, log_type, log_timestamp AS timestamp |
| 374 | 374 | FROM $loggingTable |
| 375 | - WHERE log_namespace = '" . $this->pageInfo['page']->getNamespace() . "' |
|
| 375 | + WHERE log_namespace = '".$this->pageInfo['page']->getNamespace()."' |
|
| 376 | 376 | AND log_title = '$title' AND log_timestamp > 1 |
| 377 | 377 | AND log_type IN ('delete', 'move', 'protect', 'stable')"; |
| 378 | 378 | $events = $this->conn->query($query)->fetchAll(); |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | $conn = $this->container->get('doctrine')->getManager('replicas')->getConnection(); |
| 472 | 472 | $res = $conn->query($query)->fetchAll(); |
| 473 | 473 | |
| 474 | - $terms = array_map(function ($entry) { |
|
| 474 | + $terms = array_map(function($entry) { |
|
| 475 | 475 | return $entry['term']; |
| 476 | 476 | }, $res); |
| 477 | 477 | |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | 'prio' => 2, |
| 483 | 483 | 'name' => 'Wikidata', |
| 484 | 484 | 'notice' => "Label for language <em>$lang</em> is missing", // FIXME: i18n |
| 485 | - 'explanation' => "See: <a target='_blank' " . |
|
| 485 | + 'explanation' => "See: <a target='_blank' ". |
|
| 486 | 486 | "href='//www.wikidata.org/wiki/Help:Label'>Help:Label</a>", |
| 487 | 487 | ]; |
| 488 | 488 | } |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | 'prio' => 3, |
| 492 | 492 | 'name' => 'Wikidata', |
| 493 | 493 | 'notice' => "Description for language <em>$lang</em> is missing", // FIXME: i18n |
| 494 | - 'explanation' => "See: <a target='_blank' " . |
|
| 494 | + 'explanation' => "See: <a target='_blank' ". |
|
| 495 | 495 | "href='//www.wikidata.org/wiki/Help:Description'>Help:Description</a>", |
| 496 | 496 | ]; |
| 497 | 497 | } |
@@ -512,14 +512,14 @@ discard block |
||
| 512 | 512 | return $rev['length']; |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - $lastRev = $this->pageHistory[$revIndex - 1]; |
|
| 515 | + $lastRev = $this->pageHistory[$revIndex-1]; |
|
| 516 | 516 | |
| 517 | 517 | // TODO: Remove once T101631 is resolved |
| 518 | 518 | // Treat as zero change in size if length of previous edit is missing |
| 519 | 519 | if ($lastRev['length'] === null) { |
| 520 | 520 | return 0; |
| 521 | 521 | } else { |
| 522 | - return $rev['length'] - $lastRev['length']; |
|
| 522 | + return $rev['length']-$lastRev['length']; |
|
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | |
@@ -539,10 +539,10 @@ discard block |
||
| 539 | 539 | |
| 540 | 540 | // Get UNIX timestamp of the first day of the month of the first edit |
| 541 | 541 | // This is used as a comparison when building our array of per-month stats |
| 542 | - $firstEditMonth = mktime(0, 0, 0, (int) $firstEdit->getMonth(), 1, $firstEdit->getYear()); |
|
| 542 | + $firstEditMonth = mktime(0, 0, 0, (int)$firstEdit->getMonth(), 1, $firstEdit->getYear()); |
|
| 543 | 543 | |
| 544 | 544 | $lastEdit = $this->pageInfo['lastEdit']; |
| 545 | - $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[ $revisionCount - 2 ]; |
|
| 545 | + $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[$revisionCount-2]; |
|
| 546 | 546 | |
| 547 | 547 | // Now we can start our master array. This one will be HUGE! |
| 548 | 548 | $data = [ |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | // Increment year and month counts for all edits |
| 614 | 614 | $data['year_count'][$edit->getYear()]['all']++; |
| 615 | 615 | $data['year_count'][$edit->getYear()]['months'][$edit->getMonth()]['all']++; |
| 616 | - $data['year_count'][$edit->getYear()]['size'] = (int) $rev['length']; |
|
| 616 | + $data['year_count'][$edit->getYear()]['size'] = (int)$rev['length']; |
|
| 617 | 617 | |
| 618 | 618 | $editsThisMonth = $data['year_count'][$edit->getYear()]['months'][$edit->getMonth()]['all']; |
| 619 | 619 | if ($editsThisMonth > $data['max_edits_per_month']) { |
@@ -657,9 +657,9 @@ discard block |
||
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | // determine if the next revision was a revert |
| 660 | - $nextRevision = isset($this->pageHistory[$i + 1]) ? $this->pageHistory[$i + 1] : null; |
|
| 660 | + $nextRevision = isset($this->pageHistory[$i+1]) ? $this->pageHistory[$i+1] : null; |
|
| 661 | 661 | $nextRevisionIsRevert = $nextRevision && |
| 662 | - $this->getDiffSize($i + 1) === -$edit->getSize() && |
|
| 662 | + $this->getDiffSize($i+1) === -$edit->getSize() && |
|
| 663 | 663 | $this->aeh->isRevert($nextRevision['comment']); |
| 664 | 664 | |
| 665 | 665 | // don't count this edit as content removal if the next edit reverted it |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | public function getPairData(Project $project, User $user) |
| 28 | 28 | { |
| 29 | 29 | // Set up cache. |
| 30 | - $cacheKey = 'pairdata.' . $project->getDatabaseName() . '.' . $user->getUsername(); |
|
| 30 | + $cacheKey = 'pairdata.'.$project->getDatabaseName().'.'.$user->getUsername(); |
|
| 31 | 31 | if ($this->cache->hasItem($cacheKey)) { |
| 32 | 32 | return $this->cache->getItem($cacheKey)->get(); |
| 33 | 33 | } |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | $resultQuery->execute(); |
| 154 | 154 | $results = $resultQuery->fetchAll(); |
| 155 | 155 | $logCounts = array_combine( |
| 156 | - array_map(function ($e) { |
|
| 156 | + array_map(function($e) { |
|
| 157 | 157 | return $e['source']; |
| 158 | 158 | }, $results), |
| 159 | - array_map(function ($e) { |
|
| 159 | + array_map(function($e) { |
|
| 160 | 160 | return $e['value']; |
| 161 | 161 | }, $results) |
| 162 | 162 | ); |
@@ -378,9 +378,9 @@ discard block |
||
| 378 | 378 | $resultQuery->bindParam(":id", $userId); |
| 379 | 379 | $resultQuery->execute(); |
| 380 | 380 | $results = $resultQuery->fetchAll(); |
| 381 | - $namespaceTotals = array_combine(array_map(function ($e) { |
|
| 381 | + $namespaceTotals = array_combine(array_map(function($e) { |
|
| 382 | 382 | return $e['page_namespace']; |
| 383 | - }, $results), array_map(function ($e) { |
|
| 383 | + }, $results), array_map(function($e) { |
|
| 384 | 384 | return $e['total']; |
| 385 | 385 | }, $results)); |
| 386 | 386 | |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | $queries[] = $sql; |
| 441 | 441 | } |
| 442 | - $sql = "(\n" . join("\n) UNION (\n", $queries) . ")\n"; |
|
| 442 | + $sql = "(\n".join("\n) UNION (\n", $queries).")\n"; |
|
| 443 | 443 | $resultQuery = $this->getProjectsConnection()->prepare($sql); |
| 444 | 444 | $resultQuery->bindParam(":username", $username); |
| 445 | 445 | $resultQuery->execute(); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | 'username' => $username, |
| 70 | 70 | ]); |
| 71 | 71 | } elseif ($projectName != "") { |
| 72 | - return $this->redirectToRoute("TopEditsResults", [ 'project'=>$projectName ]); |
|
| 72 | + return $this->redirectToRoute("TopEditsResults", ['project'=>$projectName]); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // Set default project so we can populate the namespace selector. |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | // Get page info about these 100 pages, so we can use their display title. |
| 173 | - $titles = array_map(function ($e) use ($namespaces) { |
|
| 173 | + $titles = array_map(function($e) use ($namespaces) { |
|
| 174 | 174 | // If non-mainspace, prepend namespace to the titles. |
| 175 | 175 | $ns = $e['page_namespace']; |
| 176 | - $nsTitle = $ns > 0 ? $namespaces[$e['page_namespace']] . ':' : ''; |
|
| 177 | - return $nsTitle . $e['page_title']; |
|
| 176 | + $nsTitle = $ns > 0 ? $namespaces[$e['page_namespace']].':' : ''; |
|
| 177 | + return $nsTitle.$e['page_title']; |
|
| 178 | 178 | }, $editData); |
| 179 | 179 | |
| 180 | 180 | /** @var ApiHelper $apiHelper */ |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | foreach ($editData as $editDatum) { |
| 191 | 191 | // If non-mainspace, prepend namespace to the titles. |
| 192 | 192 | $ns = $editDatum['page_namespace']; |
| 193 | - $nsTitle = $ns > 0 ? $namespaces[$editDatum['page_namespace']] . ':' : ''; |
|
| 194 | - $pageTitle = $nsTitle . $editDatum['page_title']; |
|
| 193 | + $nsTitle = $ns > 0 ? $namespaces[$editDatum['page_namespace']].':' : ''; |
|
| 194 | + $pageTitle = $nsTitle.$editDatum['page_title']; |
|
| 195 | 195 | $editDatum['displaytitle'] = $displayTitles[$pageTitle]; |
| 196 | 196 | // $editDatum['page_title'] is retained without the namespace |
| 197 | 197 | // so we can link to TopEdits for that page |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | // Send all to the template. |
| 252 | 252 | return $this->render('topedits/result_article.html.twig', [ |
| 253 | 253 | 'xtPage' => 'topedits', |
| 254 | - 'xtTitle' => $user->getUsername() . ' - ' . $page->getTitle(), |
|
| 254 | + 'xtTitle' => $user->getUsername().' - '.$page->getTitle(), |
|
| 255 | 255 | 'project' => $project, |
| 256 | 256 | 'user' => $user, |
| 257 | 257 | 'page' => $page, |
@@ -30,32 +30,32 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $options = ['is_safe' => ['html']]; |
| 32 | 32 | return [ |
| 33 | - new \Twig_SimpleFunction('request_time', [ $this, 'requestTime' ], $options), |
|
| 34 | - new \Twig_SimpleFunction('memory_usage', [ $this, 'requestMemory' ], $options), |
|
| 35 | - new \Twig_SimpleFunction('year', [ $this, 'generateYear' ], $options), |
|
| 36 | - new \Twig_SimpleFunction('msgPrintExists', [ $this, 'intuitionMessagePrintExists' ], $options), |
|
| 37 | - new \Twig_SimpleFunction('msgExists', [ $this, 'intuitionMessageExists' ], $options), |
|
| 38 | - new \Twig_SimpleFunction('msg', [ $this, 'intuitionMessage' ], $options), |
|
| 39 | - new \Twig_SimpleFunction('lang', [ $this, 'getLang' ], $options), |
|
| 40 | - new \Twig_SimpleFunction('langName', [ $this, 'getLangName' ], $options), |
|
| 41 | - new \Twig_SimpleFunction('allLangs', [ $this, 'getAllLangs' ]), |
|
| 42 | - new \Twig_SimpleFunction('isRTL', [ $this, 'intuitionIsRTL' ]), |
|
| 43 | - new \Twig_SimpleFunction('isRTLLang', [ $this, 'intuitionIsRTLLang' ]), |
|
| 44 | - new \Twig_SimpleFunction('shortHash', [ $this, 'gitShortHash' ]), |
|
| 45 | - new \Twig_SimpleFunction('hash', [ $this, 'gitHash' ]), |
|
| 46 | - new \Twig_SimpleFunction('enabled', [ $this, 'tabEnabled' ]), |
|
| 47 | - new \Twig_SimpleFunction('tools', [ $this, 'allTools' ]), |
|
| 48 | - new \Twig_SimpleFunction('color', [ $this, 'getColorList' ]), |
|
| 49 | - new \Twig_SimpleFunction('chartColor', [ $this, 'chartColor' ]), |
|
| 50 | - new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]), |
|
| 51 | - new \Twig_SimpleFunction('isSingleWiki', [ $this, 'isSingleWiki' ]), |
|
| 52 | - new \Twig_SimpleFunction('getReplagThreshold', [ $this, 'getReplagThreshold' ]), |
|
| 53 | - new \Twig_SimpleFunction('loadStylesheetsFromCDN', [ $this, 'loadStylesheetsFromCDN' ]), |
|
| 54 | - new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]), |
|
| 55 | - new \Twig_SimpleFunction('replag', [ $this, 'replag' ]), |
|
| 56 | - new \Twig_SimpleFunction('link', [ $this, 'link' ]), |
|
| 57 | - new \Twig_SimpleFunction('quote', [ $this, 'quote' ]), |
|
| 58 | - new \Twig_SimpleFunction('bugReportURL', [ $this, 'bugReportURL' ]), |
|
| 33 | + new \Twig_SimpleFunction('request_time', [$this, 'requestTime'], $options), |
|
| 34 | + new \Twig_SimpleFunction('memory_usage', [$this, 'requestMemory'], $options), |
|
| 35 | + new \Twig_SimpleFunction('year', [$this, 'generateYear'], $options), |
|
| 36 | + new \Twig_SimpleFunction('msgPrintExists', [$this, 'intuitionMessagePrintExists'], $options), |
|
| 37 | + new \Twig_SimpleFunction('msgExists', [$this, 'intuitionMessageExists'], $options), |
|
| 38 | + new \Twig_SimpleFunction('msg', [$this, 'intuitionMessage'], $options), |
|
| 39 | + new \Twig_SimpleFunction('lang', [$this, 'getLang'], $options), |
|
| 40 | + new \Twig_SimpleFunction('langName', [$this, 'getLangName'], $options), |
|
| 41 | + new \Twig_SimpleFunction('allLangs', [$this, 'getAllLangs']), |
|
| 42 | + new \Twig_SimpleFunction('isRTL', [$this, 'intuitionIsRTL']), |
|
| 43 | + new \Twig_SimpleFunction('isRTLLang', [$this, 'intuitionIsRTLLang']), |
|
| 44 | + new \Twig_SimpleFunction('shortHash', [$this, 'gitShortHash']), |
|
| 45 | + new \Twig_SimpleFunction('hash', [$this, 'gitHash']), |
|
| 46 | + new \Twig_SimpleFunction('enabled', [$this, 'tabEnabled']), |
|
| 47 | + new \Twig_SimpleFunction('tools', [$this, 'allTools']), |
|
| 48 | + new \Twig_SimpleFunction('color', [$this, 'getColorList']), |
|
| 49 | + new \Twig_SimpleFunction('chartColor', [$this, 'chartColor']), |
|
| 50 | + new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']), |
|
| 51 | + new \Twig_SimpleFunction('isSingleWiki', [$this, 'isSingleWiki']), |
|
| 52 | + new \Twig_SimpleFunction('getReplagThreshold', [$this, 'getReplagThreshold']), |
|
| 53 | + new \Twig_SimpleFunction('loadStylesheetsFromCDN', [$this, 'loadStylesheetsFromCDN']), |
|
| 54 | + new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']), |
|
| 55 | + new \Twig_SimpleFunction('replag', [$this, 'replag']), |
|
| 56 | + new \Twig_SimpleFunction('link', [$this, 'link']), |
|
| 57 | + new \Twig_SimpleFunction('quote', [$this, 'quote']), |
|
| 58 | + new \Twig_SimpleFunction('bugReportURL', [$this, 'bugReportURL']), |
|
| 59 | 59 | new \Twig_SimpleFunction('logged_in_user', [$this, 'functionLoggedInUser']), |
| 60 | 60 | new \Twig_SimpleFunction('isUserAnon', [$this, 'isUserAnon']), |
| 61 | 61 | new \Twig_SimpleFunction('nsName', [$this, 'nsName']), |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function requestTime($decimals = 3) |
| 71 | 71 | { |
| 72 | - return number_format(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], $decimals); |
|
| 72 | + return number_format(microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'], $decimals); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function intuitionMessageExists($message = "") |
| 104 | 104 | { |
| 105 | - return $this->getIntuition()->msgExists($message, [ "domain" => "xtools" ]); |
|
| 105 | + return $this->getIntuition()->msgExists($message, ["domain" => "xtools"]); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function intuitionMessage($message = "", $vars = []) |
| 135 | 135 | { |
| 136 | - return $this->getIntuition()->msg($message, [ "domain" => "xtools", "variables" => $vars ]); |
|
| 136 | + return $this->getIntuition()->msg($message, ["domain" => "xtools", "variables" => $vars]); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function getAllLangs() |
| 164 | 164 | { |
| 165 | - $messageFiles = glob($this->container->getParameter("kernel.root_dir") . '/../i18n/*.json'); |
|
| 165 | + $messageFiles = glob($this->container->getParameter("kernel.root_dir").'/../i18n/*.json'); |
|
| 166 | 166 | |
| 167 | 167 | $languages = array_values(array_unique(array_map( |
| 168 | - function ($filename) { |
|
| 168 | + function($filename) { |
|
| 169 | 169 | return basename($filename, '.json'); |
| 170 | 170 | }, |
| 171 | 171 | $messageFiles |
@@ -253,41 +253,41 @@ discard block |
||
| 253 | 253 | public static function getColorList($num = false) |
| 254 | 254 | { |
| 255 | 255 | $colors = [ |
| 256 | - 0 => '#Cc0000',# '#FF005A', #red '#FF5555', |
|
| 256 | + 0 => '#Cc0000', # '#FF005A', #red '#FF5555', |
|
| 257 | 257 | 1 => '#F7b7b7', |
| 258 | - 2 => '#5c8d20',# '#008800', #green'#55FF55', |
|
| 258 | + 2 => '#5c8d20', # '#008800', #green'#55FF55', |
|
| 259 | 259 | 3 => '#85eD82', |
| 260 | 260 | 4 => '#2E97E0', # blue |
| 261 | 261 | 5 => '#B9E3F9', |
| 262 | - 6 => '#e1711d', # orange |
|
| 262 | + 6 => '#e1711d', # orange |
|
| 263 | 263 | 7 => '#ffc04c', |
| 264 | 264 | 8 => '#FDFF98', # yellow |
| 265 | 265 | 9 => '#5555FF', |
| 266 | 266 | 10 => '#55FFFF', |
| 267 | - 11 => '#0000C0', # |
|
| 268 | - 12 => '#008800', # green |
|
| 267 | + 11 => '#0000C0', # |
|
| 268 | + 12 => '#008800', # green |
|
| 269 | 269 | 13 => '#00C0C0', |
| 270 | - 14 => '#FFAFAF', # rosé |
|
| 271 | - 15 => '#808080', # gray |
|
| 270 | + 14 => '#FFAFAF', # rosé |
|
| 271 | + 15 => '#808080', # gray |
|
| 272 | 272 | 16 => '#00C000', |
| 273 | 273 | 17 => '#404040', |
| 274 | - 18 => '#C0C000', # green |
|
| 274 | + 18 => '#C0C000', # green |
|
| 275 | 275 | 19 => '#C000C0', |
| 276 | - 100 => '#75A3D1', # blue |
|
| 277 | - 101 => '#A679D2', # purple |
|
| 276 | + 100 => '#75A3D1', # blue |
|
| 277 | + 101 => '#A679D2', # purple |
|
| 278 | 278 | 102 => '#660000', |
| 279 | 279 | 103 => '#000066', |
| 280 | - 104 => '#FAFFAF', # caramel |
|
| 280 | + 104 => '#FAFFAF', # caramel |
|
| 281 | 281 | 105 => '#408345', |
| 282 | 282 | 106 => '#5c8d20', |
| 283 | - 107 => '#e1711d', # red |
|
| 284 | - 108 => '#94ef2b', # light green |
|
| 285 | - 109 => '#756a4a', # brown |
|
| 283 | + 107 => '#e1711d', # red |
|
| 284 | + 108 => '#94ef2b', # light green |
|
| 285 | + 109 => '#756a4a', # brown |
|
| 286 | 286 | 110 => '#6f1dab', |
| 287 | 287 | 111 => '#301e30', |
| 288 | 288 | 112 => '#5c9d96', |
| 289 | - 113 => '#a8cd8c', # earth green |
|
| 290 | - 114 => '#f2b3f1', # light purple |
|
| 289 | + 113 => '#a8cd8c', # earth green |
|
| 290 | + 114 => '#f2b3f1', # light purple |
|
| 291 | 291 | 115 => '#9b5828', |
| 292 | 292 | 118 => '#99FFFF', |
| 293 | 293 | 119 => '#99BBFF', |
@@ -308,8 +308,8 @@ discard block |
||
| 308 | 308 | 446 => '#06DCFB', |
| 309 | 309 | 447 => '#892EE4', |
| 310 | 310 | 460 => '#99FF66', |
| 311 | - 461 => '#99CC66', # green |
|
| 312 | - 470 => '#CCCC33', # ocker |
|
| 311 | + 461 => '#99CC66', # green |
|
| 312 | + 470 => '#CCCC33', # ocker |
|
| 313 | 313 | 471 => '#CCFF33', |
| 314 | 314 | 480 => '#6699FF', |
| 315 | 315 | 481 => '#66FFFF', |
@@ -324,18 +324,18 @@ discard block |
||
| 324 | 324 | 1198 => '#FF34B3', |
| 325 | 325 | 1199 => '#8B1C62', |
| 326 | 326 | |
| 327 | - '#61a9f3',# blue |
|
| 328 | - '#f381b9',# pink |
|
| 327 | + '#61a9f3', # blue |
|
| 328 | + '#f381b9', # pink |
|
| 329 | 329 | '#61E3A9', |
| 330 | 330 | '#D56DE2', |
| 331 | 331 | '#85eD82', |
| 332 | 332 | '#F7b7b7', |
| 333 | 333 | '#CFDF49', |
| 334 | 334 | '#88d8f2', |
| 335 | - '#07AF7B',# green |
|
| 335 | + '#07AF7B', # green |
|
| 336 | 336 | '#B9E3F9', |
| 337 | 337 | '#FFF3AD', |
| 338 | - '#EF606A',# red |
|
| 338 | + '#EF606A', # red |
|
| 339 | 339 | '#EC8833', |
| 340 | 340 | '#FFF100', |
| 341 | 341 | '#87C9A5', |
@@ -526,8 +526,8 @@ discard block |
||
| 526 | 526 | public function getFilters() |
| 527 | 527 | { |
| 528 | 528 | return [ |
| 529 | - new \Twig_SimpleFilter('capitalize_first', [ $this, 'capitalizeFirst' ]), |
|
| 530 | - new \Twig_SimpleFilter('percent_format', [ $this, 'percentFormat' ]), |
|
| 529 | + new \Twig_SimpleFilter('capitalize_first', [$this, 'capitalizeFirst']), |
|
| 530 | + new \Twig_SimpleFilter('percent_format', [$this, 'percentFormat']), |
|
| 531 | 531 | ]; |
| 532 | 532 | } |
| 533 | 533 | |
@@ -554,10 +554,10 @@ discard block |
||
| 554 | 554 | if (!$denominator) { |
| 555 | 555 | $quotient = $numerator; |
| 556 | 556 | } else { |
| 557 | - $quotient = ( $numerator / $denominator ) * 100; |
|
| 557 | + $quotient = ($numerator / $denominator) * 100; |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - return round($quotient, $precision) . '%'; |
|
| 560 | + return round($quotient, $precision).'%'; |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | /** |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function getUrl($withTrailingSlash = true) |
| 119 | 119 | { |
| 120 | - return rtrim($this->getBasicInfo()['url'], '/') . ($withTrailingSlash ? '/' : ''); |
|
| 120 | + return rtrim($this->getBasicInfo()['url'], '/').($withTrailingSlash ? '/' : ''); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | $metadata = $this->getMetadata(); |
| 175 | 175 | return isset($metadata['general']['script']) |
| 176 | 176 | ? $metadata['general']['script'] |
| 177 | - : $this->getScriptPath() . '/index.php'; |
|
| 177 | + : $this->getScriptPath().'/index.php'; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function getApiUrl() |
| 186 | 186 | { |
| 187 | - return rtrim($this->getUrl(), '/') . $this->getRepository()->getApiPath(); |
|
| 187 | + return rtrim($this->getUrl(), '/').$this->getRepository()->getApiPath(); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function userOptInPage(User $user) |
| 218 | 218 | { |
| 219 | - $localPageName = 'User:' . $user->getUsername() . '/EditCounterOptIn.js'; |
|
| 219 | + $localPageName = 'User:'.$user->getUsername().'/EditCounterOptIn.js'; |
|
| 220 | 220 | return $localPageName; |
| 221 | 221 | } |
| 222 | 222 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | // 4. Lastly, see if they've opted in globally on the default project or Meta. |
| 253 | - $globalPageName = $user->getUsername() . '/EditCounterGlobalOptIn.js'; |
|
| 253 | + $globalPageName = $user->getUsername().'/EditCounterGlobalOptIn.js'; |
|
| 254 | 254 | $globalProject = $this->getRepository()->getGlobalProject(); |
| 255 | 255 | if ($globalProject instanceof Project) { |
| 256 | 256 | $globalExists = $globalProject->getRepository() |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | */ |
| 270 | 270 | public function hasPageAssessments() |
| 271 | 271 | { |
| 272 | - return (bool) $this->getRepository()->getAssessmentsConfig($this->getDomain()); |
|
| 272 | + return (bool)$this->getRepository()->getAssessmentsConfig($this->getDomain()); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | $config = $this->getRepository()->getAssessmentsConfig($this->getDomain()); |
| 283 | 283 | |
| 284 | 284 | if (isset($config['class'][$class])) { |
| 285 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config['class'][$class]['badge']; |
|
| 285 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config['class'][$class]['badge']; |
|
| 286 | 286 | } elseif (isset($config['class']['Unknown'])) { |
| 287 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config['class']['Unknown']['badge']; |
|
| 287 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config['class']['Unknown']['badge']; |
|
| 288 | 288 | } else { |
| 289 | 289 | return ""; |
| 290 | 290 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | if ($projMetadata['dbName'] == "$project" |
| 147 | 147 | || $projMetadata['url'] == "$project" |
| 148 | 148 | || $projMetadata['url'] == "https://$project") { |
| 149 | - $this->log->debug(__METHOD__ . " Using cached data for $project"); |
|
| 149 | + $this->log->debug(__METHOD__." Using cached data for $project"); |
|
| 150 | 150 | return $projMetadata; |
| 151 | 151 | } |
| 152 | 152 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | // Redis cache |
| 203 | - $cacheKey = "projectMetadata." . preg_replace("/[^A-Za-z0-9]/", '', $projectUrl); |
|
| 203 | + $cacheKey = "projectMetadata.".preg_replace("/[^A-Za-z0-9]/", '', $projectUrl); |
|
| 204 | 204 | if ($this->cache->hasItem($cacheKey)) { |
| 205 | 205 | $this->metadata = $this->cache->getItem($cacheKey)->get(); |
| 206 | 206 | return $this->metadata; |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | $optedIn = $this->container->getParameter('opted_in'); |
| 281 | 281 | // In case there's just one given. |
| 282 | 282 | if (!is_array($optedIn)) { |
| 283 | - $optedIn = [ $optedIn ]; |
|
| 283 | + $optedIn = [$optedIn]; |
|
| 284 | 284 | } |
| 285 | 285 | return $optedIn; |
| 286 | 286 | } |
@@ -47,8 +47,8 @@ |
||
| 47 | 47 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
| 48 | 48 | |
| 49 | 49 | // Check that a correct namespace value was returned |
| 50 | - $response = (array) json_decode($client->getResponse()->getContent()); |
|
| 51 | - $namespaces = (array) $response['namespaces']; |
|
| 50 | + $response = (array)json_decode($client->getResponse()->getContent()); |
|
| 51 | + $namespaces = (array)$response['namespaces']; |
|
| 52 | 52 | $this->assertEquals('Utilisateur', array_values($namespaces)[2]); // User in French |
| 53 | 53 | } |
| 54 | 54 | } |