@@ -28,7 +28,6 @@ |
||
| 28 | 28 | * @Route("/scottywong tools/adminscore.php", name="AdminScoreLegacy") |
| 29 | 29 | * @Route("/adminscore/{project}", name="AdminScoreProject") |
| 30 | 30 | * @param Request $request The HTTP request. |
| 31 | - * @param string $project The project name. |
|
| 32 | 31 | * @return Response |
| 33 | 32 | */ |
| 34 | 33 | public function indexAction(Request $request) |
@@ -10,10 +10,7 @@ |
||
| 10 | 10 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 11 | 11 | use Symfony\Component\HttpFoundation\Request; |
| 12 | 12 | use Symfony\Component\HttpFoundation\Response; |
| 13 | -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
| 14 | 13 | use DateTime; |
| 15 | -use Xtools\ProjectRepository; |
|
| 16 | -use Xtools\UserRepository; |
|
| 17 | 14 | |
| 18 | 15 | /** |
| 19 | 16 | * The AdminScoreController serves the search form and results page of the AdminScore tool |
@@ -92,20 +92,20 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | // MULTIPLIERS (to review) |
| 94 | 94 | $multipliers = [ |
| 95 | - 'account-age-mult' => 1.25, # 0 if = 365 jours |
|
| 96 | - 'edit-count-mult' => 1.25, # 0 if = 10 000 |
|
| 97 | - 'user-page-mult' => 0.1, # 0 if = |
|
| 98 | - 'patrols-mult' => 1, # 0 if = |
|
| 99 | - 'blocks-mult' => 1.4, # 0 if = 10 |
|
| 95 | + 'account-age-mult' => 1.25, # 0 if = 365 jours |
|
| 96 | + 'edit-count-mult' => 1.25, # 0 if = 10 000 |
|
| 97 | + 'user-page-mult' => 0.1, # 0 if = |
|
| 98 | + 'patrols-mult' => 1, # 0 if = |
|
| 99 | + 'blocks-mult' => 1.4, # 0 if = 10 |
|
| 100 | 100 | 'afd-mult' => 1.15, |
| 101 | - 'recent-activity-mult' => 0.9, # 0 if = |
|
| 101 | + 'recent-activity-mult' => 0.9, # 0 if = |
|
| 102 | 102 | 'aiv-mult' => 1.15, |
| 103 | - 'edit-summaries-mult' => 0.8, # 0 if = |
|
| 104 | - 'namespaces-mult' => 1.0, # 0 if = |
|
| 105 | - 'pages-created-live-mult' => 1.4, # 0 if = |
|
| 106 | - 'pages-created-deleted-mult' => 1.4, # 0 if = |
|
| 107 | - 'rpp-mult' => 1.15, # 0 if = |
|
| 108 | - 'user-rights-mult' => 0.75, # 0 if = |
|
| 103 | + 'edit-summaries-mult' => 0.8, # 0 if = |
|
| 104 | + 'namespaces-mult' => 1.0, # 0 if = |
|
| 105 | + 'pages-created-live-mult' => 1.4, # 0 if = |
|
| 106 | + 'pages-created-deleted-mult' => 1.4, # 0 if = |
|
| 107 | + 'rpp-mult' => 1.15, # 0 if = |
|
| 108 | + 'user-rights-mult' => 0.75, # 0 if = |
|
| 109 | 109 | ]; |
| 110 | 110 | |
| 111 | 111 | // Grab the connection to the replica database (which is separate from the above) |
@@ -188,14 +188,14 @@ discard block |
||
| 188 | 188 | $now = new DateTime(); |
| 189 | 189 | $date = new DateTime($value); |
| 190 | 190 | $diff = $date->diff($now); |
| 191 | - $formula = 365 * $diff->format('%y') + 30 * $diff->format('%m') + $diff->format('%d'); |
|
| 192 | - $value = $formula - 365; |
|
| 191 | + $formula = 365 * $diff->format('%y')+30 * $diff->format('%m')+$diff->format('%d'); |
|
| 192 | + $value = $formula-365; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | if ($key === 'id') { |
| 196 | 196 | $id = $value; |
| 197 | 197 | } else { |
| 198 | - $multiplierKey = $row['source'] . '-mult'; |
|
| 198 | + $multiplierKey = $row['source'].'-mult'; |
|
| 199 | 199 | $multiplier = isset($multipliers[$multiplierKey]) ? $multipliers[$multiplierKey] : 1; |
| 200 | 200 | $score = max(min($value * $multiplier, 100), -100); |
| 201 | 201 | $master[$key]['mult'] = $multiplier; |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | { |
| 144 | 144 | $dbName = $project->getDatabaseName(); |
| 145 | 145 | |
| 146 | - $cacheKey = 'editsummaryusage.' . $dbName . '.' |
|
| 147 | - . $user->getCacheKey() . '.' . $namespace; |
|
| 146 | + $cacheKey = 'editsummaryusage.'.$dbName.'.' |
|
| 147 | + . $user->getCacheKey().'.'.$namespace; |
|
| 148 | 148 | |
| 149 | 149 | $cache = $this->container->get('cache.app'); |
| 150 | 150 | if ($cache->hasItem($cacheKey)) { |
@@ -231,8 +231,7 @@ discard block |
||
| 231 | 231 | if ($row['rev_minor_edit'] == 0) { |
| 232 | 232 | if ($row['rev_comment'] !== '') { |
| 233 | 233 | isset($monthEditsummaryTotals[$monthkey]) ? |
| 234 | - $monthEditsummaryTotals[$monthkey]++ : |
|
| 235 | - $monthEditsummaryTotals[$monthkey] = 1; |
|
| 234 | + $monthEditsummaryTotals[$monthkey]++ : $monthEditsummaryTotals[$monthkey] = 1; |
|
| 236 | 235 | $totalSummariesMajor++; |
| 237 | 236 | } |
| 238 | 237 | |
@@ -249,8 +248,7 @@ discard block |
||
| 249 | 248 | // If there is a comment, count it |
| 250 | 249 | if ($row['rev_comment'] !== '') { |
| 251 | 250 | isset($monthEditsummaryTotals[$monthkey]) ? |
| 252 | - $monthEditsummaryTotals[$monthkey]++ : |
|
| 253 | - $monthEditsummaryTotals[$monthkey] = 1; |
|
| 251 | + $monthEditsummaryTotals[$monthkey]++ : $monthEditsummaryTotals[$monthkey] = 1; |
|
| 254 | 252 | $totalSummariesMinor++; |
| 255 | 253 | $totalEditsMinor++; |
| 256 | 254 | } else { |
@@ -11,9 +11,7 @@ |
||
| 11 | 11 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 12 | 12 | use Symfony\Component\HttpFoundation\Request; |
| 13 | 13 | use Symfony\Component\HttpFoundation\Response; |
| 14 | -use Psr\Cache\CacheItemPoolInterface; |
|
| 15 | 14 | use Xtools\Project; |
| 16 | -use Xtools\ProjectRepository; |
|
| 17 | 15 | use Xtools\User; |
| 18 | 16 | use DateTime; |
| 19 | 17 | use DateInterval; |
@@ -38,7 +38,6 @@ discard block |
||
| 38 | 38 | * The Edit Summary search form. |
| 39 | 39 | * |
| 40 | 40 | * @param Request $request The HTTP request. |
| 41 | - * @param string $project The project database name or domain. |
|
| 42 | 41 | * |
| 43 | 42 | * @Route("/editsummary", name="es") |
| 44 | 43 | * @Route("/editsummary", name="EditSummary") |
@@ -75,9 +74,7 @@ discard block |
||
| 75 | 74 | * Display the Edit Summary results |
| 76 | 75 | * |
| 77 | 76 | * @param Request $request The HTTP request. |
| 78 | - * @param string $project The project domain name. |
|
| 79 | - * @param string $username The username. |
|
| 80 | - * @param string $namespace Namespace ID or 'all' for all namespaces. |
|
| 77 | + * @param integer $namespace Namespace ID or 'all' for all namespaces. |
|
| 81 | 78 | * |
| 82 | 79 | * @Route("/editsummary/{project}/{username}/{namespace}", name="EditSummaryResult") |
| 83 | 80 | * |
@@ -151,8 +151,8 @@ |
||
| 151 | 151 | // Get individual counts of how many times each tool was used. |
| 152 | 152 | // This also includes a wikilink to the tool. |
| 153 | 153 | $toolCounts = $user->getAutomatedCounts($projectData, $namespace, $start, $end); |
| 154 | - $toolsTotal = array_reduce($toolCounts, function ($a, $b) { |
|
| 155 | - return $a + $b['count']; |
|
| 154 | + $toolsTotal = array_reduce($toolCounts, function($a, $b) { |
|
| 155 | + return $a+$b['count']; |
|
| 156 | 156 | }); |
| 157 | 157 | |
| 158 | 158 | // Query to get combined (semi)automated using for all edits |
@@ -11,9 +11,7 @@ |
||
| 11 | 11 | use Symfony\Component\HttpFoundation\RedirectResponse; |
| 12 | 12 | use Symfony\Component\HttpFoundation\Request; |
| 13 | 13 | use Symfony\Component\HttpFoundation\Response; |
| 14 | -use Xtools\ProjectRepository; |
|
| 15 | 14 | use Xtools\User; |
| 16 | -use Xtools\UserRepository; |
|
| 17 | 15 | |
| 18 | 16 | /** |
| 19 | 17 | * This controller serves the AutomatedEdits tool. |
@@ -41,7 +41,6 @@ discard block |
||
| 41 | 41 | * @Route("/automatededits/index.php", name="autoeditsLongIndexPhp") |
| 42 | 42 | * @Route("/autoedits/{project}", name="autoeditsProject") |
| 43 | 43 | * @param Request $request The HTTP request. |
| 44 | - * @param string $project The project name. |
|
| 45 | 44 | * @return Response |
| 46 | 45 | */ |
| 47 | 46 | public function indexAction(Request $request) |
@@ -79,7 +78,7 @@ discard block |
||
| 79 | 78 | * } |
| 80 | 79 | * ) |
| 81 | 80 | * @param Request $request The HTTP request. |
| 82 | - * @param int|string $namespace |
|
| 81 | + * @param integer $namespace |
|
| 83 | 82 | * @param null|string $start |
| 84 | 83 | * @param null|string $end |
| 85 | 84 | * @return RedirectResponse|Response |
@@ -11,12 +11,8 @@ |
||
| 11 | 11 | use Symfony\Component\HttpFoundation\RedirectResponse; |
| 12 | 12 | use Symfony\Component\HttpFoundation\Request; |
| 13 | 13 | use Symfony\Component\HttpFoundation\Response; |
| 14 | -use Xtools\Page; |
|
| 15 | -use Xtools\PagesRepository; |
|
| 16 | 14 | use Xtools\Project; |
| 17 | -use Xtools\ProjectRepository; |
|
| 18 | 15 | use Xtools\User; |
| 19 | -use Xtools\UserRepository; |
|
| 20 | 16 | use Xtools\TopEdits; |
| 21 | 17 | use Xtools\TopEditsRepository; |
| 22 | 18 | use Xtools\Edit; |
@@ -191,7 +191,7 @@ |
||
| 191 | 191 | // Send all to the template. |
| 192 | 192 | return $this->render('topedits/result_article.html.twig', [ |
| 193 | 193 | 'xtPage' => 'topedits', |
| 194 | - 'xtTitle' => $user->getUsername() . ' - ' . $page->getTitle(), |
|
| 194 | + 'xtTitle' => $user->getUsername().' - '.$page->getTitle(), |
|
| 195 | 195 | 'project' => $project, |
| 196 | 196 | 'user' => $user, |
| 197 | 197 | 'page' => $page, |
@@ -45,7 +45,6 @@ discard block |
||
| 45 | 45 | * @Route("/topedits/index.php", name="TopEditsIndex") |
| 46 | 46 | * @Route("/topedits/{project}", name="TopEditsProject") |
| 47 | 47 | * @param Request $request |
| 48 | - * @param string $project The project name. |
|
| 49 | 48 | * @return Response |
| 50 | 49 | */ |
| 51 | 50 | public function indexAction(Request $request) |
@@ -76,8 +75,6 @@ discard block |
||
| 76 | 75 | * @Route("/topedits/{project}/{username}/{namespace}/{article}", name="TopEditsResults", |
| 77 | 76 | * requirements={"article"=".+"}) |
| 78 | 77 | * @param Request $request The HTTP request. |
| 79 | - * @param string $project |
|
| 80 | - * @param string $username |
|
| 81 | 78 | * @param int $namespace |
| 82 | 79 | * @param string $article |
| 83 | 80 | * @return RedirectResponse|Response |
@@ -105,7 +102,7 @@ discard block |
||
| 105 | 102 | * @param Request $request The HTTP request. |
| 106 | 103 | * @param User $user The User. |
| 107 | 104 | * @param Project $project The project. |
| 108 | - * @param integer|string $namespace The namespace ID or 'all' |
|
| 105 | + * @param integer $namespace The namespace ID or 'all' |
|
| 109 | 106 | * @return \Symfony\Component\HttpFoundation\Response |
| 110 | 107 | * @codeCoverageIgnore |
| 111 | 108 | */ |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $params = $this->parseLegacyParams($request, $params); |
| 37 | 37 | |
| 38 | 38 | // Remove blank values. |
| 39 | - return array_filter($params, function ($param) { |
|
| 39 | + return array_filter($params, function($param) { |
|
| 40 | 40 | // 'namespace' or 'username' could be '0'. |
| 41 | 41 | return $param !== null && $param !== ''; |
| 42 | 42 | }); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | ]; |
| 183 | 183 | |
| 184 | 184 | // Remove blank values. |
| 185 | - return array_filter($params, function ($param) { |
|
| 185 | + return array_filter($params, function($param) { |
|
| 186 | 186 | // 'namespace' or 'username' could be '0'. |
| 187 | 187 | return $param !== null && $param !== ''; |
| 188 | 188 | }); |
@@ -171,7 +171,7 @@ |
||
| 171 | 171 | * @param bool $optionalStartDate If set, no start date will be provided |
| 172 | 172 | * if only an end date is given. If false, start date will be set to one |
| 173 | 173 | * month before the end date. |
| 174 | - * @return int[] Start and end date as UTC timestamps. |
|
| 174 | + * @return integer[] Start and end date as UTC timestamps. |
|
| 175 | 175 | */ |
| 176 | 176 | public function getUTCFromDateParams($start, $end, $optionalStartDate = false) |
| 177 | 177 | { |
@@ -9,13 +9,9 @@ |
||
| 9 | 9 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
| 10 | 10 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 11 | 11 | use Symfony\Component\HttpFoundation\Request; |
| 12 | -use Symfony\Component\DependencyInjection\ContainerInterface; |
|
| 13 | 12 | use Symfony\Component\HttpFoundation\Response; |
| 14 | 13 | use Symfony\Component\Process\Process; |
| 15 | 14 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
| 16 | -use Xtools\ProjectRepository; |
|
| 17 | -use Xtools\Page; |
|
| 18 | -use Xtools\PagesRepository; |
|
| 19 | 15 | use Xtools\ArticleInfo; |
| 20 | 16 | |
| 21 | 17 | /** |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | $rendered = str_replace('"', '\"', trim($rendered)); |
| 85 | 85 | |
| 86 | 86 | // Uglify temporary file. |
| 87 | - $tmpFile = sys_get_temp_dir() . '/xtools_articleinfo_gadget.js'; |
|
| 87 | + $tmpFile = sys_get_temp_dir().'/xtools_articleinfo_gadget.js'; |
|
| 88 | 88 | $script = "echo \"$rendered\" | tee $tmpFile >/dev/null && "; |
| 89 | - $script .= $this->get('kernel')->getRootDir() . |
|
| 90 | - "/Resources/node_modules/uglify-es/bin/uglifyjs $tmpFile --mangle " . |
|
| 89 | + $script .= $this->get('kernel')->getRootDir(). |
|
| 90 | + "/Resources/node_modules/uglify-es/bin/uglifyjs $tmpFile --mangle ". |
|
| 91 | 91 | "&& rm $tmpFile >/dev/null"; |
| 92 | 92 | $process = new Process($script); |
| 93 | 93 | $process->run(); |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | $rendered = str_replace('\"', '"', trim($rendered)); |
| 107 | 107 | |
| 108 | 108 | // Add comment after uglifying since it removes comments. |
| 109 | - $rendered = "/**\n * This code was automatically generated and should not " . |
|
| 110 | - "be manually edited.\n * For updates, please copy and paste from " . |
|
| 111 | - $this->generateUrl('ArticleInfoGadget', ['uglify' => 1], UrlGeneratorInterface::ABSOLUTE_URL) . |
|
| 112 | - "\n * Released under GPL v3 license.\n */\n" . $rendered; |
|
| 109 | + $rendered = "/**\n * This code was automatically generated and should not ". |
|
| 110 | + "be manually edited.\n * For updates, please copy and paste from ". |
|
| 111 | + $this->generateUrl('ArticleInfoGadget', ['uglify' => 1], UrlGeneratorInterface::ABSOLUTE_URL). |
|
| 112 | + "\n * Released under GPL v3 license.\n */\n".$rendered; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $response = new \Symfony\Component\HttpFoundation\Response($rendered); |
@@ -12,8 +12,6 @@ |
||
| 12 | 12 | use Symfony\Component\HttpFoundation\RedirectResponse; |
| 13 | 13 | use Symfony\Component\HttpFoundation\Request; |
| 14 | 14 | use Symfony\Component\HttpFoundation\Response; |
| 15 | -use Xtools\ProjectRepository; |
|
| 16 | -use Xtools\UserRepository; |
|
| 17 | 15 | |
| 18 | 16 | /** |
| 19 | 17 | * This controller serves the Pages tool. |
@@ -39,7 +39,6 @@ discard block |
||
| 39 | 39 | * @Route("/pages/index.php", name="PagesIndexPhp") |
| 40 | 40 | * @Route("/pages/{project}", name="PagesProject") |
| 41 | 41 | * @param Request $request |
| 42 | - * @param string $project The project domain name. |
|
| 43 | 42 | * @return Response |
| 44 | 43 | */ |
| 45 | 44 | public function indexAction(Request $request) |
@@ -70,8 +69,6 @@ discard block |
||
| 70 | 69 | * Display the results. |
| 71 | 70 | * @Route("/pages/{project}/{username}/{namespace}/{redirects}", name="PagesResult") |
| 72 | 71 | * @param Request $request |
| 73 | - * @param string $project The project domain name. |
|
| 74 | - * @param string $username The username. |
|
| 75 | 72 | * @param string $namespace The ID of the namespace. |
| 76 | 73 | * @param string $redirects Whether to follow redirects or not. |
| 77 | 74 | * @return RedirectResponse|Response |
@@ -12,8 +12,6 @@ |
||
| 12 | 12 | use Symfony\Component\HttpFoundation\Request; |
| 13 | 13 | use Symfony\Component\HttpFoundation\Response; |
| 14 | 14 | use Xtools\Project; |
| 15 | -use Xtools\ProjectRepository; |
|
| 16 | -use Xtools\User; |
|
| 17 | 15 | |
| 18 | 16 | /** |
| 19 | 17 | * This controller handles the Simple Edit Counter tool. |
@@ -39,7 +39,6 @@ |
||
| 39 | 39 | * @Route("/sc/index.php", name="SimpleEditCounterIndexPhp") |
| 40 | 40 | * @Route("/sc/{project}", name="SimpleEditCounterProject") |
| 41 | 41 | * @param Request $request The HTTP request. |
| 42 | - * @param string $project The project database name or domain. |
|
| 43 | 42 | * @return Response |
| 44 | 43 | */ |
| 45 | 44 | public function indexAction(Request $request) |
@@ -132,16 +132,16 @@ discard block |
||
| 132 | 132 | $rev = $row['value']; |
| 133 | 133 | } |
| 134 | 134 | if ($row['source'] == 'groups') { |
| 135 | - $groups .= $row['value']. ', '; |
|
| 135 | + $groups .= $row['value'].', '; |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Unknown user - If the user is created the $results variable will have 3 entries. |
| 140 | 140 | // This is a workaround to detect non-existent IPs. |
| 141 | 141 | if (count($results) < 3 && $arch == 0 && $rev == 0) { |
| 142 | - $this->addFlash('notice', [ 'no-result', $username]); |
|
| 142 | + $this->addFlash('notice', ['no-result', $username]); |
|
| 143 | 143 | |
| 144 | - return $this->redirectToRoute('SimpleEditCounterProject', [ 'project' => $project->getDomain() ]); |
|
| 144 | + return $this->redirectToRoute('SimpleEditCounterProject', ['project' => $project->getDomain()]); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // Remove the last comma and space |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | 'project' => $project, |
| 171 | 171 | 'id' => $id, |
| 172 | 172 | 'arch' => $arch, |
| 173 | - 'rev' => $rev + $arch, |
|
| 173 | + 'rev' => $rev+$arch, |
|
| 174 | 174 | 'live' => $rev, |
| 175 | 175 | 'groups' => $groups, |
| 176 | 176 | 'globalGroups' => $globalGroups, |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // Generate a diff for the dates - this is the number of days we're spanning. |
| 106 | - $days = ($end - $start) / 60 / 60 / 24; |
|
| 106 | + $days = ($end-$start) / 60 / 60 / 24; |
|
| 107 | 107 | |
| 108 | 108 | // Get admin ID's, used to account for inactive admins |
| 109 | 109 | $userGroupsTable = $projectData->getTableName('user_groups'); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | // Iterate over query results, loading each user id into the array |
| 125 | 125 | while ($row = $res->fetch()) { |
| 126 | - $adminIdArr[] = $row['user_id'] ; |
|
| 126 | + $adminIdArr[] = $row['user_id']; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // Set the query results to be useful in a sql statement. |