@@ -146,7 +146,7 @@ |
||
| 146 | 146 | |
| 147 | 147 | /** |
| 148 | 148 | * |
| 149 | - * @param $username |
|
| 149 | + * @param string $username |
|
| 150 | 150 | * @return integer |
| 151 | 151 | */ |
| 152 | 152 | public function getPageCounts($username, $totalRevisions) |
@@ -2,12 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace AppBundle\Helper; |
| 4 | 4 | |
| 5 | -use AppBundle\Twig\AppExtension; |
|
| 6 | -use DateInterval; |
|
| 7 | 5 | use Doctrine\DBAL\Connection; |
| 8 | 6 | use Exception; |
| 9 | 7 | use Symfony\Component\DependencyInjection\Container; |
| 10 | -use Symfony\Component\VarDumper\VarDumper; |
|
| 11 | 8 | |
| 12 | 9 | class EditCounterHelper extends HelperBase |
| 13 | 10 | { |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | $total = (int)$stmt->fetchColumn(); |
| 63 | 63 | $topEditCounts[$project['dbName']] = array_merge($project, ['total' => $total]); |
| 64 | 64 | } |
| 65 | - uasort($topEditCounts, function ($a, $b) { |
|
| 66 | - return $b['total'] - $a['total']; |
|
| 65 | + uasort($topEditCounts, function($a, $b) { |
|
| 66 | + return $b['total']-$a['total']; |
|
| 67 | 67 | }); |
| 68 | 68 | return array_slice($topEditCounts, 0, $numProjects); |
| 69 | 69 | } |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $revisionCounts = array_combine( |
| 136 | - array_map(function ($e) { |
|
| 136 | + array_map(function($e) { |
|
| 137 | 137 | return $e['source']; |
| 138 | 138 | }, $results), |
| 139 | - array_map(function ($e) { |
|
| 139 | + array_map(function($e) { |
|
| 140 | 140 | return $e['value']; |
| 141 | 141 | }, $results) |
| 142 | 142 | ); |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | // Count the number of days, accounting for when there's zero or one edit. |
| 145 | 145 | $revisionCounts['days'] = 0; |
| 146 | 146 | if (isset($revisionCounts['first']) && isset($revisionCounts['last'])) { |
| 147 | - $editingTimeInSeconds = ceil($revisionCounts['last'] - $revisionCounts['first']); |
|
| 148 | - $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds/(60*60*24) : 1; |
|
| 147 | + $editingTimeInSeconds = ceil($revisionCounts['last']-$revisionCounts['first']); |
|
| 148 | + $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds / (60 * 60 * 24) : 1; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Format the first and last dates. |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | : 0; |
| 158 | 158 | |
| 159 | 159 | // Sum deleted and live to make the total. |
| 160 | - $revisionCounts['total'] = $revisionCounts['deleted'] + $revisionCounts['live']; |
|
| 160 | + $revisionCounts['total'] = $revisionCounts['deleted']+$revisionCounts['live']; |
|
| 161 | 161 | |
| 162 | 162 | // Calculate the average number of live edits per day. |
| 163 | 163 | $revisionCounts['avg_per_day'] = round( |
@@ -196,16 +196,16 @@ discard block |
||
| 196 | 196 | $results = $resultQuery->fetchAll(); |
| 197 | 197 | |
| 198 | 198 | $pageCounts = array_combine( |
| 199 | - array_map(function ($e) { |
|
| 199 | + array_map(function($e) { |
|
| 200 | 200 | return $e['source']; |
| 201 | 201 | }, $results), |
| 202 | - array_map(function ($e) { |
|
| 202 | + array_map(function($e) { |
|
| 203 | 203 | return $e['value']; |
| 204 | 204 | }, $results) |
| 205 | 205 | ); |
| 206 | 206 | |
| 207 | 207 | // Total created. |
| 208 | - $pageCounts['created'] = $pageCounts['created-live'] + $pageCounts['created-deleted']; |
|
| 208 | + $pageCounts['created'] = $pageCounts['created-live']+$pageCounts['created-deleted']; |
|
| 209 | 209 | |
| 210 | 210 | // Calculate the average number of edits per page. |
| 211 | 211 | $pageCounts['edits_per_page'] = 0; |
@@ -232,17 +232,17 @@ discard block |
||
| 232 | 232 | $resultQuery->execute(); |
| 233 | 233 | $results = $resultQuery->fetchAll(); |
| 234 | 234 | $logCounts = array_combine( |
| 235 | - array_map(function ($e) { |
|
| 235 | + array_map(function($e) { |
|
| 236 | 236 | return $e['source']; |
| 237 | 237 | }, $results), |
| 238 | - array_map(function ($e) { |
|
| 238 | + array_map(function($e) { |
|
| 239 | 239 | return $e['value']; |
| 240 | 240 | }, $results) |
| 241 | 241 | ); |
| 242 | 242 | |
| 243 | 243 | // Make sure there is some value for each of the wanted counts. |
| 244 | 244 | $requiredCounts = [ |
| 245 | - 'thanks-thank', 'review-approve', 'patrol-patrol','block-block', 'block-unblock', |
|
| 245 | + 'thanks-thank', 'review-approve', 'patrol-patrol', 'block-block', 'block-unblock', |
|
| 246 | 246 | 'protect-protect', 'protect-unprotect', 'delete-delete', 'delete-revision', |
| 247 | 247 | 'delete-restore', 'import-import', 'upload-upload', 'upload-overwrite', |
| 248 | 248 | ]; |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | // Merge approvals together. |
| 256 | - $logCounts['review-approve'] = $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'] = $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. |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | public function getNamespaceTotals($userId) |
| 281 | 281 | { |
| 282 | 282 | $sql = "SELECT page_namespace, count(rev_id) AS total |
| 283 | - FROM ".$this->labsHelper->getTable('revision') ." r |
|
| 283 | + FROM ".$this->labsHelper->getTable('revision')." r |
|
| 284 | 284 | JOIN ".$this->labsHelper->getTable('page')." p on r.rev_page = p.page_id |
| 285 | 285 | WHERE r.rev_user = :id GROUP BY page_namespace"; |
| 286 | 286 | $resultQuery = $this->replicas->prepare($sql); |
@@ -288,10 +288,10 @@ discard block |
||
| 288 | 288 | $resultQuery->execute(); |
| 289 | 289 | $results = $resultQuery->fetchAll(); |
| 290 | 290 | $namespaceTotals = array_combine( |
| 291 | - array_map(function ($e) { |
|
| 291 | + array_map(function($e) { |
|
| 292 | 292 | return $e['page_namespace']; |
| 293 | 293 | }, $results), |
| 294 | - array_map(function ($e) { |
|
| 294 | + array_map(function($e) { |
|
| 295 | 295 | return $e['total']; |
| 296 | 296 | }, $results) |
| 297 | 297 | ); |
@@ -316,8 +316,8 @@ discard block |
||
| 316 | 316 | $sql = |
| 317 | 317 | "SELECT rev_id, rev_comment, rev_timestamp, rev_minor_edit, rev_deleted, " |
| 318 | 318 | . " rev_len, rev_parent_id, page_title " |
| 319 | - . " FROM " . $this->labsHelper->getTable('revision', $project['dbName']) |
|
| 320 | - . " JOIN " . $this->labsHelper->getTable('page', $project['dbName']) |
|
| 319 | + . " FROM ".$this->labsHelper->getTable('revision', $project['dbName']) |
|
| 320 | + . " JOIN ".$this->labsHelper->getTable('page', $project['dbName']) |
|
| 321 | 321 | . " ON (rev_page = page_id)" |
| 322 | 322 | . " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username" |
| 323 | 323 | . " ORDER BY rev_timestamp DESC" |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | continue; |
| 333 | 333 | } |
| 334 | 334 | $revsWithProject = array_map( |
| 335 | - function (&$item) use ($project) { |
|
| 335 | + function(&$item) use ($project) { |
|
| 336 | 336 | $item['project_name'] = $project['name']; |
| 337 | 337 | $item['project_url'] = $project['url']; |
| 338 | 338 | $item['project_db_name'] = $project['dbName']; |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | ); |
| 343 | 343 | $allRevisions = array_merge($allRevisions, $revsWithProject); |
| 344 | 344 | } |
| 345 | - usort($allRevisions, function ($a, $b) { |
|
| 346 | - return $b['rev_timestamp'] - $a['rev_timestamp']; |
|
| 345 | + usort($allRevisions, function($a, $b) { |
|
| 346 | + return $b['rev_timestamp']-$a['rev_timestamp']; |
|
| 347 | 347 | }); |
| 348 | 348 | return array_slice($allRevisions, 0, $contribCount); |
| 349 | 349 | } |
@@ -365,8 +365,8 @@ discard block |
||
| 365 | 365 | . " MONTH(rev_timestamp) AS `month`," |
| 366 | 366 | . " page_namespace," |
| 367 | 367 | . " COUNT(rev_id) AS `count` " |
| 368 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
| 369 | - . " JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" |
|
| 368 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
| 369 | + . " JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)" |
|
| 370 | 370 | . " WHERE rev_user_text = :username" |
| 371 | 371 | . " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace " |
| 372 | 372 | . " ORDER BY rev_timestamp DESC"; |
@@ -422,10 +422,10 @@ discard block |
||
| 422 | 422 | . " SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4) AS `year`," |
| 423 | 423 | . " page_namespace," |
| 424 | 424 | . " COUNT(rev_id) AS `count` " |
| 425 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
| 426 | - . " JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" . |
|
| 427 | - " WHERE rev_user_text = :username" . |
|
| 428 | - " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace " . |
|
| 425 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
| 426 | + . " JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)". |
|
| 427 | + " WHERE rev_user_text = :username". |
|
| 428 | + " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace ". |
|
| 429 | 429 | " ORDER BY rev_timestamp DESC "; |
| 430 | 430 | $resultQuery = $this->replicas->prepare($sql); |
| 431 | 431 | $resultQuery->bindParam(":username", $username); |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | . " DAYOFWEEK(rev_timestamp) AS `y`, " |
| 467 | 467 | . " $xCalc AS `x`, " |
| 468 | 468 | . " COUNT(rev_id) AS `r` " |
| 469 | - . " FROM " . $this->labsHelper->getTable('revision') |
|
| 469 | + . " FROM ".$this->labsHelper->getTable('revision') |
|
| 470 | 470 | . " WHERE rev_user_text = :username" |
| 471 | 471 | . " GROUP BY DAYOFWEEK(rev_timestamp), $xCalc " |
| 472 | 472 | . " "; |
@@ -4,10 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Doctrine\DBAL\Connection; |
| 6 | 6 | use Psr\Cache\CacheItemPoolInterface; |
| 7 | -use Symfony\Component\Config\Definition\Exception\Exception; |
|
| 8 | -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
| 9 | 7 | use Symfony\Component\DependencyInjection\ContainerInterface; |
| 10 | -use Symfony\Component\VarDumper\VarDumper; |
|
| 11 | 8 | |
| 12 | 9 | class AutomatedEditsHelper |
| 13 | 10 | { |
@@ -125,7 +125,7 @@ |
||
| 125 | 125 | /** @var LabsHelper $labsHelper */ |
| 126 | 126 | $labsHelper = $this->container->get('app.labs_helper'); |
| 127 | 127 | $sql = "SELECT rev_comment FROM ".$labsHelper->getTable('revision') |
| 128 | - ." WHERE rev_user=:userId ORDER BY rev_timestamp DESC LIMIT 1000"; |
|
| 128 | + ." WHERE rev_user=:userId ORDER BY rev_timestamp DESC LIMIT 1000"; |
|
| 129 | 129 | $resultQuery = $replicas->prepare($sql); |
| 130 | 130 | $resultQuery->bindParam("userId", $userId); |
| 131 | 131 | $resultQuery->execute(); |
@@ -72,7 +72,6 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * Get a link to the given user's userpage, or to Special:Contribs if $username is an IP |
| 75 | - * @param string $username Username |
|
| 76 | 75 | * @param string $projectUrl Project domain and protocol such as https://en.wikipedia.org |
| 77 | 76 | * @param string [$label] The link text, defaults to $username |
| 78 | 77 | * @return string Markup |
@@ -176,7 +175,7 @@ discard block |
||
| 176 | 175 | /** |
| 177 | 176 | * Get links to pageviews tools for the given page |
| 178 | 177 | * @param string $title Title of page |
| 179 | - * @param string $projectUrl Project domain such as en.wikipedia.org |
|
| 178 | + * @param string $project Project domain such as en.wikipedia.org |
|
| 180 | 179 | * @return string Markup |
| 181 | 180 | */ |
| 182 | 181 | public function pageviewsLinks($title, $project) |
@@ -14,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,9 +244,9 @@ discard block |
||
| 244 | 244 | public function getFilters() |
| 245 | 245 | { |
| 246 | 246 | return [ |
| 247 | - new \Twig_SimpleFilter('percent_format', [ $this, 'percentFormat' ]), |
|
| 248 | - new \Twig_SimpleFilter('diff_format', [ $this, 'diffFormat' ], [ 'is_safe' => [ 'html' ] ]), |
|
| 249 | - new \Twig_SimpleFilter('wikify_comment', [ $this, 'wikifyComment' ], [ 'is_safe' => [ 'html' ] ]), |
|
| 247 | + new \Twig_SimpleFilter('percent_format', [$this, 'percentFormat']), |
|
| 248 | + new \Twig_SimpleFilter('diff_format', [$this, 'diffFormat'], ['is_safe' => ['html']]), |
|
| 249 | + new \Twig_SimpleFilter('wikify_comment', [$this, 'wikifyComment'], ['is_safe' => ['html']]), |
|
| 250 | 250 | ]; |
| 251 | 251 | } |
| 252 | 252 | |
@@ -282,10 +282,10 @@ discard block |
||
| 282 | 282 | if (!$denominator) { |
| 283 | 283 | $quotient = $numerator; |
| 284 | 284 | } else { |
| 285 | - $quotient = ( $numerator / $denominator ) * 100; |
|
| 285 | + $quotient = ($numerator / $denominator) * 100; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - return round($quotient, $precision) . '%'; |
|
| 288 | + return round($quotient, $precision).'%'; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | if ($isSection) { |
| 304 | 304 | $sectionTitle = $sectionMatch[1][0]; |
| 305 | 305 | $sectionTitleLink = str_replace(' ', '_', $sectionTitle); |
| 306 | - $sectionWikitext = "<a target='_blank' href='$projectUrl/wiki/$title#$sectionTitleLink'>→</a>" . |
|
| 306 | + $sectionWikitext = "<a target='_blank' href='$projectUrl/wiki/$title#$sectionTitleLink'>→</a>". |
|
| 307 | 307 | "<em class='text-muted'>$sectionTitle:</em> "; |
| 308 | 308 | $wikitext = str_replace($sectionMatch[0][0], $sectionWikitext, $wikitext); |
| 309 | 309 | } |
@@ -176,7 +176,7 @@ |
||
| 176 | 176 | |
| 177 | 177 | // Iterate over query results, loading each user id into the array |
| 178 | 178 | while ($row = $res->fetch()) { |
| 179 | - $adminIdArr[] = $row["user_id"] ; |
|
| 179 | + $adminIdArr[] = $row["user_id"]; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // Set the query results to be useful in a sql statement. |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace AppBundle\Helper; |
| 4 | 4 | |
| 5 | -use DateInterval; |
|
| 6 | 5 | use Mediawiki\Api\MediawikiApi; |
| 7 | 6 | use Mediawiki\Api\SimpleRequest; |
| 8 | 7 | use Mediawiki\Api\FluentRequest; |
@@ -138,6 +138,9 @@ discard block |
||
| 138 | 138 | return $result; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | + /** |
|
| 142 | + * @param string $username |
|
| 143 | + */ |
|
| 141 | 144 | public function groups($project, $username) |
| 142 | 145 | { |
| 143 | 146 | $this->setUp($project); |
@@ -157,6 +160,9 @@ discard block |
||
| 157 | 160 | return $result; |
| 158 | 161 | } |
| 159 | 162 | |
| 163 | + /** |
|
| 164 | + * @param string $username |
|
| 165 | + */ |
|
| 160 | 166 | public function globalGroups($project, $username) |
| 161 | 167 | { |
| 162 | 168 | $this->setUp($project); |
@@ -180,7 +186,7 @@ discard block |
||
| 180 | 186 | * Get a list of namespaces on the given project. |
| 181 | 187 | * |
| 182 | 188 | * @param string $project such as en.wikipedia.org |
| 183 | - * @return string[] Array of namespace IDs (keys) to names (values). |
|
| 189 | + * @return string Array of namespace IDs (keys) to names (values). |
|
| 184 | 190 | */ |
| 185 | 191 | public function namespaces($project) |
| 186 | 192 | { |
@@ -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); |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | $username = $request->query->get('username'); |
| 31 | 31 | |
| 32 | 32 | if (($project || $queryProject) && $username) { |
| 33 | - $routeParams = [ 'project'=>($project ?: $queryProject), 'username' => $username ]; |
|
| 33 | + $routeParams = ['project'=>($project ?: $queryProject), 'username' => $username]; |
|
| 34 | 34 | return $this->redirectToRoute("EditCounterResult", $routeParams); |
| 35 | 35 | } elseif (!$project && $queryProject) { |
| 36 | - return $this->redirectToRoute("EditCounterProject", [ 'project'=>$queryProject ]); |
|
| 36 | + return $this->redirectToRoute("EditCounterProject", ['project'=>$queryProject]); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Otherwise fall through. |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | 'rev_small' => $revisionCounts['small'], |
| 115 | 115 | 'rev_large' => $revisionCounts['large'], |
| 116 | 116 | 'with_comments' => $revisionCounts['with_comments'], |
| 117 | - 'without_comments' => $revisionCounts['live'] - $revisionCounts['with_comments'], |
|
| 117 | + 'without_comments' => $revisionCounts['live']-$revisionCounts['with_comments'], |
|
| 118 | 118 | 'minor_edits' => $revisionCounts['minor_edits'], |
| 119 | - 'nonminor_edits' => $revisionCounts['live'] - $revisionCounts['minor_edits'], |
|
| 119 | + 'nonminor_edits' => $revisionCounts['live']-$revisionCounts['minor_edits'], |
|
| 120 | 120 | |
| 121 | 121 | // Page counts. |
| 122 | 122 | 'uniquePages' => $pageCounts['unique'], |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 6 | 6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
| 7 | -use Symfony\Component\Debug\Exception\ContextErrorException; |
|
| 8 | 7 | use Symfony\Component\Routing\Exception\InvalidParameterException; |
| 9 | 8 | use Symfony\Component\HttpFoundation\Request; |
| 10 | 9 | |
@@ -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, |
@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
| 6 | 6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 7 | 7 | use Symfony\Component\HttpFoundation\Request; |
| 8 | -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
| 9 | 8 | |
| 10 | 9 | class AutomatedEditsController extends Controller |
| 11 | 10 | { |
@@ -155,8 +155,8 @@ |
||
| 155 | 155 | $rev = $lh->getTable("revision", $dbName); |
| 156 | 156 | $arc = $lh->getTable("archive", $dbName); |
| 157 | 157 | |
| 158 | - $cond_begin = ( $start ) ? " AND rev_timestamp > :start " : null; |
|
| 159 | - $cond_end = ( $end ) ? " AND rev_timestamp < :end ": null; |
|
| 158 | + $cond_begin = ($start) ? " AND rev_timestamp > :start " : null; |
|
| 159 | + $cond_end = ($end) ? " AND rev_timestamp < :end " : null; |
|
| 160 | 160 | |
| 161 | 161 | foreach ($AEBTypes as $toolname => $check) { |
| 162 | 162 | $toolname = $dbh->quote($toolname, \PDO::PARAM_STR); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | 'username' => $username, |
| 50 | 50 | ]); |
| 51 | 51 | } elseif ($project != "") { |
| 52 | - return $this->redirectToRoute("TopEditsResults", [ 'project'=>$project ]); |
|
| 52 | + return $this->redirectToRoute("TopEditsResults", ['project'=>$project]); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // set default wiki so we can populate the namespace selector |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // Get page info about these 100 pages, so we can use their display title. |
| 130 | - $titles = array_map(function ($e) { |
|
| 130 | + $titles = array_map(function($e) { |
|
| 131 | 131 | return $e['page_title']; |
| 132 | 132 | }, $editData); |
| 133 | 133 | $displayTitles = $apiHelper->displayTitles($project, $titles); |