mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Editcount
synced 2024-11-27 09:42:28 +00:00
Fix all PHPCS excluded rules
Change-Id: Ia80a6ae8a7ce91b66b88888a9dad3859018907ea
This commit is contained in:
parent
41a67b1cb3
commit
6c8a2f0549
16
.phpcs.xml
16
.phpcs.xml
|
@ -1,20 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset>
|
||||
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
|
||||
<exclude name="Generic.Files.LineLength.TooLong" />
|
||||
</rule>
|
||||
<rule ref="Generic.Files.LineLength">
|
||||
<properties>
|
||||
<property name="lineLimit" value="111" />
|
||||
</properties>
|
||||
<exclude-pattern>Editcount\.alias\.php</exclude-pattern>
|
||||
</rule>
|
||||
<rule ref="Generic.Files.OneObjectStructurePerFile">
|
||||
<exclude-pattern>Editcount_body\.php</exclude-pattern>
|
||||
</rule>
|
||||
<rule ref="MediaWiki.Files.ClassMatchesFilename">
|
||||
<exclude-pattern>Editcount_body\.php</exclude-pattern>
|
||||
</rule>
|
||||
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki" />
|
||||
<file>.</file>
|
||||
<arg name="extensions" value="php"/>
|
||||
<arg name="encoding" value="UTF-8"/>
|
||||
|
|
|
@ -90,7 +90,15 @@ $specialPageAliases['fi'] = [
|
|||
|
||||
/** French (français) */
|
||||
$specialPageAliases['fr'] = [
|
||||
'Editcount' => [ 'Compteur_de_modifications', 'CompteurModifications', 'CompteurEditions', 'CompteurÉditions', 'Compteur_d\'éditions', 'CompteurÉdition', 'CompteurEdition' ],
|
||||
'Editcount' => [
|
||||
'Compteur_de_modifications',
|
||||
'CompteurModifications',
|
||||
'CompteurEditions',
|
||||
'CompteurÉditions',
|
||||
'Compteur_d\'éditions',
|
||||
'CompteurÉdition',
|
||||
'CompteurEdition'
|
||||
],
|
||||
];
|
||||
|
||||
/** Arpitan (arpetan) */
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
"EditcountAliases": "Editcount.alias.php"
|
||||
},
|
||||
"AutoloadClasses": {
|
||||
"Editcount": "Editcount_body.php",
|
||||
"EditcountHTML": "Editcount_body.php"
|
||||
"Editcount": "src/Editcount.php",
|
||||
"EditcountHTML": "src/EditcountHTML.php"
|
||||
},
|
||||
"manifest_version": 1
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class Editcount extends IncludableSpecialPage {
|
|||
* @param string|null $par User name, optionally followed by a namespace, or null
|
||||
*/
|
||||
public function execute( $par ) {
|
||||
$target = isset( $par ) ? $par : $this->getRequest()->getText( 'username' );
|
||||
$target = $par ?? $this->getRequest()->getText( 'username' );
|
||||
|
||||
list( $username, $namespace ) = $this->extractParameters( $target );
|
||||
$this->getOutput()->enableOOUI();
|
||||
|
@ -109,101 +109,3 @@ class Editcount extends IncludableSpecialPage {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
class EditcountHTML extends Editcount {
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
private $nscount;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $total;
|
||||
|
||||
/**
|
||||
* Output the HTML form on Special:Editcount
|
||||
*
|
||||
* @param string $username
|
||||
* @param int $uid
|
||||
* @param int[] $nscount
|
||||
* @param int|null $total
|
||||
*/
|
||||
public function outputHTML( $username, $uid, array $nscount, $total = null ) {
|
||||
$this->nscount = $nscount;
|
||||
$this->total = $total ?: array_sum( $nscount );
|
||||
|
||||
$this->setHeaders();
|
||||
|
||||
$action = htmlspecialchars( $this->getPageTitle()->getLocalURL() );
|
||||
$user = $this->msg( 'editcount_username' )->escaped();
|
||||
$out = "
|
||||
<form id='editcount' method='post' action=\"$action\">
|
||||
<table>
|
||||
<tr>
|
||||
<td>$user</td>
|
||||
<td>" . new OOUI\TextInputWidget( [
|
||||
'name' => 'username',
|
||||
'value' => $username,
|
||||
'autofocus' => true,
|
||||
] ) . "</td>
|
||||
<td>" . new OOUI\ButtonInputWidget( [
|
||||
'label' => $this->msg( 'editcount_submit' )->text(),
|
||||
'flags' => [ 'primary', 'progressive' ],
|
||||
'type' => 'submit',
|
||||
] ) . " </td>
|
||||
</tr>";
|
||||
if ( $username != null && $uid != 0 ) {
|
||||
$editcounttable = $this->makeTable();
|
||||
$out .= "
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>$editcounttable</td>
|
||||
<td> </td>
|
||||
</tr>";
|
||||
}
|
||||
$out .= '
|
||||
</table>
|
||||
</form>';
|
||||
$this->getOutput()->addHTML( $out );
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the editcount-by-namespaces HTML table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function makeTable() {
|
||||
$lang = $this->getLanguage();
|
||||
|
||||
$total = $this->msg( 'editcount_total' )->escaped();
|
||||
$ftotal = $lang->formatNum( $this->total );
|
||||
$percent = wfPercent( $this->total ? 100 : 0 );
|
||||
// @fixme don't use inline styles
|
||||
$ret = "<table border='1' style='background-color: #fff; border: 1px #aaa solid; border-collapse: collapse;'>
|
||||
<tr>
|
||||
<th>$total</th>
|
||||
<th>$ftotal</th>
|
||||
<th>$percent</th>
|
||||
</tr>
|
||||
";
|
||||
|
||||
foreach ( $this->nscount as $ns => $edits ) {
|
||||
$fedits = $lang->formatNum( $edits );
|
||||
$fns = ( $ns == NS_MAIN ) ? $this->msg( 'blanknamespace' ) : $lang->getFormattedNsText( $ns );
|
||||
$percent = wfPercent( $edits / $this->total * 100 );
|
||||
$fpercent = $lang->formatNum( $percent );
|
||||
$ret .= "
|
||||
<tr>
|
||||
<td>$fns</td>
|
||||
<td>$fedits</td>
|
||||
<td>$fpercent</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
$ret .= '</table>
|
||||
';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
95
src/EditcountHTML.php
Normal file
95
src/EditcountHTML.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
class EditcountHTML extends Editcount {
|
||||
/** @var int[] */
|
||||
private $nscount;
|
||||
|
||||
/** @var int */
|
||||
private $total;
|
||||
|
||||
/**
|
||||
* Output the HTML form on Special:Editcount
|
||||
*
|
||||
* @param string $username
|
||||
* @param int $uid
|
||||
* @param int[] $nscount
|
||||
* @param int|null $total
|
||||
*/
|
||||
public function outputHTML( $username, $uid, array $nscount, $total = null ) {
|
||||
$this->nscount = $nscount;
|
||||
$this->total = $total ?: array_sum( $nscount );
|
||||
|
||||
$this->setHeaders();
|
||||
|
||||
$action = htmlspecialchars( $this->getPageTitle()->getLocalURL() );
|
||||
$user = $this->msg( 'editcount_username' )->escaped();
|
||||
$out = "
|
||||
<form id='editcount' method='post' action=\"$action\">
|
||||
<table>
|
||||
<tr>
|
||||
<td>$user</td>
|
||||
<td>" . new OOUI\TextInputWidget( [
|
||||
'name' => 'username',
|
||||
'value' => $username,
|
||||
'autofocus' => true,
|
||||
] ) . "</td>
|
||||
<td>" . new OOUI\ButtonInputWidget( [
|
||||
'label' => $this->msg( 'editcount_submit' )->text(),
|
||||
'flags' => [ 'primary', 'progressive' ],
|
||||
'type' => 'submit',
|
||||
] ) . " </td>
|
||||
</tr>";
|
||||
if ( $username != null && $uid != 0 ) {
|
||||
$editcounttable = $this->makeTable();
|
||||
$out .= "
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>$editcounttable</td>
|
||||
<td> </td>
|
||||
</tr>";
|
||||
}
|
||||
$out .= '
|
||||
</table>
|
||||
</form>';
|
||||
$this->getOutput()->addHTML( $out );
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the editcount-by-namespaces HTML table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function makeTable() {
|
||||
$lang = $this->getLanguage();
|
||||
|
||||
$total = $this->msg( 'editcount_total' )->escaped();
|
||||
$ftotal = $lang->formatNum( $this->total );
|
||||
$percent = wfPercent( $this->total ? 100 : 0 );
|
||||
// @fixme don't use inline styles
|
||||
$ret = "<table border='1' style='background-color: #fff; border: 1px #aaa solid; border-collapse: collapse;'>
|
||||
<tr>
|
||||
<th>$total</th>
|
||||
<th>$ftotal</th>
|
||||
<th>$percent</th>
|
||||
</tr>
|
||||
";
|
||||
|
||||
foreach ( $this->nscount as $ns => $edits ) {
|
||||
$fedits = $lang->formatNum( $edits );
|
||||
$fns = ( $ns == NS_MAIN ) ? $this->msg( 'blanknamespace' ) : $lang->getFormattedNsText( $ns );
|
||||
$percent = wfPercent( $edits / $this->total * 100 );
|
||||
$fpercent = $lang->formatNum( $percent );
|
||||
$ret .= "
|
||||
<tr>
|
||||
<td>$fns</td>
|
||||
<td>$fedits</td>
|
||||
<td>$fpercent</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
$ret .= '</table>
|
||||
';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue