'key' => 'R'
)
);
- $toolbar = "<div id='toolbar'>\n";
$script = '';
foreach ( $toolarray as $tool ) {
$cssId = $tool['id'],
);
- $paramList = implode( ',',
- array_map( array( 'Xml', 'encodeJsVar' ), $params ) );
- $script .= "mw.toolbar.addButton($paramList);\n";
+ $script .= Xml::encodeJsCall( 'mw.toolbar.addButton', $params );
}
- $wgOut->addScript( Html::inlineScript(
- "if ( window.mediaWiki ) {{$script}}"
- ) );
+ $wgOut->addScript( Html::inlineScript( ResourceLoader::makeLoaderConditionalScript( $script ) ) );
- $toolbar .= "\n</div>";
+ $toolbar = '<div id="toolbar"></div>';
wfRunHooks( 'EditPageBeforeEditToolbar', array( &$toolbar ) );
}
function buildCleanupScript() {
- global $wgRestrictionLevels, $wgGroupPermissions;
- $script = 'var wgCascadeableLevels=';
- $CascadeableLevels = array();
+ global $wgRestrictionLevels, $wgGroupPermissions, $wgOut;
+
+ $cascadeableLevels = array();
foreach( $wgRestrictionLevels as $key ) {
- if ( (isset($wgGroupPermissions[$key]['protect']) && $wgGroupPermissions[$key]['protect']) || $key == 'protect' ) {
- $CascadeableLevels[] = "'" . Xml::escapeJsString( $key ) . "'";
+ if ( ( isset( $wgGroupPermissions[$key]['protect'] ) && $wgGroupPermissions[$key]['protect'] )
+ || $key == 'protect'
+ ) {
+ $cascadeableLevels[] = $key;
}
}
- $script .= "[" . implode(',',$CascadeableLevels) . "];\n";
- $options = (object)array(
+ $options = array(
'tableId' => 'mwProtectSet',
- 'labelText' => wfMsg( 'protect-unchain-permissions' ),
- 'numTypes' => count($this->mApplicableTypes),
- 'existingMatch' => 1 == count( array_unique( $this->mExistingExpiry ) ),
+ 'labelText' => wfMessage( 'protect-unchain-permissions' )->plain(),
+ 'numTypes' => count( $this->mApplicableTypes ),
+ 'existingMatch' => count( array_unique( $this->mExistingExpiry ) ) === 1,
);
- $encOptions = Xml::encodeJsVar( $options );
- $script .= "ProtectionForm.init($encOptions)";
- return Html::inlineScript( "if ( window.mediaWiki ) { $script }" );
+ $wgOut->addJsConfigVars( 'wgCascadeableLevels', $cascadeableLevels );
+ $script = Xml::encodeJsCall( 'ProtectionForm.init', array( $options ) );
+ return Html::inlineScript( ResourceLoader::makeLoaderConditionalScript( $script ) );
}
/**