@@ -53,10 +53,10 @@ |
||
| 53 | 53 | $username = $request->query->get('username'); |
| 54 | 54 | |
| 55 | 55 | if (($project || $queryProject) && $username) { |
| 56 | - $routeParams = [ 'project'=>($project ?: $queryProject), 'username' => $username ]; |
|
| 56 | + $routeParams = ['project'=>($project ?: $queryProject), 'username' => $username]; |
|
| 57 | 57 | return $this->redirectToRoute("EditCounterResult", $routeParams); |
| 58 | 58 | } elseif (!$project && $queryProject) { |
| 59 | - return $this->redirectToRoute("EditCounterProject", [ 'project'=>$queryProject ]); |
|
| 59 | + return $this->redirectToRoute("EditCounterProject", ['project'=>$queryProject]); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $this->init($project); |
@@ -3,16 +3,13 @@ |
||
| 3 | 3 | namespace AppBundle\Controller; |
| 4 | 4 | |
| 5 | 5 | use AppBundle\Helper\ApiHelper; |
| 6 | -use AppBundle\Helper\AutomatedEditsHelper; |
|
| 7 | 6 | use AppBundle\Helper\LabsHelper; |
| 8 | 7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
| 9 | 8 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 10 | 9 | use Symfony\Component\HttpFoundation\Request; |
| 11 | 10 | use Xtools\EditCounter; |
| 12 | 11 | use Xtools\EditCounterRepository; |
| 13 | -use Xtools\Project; |
|
| 14 | 12 | use Xtools\ProjectRepository; |
| 15 | -use Xtools\User; |
|
| 16 | 13 | use Xtools\UserRepository; |
| 17 | 14 | |
| 18 | 15 | class EditCounterController extends Controller |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | * List top edits by this user for all pages in a particular namespace. |
| 97 | 97 | * @param User $user The User. |
| 98 | 98 | * @param Project $project The project. |
| 99 | - * @param integer|string $namespaceId The namespace ID or 'all' |
|
| 99 | + * @param integer $namespaceId The namespace ID or 'all' |
|
| 100 | 100 | * @return \Symfony\Component\HttpFoundation\Response |
| 101 | 101 | */ |
| 102 | 102 | protected function namespaceTopEdits(User $user, Project $project, $namespaceId) |
@@ -7,7 +7,6 @@ |
||
| 7 | 7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
| 8 | 8 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 9 | 9 | use Symfony\Component\HttpFoundation\Request; |
| 10 | -use Symfony\Component\VarDumper\VarDumper; |
|
| 11 | 10 | use Xtools\Page; |
| 12 | 11 | use Xtools\PagesRepository; |
| 13 | 12 | use Xtools\Project; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | 'username' => $username, |
| 56 | 56 | ]); |
| 57 | 57 | } elseif ($projectName != "") { |
| 58 | - return $this->redirectToRoute("TopEditsResults", [ 'project'=>$projectName ]); |
|
| 58 | + return $this->redirectToRoute("TopEditsResults", ['project'=>$projectName]); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Set default project so we can populate the namespace selector. |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // Get page info about these 100 pages, so we can use their display title. |
| 133 | - $titles = array_map(function ($e) { |
|
| 133 | + $titles = array_map(function($e) { |
|
| 134 | 134 | return $e['page_title']; |
| 135 | 135 | }, $editData); |
| 136 | 136 | /** @var ApiHelper $apiHelper */ |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | foreach ($editData as $editDatum) { |
| 143 | 143 | $pageTitle = $editDatum['page_title']; |
| 144 | 144 | // If 'all' namespaces, prepend namespace to display title. |
| 145 | - $nsTitle = !is_numeric($namespaceId) ? $namespaces[$editDatum['page_namespace']] . ':' : ''; |
|
| 145 | + $nsTitle = !is_numeric($namespaceId) ? $namespaces[$editDatum['page_namespace']].':' : ''; |
|
| 146 | 146 | $editDatum['displaytitle'] = $nsTitle.$displayTitles[$pageTitle]; |
| 147 | 147 | $edits[] = $editDatum; |
| 148 | 148 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @param Project $project The project to which the page belongs. |
| 16 | 16 | * @param string $pageTitle Page title. |
| 17 | 17 | * @param boolean $followRedirects Whether or not to resolve redirects |
| 18 | - * @return string[] Array with some of the following keys: pageid, title, missing, displaytitle, |
|
| 18 | + * @return string|null Array with some of the following keys: pageid, title, missing, displaytitle, |
|
| 19 | 19 | * url. |
| 20 | 20 | */ |
| 21 | 21 | public function getPageInfo(Project $project, $pageTitle, $followRedirects = true) |
@@ -63,9 +63,8 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * Get revisions of a single page. |
| 66 | - * @param Project $project |
|
| 67 | 66 | * @param Page $page |
| 68 | - * @param User|null $user |
|
| 67 | + * @param User $user |
|
| 69 | 68 | * @return string[] Each member with keys: id, timestamp, length- |
| 70 | 69 | */ |
| 71 | 70 | public function getRevisions(Page $page, User $user) |
@@ -16,39 +16,39 @@ discard block |
||
| 16 | 16 | { |
| 17 | 17 | $options = ['is_safe' => ['html']]; |
| 18 | 18 | return [ |
| 19 | - new \Twig_SimpleFunction('request_time', [ $this, 'requestTime' ], $options), |
|
| 20 | - new \Twig_SimpleFunction('memory_usage', [ $this, 'requestMemory' ], $options), |
|
| 21 | - new \Twig_SimpleFunction('year', [ $this, 'generateYear' ], $options), |
|
| 22 | - new \Twig_SimpleFunction('msgPrintExists', [ $this, 'intuitionMessagePrintExists' ], $options), |
|
| 23 | - new \Twig_SimpleFunction('msgExists', [ $this, 'intuitionMessageExists' ], $options), |
|
| 24 | - new \Twig_SimpleFunction('msg', [ $this, 'intuitionMessage' ], $options), |
|
| 25 | - new \Twig_SimpleFunction('lang', [ $this, 'getLang' ], $options), |
|
| 26 | - new \Twig_SimpleFunction('langName', [ $this, 'getLangName' ], $options), |
|
| 27 | - new \Twig_SimpleFunction('allLangs', [ $this, 'getAllLangs' ]), |
|
| 28 | - new \Twig_SimpleFunction('isRTL', [ $this, 'intuitionIsRTL' ]), |
|
| 29 | - new \Twig_SimpleFunction('isRTLLang', [ $this, 'intuitionIsRTLLang' ]), |
|
| 30 | - new \Twig_SimpleFunction('shortHash', [ $this, 'gitShortHash' ]), |
|
| 31 | - new \Twig_SimpleFunction('hash', [ $this, 'gitHash' ]), |
|
| 32 | - new \Twig_SimpleFunction('enabled', [ $this, 'tabEnabled' ]), |
|
| 33 | - new \Twig_SimpleFunction('tools', [ $this, 'allTools' ]), |
|
| 34 | - new \Twig_SimpleFunction('color', [ $this, 'getColorList' ]), |
|
| 35 | - new \Twig_SimpleFunction('chartColor', [ $this, 'chartColor' ]), |
|
| 36 | - new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]), |
|
| 37 | - new \Twig_SimpleFunction('isSingleWiki', [ $this, 'isSingleWiki' ]), |
|
| 38 | - new \Twig_SimpleFunction('getReplagThreshold', [ $this, 'getReplagThreshold' ]), |
|
| 39 | - new \Twig_SimpleFunction('loadStylesheetsFromCDN', [ $this, 'loadStylesheetsFromCDN' ]), |
|
| 40 | - new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]), |
|
| 41 | - new \Twig_SimpleFunction('replag', [ $this, 'replag' ]), |
|
| 42 | - new \Twig_SimpleFunction('link', [ $this, 'link' ]), |
|
| 43 | - new \Twig_SimpleFunction('quote', [ $this, 'quote' ]), |
|
| 44 | - new \Twig_SimpleFunction('bugReportURL', [ $this, 'bugReportURL' ]), |
|
| 19 | + new \Twig_SimpleFunction('request_time', [$this, 'requestTime'], $options), |
|
| 20 | + new \Twig_SimpleFunction('memory_usage', [$this, 'requestMemory'], $options), |
|
| 21 | + new \Twig_SimpleFunction('year', [$this, 'generateYear'], $options), |
|
| 22 | + new \Twig_SimpleFunction('msgPrintExists', [$this, 'intuitionMessagePrintExists'], $options), |
|
| 23 | + new \Twig_SimpleFunction('msgExists', [$this, 'intuitionMessageExists'], $options), |
|
| 24 | + new \Twig_SimpleFunction('msg', [$this, 'intuitionMessage'], $options), |
|
| 25 | + new \Twig_SimpleFunction('lang', [$this, 'getLang'], $options), |
|
| 26 | + new \Twig_SimpleFunction('langName', [$this, 'getLangName'], $options), |
|
| 27 | + new \Twig_SimpleFunction('allLangs', [$this, 'getAllLangs']), |
|
| 28 | + new \Twig_SimpleFunction('isRTL', [$this, 'intuitionIsRTL']), |
|
| 29 | + new \Twig_SimpleFunction('isRTLLang', [$this, 'intuitionIsRTLLang']), |
|
| 30 | + new \Twig_SimpleFunction('shortHash', [$this, 'gitShortHash']), |
|
| 31 | + new \Twig_SimpleFunction('hash', [$this, 'gitHash']), |
|
| 32 | + new \Twig_SimpleFunction('enabled', [$this, 'tabEnabled']), |
|
| 33 | + new \Twig_SimpleFunction('tools', [$this, 'allTools']), |
|
| 34 | + new \Twig_SimpleFunction('color', [$this, 'getColorList']), |
|
| 35 | + new \Twig_SimpleFunction('chartColor', [$this, 'chartColor']), |
|
| 36 | + new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']), |
|
| 37 | + new \Twig_SimpleFunction('isSingleWiki', [$this, 'isSingleWiki']), |
|
| 38 | + new \Twig_SimpleFunction('getReplagThreshold', [$this, 'getReplagThreshold']), |
|
| 39 | + new \Twig_SimpleFunction('loadStylesheetsFromCDN', [$this, 'loadStylesheetsFromCDN']), |
|
| 40 | + new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']), |
|
| 41 | + new \Twig_SimpleFunction('replag', [$this, 'replag']), |
|
| 42 | + new \Twig_SimpleFunction('link', [$this, 'link']), |
|
| 43 | + new \Twig_SimpleFunction('quote', [$this, 'quote']), |
|
| 44 | + new \Twig_SimpleFunction('bugReportURL', [$this, 'bugReportURL']), |
|
| 45 | 45 | ]; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function requestTime($decimals = 3) |
| 49 | 49 | { |
| 50 | 50 | |
| 51 | - return number_format(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], $decimals); |
|
| 51 | + return number_format(microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'], $decimals); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function requestMemory() |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | // TODO: refactor all intuition stuff so it can be used anywhere |
| 69 | 69 | public function intuitionMessageExists($message = "") |
| 70 | 70 | { |
| 71 | - return $this->getIntuition()->msgExists($message, [ "domain" => "xtools" ]); |
|
| 71 | + return $this->getIntuition()->msgExists($message, ["domain" => "xtools"]); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public function intuitionMessagePrintExists($message = "", $vars = []) |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | public function intuitionMessage($message = "", $vars = []) |
| 89 | 89 | { |
| 90 | - return $this->getIntuition()->msg($message, [ "domain" => "xtools", "variables" => $vars ]); |
|
| 90 | + return $this->getIntuition()->msg($message, ["domain" => "xtools", "variables" => $vars]); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | public function getLang() |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function getAllLangs() |
| 110 | 110 | { |
| 111 | - $messageFiles = glob($this->container->getParameter("kernel.root_dir") . '/../i18n/*.json'); |
|
| 111 | + $messageFiles = glob($this->container->getParameter("kernel.root_dir").'/../i18n/*.json'); |
|
| 112 | 112 | |
| 113 | 113 | $languages = array_values(array_unique(array_map( |
| 114 | - function ($filename) { |
|
| 114 | + function($filename) { |
|
| 115 | 115 | return basename($filename, '.json'); |
| 116 | 116 | }, |
| 117 | 117 | $messageFiles |
@@ -168,41 +168,41 @@ discard block |
||
| 168 | 168 | public static function getColorList($num = false) |
| 169 | 169 | { |
| 170 | 170 | $colors = [ |
| 171 | - 0 => '#Cc0000',# '#FF005A', #red '#FF5555', |
|
| 171 | + 0 => '#Cc0000', # '#FF005A', #red '#FF5555', |
|
| 172 | 172 | 1 => '#F7b7b7', |
| 173 | - 2 => '#5c8d20',# '#008800', #green'#55FF55', |
|
| 173 | + 2 => '#5c8d20', # '#008800', #green'#55FF55', |
|
| 174 | 174 | 3 => '#85eD82', |
| 175 | 175 | 4 => '#2E97E0', # blue |
| 176 | 176 | 5 => '#B9E3F9', |
| 177 | - 6 => '#e1711d', # orange |
|
| 177 | + 6 => '#e1711d', # orange |
|
| 178 | 178 | 7 => '#ffc04c', |
| 179 | 179 | 8 => '#FDFF98', # yellow |
| 180 | 180 | 9 => '#5555FF', |
| 181 | 181 | 10 => '#55FFFF', |
| 182 | - 11 => '#0000C0', # |
|
| 183 | - 12 => '#008800', # green |
|
| 182 | + 11 => '#0000C0', # |
|
| 183 | + 12 => '#008800', # green |
|
| 184 | 184 | 13 => '#00C0C0', |
| 185 | - 14 => '#FFAFAF', # rosé |
|
| 186 | - 15 => '#808080', # gray |
|
| 185 | + 14 => '#FFAFAF', # rosé |
|
| 186 | + 15 => '#808080', # gray |
|
| 187 | 187 | 16 => '#00C000', |
| 188 | 188 | 17 => '#404040', |
| 189 | - 18 => '#C0C000', # green |
|
| 189 | + 18 => '#C0C000', # green |
|
| 190 | 190 | 19 => '#C000C0', |
| 191 | - 100 => '#75A3D1', # blue |
|
| 192 | - 101 => '#A679D2', # purple |
|
| 191 | + 100 => '#75A3D1', # blue |
|
| 192 | + 101 => '#A679D2', # purple |
|
| 193 | 193 | 102 => '#660000', |
| 194 | 194 | 103 => '#000066', |
| 195 | - 104 => '#FAFFAF', # caramel |
|
| 195 | + 104 => '#FAFFAF', # caramel |
|
| 196 | 196 | 105 => '#408345', |
| 197 | 197 | 106 => '#5c8d20', |
| 198 | - 107 => '#e1711d', # red |
|
| 199 | - 108 => '#94ef2b', # light green |
|
| 200 | - 109 => '#756a4a', # brown |
|
| 198 | + 107 => '#e1711d', # red |
|
| 199 | + 108 => '#94ef2b', # light green |
|
| 200 | + 109 => '#756a4a', # brown |
|
| 201 | 201 | 110 => '#6f1dab', |
| 202 | 202 | 111 => '#301e30', |
| 203 | 203 | 112 => '#5c9d96', |
| 204 | - 113 => '#a8cd8c', # earth green |
|
| 205 | - 114 => '#f2b3f1', # light purple |
|
| 204 | + 113 => '#a8cd8c', # earth green |
|
| 205 | + 114 => '#f2b3f1', # light purple |
|
| 206 | 206 | 115 => '#9b5828', |
| 207 | 207 | 118 => '#99FFFF', |
| 208 | 208 | 119 => '#99BBFF', |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | 446 => '#06DCFB', |
| 224 | 224 | 447 => '#892EE4', |
| 225 | 225 | 460 => '#99FF66', |
| 226 | - 461 => '#99CC66', # green |
|
| 227 | - 470 => '#CCCC33', # ocker |
|
| 226 | + 461 => '#99CC66', # green |
|
| 227 | + 470 => '#CCCC33', # ocker |
|
| 228 | 228 | 471 => '#CCFF33', |
| 229 | 229 | 480 => '#6699FF', |
| 230 | 230 | 481 => '#66FFFF', |
@@ -239,18 +239,18 @@ discard block |
||
| 239 | 239 | 1198 => '#FF34B3', |
| 240 | 240 | 1199 => '#8B1C62', |
| 241 | 241 | |
| 242 | - '#61a9f3',# blue |
|
| 243 | - '#f381b9',# pink |
|
| 242 | + '#61a9f3', # blue |
|
| 243 | + '#f381b9', # pink |
|
| 244 | 244 | '#61E3A9', |
| 245 | 245 | '#D56DE2', |
| 246 | 246 | '#85eD82', |
| 247 | 247 | '#F7b7b7', |
| 248 | 248 | '#CFDF49', |
| 249 | 249 | '#88d8f2', |
| 250 | - '#07AF7B',# green |
|
| 250 | + '#07AF7B', # green |
|
| 251 | 251 | '#B9E3F9', |
| 252 | 252 | '#FFF3AD', |
| 253 | - '#EF606A',# red |
|
| 253 | + '#EF606A', # red |
|
| 254 | 254 | '#EC8833', |
| 255 | 255 | '#FFF100', |
| 256 | 256 | '#87C9A5', |
@@ -400,8 +400,8 @@ discard block |
||
| 400 | 400 | public function getFilters() |
| 401 | 401 | { |
| 402 | 402 | return [ |
| 403 | - new \Twig_SimpleFilter('capitalize_first', [ $this, 'capitalizeFirst' ]), |
|
| 404 | - new \Twig_SimpleFilter('percent_format', [ $this, 'percentFormat' ]), |
|
| 403 | + new \Twig_SimpleFilter('capitalize_first', [$this, 'capitalizeFirst']), |
|
| 404 | + new \Twig_SimpleFilter('percent_format', [$this, 'percentFormat']), |
|
| 405 | 405 | ]; |
| 406 | 406 | } |
| 407 | 407 | |
@@ -428,9 +428,9 @@ discard block |
||
| 428 | 428 | if (!$denominator) { |
| 429 | 429 | $quotient = $numerator; |
| 430 | 430 | } else { |
| 431 | - $quotient = ( $numerator / $denominator ) * 100; |
|
| 431 | + $quotient = ($numerator / $denominator) * 100; |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - return round($quotient, $precision) . '%'; |
|
| 434 | + return round($quotient, $precision).'%'; |
|
| 435 | 435 | } |
| 436 | 436 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | protected function getRevisionCounts() |
| 42 | 42 | { |
| 43 | - if (! is_array($this->revisionCounts)) { |
|
| 43 | + if (!is_array($this->revisionCounts)) { |
|
| 44 | 44 | $this->revisionCounts = $this->getRepository() |
| 45 | 45 | ->getRevisionCounts($this->project, $this->user); |
| 46 | 46 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | protected function getRevisionDates() |
| 55 | 55 | { |
| 56 | - if (! is_array($this->revisionDates)) { |
|
| 56 | + if (!is_array($this->revisionDates)) { |
|
| 57 | 57 | $this->revisionDates = $this->getRepository() |
| 58 | 58 | ->getRevisionDates($this->project, $this->user); |
| 59 | 59 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | protected function getPageCounts() |
| 68 | 68 | { |
| 69 | - if (! is_array($this->pageCounts)) { |
|
| 69 | + if (!is_array($this->pageCounts)) { |
|
| 70 | 70 | $this->pageCounts = $this->getRepository() |
| 71 | 71 | ->getPageCounts($this->project, $this->user); |
| 72 | 72 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | protected function getLogCounts() |
| 81 | 81 | { |
| 82 | - if (! is_array($this->logCounts)) { |
|
| 82 | + if (!is_array($this->logCounts)) { |
|
| 83 | 83 | $this->logCounts = $this->getRepository() |
| 84 | 84 | ->getLogCounts($this->project, $this->user); |
| 85 | 85 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function countAllRevisions() |
| 110 | 110 | { |
| 111 | - return $this->countLiveRevisions() + $this->countDeletedRevisions(); |
|
| 111 | + return $this->countLiveRevisions()+$this->countDeletedRevisions(); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function countRevisionsWithoutComments() |
| 129 | 129 | { |
| 130 | - return $this->countAllRevisions() - $this->countRevisionsWithComments(); |
|
| 130 | + return $this->countAllRevisions()-$this->countRevisionsWithComments(); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function countAllPagesEdited() |
| 182 | 182 | { |
| 183 | - return $this->countLivePagesEdited() + $this->countDeletedPagesEdited(); |
|
| 183 | + return $this->countLivePagesEdited()+$this->countDeletedPagesEdited(); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function countPagesCreated() |
| 200 | 200 | { |
| 201 | - return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted(); |
|
| 201 | + return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted(); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -328,9 +328,9 @@ discard block |
||
| 328 | 328 | public function approvals() |
| 329 | 329 | { |
| 330 | 330 | $logCounts = $this->getLogCounts(); |
| 331 | - $total = $logCounts['review-approve'] + |
|
| 332 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + |
|
| 333 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
| 331 | + $total = $logCounts['review-approve']+ |
|
| 332 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ |
|
| 333 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
| 334 | 334 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); |
| 335 | 335 | return $total; |
| 336 | 336 | } |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace Xtools; |
| 4 | 4 | |
| 5 | 5 | use \DateTime; |
| 6 | -use Symfony\Component\VarDumper\VarDumper; |
|
| 7 | 6 | |
| 8 | 7 | /** |
| 9 | 8 | * An EditCounter provides statistics about a user's edits on a project. |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | public function getRevisionCounts(Project $project, User $user) |
| 17 | 17 | { |
| 18 | 18 | // Set up cache. |
| 19 | - $cacheKey = 'revisioncounts.' . $project->getDatabaseName() . '.' . $user->getUsername(); |
|
| 19 | + $cacheKey = 'revisioncounts.'.$project->getDatabaseName().'.'.$user->getUsername(); |
|
| 20 | 20 | if ($this->cache->hasItem($cacheKey)) { |
| 21 | 21 | return $this->cache->getItem($cacheKey)->get(); |
| 22 | 22 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public function getRevisionDates(Project $project, User $user) |
| 78 | 78 | { |
| 79 | 79 | // Set up cache. |
| 80 | - $cacheKey = 'revisiondates.' . $project->getDatabaseName() . '.' . $user->getUsername(); |
|
| 80 | + $cacheKey = 'revisiondates.'.$project->getDatabaseName().'.'.$user->getUsername(); |
|
| 81 | 81 | if ($this->cache->hasItem($cacheKey)) { |
| 82 | 82 | return $this->cache->getItem($cacheKey)->get(); |
| 83 | 83 | } |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | $results = $resultQuery->fetchAll(); |
| 150 | 150 | |
| 151 | 151 | $pageCounts = array_combine( |
| 152 | - array_map(function ($e) { |
|
| 152 | + array_map(function($e) { |
|
| 153 | 153 | return $e['source']; |
| 154 | 154 | }, $results), |
| 155 | - array_map(function ($e) { |
|
| 155 | + array_map(function($e) { |
|
| 156 | 156 | return $e['value']; |
| 157 | 157 | }, $results) |
| 158 | 158 | ); |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | // Query. |
| 185 | 185 | $sql = "SELECT CONCAT(log_type, '-', log_action) AS source, COUNT(log_id) AS value |
| 186 | - FROM " . $this->getTableName($project->getDatabaseName(), 'logging') . " |
|
| 186 | + FROM " . $this->getTableName($project->getDatabaseName(), 'logging')." |
|
| 187 | 187 | WHERE log_user = :userId |
| 188 | 188 | GROUP BY log_type, log_action"; |
| 189 | 189 | $resultQuery = $this->getProjectsConnection()->prepare($sql); |
@@ -192,10 +192,10 @@ discard block |
||
| 192 | 192 | $resultQuery->execute(); |
| 193 | 193 | $results = $resultQuery->fetchAll(); |
| 194 | 194 | $logCounts = array_combine( |
| 195 | - array_map(function ($e) { |
|
| 195 | + array_map(function($e) { |
|
| 196 | 196 | return $e['source']; |
| 197 | 197 | }, $results), |
| 198 | - array_map(function ($e) { |
|
| 198 | + array_map(function($e) { |
|
| 199 | 199 | return $e['value']; |
| 200 | 200 | }, $results) |
| 201 | 201 | ); |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | public function getTopProjectsEditCounts($projectUrl, $username, $numProjects = 10) |
| 286 | 286 | { |
| 287 | 287 | $this->debug("Getting top project edit counts for $username"); |
| 288 | - $cacheKey = 'topprojectseditcounts.' . $username; |
|
| 288 | + $cacheKey = 'topprojectseditcounts.'.$username; |
|
| 289 | 289 | if ($this->cacheHas($cacheKey)) { |
| 290 | 290 | return $this->cacheGet($cacheKey); |
| 291 | 291 | } |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | if (false === $topEditCounts) { |
| 298 | 298 | // If no CentralAuth, fall back to querying each database in turn. |
| 299 | 299 | foreach ($this->labsHelper->getProjectsInfo() as $project) { |
| 300 | - $this->container->get('logger')->debug('Getting edit count for ' . $project['url']); |
|
| 300 | + $this->container->get('logger')->debug('Getting edit count for '.$project['url']); |
|
| 301 | 301 | $revisionTableName = $this->labsHelper->getTable('revision', $project['dbName']); |
| 302 | 302 | $sql = "SELECT COUNT(rev_id) FROM $revisionTableName WHERE rev_user_text=:username"; |
| 303 | 303 | $stmt = $this->replicas->prepare($sql); |
@@ -307,8 +307,8 @@ discard block |
||
| 307 | 307 | $topEditCounts[$project['dbName']] = array_merge($project, ['total' => $total]); |
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | - uasort($topEditCounts, function ($a, $b) { |
|
| 311 | - return $b['total'] - $a['total']; |
|
| 310 | + uasort($topEditCounts, function($a, $b) { |
|
| 311 | + return $b['total']-$a['total']; |
|
| 312 | 312 | }); |
| 313 | 313 | $out = array_slice($topEditCounts, 0, $numProjects); |
| 314 | 314 | |
@@ -327,16 +327,16 @@ discard block |
||
| 327 | 327 | { |
| 328 | 328 | $userId = $this->getUserId($username); |
| 329 | 329 | $sql = "SELECT page_namespace, count(rev_id) AS total |
| 330 | - FROM " . $this->labsHelper->getTable('revision') . " r |
|
| 331 | - JOIN " . $this->labsHelper->getTable('page') . " p on r.rev_page = p.page_id |
|
| 330 | + FROM " . $this->labsHelper->getTable('revision')." r |
|
| 331 | + JOIN " . $this->labsHelper->getTable('page')." p on r.rev_page = p.page_id |
|
| 332 | 332 | WHERE r.rev_user = :id GROUP BY page_namespace"; |
| 333 | 333 | $resultQuery = $this->replicas->prepare($sql); |
| 334 | 334 | $resultQuery->bindParam(":id", $userId); |
| 335 | 335 | $resultQuery->execute(); |
| 336 | 336 | $results = $resultQuery->fetchAll(); |
| 337 | - $namespaceTotals = array_combine(array_map(function ($e) { |
|
| 337 | + $namespaceTotals = array_combine(array_map(function($e) { |
|
| 338 | 338 | return $e['page_namespace']; |
| 339 | - }, $results), array_map(function ($e) { |
|
| 339 | + }, $results), array_map(function($e) { |
|
| 340 | 340 | return $e['total']; |
| 341 | 341 | }, $results)); |
| 342 | 342 | |
@@ -359,14 +359,14 @@ discard block |
||
| 359 | 359 | $revisions = $this->cacheGet($cacheKey); |
| 360 | 360 | } else { |
| 361 | 361 | $sql = |
| 362 | - "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, " . |
|
| 363 | - " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, " . |
|
| 364 | - " page_title, page_namespace " . " FROM " . |
|
| 365 | - $this->labsHelper->getTable('revision', $project['dbName']) . " JOIN " . |
|
| 366 | - $this->labsHelper->getTable('page', $project['dbName']) . |
|
| 367 | - " ON (rev_page = page_id)" . |
|
| 368 | - " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username" . |
|
| 369 | - " ORDER BY rev_timestamp DESC" . " LIMIT 10"; |
|
| 362 | + "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, ". |
|
| 363 | + " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, ". |
|
| 364 | + " page_title, page_namespace "." FROM ". |
|
| 365 | + $this->labsHelper->getTable('revision', $project['dbName'])." JOIN ". |
|
| 366 | + $this->labsHelper->getTable('page', $project['dbName']). |
|
| 367 | + " ON (rev_page = page_id)". |
|
| 368 | + " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username". |
|
| 369 | + " ORDER BY rev_timestamp DESC"." LIMIT 10"; |
|
| 370 | 370 | $resultQuery = $this->replicas->prepare($sql); |
| 371 | 371 | $resultQuery->bindParam(":username", $username); |
| 372 | 372 | $resultQuery->execute(); |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | if (count($revisions) === 0) { |
| 377 | 377 | continue; |
| 378 | 378 | } |
| 379 | - $revsWithProject = array_map(function (&$item) use ($project) { |
|
| 379 | + $revsWithProject = array_map(function(&$item) use ($project) { |
|
| 380 | 380 | $item['project_name'] = $project['wikiName']; |
| 381 | 381 | $item['project_url'] = $project['url']; |
| 382 | 382 | $item['project_db_name'] = $project['dbName']; |
@@ -386,8 +386,8 @@ discard block |
||
| 386 | 386 | }, $revisions); |
| 387 | 387 | $allRevisions = array_merge($allRevisions, $revsWithProject); |
| 388 | 388 | } |
| 389 | - usort($allRevisions, function ($a, $b) { |
|
| 390 | - return $b['rev_timestamp'] - $a['rev_timestamp']; |
|
| 389 | + usort($allRevisions, function($a, $b) { |
|
| 390 | + return $b['rev_timestamp']-$a['rev_timestamp']; |
|
| 391 | 391 | }); |
| 392 | 392 | |
| 393 | 393 | return array_slice($allRevisions, 0, $topN); |
@@ -406,12 +406,12 @@ discard block |
||
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | $sql = |
| 409 | - "SELECT " . " YEAR(rev_timestamp) AS `year`," . |
|
| 410 | - " MONTH(rev_timestamp) AS `month`," . " page_namespace," . |
|
| 411 | - " COUNT(rev_id) AS `count` " . " FROM " . $this->labsHelper->getTable('revision') . |
|
| 412 | - " JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" . |
|
| 413 | - " WHERE rev_user_text = :username" . |
|
| 414 | - " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace " . |
|
| 409 | + "SELECT "." YEAR(rev_timestamp) AS `year`,". |
|
| 410 | + " MONTH(rev_timestamp) AS `month`,"." page_namespace,". |
|
| 411 | + " COUNT(rev_id) AS `count` "." FROM ".$this->labsHelper->getTable('revision'). |
|
| 412 | + " JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)". |
|
| 413 | + " WHERE rev_user_text = :username". |
|
| 414 | + " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace ". |
|
| 415 | 415 | " ORDER BY rev_timestamp DESC"; |
| 416 | 416 | $resultQuery = $this->replicas->prepare($sql); |
| 417 | 417 | $resultQuery->bindParam(":username", $username); |
@@ -433,14 +433,14 @@ discard block |
||
| 433 | 433 | if (!isset($out['totals'][$ns])) { |
| 434 | 434 | $out['totals'][$ns] = []; |
| 435 | 435 | } |
| 436 | - $out['totals'][$ns][$total['year'] . $total['month']] = $total['count']; |
|
| 436 | + $out['totals'][$ns][$total['year'].$total['month']] = $total['count']; |
|
| 437 | 437 | } |
| 438 | 438 | // Fill in the blanks (where no edits were made in a given month for a namespace). |
| 439 | 439 | for ($y = $out['min_year']; $y <= $out['max_year']; $y++) { |
| 440 | 440 | for ($m = 1; $m <= 12; $m++) { |
| 441 | 441 | foreach ($out['totals'] as $nsId => &$total) { |
| 442 | - if (!isset($total[$y . $m])) { |
|
| 443 | - $total[$y . $m] = 0; |
|
| 442 | + if (!isset($total[$y.$m])) { |
|
| 443 | + $total[$y.$m] = 0; |
|
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | } |
@@ -463,12 +463,12 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | $sql = |
| 466 | - "SELECT " . " SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4) AS `year`," . |
|
| 467 | - " page_namespace," . " COUNT(rev_id) AS `count` " . " FROM " . |
|
| 468 | - $this->labsHelper->getTable('revision') . " JOIN " . |
|
| 469 | - $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" . |
|
| 470 | - " WHERE rev_user_text = :username" . |
|
| 471 | - " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace " . |
|
| 466 | + "SELECT "." SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4) AS `year`,". |
|
| 467 | + " page_namespace,"." COUNT(rev_id) AS `count` "." FROM ". |
|
| 468 | + $this->labsHelper->getTable('revision')." JOIN ". |
|
| 469 | + $this->labsHelper->getTable('page')." ON (rev_page = page_id)". |
|
| 470 | + " WHERE rev_user_text = :username". |
|
| 471 | + " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace ". |
|
| 472 | 472 | " ORDER BY rev_timestamp DESC "; |
| 473 | 473 | $resultQuery = $this->replicas->prepare($sql); |
| 474 | 474 | $resultQuery->bindParam(":username", $username); |
@@ -507,9 +507,9 @@ discard block |
||
| 507 | 507 | $hourInterval = 2; |
| 508 | 508 | $xCalc = "ROUND(HOUR(rev_timestamp)/$hourInterval)*$hourInterval"; |
| 509 | 509 | $sql = |
| 510 | - "SELECT " . " DAYOFWEEK(rev_timestamp) AS `y`, " . " $xCalc AS `x`, " . |
|
| 511 | - " COUNT(rev_id) AS `r` " . " FROM " . $this->labsHelper->getTable('revision') . |
|
| 512 | - " WHERE rev_user_text = :username" . " GROUP BY DAYOFWEEK(rev_timestamp), $xCalc " . |
|
| 510 | + "SELECT "." DAYOFWEEK(rev_timestamp) AS `y`, "." $xCalc AS `x`, ". |
|
| 511 | + " COUNT(rev_id) AS `r` "." FROM ".$this->labsHelper->getTable('revision'). |
|
| 512 | + " WHERE rev_user_text = :username"." GROUP BY DAYOFWEEK(rev_timestamp), $xCalc ". |
|
| 513 | 513 | " "; |
| 514 | 514 | $resultQuery = $this->replicas->prepare($sql); |
| 515 | 515 | $resultQuery->bindParam(":username", $username); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $this->stopwatch->start($cacheKey, 'XTools'); |
| 62 | 62 | $api = $this->getMediawikiApi($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 | $res = $api->getRequest($query); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | // Create the API query. |
| 98 | 98 | $api = $this->getMediawikiApi($project); |
| 99 | - $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
| 99 | + $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"]; |
|
| 100 | 100 | $query = new SimpleRequest('query', $params); |
| 101 | 101 | |
| 102 | 102 | // Get the result. |