Fixed spacing
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderWikiModule.php
index d45316f..2a1736d 100644 (file)
@@ -81,9 +81,15 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
         * @return null|string
         */
        protected function getContent( $title ) {
-               if ( !$title->isCssJsSubpage() && !$title->isCssOrJsPage() ) {
+               $handler = ContentHandler::getForTitle( $title );
+               if ( $handler->isSupportedFormat( CONTENT_FORMAT_CSS ) ) {
+                       $format = CONTENT_FORMAT_CSS;
+               } elseif ( $handler->isSupportedFormat( CONTENT_FORMAT_JAVASCRIPT ) ) {
+                       $format = CONTENT_FORMAT_JAVASCRIPT;
+               } else {
                        return null;
                }
+
                $revision = Revision::newFromTitle( $title, false, Revision::READ_NORMAL );
                if ( !$revision ) {
                        return null;
@@ -96,14 +102,7 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
                        return null;
                }
 
-               $model = $content->getModel();
-
-               if ( $model !== CONTENT_MODEL_CSS && $model !== CONTENT_MODEL_JAVASCRIPT ) {
-                       wfDebugLog( 'resourceloader', __METHOD__ . ': bad content model $model for JS/CSS page!' );
-                       return null;
-               }
-
-               return $content->getNativeData(); //NOTE: this is safe, we know it's JS or CSS
+               return $content->serialize( $format );
        }
 
        /* Methods */
@@ -152,8 +151,6 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
                        }
                        if ( $this->getFlip( $context ) ) {
                                $style = CSSJanus::transform( $style, true, false );
-                       } else {
-                               $style = CSSJanus::nullTransform( $style );
                        }
                        $style = CSSMin::remap( $style, false, $this->getConfig()->get( 'ScriptPath' ), true );
                        if ( !isset( $styles[$media] ) ) {
@@ -173,7 +170,7 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
                $modifiedTime = 1; // wfTimestamp() interprets 0 as "now"
                $titleInfo = $this->getTitleInfo( $context );
                if ( count( $titleInfo ) ) {
-                       $mtimes = array_map( function( $value ) {
+                       $mtimes = array_map( function ( $value ) {
                                return $value['timestamp'];
                        }, $titleInfo );
                        $modifiedTime = max( $modifiedTime, max( $mtimes ) );