bug 18608 done in a fashion much closer to how I should've done it originally.
authorSam Reed <reedy@users.mediawiki.org>
Mon, 24 May 2010 16:35:23 +0000 (16:35 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Mon, 24 May 2010 16:35:23 +0000 (16:35 +0000)
Latching onto bug 22061 output

Following up r62195 and r61125

includes/OutputPage.php
includes/api/ApiParse.php

index 9f4d61e..f8acd0b 100644 (file)
@@ -2415,15 +2415,18 @@ class OutputPage {
         * These will be applied to various media & IE conditionals.
         */
        public function buildCssLinks() {
+               return implode( "\n", $this->buildCssLinksArray() );
+       }
+
+       public function buildCssLinksArray() {
                $links = array();
                foreach( $this->styles as $file => $options ) {
                        $link = $this->styleLink( $file, $options );
                        if( $link ) {
-                               $links[] = $link;
+                               $links[$file] = $link;
                        }
                }
-
-               return implode( "\n", $links );
+               return $links;
        }
 
        /**
index 1c22ced..86cadc1 100644 (file)
@@ -217,15 +217,26 @@ class ApiParse extends ApiBase {
                                                        $titleObj->getPrefixedText();
                }
 
+               if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) {
+                       $out = new OutputPage;
+                       $out->addParserOutputNoText( $p_result );
+                       $userSkin = $wgUser->getSkin();
+               }
+
                if ( isset( $prop['headitems'] ) ) {
-                       $result_array['headitems'] = $this->formatHeadItems( $p_result->getHeadItems() );
+                       $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
+
+                       $userSkin->setupUserCss( $out );
+                       $css = $this->formatCss( $out->buildCssLinksArray() );
+
+                       $scripts = array( $out->getHeadScripts( $userSkin ) );
+
+                       $result_array['headitems'] = array_merge( $headItems , $css, $scripts );
                }
 
                if ( isset( $prop['headhtml'] ) ) {
-                       $out = new OutputPage;
-                       $out->addParserOutputNoText( $p_result );
                        $result_array['headhtml'] = array();
-                       $result->setContent( $result_array['headhtml'], $out->headElement( $wgUser->getSkin() ) );
+                       $result->setContent( $result_array['headhtml'], $out->headElement( $userSkin ) );
                }
 
                if ( !is_null( $oldid ) ) {
@@ -241,7 +252,7 @@ class ApiParse extends ApiBase {
                        'images' => 'img',
                        'externallinks' => 'el',
                        'sections' => 's',
-                       'headitems' => 'hi'
+                       'headitems' => 'hi',
                );
                $this->setIndexedTagNames( $result_array, $result_mapping );
                $result->addValue( null, $this->getModuleName(), $result_array );
@@ -310,6 +321,17 @@ class ApiParse extends ApiBase {
                return $result;
        }
 
+       private function formatCss( $css ) {
+               $result = array();
+               foreach ( $css as $file => $link ) {
+                       $entry = array();
+                       $entry['file'] = $file;
+                       $this->getResult()->setContent( $entry, $link );
+                       $result[] = $entry;
+               }
+               return $result;
+       }
+
        private function setIndexedTagNames( &$array, $mapping ) {
                foreach ( $mapping as $key => $name ) {
                        if ( isset( $array[$key] ) ) {