@@ -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\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. |
@@ -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, |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $timeline = []; |
75 | 75 | $startObj = new DateTime($start); |
76 | 76 | $endObj = new DateTime($end); |
77 | - $numDays = (int) $endObj->diff($startObj)->format("%a"); |
|
77 | + $numDays = (int)$endObj->diff($startObj)->format("%a"); |
|
78 | 78 | $grandSum = 0; |
79 | 79 | |
80 | 80 | // Generate array of date labels |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | |
85 | 85 | foreach ($data as $entry) { |
86 | 86 | if (!isset($totals[$entry['tool']])) { |
87 | - $totals[$entry['tool']] = (int) $entry['count']; |
|
87 | + $totals[$entry['tool']] = (int)$entry['count']; |
|
88 | 88 | |
89 | 89 | // Create arrays for each tool, filled with zeros for each date in the timeline |
90 | 90 | $timeline[$entry['tool']] = array_fill(0, $numDays, 0); |
91 | 91 | } else { |
92 | - $totals[$entry['tool']] += (int) $entry['count']; |
|
92 | + $totals[$entry['tool']] += (int)$entry['count']; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $date = new DateTime($entry['date']); |
96 | - $dateIndex = (int) $date->diff($startObj)->format("%a"); |
|
97 | - $timeline[$entry['tool']][$dateIndex] = (int) $entry['count']; |
|
96 | + $dateIndex = (int)$date->diff($startObj)->format("%a"); |
|
97 | + $timeline[$entry['tool']][$dateIndex] = (int)$entry['count']; |
|
98 | 98 | |
99 | 99 | $grandSum += $entry['count']; |
100 | 100 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | $conn = $this->container->get('doctrine')->getManager('default')->getConnection(); |
148 | - $date = date('Y-m-d'); |
|
148 | + $date = date('Y-m-d'); |
|
149 | 149 | |
150 | 150 | // Increment count in timeline |
151 | 151 | $existsSql = "SELECT 1 FROM usage_timeline |
@@ -42,7 +42,7 @@ |
||
42 | 42 | $params = $this->convertLegacyParams($params); |
43 | 43 | |
44 | 44 | // Remove blank values. |
45 | - return array_filter($params, function ($param) { |
|
45 | + return array_filter($params, function($param) { |
|
46 | 46 | // 'namespace' or 'username' could be '0'. |
47 | 47 | return $param !== null && $param !== ''; |
48 | 48 | }); |
@@ -248,7 +248,7 @@ |
||
248 | 248 | * @param bool $useDefaults Whether to use defaults if the values |
249 | 249 | * are blank. The start date is set to one month before the end date, |
250 | 250 | * and the end date is set to the present. |
251 | - * @return mixed[] Start and end date as UTC timestamps or 'false' if empty. |
|
251 | + * @return integer[] Start and end date as UTC timestamps or 'false' if empty. |
|
252 | 252 | */ |
253 | 253 | public function getUTCFromDateParams($start, $end, $useDefaults = true) |
254 | 254 | { |
@@ -16,7 +16,6 @@ |
||
16 | 16 | use Symfony\Component\HttpFoundation\JsonResponse; |
17 | 17 | use Xtools\AdminStats; |
18 | 18 | use Xtools\AdminStatsRepository; |
19 | -use Xtools\ProjectRepository; |
|
20 | 19 | |
21 | 20 | /** |
22 | 21 | * Class AdminStatsController |
@@ -171,7 +171,7 @@ |
||
171 | 171 | public function adminStatsApiAction($project, $days = 30) |
172 | 172 | { |
173 | 173 | // Maximum 30 days. |
174 | - $days = min((int) $days, 30); |
|
174 | + $days = min((int)$days, 30); |
|
175 | 175 | $start = date('Y-m-d', strtotime("-$days days")); |
176 | 176 | $end = date('Y-m-d'); |
177 | 177 |
@@ -5,9 +5,6 @@ |
||
5 | 5 | |
6 | 6 | namespace Xtools; |
7 | 7 | |
8 | -use Symfony\Component\DependencyInjection\Container; |
|
9 | -use DateTime; |
|
10 | - |
|
11 | 8 | /** |
12 | 9 | * AdminStats returns information about users with administrative |
13 | 10 | * rights on a given wiki. |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function numDays() |
119 | 119 | { |
120 | - return ($this->end - $this->start) / 60 / 60 / 24; |
|
120 | + return ($this->end-$this->start) / 60 / 60 / 24; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | */ |
281 | 281 | public function getNumAdminsWithActions() |
282 | 282 | { |
283 | - return $this->numAdmins() - $this->adminsWithoutActions; |
|
283 | + return $this->numAdmins()-$this->adminsWithoutActions; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public function groups($project, $username) |
61 | 61 | { |
62 | 62 | $this->setUp($project); |
63 | - $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ]; |
|
63 | + $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"]; |
|
64 | 64 | $query = new SimpleRequest('query', $params); |
65 | 65 | $result = []; |
66 | 66 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function globalGroups($project, $username) |
89 | 89 | { |
90 | 90 | $this->setUp($project); |
91 | - $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
91 | + $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"]; |
|
92 | 92 | $query = new SimpleRequest('query', $params); |
93 | 93 | $result = []; |
94 | 94 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $normalized = []; |
131 | 131 | if (isset($result['query']['normalized'])) { |
132 | 132 | array_map( |
133 | - function ($e) use (&$normalized) { |
|
133 | + function($e) use (&$normalized) { |
|
134 | 134 | $normalized[$e['to']] = $e['from']; |
135 | 135 | }, |
136 | 136 | $result['query']['normalized'] |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $query = FluentRequest::factory()->setAction('query')->setParams($requestData); |
216 | 216 | $innerPromise = $this->api->getRequestAsync($query); |
217 | 217 | |
218 | - $innerPromise->then(function ($result) use (&$data) { |
|
218 | + $innerPromise->then(function($result) use (&$data) { |
|
219 | 219 | // some failures come back as 200s, so we still resolve and let the outer function handle it |
220 | 220 | if (isset($result['error']) || !isset($result['query'])) { |
221 | 221 | return $data['promise']->resolve($data); |
@@ -52,7 +52,7 @@ |
||
52 | 52 | $userGroupsTable = $project->getTableName('user_groups'); |
53 | 53 | $ufgTable = $project->getTableName('user_former_groups'); |
54 | 54 | |
55 | - $adminGroups = join(array_map(function ($group) { |
|
55 | + $adminGroups = join(array_map(function($group) { |
|
56 | 56 | return "'$group'"; |
57 | 57 | }, $this->getAdminGroups($project)), ','); |
58 | 58 |