@ 2017-12-03T07:45:49Z <?php
// Stub
class HTMLCheckField {}
/*
* This file is part of the MediaWiki extension BetaFeatures.
*
* BetaFeatures is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* BetaFeatures is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with BetaFeatures. If not, see <http://www.gnu.org/licenses/>.
*
* New HTML check field
*
* @file
* @ingroup Extensions
* @copyright 2013 Mark Holmquist and others; see AUTHORS
* @license GNU General Public License version 2 or later
*/
class NewHTMLCheckField extends HTMLCheckField {
/**
* @var boolean directive whether to include a label with the checkbox
*/
protected $includeLabel = true;
// Protected internal methods for getting the bits of the field
// Override these in subclasses (see HTMLFeatureField, e.g.)
/**
* @param string $value
* @param string $attr
* @return string
*/
protected function getCheckboxHTML( $value, $attr ) {
if ( !empty( $this->mParams['invert'] ) ) {
$value = !$value;
}
$out = $this->mParent->getOutput();
$out->addModules( 'ext.betaFeatures' );
$out->addModuleStyles( 'ext.betaFeatures.styles' );
$out->enableOOUI();
// TODO: Support $this->getTooltipAndAccessKey?
return Html::openElement( 'div', [ 'class' => 'mw-ui-feature-checkbox' ] ) .
new OOUI\FieldLayout(
new OOUI\CheckboxInputWidget( [
'name' => $this->mName,
'selected' => $value,
'value' => 1,
'classes' => $this->mClass ? [ $this->mClass ] : [],
'disabled' => isset( $this->mParams['disabled'] ) &&
$this->mParams['disabled'] === true,
] ),
[
'align' => 'inline',
'label' => $this->includeLabel ? $this->mLabel : '',
]
) .
Html::closeElement( 'div' );
}
/**
* @return string
*/
protected function getPostCheckboxLabelHTML() {
return Html::rawElement(
'label',
[ 'for' => $this->mID, 'class' => 'mw-ui-text-check-label' ],
$this->mLabel
);
}
/**
* @param string $value
* @param null $attr
* @return String
*/
public function getInputHTML( $value, $attr = null ) {
return $this->getCheckboxHTML( $value, $attr );
}
public function getInputOOUI( $value ) {
// Use the same output as for the HTML version, otherwise OOUIHTMLForm would use
// a plain checkbox, inherited from HTMLCheckField. This isn't actually a widget
// (just a HTML string) but that's okay, HTMLFormField::getOOUI() will handle it.
return $this->getInputHTML( $value );
}
protected function getFieldLayoutOOUI( $inputField, $config ) {
// Label is already included in the field's HTML, do not duplicate it
unset( $config['label'] );
return parent::getFieldLayoutOOUI( $inputField, $config );
}
}
/*
* This file is part of the MediaWiki extension BetaFeatures.
*
* BetaFeatures is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* BetaFeatures is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with BetaFeatures. If not, see <http://www.gnu.org/licenses/>.
*
* HTML feature field
*
* @file
* @ingroup Extensions
* @copyright 2013 Mark Holmquist and others; see AUTHORS
* @license GNU General Public License version 2 or later
*/
class HTMLFeatureField extends NewHTMLCheckField {
const OPTION_ENABLED = '1';
const OPTION_DISABLED = '0';
function __construct( $options ) {
// We need the new checkbox style to have a sane-looking field
$options['mw-ui'] = true;
parent::__construct( $options );
}
function getHeaderHTML( $value ) {
$html = Html::openElement( 'div', [
'class' => 'mw-ui-feature-header',
] );
$attrs = $this->getTooltipAndAccessKey();
$attrs['id'] = $this->mID;
$attrs['class'] = 'mw-ui-feature-toggle';
if ( isset( $this->mParams['disabled'] ) &&
$this->mParams['disabled'] === true ) {
$attrs['disabled'] = true;
}
$html .= Html::openElement( 'div', [
'class' => 'mw-ui-feature-title-contain',
] );
$html .= $this->getCheckboxHTML( $value, $attrs );
// Close -title-contain
$html .= Html::closeElement( 'div' );
if ( isset( $this->mParams['info-message'] ) ) {
$infoLink = $this->mParent->msg( $this->mParams['info-message'] )->escaped();
} else {
$infoLink = $this->mParams['info-link'];
}
if ( isset( $this->mParams['discussion-message'] ) ) {
$discussionLink = $this->mParent->msg( $this->mParams['discussion-message'] )->escaped();
} else {
$discussionLink = $this->mParams['discussion-link'];
}
$infoLinkClasses = [
'mw-ui-feature-info-links',
];
if ( isset( $infoLink ) || isset( $discussionLink ) ) {
$infoLinkClasses[] = 'filled';
}
$html .= Html::openElement( 'div', [
'class' => $infoLinkClasses,
] );
$out = $this->mParent->getOutput();
if ( isset( $infoLink ) ) {
$out->addModuleStyles( 'oojs-ui.styles.icons-content' );
$html .= Html::rawElement( 'a', [
'href' => $infoLink,
'class' => 'mw-ui-feature-info-link',
],
new OOUI\IconWidget( [
'icon' => 'article'
] ).
$this->mParent->msg( 'mw-ui-feature-info' )->escaped()
);
$html .= ' ';
}
if ( isset( $discussionLink ) ) {
$out->addModuleStyles( 'oojs-ui.styles.icons-alerts' );
$html .= Html::rawElement( 'a', [
'href' => $discussionLink,
'class' => 'mw-ui-feature-discussion-link',
],
new OOUI\IconWidget( [
'icon' => 'speechBubbles'
] ).
$this->mParent->msg( 'mw-ui-feature-discuss' )->escaped()
);
}
// mw-ui-feature-info-links
$html .= Html::closeElement( 'div' );
// Close -header
$html .= Html::closeElement( 'div' );
return $html;
}
function getMainHTML( $value ) {
$parent = $this->mParent;
$html = Html::openElement( 'div', [
'class' => 'mw-ui-feature-main',
] );
$html .= Html::openElement( 'div', [
'class' => 'mw-ui-feature-meta',
] );
if ( isset( $this->mParams['user-count'] ) ) {
$userCountMsg = 'mw-ui-feature-user-count';
if ( isset( $this->mParams['user-count-msg'] ) ) {
$userCountMsg = $this->mParams['user-count-msg'];
}
$html .= Html::rawElement(
'p',
[ 'class' => 'mw-ui-feature-user-count' ],
$parent->msg( $userCountMsg )->numParams( $this->mParams['user-count'] )->escaped()
);
$attrs['data-count'] = $this->mParams['user-count'];
}
if ( isset( $this->mParams['desc-message'] ) ) {
$html .= Html::rawElement(
'p',
[
'class' => 'mw-ui-feature-description',
],
$parent->msg( $this->mParams['desc-message'] )->parse() );
}
$html .= Html::openElement( 'ul', [
'class' => 'mw-ui-feature-requirements-list',
] );
if ( isset( $this->mParams['requirements'] ) ) {
if (
isset( $this->mParams['requirements']['javascript'] ) &&
$this->mParams['requirements']['javascript']
) {
$html .= Html::rawElement(
'li',
[ 'class' => 'mw-ui-feature-requirements-javascript' ],
$parent->msg( 'mw-ui-feature-requirements-javascript' )->escaped()
);
}
if ( isset( $this->mParams['requirements']['blacklist'] ) ) {
$html .= Html::openElement(
'li',
[ 'class' => 'mw-ui-feature-requirements-browser' ]
);
$browserCount = count( $this->mParams['requirements']['blacklist'] );
$html .= $parent->msg( 'mw-ui-feature-requirements-browser', $browserCount )->escaped();
$html .= Html::openElement( 'ul' );
foreach ( $this->mParams['requirements']['blacklist'] as $browser => $versions ) {
$browserString = $browser;
if ( $versions ) {
foreach ( $versions as $version ) {
$browserString .= ' ' . implode( ' ', $version );
}
}
$html .= Html::element(
'li',
[],
$browserString
);
}
$html .= Html::closeElement( 'ul' );
$html .= Html::closeElement( 'li' );
}
if (
isset( $this->mParams['requirements']['skin-not-supported'] ) &&
$this->mParams['requirements']['skin-not-supported'] === true
) {
$html .= Html::openElement(
'li',
[ 'class' => 'mw-ui-feature-requirements-skins' ]
);
$skinCount = count( $this->mParams['requirements']['skins'] );
$html .= $parent->msg( 'mw-ui-feature-requirements-skins', $skinCount )->escaped();
$html .= Html::openElement( 'ul' );
foreach ( $this->mParams['requirements']['skins'] as $skin ) {
$html .= Html::element(
'li',
[],
$parent->msg( "skinname-$skin" )->text()
);
}
$html .= Html::closeElement( 'ul' );
$html .= Html::closeElement( 'li' );
}
if ( isset( $this->mParams['requirements']['betafeatures-messages'] ) ) {
$html .= Html::openElement(
'li',
[ 'class' => 'mw-ui-feature-requirements-betafeatures' ]
);
$featureCount = count( $this->mParams['requirements']['betafeatures-messages'] );
$html .= $parent->msg( 'mw-ui-feature-requirements-betafeatures', $featureCount )->escaped();
$html .= Html::openElement( 'ul' );
foreach ( $this->mParams['requirements']['betafeatures-messages'] as $message ) {
$html .= Html::rawElement(
'li',
[],
$parent->msg( $message )->escaped()
);
}
$html .= Html::closeElement( 'ul' );
$html .= Html::closeElement( 'li' );
}
}
// mw-ui-feature-requirements-list
$html .= Html::closeElement( 'ul' );
// Close -meta
$html .= Html::closeElement( 'div' );
$html .= Html::openElement( 'div', [
'class' => 'mw-ui-feature-screenshot-contain',
] );
if ( isset( $this->mParams['screenshot'] ) ) {
$screenshot = $this->mParams['screenshot'];
// The screenshot parameter is either a string with a filename
// or an array that specifies a screenshot for each language,
// and default screenshots for rtl and ltr languages
if ( is_array( $screenshot ) ) {
$language = $this->mParent->getLanguage();
$langCode = $language->getCode();
if ( array_key_exists( $langCode, $screenshot ) ) {
$screenshot = $screenshot[$langCode];
} else {
$screenshot = $screenshot[$language->getDir()];
}
}
$html .= Html::element( 'img', [
'src' => $screenshot,
'class' => 'mw-ui-feature-screenshot',
] );
}
// Close -screenshot-contain
$html .= Html::closeElement( 'div' );
// Close -main
$html .= Html::closeElement( 'div' );
return $html;
}
function getInputHTML( $value ) {
$html = '';
$divClasses = [
'mw-ui-feature-field',
];
// Use 'cssclass' to populate this. Separate from 'class', of course.
if ( $this->mClass !== '' ) {
$divClasses[] = $this->mClass;
}
$html .= Html::openElement( 'div', [
'class' => implode( ' ', $divClasses ),
] );
$html .= Html::openElement( 'div', [
'class' => 'mw-ui-feature-contain',
] );
$html .= $this->getHeaderHTML( $value );
$html .= $this->getMainHTML( $value );
// mw-ui-feature-contain
$html .= Html::closeElement( 'div' );
// mw-ui-feature-field
$html .= Html::closeElement( 'div' );
return $html;
}
/**
* Override to use integers, so we don't lose the database rows on
* unset...
* @param WebRequest $request
* @return string
*/
function loadDataFromRequest( $request ) {
$res = parent::loadDataFromRequest( $request );
if ( $res === true ) {
return self::OPTION_ENABLED;
} elseif ( $res === false ) {
return self::OPTION_DISABLED;
} else {
// Dunno what happened, but I'm not gonna fight it.
return $res;
}
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 Fatal error: Declaration of HTMLFeatureField::getInputHTML($value) must be compatible with NewHTMLCheckField::getInputHTML($value, $attr = null) in /in/QSD7O on line 389
Process exited with code 255 . Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Fatal error: Declaration of HTMLFeatureField::getInputHTML($value) must be compatible with NewHTMLCheckField::getInputHTML($value, $attr = null) in /in/QSD7O on line 389
Process exited with code 255 . Output for 7.4.0 - 7.4.33 Warning: Declaration of HTMLFeatureField::getInputHTML($value) should be compatible with NewHTMLCheckField::getInputHTML($value, $attr = NULL) in /in/QSD7O on line 389
Output for 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 Warning: Declaration of HTMLFeatureField::getInputHTML($value) should be compatible with NewHTMLCheckField::getInputHTML($value, $attr = NULL) in /in/QSD7O on line 439
preferences:dark mode live preview
184.38 ms | 402 KiB | 202 Q