@@ -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,16 +68,16 @@ discard block |
||
| 68 | 68 | if ($this->container->getParameter('app.single_wiki')) { |
| 69 | 69 | $project = $this->container->getParameter('wiki_url'); |
| 70 | 70 | } else { |
| 71 | - $project = "https://" . $normalizedProject; |
|
| 71 | + $project = "https://".$normalizedProject; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $cacheKey = "siteinfo." . $normalizedProject; |
|
| 74 | + $cacheKey = "siteinfo.".$normalizedProject; |
|
| 75 | 75 | if ($this->cacheHas($cacheKey)) { |
| 76 | 76 | return $this->cacheGet($cacheKey); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $this->setUp($normalizedProject); |
| 80 | - $params = [ 'meta'=>'siteinfo', 'siprop'=>'general|namespaces' ]; |
|
| 80 | + $params = ['meta'=>'siteinfo', 'siprop'=>'general|namespaces']; |
|
| 81 | 81 | $query = new SimpleRequest('query', $params); |
| 82 | 82 | |
| 83 | 83 | $result = [ |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | public function groups($project, $username) |
| 142 | 142 | { |
| 143 | 143 | $this->setUp($project); |
| 144 | - $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ]; |
|
| 144 | + $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"]; |
|
| 145 | 145 | $query = new SimpleRequest('query', $params); |
| 146 | 146 | $result = []; |
| 147 | 147 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | public function globalGroups($project, $username) |
| 161 | 161 | { |
| 162 | 162 | $this->setUp($project); |
| 163 | - $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
| 163 | + $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"]; |
|
| 164 | 164 | $query = new SimpleRequest('query', $params); |
| 165 | 165 | $result = []; |
| 166 | 166 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $groups[] = "B"; |
| 209 | 209 | } |
| 210 | 210 | if (in_array("steward", $admin["groups"])) { |
| 211 | - $groups[] = "S" ; |
|
| 211 | + $groups[] = "S"; |
|
| 212 | 212 | } |
| 213 | 213 | if (in_array("checkuser", $admin["groups"])) { |
| 214 | 214 | $groups[] = "CU"; |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | if (in_array("bot", $admin["groups"])) { |
| 220 | 220 | $groups[] = "Bot"; |
| 221 | 221 | } |
| 222 | - $result[ $admin["name"] ] = [ |
|
| 222 | + $result[$admin["name"]] = [ |
|
| 223 | 223 | "groups" => implode('/', $groups) |
| 224 | 224 | ]; |
| 225 | 225 | } |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | $normalized = []; |
| 295 | 295 | if (isset($result['query']['normalized'])) { |
| 296 | 296 | array_map( |
| 297 | - function ($e) use (&$normalized) { |
|
| 297 | + function($e) use (&$normalized) { |
|
| 298 | 298 | $normalized[$e['to']] = $e['from']; |
| 299 | 299 | }, |
| 300 | 300 | $result['query']['normalized'] |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | ]; |
| 341 | 341 | |
| 342 | 342 | // get assessments for this page from the API |
| 343 | - $assessments = $this->massApi($params, $project, function ($data) { |
|
| 343 | + $assessments = $this->massApi($params, $project, function($data) { |
|
| 344 | 344 | return isset($data['pages'][0]['pageassessments']) ? $data['pages'][0]['pageassessments'] : []; |
| 345 | 345 | }, 'pacontinue')['pages']; |
| 346 | 346 | |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | $classAttrs = $config['class']['Unknown']; |
| 365 | 365 | $assessment['class']['value'] = '???'; |
| 366 | 366 | $assessment['class']['category'] = $classAttrs['category']; |
| 367 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". $classAttrs['badge']; |
|
| 367 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/".$classAttrs['badge']; |
|
| 368 | 368 | } else { |
| 369 | 369 | $classAttrs = $config['class'][$classValue]; |
| 370 | 370 | $assessment['class'] = [ |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | // add full URL to badge icon |
| 377 | 377 | if ($classAttrs['badge'] !== '') { |
| 378 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/" . |
|
| 378 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". |
|
| 379 | 379 | $classAttrs['badge']; |
| 380 | 380 | } |
| 381 | 381 | |
@@ -424,9 +424,9 @@ discard block |
||
| 424 | 424 | $config = $this->getAssessmentsConfig(); |
| 425 | 425 | |
| 426 | 426 | if (isset($config[$project]['class'][$class])) { |
| 427 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class'][$class]['badge']; |
|
| 427 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class'][$class]['badge']; |
|
| 428 | 428 | } elseif (isset($config[$project]['class']['Unknown'])) { |
| 429 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class']['Unknown']['badge']; |
|
| 429 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class']['Unknown']['badge']; |
|
| 430 | 430 | } else { |
| 431 | 431 | return ""; |
| 432 | 432 | } |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | $query = FluentRequest::factory()->setAction('query')->setParams($requestData); |
| 520 | 520 | $innerPromise = $this->api->getRequestAsync($query); |
| 521 | 521 | |
| 522 | - $innerPromise->then(function ($result) use (&$data) { |
|
| 522 | + $innerPromise->then(function($result) use (&$data) { |
|
| 523 | 523 | // some failures come back as 200s, so we still resolve and let the outer function handle it |
| 524 | 524 | if (isset($result['error']) || !isset($result['query'])) { |
| 525 | 525 | return $data['promise']->resolve($data); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $this->dbName = $dbName; |
| 72 | 72 | $this->url = $url; |
| 73 | 73 | |
| 74 | - return [ 'dbName' => $dbName, 'wikiName' => $wikiName, 'url' => $url, 'lang' => $lang ]; |
|
| 74 | + return ['dbName' => $dbName, 'wikiName' => $wikiName, 'url' => $url, 'lang' => $lang]; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | // Create the query we're going to run against the meta database |
| 100 | 100 | $wikiQuery = $this->client->createQueryBuilder(); |
| 101 | 101 | $wikiQuery |
| 102 | - ->select([ 'dbname', 'name', 'url', 'lang' ]) |
|
| 102 | + ->select(['dbname', 'name', 'url', 'lang']) |
|
| 103 | 103 | ->from('wiki') |
| 104 | 104 | ->where($wikiQuery->expr()->eq('dbname', ':project')) |
| 105 | 105 | // The meta database will have the project's URL stored as https://en.wikipedia.org |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | public function allProjects() |
| 150 | 150 | { |
| 151 | 151 | $wikiQuery = $this->client->createQueryBuilder(); |
| 152 | - $wikiQuery->select([ 'dbName', 'name', 'url' ])->from('wiki'); |
|
| 152 | + $wikiQuery->select(['dbName', 'name', 'url'])->from('wiki'); |
|
| 153 | 153 | $stmt = $wikiQuery->execute(); |
| 154 | 154 | $out = $stmt->fetchAll(); |
| 155 | 155 | return $out; |