Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compatible with MediaWiki REL1_39 #32

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ApiGetHeaderFooter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @since Version 3.0
*/

use Wikimedia\ParamValidator\ParamValidator;

/**
* API module to review revisions
*/
Expand Down Expand Up @@ -48,12 +50,12 @@ public function execute() {
public function getAllowedParams() {
return array(
'contexttitle' => array(
ApiBase::PARAM_REQUIRED => true,
ApiBase::PARAM_TYPE => 'string'
ParamValidator::PARAM_REQUIRED => true,
ParamValidator::PARAM_TYPE => 'string'
),
'messageid' => array(
ApiBase::PARAM_REQUIRED => true,
ApiBase::PARAM_TYPE => 'string'
ParamValidator::PARAM_REQUIRED => true,
ParamValidator::PARAM_TYPE => 'string'
)
);
}
Expand Down
36 changes: 18 additions & 18 deletions HeaderFooter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ class HeaderFooter
{
/**
* Main Hook
* @param OutputPage $op
* @param ParserOutput $parserOutput
*/
public static function hOutputPageParserOutput( &$op, $parserOutput ) {

$action = $op->parserOptions()->getUser()->getRequest()->getVal("action");
$action = $op->getRequest()->getVal("action");
if ( ($action == 'edit') || ($action == 'submit') || ($action == 'history') ) {
return true;
}
Expand All @@ -19,13 +21,13 @@ public static function hOutputPageParserOutput( &$op, $parserOutput ) {
$ns = $wgTitle->getNsText();
$name = $wgTitle->getPrefixedDBKey();

$text = $parserOutput->getText();

$nsheader = self::conditionalInclude( $text, '__NONSHEADER__', 'hf-nsheader', $ns );
$header = self::conditionalInclude( $text, '__NOHEADER__', 'hf-header', $name );
$footer = self::conditionalInclude( $text, '__NOFOOTER__', 'hf-footer', $name );
$nsfooter = self::conditionalInclude( $text, '__NONSFOOTER__', 'hf-nsfooter', $ns );
$nsheader = self::conditionalInclude( 'hf_nsheader', 'hf-nsheader', $ns, $parserOutput );
$header = self::conditionalInclude( 'hf_header', 'hf-header', $name, $parserOutput );
$footer = self::conditionalInclude( 'hf_footer', 'hf-footer', $name, $parserOutput );
$nsfooter = self::conditionalInclude( 'hf_nsfooter', 'hf-nsfooter', $ns, $parserOutput );

// Grab only raw text to prevent doubled parser-output class
$text = $parserOutput->getRawText();
$parserOutput->setText( $nsheader . $header . $text . $footer . $nsfooter );

global $egHeaderFooterEnableAsyncHeader, $egHeaderFooterEnableAsyncFooter;
Expand All @@ -36,20 +38,18 @@ public static function hOutputPageParserOutput( &$op, $parserOutput ) {
return true;
}

public static function onGetDoubleUnderscoreIDs( &$doubleUnderscoreIDs ) {
$doubleUnderscoreIDs[] = 'hf_nsheader';
$doubleUnderscoreIDs[] = 'hf_header';
$doubleUnderscoreIDs[] = 'hf_footer';
$doubleUnderscoreIDs[] = 'hf_nsfooter';
}

/**
* Verifies & Strips ''disable command'', returns $content if all OK.
*/
static function conditionalInclude( &$text, $disableWord, $class, $unique ) {

// is there a disable command lurking around?
$disable = strpos( $text, $disableWord ) !== false;

// if there is, get rid of it
// make sure that the disableWord does not break the REGEX below!
$text = preg_replace('/'.$disableWord.'/si', '', $text );

// if there is a disable command, then don't return anything
if ( $disable ) {
static function conditionalInclude( $disableWord, $class, $unique, $parser ) {
if ( $parser->getPageProperty( $disableWord ) !== null ) {
return null;
}

Expand Down
14 changes: 0 additions & 14 deletions HeaderFooter.php

This file was deleted.

5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
"github": "https://github.com/enterprisemediawiki/HeaderFooter/issues"
},
"require": {
"composer/installers": ">=1.0.1"
},
"autoload": {
"files": ["HeaderFooter.php"]
"composer/installers": ">=1.0.1|~2"
}
}
20 changes: 14 additions & 6 deletions extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "HeaderFooter",
"version": "3.0.0",
"version": "4.0.0",
"author": "Jean-Lou Dupont, James Montalvo, Douglas Mason",
"url": "http://mediawiki.org/wiki/Extension:HeaderFooter",
"descriptionmsg": "headerfooter-desc",
Expand All @@ -14,13 +14,17 @@
},
"Hooks": {
"OutputPageParserOutput": "HeaderFooter::hOutputPageParserOutput",
"ResourceLoaderGetConfigVars": "HeaderFooter::onResourceLoaderGetConfigVars"
"ResourceLoaderGetConfigVars": "HeaderFooter::onResourceLoaderGetConfigVars",
"GetDoubleUnderscoreIDs": "HeaderFooter::onGetDoubleUnderscoreIDs"
},
"MessagesDirs": {
"HeaderFooter": [
"i18n"
]
},
"ExtensionMessagesFiles": {
"HeaderFooterMagic": "languages/HeaderFooter.i18n.magic.php"
},
"ResourceFileModulePaths": {
"localBasePath": "modules",
"remoteExtPath": "HeaderFooter/modules"
Expand All @@ -32,10 +36,14 @@
]
}
},
"config_prefix": "egHeaderFooter",
"config": {
"_prefix": "eg",
"HeaderFooterEnableAsyncHeader": false,
"HeaderFooterEnableAsyncFooter": false
"EnableAsyncHeader": {
"value": false
},
"EnableAsyncFooter": {
"value": false
}
},
"manifest_version": 1
"manifest_version": 2
}
16 changes: 16 additions & 0 deletions languages/HeaderFooter.i18n.magic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
$magicWords = [];

$magicWords['en'] = [
'hf_footer' => [ 0, '__NOFOOTER__', '__NOFOOTER__' ],
'hf_nsfooter' => [ 0, '__NONSFOOTER__', '__NONSFOOTER__' ],
'hf_header' => [ 0, '__NOHEADER__', '__NOHEADER__' ],
'hf_nsheader' => [ 0, '__NONSHEADER__', '__NONSHEADER__' ],
];

$magicWords['de'] = [
'hf_footer' => [ 0, '__NOFOOTER__', '__NOFOOTER__' ],
'hf_nsfooter' => [ 0, '__NONSFOOTER__', '__NONSFOOTER__' ],
'hf_header' => [ 0, '__NOHEADER__', '__NOHEADER__' ],
'hf_nsheader' => [ 0, '__NONSHEADER__', '__NONSHEADER__' ],
];