Index: branches/js2-work/phase3/includes/OutputPage.php |
— | — | @@ -46,6 +46,7 @@ |
47 | 47 | * $Script Loader Class List |
48 | 48 | * |
49 | 49 | * An array of script-classes to be grouped and loaded by script loader |
| 50 | + * for both css and js |
50 | 51 | * |
51 | 52 | * Default Buckets include: |
52 | 53 | * 'page' - Default, Script part of the "current page" |
— | — | @@ -56,8 +57,14 @@ |
57 | 58 | * 'core' - scripts /css loaded on every page view |
58 | 59 | * ( mwEmbed.js, jQuery, and wikibits are in this bucket by deafult ) |
59 | 60 | */ |
60 | | - var $mScriptLoaderClassList = array(); |
| 61 | + var $mScriptLoaderClassList = array( |
| 62 | + 'js'=> array(), |
| 63 | + 'css'=>array() |
| 64 | + ); |
61 | 65 | |
| 66 | + // Stores the options for a given bucket ( like css media type ) |
| 67 | + var $mScriptLoaderBucketOptions = array(); |
| 68 | + |
62 | 69 | // Local scriptLoader instance object |
63 | 70 | var $mScriptLoader = null; |
64 | 71 | |
— | — | @@ -217,14 +224,20 @@ |
218 | 225 | |
219 | 226 | // If script-loader enabled check if we can add the script via script-loader |
220 | 227 | if( $wgEnableScriptLoader ) { |
221 | | - $jsClass = $this->getJsClassFromPath( $path ); |
| 228 | + $jsClass = $this->getClassFromPath( $path ); |
222 | 229 | if( $jsClass ) { |
223 | | - $this->addScriptClass( $jsClass ); |
| 230 | + $this->addScriptClass( $jsClass, $scriptRequestBucket ); |
224 | 231 | return true; |
225 | 232 | } |
226 | 233 | } |
227 | | - |
228 | | - // Do checks for wiki-titles |
| 234 | + // Add script without grouping |
| 235 | + $this->addScript( Html::linkedScript( wfAppendQuery( $path, $wgStyleVersion ) ) ); |
| 236 | + } |
| 237 | + /* |
| 238 | + * Gets the class name From an internal wiki title link |
| 239 | + */ |
| 240 | + function getClassNameFromWikiTitle( $path ){ |
| 241 | + global $wgScript; |
229 | 242 | if( strpos( $path, $wgScript ) !== false ) { |
230 | 243 | $reqPath = str_replace( $wgScript . '?', '', $path ); |
231 | 244 | $reqArgs = explode( '&', $reqPath ); |
— | — | @@ -232,31 +245,31 @@ |
233 | 246 | |
234 | 247 | foreach( $reqArgs as $arg ) { |
235 | 248 | list( $key, $var ) = explode( '=', $arg ); |
236 | | - $reqSet[$key] = $var; |
| 249 | + $reqSet[ $key ] = $var; |
237 | 250 | } |
238 | 251 | |
239 | 252 | if( isset( $reqSet['title'] ) && $reqSet != '' ) { |
240 | | - $jsTitleClass = 'WT:' . $reqSet['title']; |
241 | | - if( $wgEnableScriptLoader ) { |
242 | | - // Extract any extra parameters (for now just skin) |
243 | | - $ext_param = ( isset( $reqSet['useskin'] ) && $reqSet['useskin'] != '' ) |
244 | | - ? '|useskin=' . ucfirst( $reqSet['useskin'] ) : ''; |
| 253 | + // Make sure the title ends with .js or css |
| 254 | + if( substr( $reqSet['title'], -3 ) != '.js' && |
| 255 | + substr( $reqSet['title'], -3 ) != 'css' && |
| 256 | + $reqSet['title'] != '-' ){ |
| 257 | + return false; |
| 258 | + } |
245 | 259 | |
246 | | - $this->addClassToOutputBucket( $scriptRequestBucket, $jsTitleClass . $ext_param ); |
247 | | - return true; |
248 | | - }else{ |
249 | | - $this->addScript( Html::linkedScript( |
250 | | - wfAppendQuery( $path, $this->getURIDparam( $jsTitleClass ) ) |
251 | | - ) |
252 | | - ); |
253 | | - return true; |
| 260 | + $className = 'WT:' . $reqSet['title']; |
| 261 | + // Extract any extra parameters (for now just skin) |
| 262 | + $extraParams = array(); |
| 263 | + if( isset( $reqSet['useskin'] ) && $reqSet['useskin'] != '' ) { |
| 264 | + $className .= '|useskin=' . ucfirst( $reqSet['useskin'] ); |
254 | 265 | } |
| 266 | + if( isset( $reqSet['gen'] ) && $reqSet['gen'] != '' ) { |
| 267 | + $className .= '|gen=' . $reqSet['gen']; |
| 268 | + } |
| 269 | + return $className; |
255 | 270 | } |
256 | 271 | } |
257 | | - |
258 | | - $this->addScript( Html::linkedScript( wfAppendQuery( $path, $wgStyleVersion ) ) ); |
| 272 | + return false; |
259 | 273 | } |
260 | | - |
261 | 274 | /** |
262 | 275 | * Add a self-contained script tag with the given contents |
263 | 276 | * |
— | — | @@ -2253,7 +2266,8 @@ |
2254 | 2267 | |
2255 | 2268 | // Add site JS if enabled: |
2256 | 2269 | if( $wgUseSiteJs ) { |
2257 | | - $this->addScriptClass( 'WT:-|useskin=' . urlencode( $sk->getSkinName() ) ); |
| 2270 | + $this->addScriptClass( 'WT:-|useskin=' . |
| 2271 | + urlencode( $sk->getSkinName() ) .'|gen=js' ); |
2258 | 2272 | } |
2259 | 2273 | |
2260 | 2274 | // Add user js if enabled: |
— | — | @@ -2278,35 +2292,46 @@ |
2279 | 2293 | } |
2280 | 2294 | } |
2281 | 2295 | |
2282 | | - // Add our core scripts to mScripts (includes jQuery, mwEmbed & wikibits |
| 2296 | + // Add our core scripts to mScripts ( includes jQuery, mwEmbed & wikibits ) |
2283 | 2297 | $this->includeCoreJS(); |
2284 | 2298 | |
2285 | | - /* |
2286 | | - * If the script-loader is enabled get script-loader classes per buckets |
2287 | | - * ( if script-loader is off $this->mScripts already has script links ) |
2288 | | - */ |
| 2299 | + |
| 2300 | + // If the script-loader is enabled get script-loader classes per buckets |
2289 | 2301 | if( $wgEnableScriptLoader ) { |
2290 | | - foreach( $this->mScriptLoaderClassList as $bucket => $classSet ){ |
2291 | | - // Note we don't include the "core" bucket since its handled by |
2292 | | - // includeCoreJS |
2293 | | - if( count( $classSet) && $bucket != 'core' ){ |
2294 | | - if( $wgDebugJavaScript ){ |
2295 | | - $this->addScript( "\n<!-- Script bucket: $bucket --> \n" ); |
2296 | | - } |
2297 | | - $this->mScripts.= $this->getLinkedScriptLoaderJs( $classSet ); |
2298 | | - } |
2299 | | - } |
| 2302 | + $this->mScripts .= $this->getScriptLoaderJS(); |
2300 | 2303 | } |
| 2304 | + |
2301 | 2305 | $scripts .= "\n" . $this->mScripts; |
2302 | 2306 | return $scripts; |
2303 | 2307 | } |
2304 | | - protected function addClassToOutputBucket( $bucket, $classPath){ |
2305 | | - if( ! isset( $this->mScriptLoaderClassList[ $bucket ] ) ){ |
2306 | | - $this->mScriptLoaderClassList[ $bucket ] = array(); |
| 2308 | + |
| 2309 | + /** |
| 2310 | + * Add a className to an output Bucket |
| 2311 | + */ |
| 2312 | + protected function addClassToOutputBucket( $className, $bucket, $type = 'js' ){ |
| 2313 | + if( ! isset( $this->mScriptLoaderClassList[ $type ][ $bucket ] ) ){ |
| 2314 | + $this->mScriptLoaderClassList[ $type ][ $bucket ] = array(); |
2307 | 2315 | } |
2308 | | - $this->mScriptLoaderClassList[ $bucket ][] = $classPath; |
| 2316 | + $this->mScriptLoaderClassList[ $type ][ $bucket ][] = $className; |
2309 | 2317 | } |
| 2318 | + |
2310 | 2319 | /** |
| 2320 | + * Set the embed options for a given bucketKey |
| 2321 | + * @param $bucketKey String: the bucketkey to apply the options to. |
| 2322 | + */ |
| 2323 | + protected function setClassBucketOptions( $bucketKey, $options ){ |
| 2324 | + $this->mScriptLoaderBucketOptions[ $bucketKey ] = $options; |
| 2325 | + } |
| 2326 | + /** |
| 2327 | + * Get class bucket options |
| 2328 | + */ |
| 2329 | + protected function getClassBucketOptions( $bucketKey ){ |
| 2330 | + if( isset( $this->mScriptLoaderBucketOptions[ $bucketKey ] ) ){ |
| 2331 | + return $this->mScriptLoaderBucketOptions[ $bucketKey ]; |
| 2332 | + } |
| 2333 | + return array(); |
| 2334 | + } |
| 2335 | + /** |
2311 | 2336 | * Add default \<meta\> tags |
2312 | 2337 | */ |
2313 | 2338 | protected function addDefaultMeta() { |
— | — | @@ -2436,18 +2461,62 @@ |
2437 | 2462 | * @param $media String: to specify a media type, 'screen', 'printable', 'handheld' or any. |
2438 | 2463 | * @param $condition String: for IE conditional comments, specifying an IE version |
2439 | 2464 | * @param $dir String: set to 'rtl' or 'ltr' for direction-specific sheets |
| 2465 | + * @param $bucket String: Script-loader grouping string |
2440 | 2466 | */ |
2441 | | - public function addStyle( $style, $media='', $condition='', $dir='' ) { |
| 2467 | + public function addStyle( $style, $media='', $condition='', $dir='', $bucket='' ) { |
| 2468 | + global $wgEnableScriptLoader; |
2442 | 2469 | $options = array(); |
2443 | | - // Even though we expect the media type to be lowercase, but here we |
2444 | | - // force it to lowercase to be safe. |
2445 | | - if( $media ) |
2446 | | - $options['media'] = $media; |
2447 | | - if( $condition ) |
2448 | | - $options['condition'] = $condition; |
2449 | | - if( $dir ) |
2450 | | - $options['dir'] = $dir; |
2451 | | - $this->styles[$style] = $options; |
| 2470 | + |
| 2471 | + if( $media ) { |
| 2472 | + $options['media'] = $media; |
| 2473 | + } |
| 2474 | + if( $condition ) { |
| 2475 | + $options['condition'] = $condition; |
| 2476 | + } |
| 2477 | + if( $bucket ){ |
| 2478 | + $options['bucket'] = $bucket; |
| 2479 | + } |
| 2480 | + |
| 2481 | + // Build the bucket key with supplied options |
| 2482 | + //( no dir key since dir does not require a separate bucket ) |
| 2483 | + $bucketKey = implode( '.', $options ); |
| 2484 | + |
| 2485 | + if( $dir ) { |
| 2486 | + $options['dir'] = $dir; |
| 2487 | + } |
| 2488 | + |
| 2489 | + // Check if the style will be included in output: |
| 2490 | + if( isset( $options['dir'] ) ) { |
| 2491 | + global $wgContLang; |
| 2492 | + $siteDir = $wgContLang->getDir(); |
| 2493 | + if( $siteDir != $options['dir'] ) |
| 2494 | + return ''; |
| 2495 | + } |
| 2496 | + // If style set media is for different than request don't include |
| 2497 | + if( isset( $options['media'] ) ) { |
| 2498 | + $media = $this->transformCssMedia( $options['media'] ); |
| 2499 | + if( is_null( $media ) ) { |
| 2500 | + return ''; |
| 2501 | + } |
| 2502 | + } |
| 2503 | + |
| 2504 | + // If script-loader enabled check if we can add the script via script-loader |
| 2505 | + if( $wgEnableScriptLoader ) { |
| 2506 | + global $wgStylePath, $wgScript; |
| 2507 | + // Append style path if we are not a wikititle self reference: |
| 2508 | + if( strpos( $style, $wgScript ) === false ) { |
| 2509 | + $style = $wgStylePath ."/". $style; |
| 2510 | + } |
| 2511 | + $cssClass = $this->getClassFromPath( $style ); |
| 2512 | + if( $cssClass ) { |
| 2513 | + $this->addScriptClass( $cssClass, $bucketKey, 'css'); |
| 2514 | + // Update the options for this script bucket. ( css has per-bucket options ) |
| 2515 | + $this->setClassBucketOptions( $bucketKey, $options ); |
| 2516 | + return true; |
| 2517 | + } |
| 2518 | + } |
| 2519 | + // Else use normal styles output: |
| 2520 | + $this->styles[ $style ] = $options; |
2452 | 2521 | } |
2453 | 2522 | |
2454 | 2523 | /** |
— | — | @@ -2463,6 +2532,13 @@ |
2464 | 2533 | * These will be applied to various media & IE conditionals. |
2465 | 2534 | */ |
2466 | 2535 | public function getCssLinks() { |
| 2536 | + global $wgEnableScriptLoader; |
| 2537 | + |
| 2538 | + $scriptLoaderCss = ''; |
| 2539 | + if( $wgEnableScriptLoader ){ |
| 2540 | + $scriptLoaderCss = $this->getScriptLoaderCss(); |
| 2541 | + } |
| 2542 | + |
2467 | 2543 | $links = array(); |
2468 | 2544 | foreach( $this->styles as $file => $options ) { |
2469 | 2545 | $link = $this->styleLink( $file, $options ); |
— | — | @@ -2470,7 +2546,7 @@ |
2471 | 2547 | $links[] = $link; |
2472 | 2548 | } |
2473 | 2549 | |
2474 | | - return implode( "\n", $links ); |
| 2550 | + return $scriptLoaderCss . "\n" . implode( "\n", $links ); |
2475 | 2551 | } |
2476 | 2552 | |
2477 | 2553 | /** |
— | — | @@ -2709,8 +2785,8 @@ |
2710 | 2786 | $coreClasses = array( 'window.jQuery', 'mwEmbed', 'wikibits' ); |
2711 | 2787 | |
2712 | 2788 | // Merge in any scripts that have been set as "core" |
2713 | | - if( isset( $this->mScriptLoaderClassList[ 'core' ] ) ) { |
2714 | | - $coreClasses = array_merge($coreClasses, $this->mScriptLoaderClassList[ 'core' ] ); |
| 2789 | + if( isset( $this->mScriptLoaderClassList[ 'js' ][ 'core' ] ) ) { |
| 2790 | + $coreClasses = array_merge($coreClasses, $this->mScriptLoaderClassList[ 'js' ][ 'core' ] ); |
2715 | 2791 | } |
2716 | 2792 | |
2717 | 2793 | // Make sure scripts are the first scripts include on the page. |
— | — | @@ -2737,29 +2813,83 @@ |
2738 | 2814 | //Now re-append any scripts that got added prior to the includeJQuery call |
2739 | 2815 | $this->mScripts = $this->mScripts . $postScripts; |
2740 | 2816 | } |
| 2817 | + /** |
| 2818 | + * Get style sheets grouped by "media", "condition" & "bucket" attributes |
| 2819 | + * call getLinkedScriptLoaderCss for each group |
| 2820 | + */ |
| 2821 | + private function getScriptLoaderCss( ){ |
| 2822 | + $s=''; |
| 2823 | + foreach( $this->mScriptLoaderClassList['css'] as $bucketKey => $classSet ){ |
| 2824 | + // Note we don't include the "core" bucket since its handled by |
| 2825 | + // includeCoreJS |
| 2826 | + if( count( $classSet) ) { |
| 2827 | + $options = $this->getClassBucketOptions( $bucketKey ); |
| 2828 | + $s .= "\n<!-- Css bucket: " . htmlspecialchars( $bucketKey ) . "--> \n"; |
| 2829 | + $s .= $this->getLinkedScriptLoaderCss( $classSet, $options ); |
| 2830 | + } |
| 2831 | + } |
| 2832 | + return $s; |
| 2833 | + } |
| 2834 | + /** |
| 2835 | + * Get the linked css script-loader calls |
| 2836 | + * @param Array $stylesAry Array of style sheets to be added. |
| 2837 | + */ |
| 2838 | + private function getLinkedScriptLoaderCss( $stylesAry, $options) { |
| 2839 | + global $wgRequest, $wgDebugJavaScript; |
| 2840 | + $stylesString = implode( ',', $stylesAry ); |
2741 | 2841 | |
| 2842 | + $url = wfScript( 'mwScriptLoader' ) . |
| 2843 | + "?class={$stylesString}&" . $this->getURIDparam( $stylesAry ). "&ctype=css"; |
| 2844 | + |
| 2845 | + // Check for the media option: |
| 2846 | + if( isset( $options['media'] ) && $options['media']!='' ){ |
| 2847 | + $link = Html::linkedStyle( $url, $options['media']); |
| 2848 | + } else { |
| 2849 | + $link = Html::linkedStyle( $url ); |
| 2850 | + } |
| 2851 | + |
| 2852 | + if( isset( $options['condition'] ) ) { |
| 2853 | + $condition = htmlspecialchars( $options['condition'] ); |
| 2854 | + $link = "<!--[if $condition]>$link<![endif]-->"; |
| 2855 | + } |
| 2856 | + |
| 2857 | + return $link; |
| 2858 | + } |
| 2859 | + /* |
| 2860 | + * Adds the script loader to mScripts |
| 2861 | + */ |
| 2862 | + private function getScriptLoaderJs(){ |
| 2863 | + $s=''; |
| 2864 | + foreach( $this->mScriptLoaderClassList['js'] as $bucket => $classSet ){ |
| 2865 | + // Note we don't include the "core" bucket since its handled by |
| 2866 | + // includeCoreJS |
| 2867 | + if( count( $classSet) && $bucket != 'core' ){ |
| 2868 | + $s .= "\n<!-- Script bucket: $bucket --> \n"; |
| 2869 | + $s .= $this->getLinkedScriptLoaderJs( $classSet ); |
| 2870 | + } |
| 2871 | + } |
| 2872 | + return $s; |
| 2873 | + } |
2742 | 2874 | /** |
2743 | 2875 | * Get the <script> tag which will invoke the script loader |
2744 | 2876 | * @param $classAry A class array |
| 2877 | + * @param $format String either 'js' or 'css' |
2745 | 2878 | */ |
2746 | 2879 | private function getLinkedScriptLoaderJs( $classAry ) { |
2747 | 2880 | global $wgRequest, $wgDebugJavaScript; |
2748 | | - $classList = implode( ',', $classAry ); |
| 2881 | + $classListString = implode( ',', $classAry ); |
2749 | 2882 | |
2750 | | - $debugParam = ( $wgDebugJavaScript || |
2751 | | - $wgRequest->getVal( 'debug' ) == 'true' || |
2752 | | - $wgRequest->getVal( 'debug' ) == '1' ) |
2753 | | - ? '&debug=true' : ''; |
2754 | | - |
2755 | 2883 | return Html::linkedScript( wfScript( 'mwScriptLoader' ) . |
2756 | | - "?class={$classList}{$debugParam}&" . $this->getURIDparam( $classAry) ) . "\n"; |
| 2884 | + "?class={$classListString}&" . $this->getURIDparam( $classAry) ) . "\n"; |
2757 | 2885 | } |
2758 | 2886 | |
2759 | 2887 | /** |
2760 | | - * @param $className String Name of the JavaScript class |
| 2888 | + * @param $className String Name of the class |
| 2889 | + * @param $scriptRequestBucket Name of bucket for the class |
| 2890 | + * @param $type 'js' or 'css' for type of head item being included |
2761 | 2891 | * @return boolean False if the class wasn't found, True on success |
2762 | 2892 | */ |
2763 | | - function addScriptClass( $className, $scriptRequestBucket = 'page' ) { |
| 2893 | + function addScriptClass( $className, $scriptRequestBucket = 'page' , $type='js') { |
2764 | 2894 | global $wgDebugJavaScript, $wgJSAutoloadClasses, $IP, |
2765 | 2895 | $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath, $wgStylePath, |
2766 | 2896 | $wgUser; |
— | — | @@ -2768,7 +2898,7 @@ |
2769 | 2899 | if ( substr( $className, 0, 3 ) == 'WT:' ) { |
2770 | 2900 | if( $wgEnableScriptLoader ) { |
2771 | 2901 | // Add to the mScriptLoaderClassList list |
2772 | | - $this->addClassToOutputBucket( $scriptRequestBucket, $className ); |
| 2902 | + $this->addClassToOutputBucket( $className, $scriptRequestBucket, $type); |
2773 | 2903 | } else { |
2774 | 2904 | $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : ''; |
2775 | 2905 | $titlePage = substr( $className, 3 ); |
— | — | @@ -2781,7 +2911,7 @@ |
2782 | 2912 | } |
2783 | 2913 | $this->addScriptFile( |
2784 | 2914 | Skin::makeUrl( $titlePage, |
2785 | | - "action=raw$jsCache&gen=js$titleArg" |
| 2915 | + "action=raw$jsCache&gen=js$titleArg" |
2786 | 2916 | ) |
2787 | 2917 | ); |
2788 | 2918 | } |
— | — | @@ -2792,14 +2922,15 @@ |
2793 | 2923 | // Get js or css path: |
2794 | 2924 | $path = jsScriptLoader::getPathFromClass( $className ); |
2795 | 2925 | if( $path == false ){ |
| 2926 | + // NOTE:: could throw an error here |
2796 | 2927 | //print "could not find: $className\n"; |
2797 | | - wfDebug( __METHOD__ . ' could not find js_class: ' . $className ); |
| 2928 | + wfDebug( __METHOD__ . ' scriptLoader could not find class: ' . $className ); |
2798 | 2929 | return false; // could not find the class |
2799 | 2930 | } |
2800 | | - // Valid path add it to script-loder or "link" directly |
| 2931 | + // Valid path add it to script-loader or "link" directly |
2801 | 2932 | if( $wgEnableScriptLoader ) { |
2802 | 2933 | // Register it with the script loader |
2803 | | - $this->addClassToOutputBucket( $scriptRequestBucket, $className ); |
| 2934 | + $this->addClassToOutputBucket( $className, $scriptRequestBucket, $type ); |
2804 | 2935 | } else { |
2805 | 2936 | // Source the script directly |
2806 | 2937 | $prefix = "skins/common/"; |
— | — | @@ -2827,39 +2958,34 @@ |
2828 | 2959 | } |
2829 | 2960 | |
2830 | 2961 | /** |
2831 | | - * Get the JS class name from script path |
| 2962 | + * Get the class name from script path |
2832 | 2963 | * return false if no such path is registered. |
2833 | 2964 | * |
2834 | 2965 | * @param $path string |
2835 | 2966 | * @return String script path or Boolean false if not found |
2836 | 2967 | */ |
2837 | | - function getJsClassFromPath( $path ) { |
| 2968 | + function getClassFromPath( $path ) { |
2838 | 2969 | global $wgJSAutoloadClasses, $wgScriptPath; |
2839 | | - //Make sure we have the scriptClasses loaded: |
2840 | | - $this->loadJsClassPaths(); |
| 2970 | + // Make sure we have the scriptClass paths loaded: |
| 2971 | + jsClassLoader::loadClassPaths(); |
2841 | 2972 | |
2842 | | - foreach( $wgJSAutoloadClasses as $jsClass => $jsPath ) { |
2843 | | - $jsPath = "{$wgScriptPath}/{$jsPath}"; |
2844 | | - if( $path == $jsPath ) |
2845 | | - return $jsClass; |
| 2973 | + // Check the autoload js class list |
| 2974 | + foreach( $wgJSAutoloadClasses as $className => $classPath ) { |
| 2975 | + $classPath = "{$wgScriptPath}/{$classPath}"; |
| 2976 | + if( $path == $classPath ){ |
| 2977 | + return $className; |
| 2978 | + } |
2846 | 2979 | } |
| 2980 | + // Check for mediaWiki generated path: |
| 2981 | + $className = $this->getClassNameFromWikiTitle( $path ); |
| 2982 | + if( $className ){ |
| 2983 | + return $className; |
| 2984 | + } |
| 2985 | + |
2847 | 2986 | return false; |
2848 | 2987 | } |
2849 | 2988 | |
2850 | 2989 | /** |
2851 | | - * Loads the javascript class paths into the AutoLoad class var |
2852 | | - */ |
2853 | | - function loadJsClassPaths(){ |
2854 | | - // Load the javascript script class paths |
2855 | | - if( ! $this->mLoadedJavascriptClasses ){ |
2856 | | - // Issue the load request: |
2857 | | - jsClassLoader::loadClassPaths(); |
2858 | | - // Set the flag to true |
2859 | | - $this->mLoadedJavascriptClasses = true; |
2860 | | - } |
2861 | | - } |
2862 | | - |
2863 | | - /** |
2864 | 2990 | * Get the latest title revision from a title |
2865 | 2991 | * update the tRev if larger than the current |
2866 | 2992 | * @param {Number} $currentTitleRev Current latest revision |
— | — | @@ -2883,13 +3009,15 @@ |
2884 | 3010 | */ |
2885 | 3011 | function getURIDparam( $classAry = array() ) { |
2886 | 3012 | global $wgDebugJavaScript, $wgStyleVersion, $IP, $wgScriptModifiedFileCheck; |
2887 | | - global $wgLang, $wgUser, $wgScriptModifiedMsgCheck; |
| 3013 | + global $wgLang, $wgUser, $wgRequest, $wgScriptModifiedMsgCheck; |
2888 | 3014 | |
2889 | | - //Always the language key param to keep urls distinct per language |
| 3015 | + // Set language key param to keep urls distinct per language |
2890 | 3016 | $uriParam = 'uselang=' . $wgLang->getCode(); |
2891 | 3017 | |
2892 | 3018 | // If debug mode always send fresh url: |
2893 | | - if( $wgDebugJavaScript ) { |
| 3019 | + if( $wgDebugJavaScript || |
| 3020 | + $wgRequest->getVal( 'debug' ) == 'true' || |
| 3021 | + $wgRequest->getVal( 'debug' ) == '1' ) { |
2894 | 3022 | return $uriParam . '&urid=' . time() . '&debug=true'; |
2895 | 3023 | } else { |
2896 | 3024 | // Support single $classAry string |
— | — | @@ -2925,7 +3053,7 @@ |
2926 | 3054 | } |
2927 | 3055 | } |
2928 | 3056 | } |
2929 | | - // uild the actual unique request id: |
| 3057 | + // use the actual unique request id: |
2930 | 3058 | $uriParam .= "&urid={$wgStyleVersion}"; |
2931 | 3059 | |
2932 | 3060 | // Add the file modification time if set |
— | — | @@ -2939,7 +3067,7 @@ |
2940 | 3068 | } |
2941 | 3069 | |
2942 | 3070 | // Add the latest msg rev id if $wgScriptModifiedMsgCheck is enabled |
2943 | | - // NOTE this is too slow so its disabled (we need to cache the msg key versions somehow |
| 3071 | + // NOTE this is too slow so its disabled ( we need to cache the msg key in the database ) |
2944 | 3072 | /* |
2945 | 3073 | if( $wgScriptModifiedMsgCheck ){ |
2946 | 3074 | $dbr = wfGetDB( DB_SLAVE ); |
Index: branches/js2-work/phase3/includes/AutoLoader.php |
— | — | @@ -653,7 +653,13 @@ |
654 | 654 | 'uploadPage' => 'js/uploadPage.js', |
655 | 655 | 'editPage' => 'js/editPage.js', |
656 | 656 | 'ajaxCategories' => 'js/ajaxcategories.js', |
657 | | - 'apiProxyPage' => 'js/apiProxyPage.js' |
| 657 | + 'apiProxyPage' => 'js/apiProxyPage.js', |
| 658 | + |
| 659 | + // Css bindings |
| 660 | + 'mw.style.shared' => 'skins/common/shared.css', |
| 661 | + 'mw.style.commonPrint' => 'skins/common/commonPrint.css', |
| 662 | + 'mw.style.vectorMainLTR' => 'skins/vector/main-ltr.css', |
| 663 | + |
658 | 664 | ); |
659 | 665 | |
660 | 666 | |
Index: branches/js2-work/phase3/js/mwEmbed/includes/jsClassLoader.php |
— | — | @@ -33,8 +33,9 @@ |
34 | 34 | $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $IP; |
35 | 35 | |
36 | 36 | // Only run once |
37 | | - if( self::$classesLoaded ) |
| 37 | + if( self::$classesLoaded ) { |
38 | 38 | return false; |
| 39 | + } |
39 | 40 | self::$classesLoaded = true; |
40 | 41 | |
41 | 42 | // Load classes from mediaWiki $wgJSAutoloadLocalClasses var: |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js |
— | — | @@ -3076,20 +3076,22 @@ |
3077 | 3077 | // Test what codecs the native player supports: |
3078 | 3078 | try { |
3079 | 3079 | var dummyvid = document.createElement( "video" ); |
3080 | | - // Test for h264: |
3081 | | - if ( dummyvid.canPlayType && dummyvid.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"' ) == "probably" ){ |
3082 | | - this.players.addPlayer( h264NativePlayer ); |
| 3080 | + if( dummyvid.canPlayType ) { |
| 3081 | + var canPlayH264 = dummyvid.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"' ); |
| 3082 | + var canPlayOgg = dummyvid.canPlayType && dummyvid.canPlayType( "video/ogg;codecs=\"theora,vorbis\"" ); |
| 3083 | + // Test for h264: |
| 3084 | + if ( canPlayH264 == "probably" || canPlayH264 == "maybe" ) { |
| 3085 | + this.players.addPlayer( h264NativePlayer ); |
| 3086 | + } |
| 3087 | + // Test for ogg |
| 3088 | + if ( canPlayOgg == "probably" || canPlayOgg == "maybe" ) { |
| 3089 | + this.players.addPlayer( oggNativePlayer ); |
| 3090 | + // older versions of safari do not support canPlayType, |
| 3091 | + // but xiph qt registers mimetype via quicktime plugin |
| 3092 | + } else if ( this.supportedMimeType( 'video/ogg' ) ) { |
| 3093 | + this.players.addPlayer( oggNativePlayer ); |
| 3094 | + } |
3083 | 3095 | } |
3084 | | - // Test for ogg |
3085 | | - if ( dummyvid.canPlayType && dummyvid.canPlayType( "video/ogg;codecs=\"theora,vorbis\"" ) == "probably" ) |
3086 | | - { |
3087 | | - this.players.addPlayer( oggNativePlayer ); |
3088 | | - |
3089 | | - // older versions of safari do not support canPlayType, |
3090 | | - // but xiph qt registers mimetype via quicktime plugin |
3091 | | - } else if ( this.supportedMimeType( 'video/ogg' ) ) { |
3092 | | - this.players.addPlayer( oggNativePlayer ); |
3093 | | - } |
3094 | 3096 | } catch ( e ) { |
3095 | 3097 | mw.log( 'could not run canPlayType ' + e ); |
3096 | 3098 | } |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/skins/ctrlBuilder.js |
— | — | @@ -78,8 +78,7 @@ |
79 | 79 | }, |
80 | 80 | |
81 | 81 | /** |
82 | | - * Get the controls html |
83 | | - * @return {String} html output of controls |
| 82 | + * Add the controls html to palyer interface |
84 | 83 | */ |
85 | 84 | addControls: function() { |
86 | 85 | // Set up local pointer to the embedPlayer |
— | — | @@ -129,8 +128,7 @@ |
130 | 129 | }, |
131 | 130 | |
132 | 131 | /** |
133 | | - * Builds the interface controls |
134 | | - * @return the interface html string |
| 132 | + * Add control components as defined per this.components |
135 | 133 | */ |
136 | 134 | addControlComponents: function( ) { |
137 | 135 | var _this = this; |
— | — | @@ -571,10 +569,8 @@ |
572 | 570 | * Hide the control bar. |
573 | 571 | */ |
574 | 572 | hideControlBar : function(){ |
575 | | - var animateDuration = 'slow'; |
576 | | - // Else hide the control bar ( if checkOverlayControls is still true ) |
| 573 | + var animateDuration = 'slow'; |
577 | 574 | this.embedPlayer.$interface.find( '.control-bar') |
578 | | - .stop() |
579 | 575 | .fadeOut( animateDuration ); |
580 | 576 | |
581 | 577 | this.embedPlayer.$interface.find( '.itext' ) |
— | — | @@ -589,8 +585,7 @@ |
590 | 586 | * Show the control bar |
591 | 587 | */ |
592 | 588 | showControlBar : function(){ |
593 | | - var animateDuration = 'slow'; |
594 | | - |
| 589 | + var animateDuration = 'slow'; |
595 | 590 | // Move up itext if present |
596 | 591 | this.embedPlayer.$interface.find( '.itext' ) |
597 | 592 | .animate( |
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js |
— | — | @@ -428,8 +428,8 @@ |
429 | 429 | * @param {URL} apiUrl The url of the api server |
430 | 430 | */ |
431 | 431 | // Include gadget js ( in case the user has not enabled the gadget on that domain ) |
432 | | - //var gadgetWithJS = '?withJS=MediaWiki:MwEmbed.js'; |
433 | | - var gadgetWithJS = ''; |
| 432 | + var gadgetWithJS = '?withJS=MediaWiki:MwEmbed.js'; |
| 433 | + //var gadgetWithJS = ''; |
434 | 434 | function getServerFrame( context ) { |
435 | 435 | if( ! context || ! context.apiUrl ){ |
436 | 436 | mw.log( "Error no context api url " ); |
Index: branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php |
— | — | @@ -32,15 +32,22 @@ |
33 | 33 | // The language code for the script-loader request |
34 | 34 | var $langCode = ''; |
35 | 35 | |
36 | | - // The javascript output string |
37 | | - var $jsout = ''; |
| 36 | + // The output string |
| 37 | + var $output = ''; |
38 | 38 | |
| 39 | + // Special prepend js var to be added to the top of minification output. |
| 40 | + // useful for special comment tags in minification output |
| 41 | + var $notMinifiedTopOutput = ''; |
| 42 | + |
39 | 43 | // The request Key for the js |
40 | 44 | var $requestKey = ''; |
41 | 45 | |
42 | 46 | // Error msg |
43 | 47 | var $errorMsg = ''; |
44 | 48 | |
| 49 | + // Output format is either 'js' or 'css'; |
| 50 | + var $outputFormat = 'js'; |
| 51 | + |
45 | 52 | // Debug flag |
46 | 53 | var $debug = false; |
47 | 54 | |
— | — | @@ -59,7 +66,7 @@ |
60 | 67 | $this->sFileCache = new simpleFileCache( $this->requestKey ); |
61 | 68 | if ( $this->sFileCache->isFileCached() ) { |
62 | 69 | // Output headers |
63 | | - $this->outputJsHeaders(); |
| 70 | + $this->outputHeaders(); |
64 | 71 | // Output cached file |
65 | 72 | $this->sFileCache->outputFile(); |
66 | 73 | return true; |
— | — | @@ -91,66 +98,67 @@ |
92 | 99 | |
93 | 100 | // Reset the requestKey: |
94 | 101 | $this->requestKey = ''; |
| 102 | + |
95 | 103 | // Do the post proc request with configuration vars: |
96 | 104 | $this->postProcRequestVars(); |
97 | | - //update the filename (if gzip is on) |
| 105 | + |
| 106 | + // Update the filename (if gzip is on) |
98 | 107 | $this->sFileCache->getCacheFileName(); |
99 | 108 | |
100 | | - // Setup script loader header: |
101 | | - $this->jsout .= 'var mwScriptLoaderDate = "' . date( 'c' ) . '";' . "\n"; |
102 | | - $this->jsout .= 'var mwScriptLoaderRequestKey = "' . htmlspecialchars( $this->requestKey ) . '";' . "\n"; |
103 | | - $this->jsout .= 'var mwLang = "' . htmlspecialchars( $this->langCode ) . '";' . "\n"; |
| 109 | + // Setup script loader header ( to easy identify file data ) |
| 110 | + if( $this->outputFormat == 'js' ) { |
| 111 | + $this->output .= 'var mwScriptLoaderDate = "' . |
| 112 | + xml::escapeJsString( date( 'c' ) ) . '";' . "\n"; |
| 113 | + $this->output .= 'var mwScriptLoaderRequestKey = "' . |
| 114 | + xml::escapeJsString( $this->requestKey ) . '";' . "\n"; |
| 115 | + } |
104 | 116 | |
105 | | - // Special prepend js var to be added to the top of minification output. |
106 | | - // useful for special comment tags in minification output |
107 | | - $NotMinifiedTopJs = ''; |
108 | | - |
109 | 117 | // Build the output |
110 | 118 | // Swap in the appropriate language per js_file |
111 | 119 | foreach ( $this->jsFileList as $classKey => $filePath ) { |
112 | 120 | |
113 | 121 | // Get the localized script content |
114 | | - $this->jsout .= $this->getLocalizedScriptText( $classKey ); |
| 122 | + $this->output .= $this->getLocalizedScriptText( $classKey ); |
115 | 123 | |
116 | 124 | // If the core mwEmbed class entry point add some |
117 | 125 | // other "core" files: |
118 | 126 | if( $classKey == 'mwEmbed' ){ |
119 | 127 | // Output core components ( parts of mwEmbed that are in different files ) |
120 | | - $this->jsout .= jsClassLoader::getCombinedComponentJs( $this ); |
| 128 | + $this->output .= jsClassLoader::getCombinedComponentJs( $this ); |
121 | 129 | |
122 | 130 | // Output the loaders: |
123 | | - $this->jsout .= jsClassLoader::getCombinedLoaderJs(); |
| 131 | + $this->output .= jsClassLoader::getCombinedLoaderJs(); |
124 | 132 | |
125 | 133 | // Output the current language class js |
126 | | - $this->jsout .= jsClassLoader::getLanguageJs( $this->langCode ); |
| 134 | + $this->output .= jsClassLoader::getLanguageJs( $this->langCode ); |
127 | 135 | |
128 | 136 | // Output the "common" css file |
129 | | - $this->jsout .= $this->getScriptText( 'mw.style.common' ); |
| 137 | + $this->output .= $this->getScriptText( 'mw.style.common' ); |
130 | 138 | |
131 | 139 | // Output the jQuery ui theme css |
132 | | - $this->jsout .= $this->getScriptText( 'mw.style.redmond' ); |
| 140 | + $this->output .= $this->getScriptText( 'mw.style.redmond' ); |
133 | 141 | |
134 | 142 | // Output special IE comment tag to support special mwEmbed tags. |
135 | | - $NotMinifiedTopJs.='/*@cc_on\'video source itext playlist\'.replace(/\w+/g,function(n){document.createElement(n)})@*/'."\n"; |
| 143 | + $this->notMinifiedTopOutput .='/*@cc_on\'video source itext playlist\'.replace(/\w+/g,function(n){document.createElement(n)})@*/'."\n"; |
136 | 144 | } |
137 | 145 | } |
138 | 146 | |
139 | 147 | /* |
140 | 148 | * Add a mw.loadDone class callback if there was no "error" in getting any of the classes |
141 | 149 | */ |
142 | | - if ( $this->errorMsg == '' ){ |
143 | | - $this->jsout .= self::getOnDoneCallback( ); |
| 150 | + if ( $this->errorMsg == '' && $this->outputFormat == 'js' ){ |
| 151 | + $this->output .= self::getOnDoneCallback( ); |
144 | 152 | } |
145 | 153 | |
146 | 154 | // Check if we should minify the whole thing: |
147 | 155 | if ( !$this->debug ) { |
148 | | - $this->jsout = self::getMinifiedJs( $this->jsout , $this->requestKey ); |
149 | | - $this->jsout = $NotMinifiedTopJs . $this->jsout; |
| 156 | + $this->output = self::getMinifiedJs( $this->output , $this->requestKey ); |
| 157 | + $this->output = $this->notMinifiedTopOutput . $this->output; |
150 | 158 | } |
151 | 159 | |
152 | 160 | // Save to the file cache |
153 | 161 | if ( $wgUseFileCache && !$this->debug ) { |
154 | | - $status = $this->sFileCache->saveToFileCache( $this->jsout ); |
| 162 | + $status = $this->sFileCache->saveToFileCache( $this->output ); |
155 | 163 | if ( $status !== true ) |
156 | 164 | $this->errorMsg .= $status; |
157 | 165 | } |
— | — | @@ -160,7 +168,7 @@ |
161 | 169 | //just set the content type (don't send cache header) |
162 | 170 | header( 'Content-Type: text/javascript' ); |
163 | 171 | echo 'alert(\'Error With ScriptLoader ::' . str_replace( "\n", '\'+"\n"+' . "\n'", $this->errorMsg ) . '\');'; |
164 | | - echo trim( $this->jsout ); |
| 172 | + echo trim( $this->output ); |
165 | 173 | } else { |
166 | 174 | // All good, let's output "cache" headers |
167 | 175 | $this->outputJsWithHeaders(); |
— | — | @@ -259,9 +267,9 @@ |
260 | 268 | * @return String javascript to be included. |
261 | 269 | */ |
262 | 270 | function getLocalizedScriptText( $classKey ){ |
263 | | - $jstxt = $this->getScriptText( $classKey ); |
264 | | - if( $jstxt ){ |
265 | | - return $this->doProcessJs( $jstxt ); |
| 271 | + $scriptText = $this->getScriptText( $classKey ); |
| 272 | + if( $scriptText ){ |
| 273 | + return $this->doProcessJs( $scriptText ); |
266 | 274 | } |
267 | 275 | // Return an empty string ( error is put into $this->errorMsg ) |
268 | 276 | return ''; |
— | — | @@ -275,33 +283,44 @@ |
276 | 284 | * @return unknown |
277 | 285 | */ |
278 | 286 | function getScriptText( $classKey ){ |
279 | | - $jsout = ''; |
280 | | - |
| 287 | + $output = ''; |
281 | 288 | // Special case: title classes |
282 | 289 | if ( substr( $classKey, 0, 3 ) == 'WT:' ) { |
283 | 290 | global $wgUser; |
284 | 291 | // Get just the title part |
285 | 292 | $titleBlock = substr( $classKey, 3 ); |
286 | | - if ( $titleBlock[0] == '-' && strpos( $titleBlock, '|' ) !== false ) { |
287 | | - // Special case of "-" title with skin |
| 293 | + if ( $titleBlock[0] == '-' ) { |
| 294 | + // Special case of "-" title |
288 | 295 | $parts = explode( '|', $titleBlock ); |
289 | 296 | $title = array_shift( $parts ); |
290 | | - foreach ( $parts as $tparam ) { |
291 | | - list( $key, $val ) = explode( '=', $tparam ); |
292 | | - if ( $key == 'useskin' ) { |
293 | | - $skin = $val; |
294 | | - } |
| 297 | + $titleParams = array (); |
| 298 | + foreach ( $parts as $titleParam ) { |
| 299 | + list( $key, $val ) = explode( '=', $titleParam ); |
| 300 | + $titleParams[ $key ] = $val; |
295 | 301 | } |
| 302 | + /* |
| 303 | + * The "-" is a special key to user / site js system sucks |
| 304 | + * here is some code to handle it ... but it really |
| 305 | + * should be depreciated for some more logical system |
| 306 | + * like directly referencing the titles that we have a script-loader |
| 307 | + */ |
296 | 308 | $sk = $wgUser->getSkin(); |
297 | | - // Make sure the skin name is valid |
298 | | - $skinNames = Skin::getSkinNames(); |
299 | | - $skinNames = array_keys( $skinNames ); |
300 | | - if ( in_array( strtolower( $skin ), $skinNames ) ) { |
301 | | - // If in debug mode, add a comment with wiki title and rev: |
302 | | - if ( $this->debug ) { |
303 | | - $jsout .= "\n/**\n* GenerateUserJs: \n*/\n"; |
| 309 | + if( isset( $titleParams[ 'useskin' ] ) ) { |
| 310 | + // Make sure the skin name is valid |
| 311 | + $skinNames = Skin::getSkinNames(); |
| 312 | + $skinNames = array_keys( $skinNames ); |
| 313 | + if ( in_array( strtolower( $titleParams[ 'useskin' ] ), $skinNames ) ) { |
| 314 | + if( $titleParams['gen' ] == 'css' ){ |
| 315 | + return $sk->generateUserStylesheet(); |
| 316 | + } |
| 317 | + // If in debug mode, add a comment with wiki title and rev: |
| 318 | + if ( $this->debug ) { |
| 319 | + $output .= "\n/**\n* GenerateUserJs: \n*/\n"; |
| 320 | + } |
| 321 | + return $sk->generateUserJs( $titleParams[ 'useskin' ] ) . "\n"; |
304 | 322 | } |
305 | | - return $sk->generateUserJs( $skin ) . "\n"; |
| 323 | + } else if( isset( $titleParams['gen' ] ) && $titleParams['gen' ] == 'css' ) { |
| 324 | + return $sk->generateUserStylesheet(); |
306 | 325 | } |
307 | 326 | } else { |
308 | 327 | $ext = substr($titleBlock, strrpos($titleBlock, '.') + 1); |
— | — | @@ -316,13 +335,14 @@ |
317 | 336 | // Only get the content if the page is not empty: |
318 | 337 | if ( $a->getID() !== 0 ) { |
319 | 338 | // If in debug mode, add a comment with wiki title and rev: |
320 | | - if ( $this->debug ) |
321 | | - $jsout .= "\n/**\n* WikiJSPage: " . xml::escapeJsString( $titleBlock ) . " rev: " . $a->getID() . " \n*/\n"; |
| 339 | + if ( $this->debug ) { |
| 340 | + $output .= "\n/**\n* ScriptLoader WikiPage: " . xml::escapeJsString( $titleBlock ) . " rev: " . $a->getID() . " \n*/\n"; |
| 341 | + } |
322 | 342 | $fileStr = $a->getContent() . "\n"; |
323 | | - $jsout.= ( $ext == 'css' ) ? |
| 343 | + $output.= ( $ext == 'css' ) ? |
324 | 344 | $this->transformCssOutput( $classKey, $fileStr ) : |
325 | 345 | $fileStr; |
326 | | - return $jsout; |
| 346 | + return $output; |
327 | 347 | } |
328 | 348 | } |
329 | 349 | } |
— | — | @@ -344,13 +364,13 @@ |
345 | 365 | if( $fileStr ){ |
346 | 366 | // Add the file name if debug is enabled |
347 | 367 | if ( $this->debug ){ |
348 | | - $jsout .= "\n/**\n* File: " . xml::escapeJsString( $filePath ) . "\n*/\n"; |
| 368 | + $output .= "\n/**\n* File: " . xml::escapeJsString( $filePath ) . "\n*/\n"; |
349 | 369 | } |
350 | | - $jsout.= ( $ext == 'css' ) ? |
| 370 | + $output.= ( $ext == 'css' ) ? |
351 | 371 | $this->transformCssOutput( $classKey, $fileStr, $filePath ) : |
352 | 372 | $fileStr; |
353 | 373 | |
354 | | - return $jsout; |
| 374 | + return $output; |
355 | 375 | }else{ |
356 | 376 | $this->errorMsg .= "\nError could not read file: ". xml::escapeJsString( $filePath ) ."\n"; |
357 | 377 | return false; |
— | — | @@ -384,8 +404,16 @@ |
385 | 405 | str_replace('jsScriptLoader.php', '', $serverUri) |
386 | 406 | . dirname( $path ) . '/'; |
387 | 407 | } |
| 408 | + // We always run minify to update css urls |
388 | 409 | $cssString = Minify_CSS::minify( $cssString, $cssOptions); |
389 | | - // css classes should be of form mw.style.{className} |
| 410 | + |
| 411 | + // Check output format ( if format is "css" ) return the css string directly |
| 412 | + if( $this->outputFormat == 'css' ) { |
| 413 | + return $cssString; |
| 414 | + } |
| 415 | + |
| 416 | + // Format is "javascript" return the string in an addStyleString call |
| 417 | + // CSS classes should be of form mw.style.{className} |
390 | 418 | $cssStyleName = str_replace('mw.style.', '', $classKey ); |
391 | 419 | return 'mw.addStyleString("' . Xml::escapeJsString( $cssStyleName ) |
392 | 420 | . '", "' . Xml::escapeJsString( $cssString ) . '");' . "\n"; |
— | — | @@ -416,9 +444,13 @@ |
417 | 445 | /** |
418 | 446 | * Outputs the script headers |
419 | 447 | */ |
420 | | - function outputJsHeaders() { |
421 | | - // Output JS MIME type: |
422 | | - header( 'Content-Type: text/javascript' ); |
| 448 | + function outputHeaders() { |
| 449 | + // Output MIME type: |
| 450 | + if( $this->outputFormat == 'css' ){ |
| 451 | + header( 'Content-Type: text/css' ); |
| 452 | + } else if ( $this->outputFormat == 'js' ) { |
| 453 | + header( 'Content-Type: text/javascript' ); |
| 454 | + } |
423 | 455 | header( 'Pragma: public' ); |
424 | 456 | if( $this->debug ){ |
425 | 457 | header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 |
— | — | @@ -435,16 +467,16 @@ |
436 | 468 | */ |
437 | 469 | function outputJsWithHeaders() { |
438 | 470 | global $wgUseGzip; |
439 | | - $this->outputJsHeaders(); |
| 471 | + $this->outputHeaders(); |
440 | 472 | if ( $wgUseGzip ) { |
441 | 473 | if ( $this->clientAcceptsGzip() ) { |
442 | 474 | header( 'Content-Encoding: gzip' ); |
443 | | - echo gzencode( $this->jsout ); |
| 475 | + echo gzencode( $this->output ); |
444 | 476 | } else { |
445 | | - echo $this->jsout; |
| 477 | + echo $this->output; |
446 | 478 | } |
447 | 479 | } else { |
448 | | - echo $this->jsout; |
| 480 | + echo $this->output; |
449 | 481 | } |
450 | 482 | } |
451 | 483 | |
— | — | @@ -502,9 +534,15 @@ |
503 | 535 | //set English as default |
504 | 536 | $this->langCode = 'en'; |
505 | 537 | } |
506 | | - |
507 | 538 | $this->langCode = self::checkForCommonsLanguageFormHack( $this->langCode ); |
508 | 539 | |
| 540 | + // Check if the outupt format is "css" or "js" |
| 541 | + if( isset( $_GET['ctype'] ) && $_GET['ctype'] == 'css' ){ |
| 542 | + $this->outputFormat = 'css'; |
| 543 | + } else { |
| 544 | + $this->outputFormat = 'js'; |
| 545 | + } |
| 546 | + |
509 | 547 | $reqClassList = false; |
510 | 548 | if ( isset( $_GET['class'] ) && $_GET['class'] != '' ) { |
511 | 549 | $reqClassList = explode( ',', $_GET['class'] ); |
— | — | @@ -572,7 +610,7 @@ |
573 | 611 | */ |
574 | 612 | function preProcRequestVars() { |
575 | 613 | $requestKey = ''; |
576 | | - // Check for debug (won't use the cache) |
| 614 | + // Check for debug ( won't use the cache) |
577 | 615 | if ( ( isset( $_GET['debug'] ) && $_GET['debug'] == 'true' ) ) { |
578 | 616 | // We are going to have to run postProcRequest |
579 | 617 | return false; |
— | — | @@ -595,7 +633,6 @@ |
596 | 634 | // Set English as default |
597 | 635 | $langCode = 'en'; |
598 | 636 | } |
599 | | - |
600 | 637 | $langCode = self::checkForCommonsLanguageFormHack( $langCode ); |
601 | 638 | |
602 | 639 | $reqClassList = false; |
— | — | @@ -622,11 +659,21 @@ |
623 | 660 | } |
624 | 661 | } |
625 | 662 | } |
| 663 | + // Check if the outupt format is "css" or "js" |
| 664 | + if( isset( $_GET['ctype'] ) && $_GET['ctype'] == 'css' ){ |
| 665 | + $outputFormat = 'css'; |
| 666 | + } else { |
| 667 | + $outputFormat = 'js'; |
| 668 | + } |
| 669 | + |
626 | 670 | // Add the language code to the requestKey: |
627 | 671 | $requestKey .= '_' . $langCode; |
628 | 672 | |
| 673 | + // Add the format to the requestKey: |
| 674 | + $requestKey .= '_' . $outputFormat; |
| 675 | + |
629 | 676 | // Add the unique rid |
630 | | - $requestKey .= $urid; |
| 677 | + $requestKey .= '_' . $urid; |
631 | 678 | |
632 | 679 | return $requestKey; |
633 | 680 | } |
Index: branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | */ |
6 | 6 | var urlparts = getRemoteEmbedPath(); |
7 | 7 | var mwEmbedHostPath = urlparts[0]; |
8 | | -var mwRemoteVersion = 'r119'; |
| 8 | +var mwRemoteVersion = 'r120'; |
9 | 9 | var mwUseScriptLoader = true; |
10 | 10 | |
11 | 11 | // Log the mwRemote version ( will determine what version of js we get ) |