Index: trunk/phase3/includes/ProtectionForm.php |
— | — | @@ -576,25 +576,26 @@ |
577 | 577 | } |
578 | 578 | |
579 | 579 | function buildCleanupScript() { |
580 | | - global $wgRestrictionLevels, $wgGroupPermissions; |
581 | | - $script = 'var wgCascadeableLevels='; |
582 | | - $CascadeableLevels = array(); |
| 580 | + global $wgRestrictionLevels, $wgGroupPermissions, $wgOut; |
| 581 | + |
| 582 | + $cascadeableLevels = array(); |
583 | 583 | foreach( $wgRestrictionLevels as $key ) { |
584 | | - if ( (isset($wgGroupPermissions[$key]['protect']) && $wgGroupPermissions[$key]['protect']) || $key == 'protect' ) { |
585 | | - $CascadeableLevels[] = "'" . Xml::escapeJsString( $key ) . "'"; |
| 584 | + if ( ( isset( $wgGroupPermissions[$key]['protect'] ) && $wgGroupPermissions[$key]['protect'] ) |
| 585 | + || $key == 'protect' |
| 586 | + ) { |
| 587 | + $cascadeableLevels[] = $key; |
586 | 588 | } |
587 | 589 | } |
588 | | - $script .= "[" . implode(',',$CascadeableLevels) . "];\n"; |
589 | | - $options = (object)array( |
| 590 | + $options = array( |
590 | 591 | 'tableId' => 'mwProtectSet', |
591 | | - 'labelText' => wfMsg( 'protect-unchain-permissions' ), |
592 | | - 'numTypes' => count($this->mApplicableTypes), |
593 | | - 'existingMatch' => 1 == count( array_unique( $this->mExistingExpiry ) ), |
| 592 | + 'labelText' => wfMessage( 'protect-unchain-permissions' )->plain(), |
| 593 | + 'numTypes' => count( $this->mApplicableTypes ), |
| 594 | + 'existingMatch' => count( array_unique( $this->mExistingExpiry ) ) === 1, |
594 | 595 | ); |
595 | | - $encOptions = Xml::encodeJsVar( $options ); |
596 | 596 | |
597 | | - $script .= "ProtectionForm.init($encOptions)"; |
598 | | - return Html::inlineScript( "if ( window.mediaWiki ) { $script }" ); |
| 597 | + $wgOut->addJsConfigVars( 'wgCascadeableLevels', $cascadeableLevels ); |
| 598 | + $script = Xml::encodeJsCall( 'ProtectionForm.init', array( $options ) ); |
| 599 | + return Html::inlineScript( ResourceLoader::makeLoaderConditionalScript( $script ) ); |
599 | 600 | } |
600 | 601 | |
601 | 602 | /** |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -2539,7 +2539,6 @@ |
2540 | 2540 | 'key' => 'R' |
2541 | 2541 | ) |
2542 | 2542 | ); |
2543 | | - $toolbar = "<div id='toolbar'>\n"; |
2544 | 2543 | |
2545 | 2544 | $script = ''; |
2546 | 2545 | foreach ( $toolarray as $tool ) { |
— | — | @@ -2560,15 +2559,11 @@ |
2561 | 2560 | $cssId = $tool['id'], |
2562 | 2561 | ); |
2563 | 2562 | |
2564 | | - $paramList = implode( ',', |
2565 | | - array_map( array( 'Xml', 'encodeJsVar' ), $params ) ); |
2566 | | - $script .= "mw.toolbar.addButton($paramList);\n"; |
| 2563 | + $script .= Xml::encodeJsCall( 'mw.toolbar.addButton', $params ); |
2567 | 2564 | } |
2568 | | - $wgOut->addScript( Html::inlineScript( |
2569 | | - "if ( window.mediaWiki ) {{$script}}" |
2570 | | - ) ); |
| 2565 | + $wgOut->addScript( Html::inlineScript( ResourceLoader::makeLoaderConditionalScript( $script ) ) ); |
2571 | 2566 | |
2572 | | - $toolbar .= "\n</div>"; |
| 2567 | + $toolbar = '<div id="toolbar"></div>'; |
2573 | 2568 | |
2574 | 2569 | wfRunHooks( 'EditPageBeforeEditToolbar', array( &$toolbar ) ); |
2575 | 2570 | |
Index: trunk/phase3/includes/resourceloader/ResourceLoader.php |
— | — | @@ -812,7 +812,7 @@ |
813 | 813 | */ |
814 | 814 | public static function makeLoaderConditionalScript( $script ) { |
815 | 815 | $script = str_replace( "\n", "\n\t", trim( $script ) ); |
816 | | - return "if ( window.mediaWiki ) {\n\t$script\n}\n"; |
| 816 | + return "if(window.mw){\n\t$script\n}\n"; |
817 | 817 | } |
818 | 818 | |
819 | 819 | /** |