@ 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.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.3.6 0.006 0.013 16.87 8.3.5 0.006 0.013 16.63 8.3.4 0.012 0.003 18.79 8.3.3 0.019 0.003 18.67 8.3.2 0.004 0.011 20.43 8.3.1 0.003 0.006 21.85 8.3.0 0.011 0.007 21.86 8.2.18 0.009 0.006 18.00 8.2.17 0.006 0.009 22.96 8.2.16 0.006 0.009 20.40 8.2.15 0.000 0.008 24.18 8.2.14 0.006 0.003 24.66 8.2.13 0.004 0.004 22.29 8.2.12 0.004 0.004 26.35 8.2.11 0.009 0.009 21.18 8.2.10 0.004 0.011 17.84 8.2.9 0.000 0.008 19.17 8.2.8 0.008 0.000 17.97 8.2.7 0.003 0.006 17.38 8.2.6 0.008 0.000 18.04 8.2.5 0.003 0.006 18.22 8.2.4 0.004 0.004 20.57 8.2.3 0.000 0.008 19.19 8.2.2 0.000 0.007 18.18 8.2.1 0.004 0.004 18.09 8.2.0 0.000 0.007 18.17 8.1.28 0.011 0.004 25.92 8.1.27 0.008 0.000 22.26 8.1.26 0.004 0.004 26.35 8.1.25 0.004 0.004 28.09 8.1.24 0.000 0.009 23.92 8.1.23 0.011 0.000 20.64 8.1.22 0.006 0.003 17.79 8.1.21 0.003 0.005 18.77 8.1.20 0.000 0.009 17.48 8.1.19 0.003 0.005 17.22 8.1.18 0.004 0.004 20.45 8.1.17 0.005 0.003 18.75 8.1.16 0.003 0.006 19.05 8.1.15 0.007 0.000 20.30 8.1.14 0.004 0.004 19.21 8.1.13 0.003 0.005 18.92 8.1.12 0.000 0.007 17.55 8.1.11 0.002 0.005 17.55 8.1.10 0.004 0.004 17.53 8.1.9 0.006 0.003 17.54 8.1.8 0.004 0.004 17.53 8.1.7 0.000 0.007 17.54 8.1.6 0.000 0.008 17.74 8.1.5 0.005 0.003 17.55 8.1.4 0.000 0.008 17.63 8.1.3 0.004 0.004 17.77 8.1.2 0.005 0.005 17.70 8.1.1 0.003 0.006 17.61 8.1.0 0.004 0.004 17.54 8.0.30 0.000 0.008 18.77 8.0.29 0.000 0.008 16.88 8.0.28 0.003 0.003 18.50 8.0.27 0.005 0.003 17.30 8.0.26 0.003 0.005 16.95 8.0.25 0.000 0.008 17.07 8.0.24 0.008 0.003 16.98 8.0.23 0.004 0.004 17.04 8.0.22 0.000 0.007 17.00 8.0.21 0.007 0.000 16.90 8.0.20 0.004 0.004 17.13 8.0.19 0.003 0.005 17.00 8.0.18 0.004 0.004 17.04 8.0.17 0.004 0.004 17.04 8.0.16 0.000 0.007 16.93 8.0.15 0.005 0.002 16.82 8.0.14 0.003 0.006 16.96 8.0.13 0.007 0.000 13.50 8.0.12 0.008 0.000 16.88 8.0.11 0.000 0.008 16.93 8.0.10 0.008 0.000 17.05 8.0.9 0.004 0.004 17.11 8.0.8 0.003 0.012 16.95 8.0.7 0.004 0.004 17.02 8.0.6 0.000 0.007 16.90 8.0.5 0.000 0.008 17.08 8.0.3 0.007 0.012 17.17 8.0.2 0.009 0.012 17.42 8.0.1 0.004 0.004 17.13 8.0.0 0.009 0.009 16.90 7.4.33 0.000 0.005 15.55 7.4.32 0.003 0.003 16.66 7.4.30 0.000 0.006 16.68 7.4.29 0.003 0.003 16.60 7.4.28 0.000 0.008 16.65 7.4.27 0.000 0.007 16.59 7.4.26 0.000 0.008 16.46 7.4.25 0.003 0.005 16.45 7.4.24 0.004 0.004 16.64 7.4.23 0.004 0.004 16.55 7.4.22 0.007 0.011 16.57 7.4.21 0.004 0.016 16.77 7.4.20 0.008 0.000 16.73 7.4.16 0.013 0.005 16.68 7.4.15 0.011 0.017 17.40 7.4.14 0.012 0.009 17.86 7.4.13 0.010 0.014 16.44 7.4.12 0.012 0.009 16.52 7.4.11 0.003 0.015 16.62 7.4.10 0.009 0.009 16.59 7.4.9 0.006 0.012 16.52 7.4.8 0.009 0.012 19.39 7.4.7 0.007 0.014 16.52 7.4.6 0.010 0.007 16.73 7.4.5 0.003 0.013 16.67 7.4.4 0.012 0.006 16.51 7.4.3 0.011 0.005 16.64 7.4.0 0.010 0.010 15.19 7.3.33 0.000 0.005 13.34 7.3.32 0.000 0.005 13.28 7.3.31 0.008 0.000 16.41 7.3.30 0.008 0.000 16.42 7.3.29 0.006 0.011 16.41 7.3.28 0.005 0.013 16.37 7.3.27 0.016 0.010 17.40 7.3.26 0.012 0.009 16.42 7.3.25 0.012 0.008 16.42 7.3.24 0.010 0.010 16.49 7.3.23 0.013 0.003 16.63 7.3.21 0.010 0.013 16.36 7.3.20 0.014 0.003 16.70 7.3.19 0.010 0.006 16.50 7.3.18 0.014 0.003 16.40 7.3.17 0.010 0.007 16.44 7.3.16 0.007 0.010 16.45 7.3.12 0.010 0.006 14.62 7.3.11 0.003 0.013 14.74 7.3.10 0.013 0.000 14.86 7.3.9 0.003 0.007 14.70 7.3.8 0.003 0.010 15.14 7.3.7 0.008 0.008 14.86 7.3.6 0.009 0.006 14.93 7.3.5 0.004 0.008 14.80 7.3.4 0.007 0.011 14.69 7.3.3 0.012 0.006 14.80 7.3.2 0.004 0.007 16.63 7.3.1 0.007 0.005 16.54 7.3.0 0.007 0.006 16.49 7.2.33 0.010 0.010 16.53 7.2.32 0.012 0.009 16.57 7.2.31 0.011 0.012 16.40 7.2.30 0.012 0.006 16.47 7.2.29 0.010 0.006 16.70 7.2.25 0.004 0.015 15.00 7.2.24 0.003 0.016 14.86 7.2.23 0.007 0.007 15.09 7.2.22 0.000 0.016 15.30 7.2.21 0.000 0.011 14.76 7.2.20 0.003 0.013 14.98 7.2.19 0.009 0.003 15.06 7.2.18 0.000 0.012 14.93 7.2.17 0.003 0.010 15.10 7.2.16 0.004 0.011 15.15 7.2.15 0.000 0.015 16.59 7.2.14 0.000 0.011 16.73 7.2.13 0.006 0.009 16.77 7.2.12 0.005 0.009 16.73 7.2.11 0.005 0.007 16.54 7.2.10 0.004 0.011 16.65 7.2.9 0.002 0.012 16.81 7.2.8 0.005 0.009 16.47 7.2.7 0.005 0.007 16.67 7.2.6 0.002 0.013 16.48 7.2.5 0.008 0.005 16.59 7.2.4 0.003 0.011 16.80 7.2.3 0.003 0.009 16.84 7.2.2 0.002 0.009 16.50 7.2.1 0.002 0.010 16.84 7.2.0 0.005 0.010 17.54 7.1.33 0.000 0.013 15.63 7.1.32 0.007 0.007 15.66 7.1.31 0.000 0.014 15.60 7.1.30 0.007 0.004 15.66 7.1.29 0.003 0.009 15.44 7.1.28 0.007 0.007 15.54 7.1.27 0.000 0.009 15.36 7.1.26 0.004 0.007 15.28 7.1.25 0.007 0.008 15.63 7.1.20 0.003 0.007 15.68 7.1.12 0.008 0.008 18.68 7.1.11 0.006 0.010 17.54 7.1.10 0.004 0.015 17.89 7.1.9 0.008 0.005 18.02 7.1.8 0.004 0.012 17.81 7.1.7 0.015 0.003 16.85 7.1.6 0.027 0.014 35.03 7.1.5 0.020 0.019 34.63 7.1.4 0.020 0.013 34.33 7.1.3 0.028 0.012 34.07 7.1.2 0.019 0.016 34.36 7.1.1 0.010 0.007 16.48 7.1.0 0.006 0.009 16.64
preferences:dark mode live preview
95.3 ms | 400 KiB | 5 Q