mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CiteThisPage
synced 2024-11-30 10:24:30 +00:00
Add php code sniffer
Change-Id: I95b39047cf07694b276728d2831bc811ee9e329d
This commit is contained in:
parent
ddb86d726d
commit
f403a8d42e
|
@ -9,14 +9,17 @@ class CiteThisPageHooks {
|
||||||
* @param $revid
|
* @param $revid
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function onSkinTemplateBuildNavUrlsNav_urlsAfterPermalink( &$skintemplate, &$nav_urls, &$oldid, &$revid ) {
|
public static function onSkinTemplateBuildNavUrlsNav_urlsAfterPermalink(
|
||||||
|
&$skintemplate, &$nav_urls, &$oldid, &$revid
|
||||||
|
) {
|
||||||
// check whether we’re in the right namespace, the $revid has the correct type and is not empty
|
// check whether we’re in the right namespace, the $revid has the correct type and is not empty
|
||||||
// (which would mean that the current page doesn’t exist)
|
// (which would mean that the current page doesn’t exist)
|
||||||
$title = $skintemplate->getTitle();
|
$title = $skintemplate->getTitle();
|
||||||
if ( $title->isContentPage() && $revid !== 0 && !empty( $revid ) )
|
if ( $title->isContentPage() && $revid !== 0 && !empty( $revid ) ) {
|
||||||
$nav_urls['citeThisPage'] = array(
|
$nav_urls['citeThisPage'] = array(
|
||||||
'args' => array( 'page' => $title->getPrefixedDBkey(), 'id' => $revid )
|
'args' => array( 'page' => $title->getPrefixedDBkey(), 'id' => $revid )
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ if ( function_exists( 'wfLoadExtension' ) ) {
|
||||||
$wgMessagesDirs['CiteThisPage'] = __DIR__ . '/i18n';
|
$wgMessagesDirs['CiteThisPage'] = __DIR__ . '/i18n';
|
||||||
$wgExtensionMessagesFiles['CiteThisPageAliases'] = __DIR__ . '/CiteThisPage.alias.php';
|
$wgExtensionMessagesFiles['CiteThisPageAliases'] = __DIR__ . '/CiteThisPage.alias.php';
|
||||||
/* wfWarn(
|
/* wfWarn(
|
||||||
'Deprecated PHP entry point used for CiteThisPage extension. Please use wfLoadExtension instead, ' .
|
'Deprecated PHP entry point used for CiteThisPage extension. ' .
|
||||||
|
'Please use wfLoadExtension instead, ' .
|
||||||
'see https://www.mediawiki.org/wiki/Extension_registration for more details.'
|
'see https://www.mediawiki.org/wiki/Extension_registration for more details.'
|
||||||
); */
|
); */
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -113,11 +113,12 @@ class CiteThisPageOutput {
|
||||||
|
|
||||||
$msg = wfMessage( 'citethispage-content' )->inContentLanguage()->plain();
|
$msg = wfMessage( 'citethispage-content' )->inContentLanguage()->plain();
|
||||||
if ( $msg == '' ) {
|
if ( $msg == '' ) {
|
||||||
# With MediaWiki 1.20 the plain text files were deleted and the text moved into SpecialCite.i18n.php
|
# With MediaWiki 1.20 the plain text files were deleted
|
||||||
|
# and the text moved into SpecialCite.i18n.php
|
||||||
# This code is kept for b/c in case an installation has its own file "citethispage-content-xx"
|
# This code is kept for b/c in case an installation has its own file "citethispage-content-xx"
|
||||||
# for a previously not supported language.
|
# for a previously not supported language.
|
||||||
global $wgContLang, $wgContLanguageCode;
|
global $wgContLang, $wgContLanguageCode;
|
||||||
$dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
|
$dir = __DIR__ . DIRECTORY_SEPARATOR;
|
||||||
$code = $wgContLang->lc( $wgContLanguageCode );
|
$code = $wgContLang->lc( $wgContLanguageCode );
|
||||||
if ( file_exists( "${dir}citethispage-content-$code" ) ) {
|
if ( file_exists( "${dir}citethispage-content-$code" ) ) {
|
||||||
$msg = file_get_contents( "${dir}citethispage-content-$code" );
|
$msg = file_get_contents( "${dir}citethispage-content-$code" );
|
||||||
|
@ -125,11 +126,13 @@ class CiteThisPageOutput {
|
||||||
$msg = file_get_contents( "${dir}citethispage-content" );
|
$msg = file_get_contents( "${dir}citethispage-content" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ret = $wgParser->parse( $msg, $this->mTitle, $this->mParserOptions, false, true, $this->getRevId() );
|
$ret = $wgParser->parse(
|
||||||
|
$msg, $this->mTitle, $this->mParserOptions, false, true, $this->getRevId()
|
||||||
|
);
|
||||||
$wgOut->addModuleStyles( 'ext.citeThisPage' );
|
$wgOut->addModuleStyles( 'ext.citeThisPage' );
|
||||||
|
|
||||||
# Introduced in 1.24
|
# Introduced in 1.24
|
||||||
if( method_exists( $wgOut, 'addParserOutputContent' ) ) {
|
if ( method_exists( $wgOut, 'addParserOutputContent' ) ) {
|
||||||
$wgOut->addParserOutputContent( $ret );
|
$wgOut->addParserOutputContent( $ret );
|
||||||
} else {
|
} else {
|
||||||
$wgOut->addHTML( $ret->getText() );
|
$wgOut->addHTML( $ret->getText() );
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
{
|
{
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"jakub-onderka/php-parallel-lint": "0.9.2"
|
"jakub-onderka/php-parallel-lint": "0.9.2",
|
||||||
|
"mediawiki/mediawiki-codesniffer": "0.5.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": [
|
"test": [
|
||||||
"parallel-lint . --exclude node_modules --exclude vendor"
|
"parallel-lint . --exclude node_modules --exclude vendor",
|
||||||
|
"phpcs -p -s"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue