Refactor code a little bit, save doing redundant checks if known not necessary.
authorSam Reed <reedy@users.mediawiki.org>
Thu, 24 Feb 2011 23:03:55 +0000 (23:03 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Thu, 24 Feb 2011 23:03:55 +0000 (23:03 +0000)
Improves flow a little

includes/api/ApiParse.php

index ab9c12a..fba6068 100644 (file)
@@ -253,23 +253,23 @@ class ApiParse extends ApiBase {
                if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) {
                        $out = new OutputPage;
                        $out->addParserOutputNoText( $p_result );
-                       $userSkin = $wgUser->getSkin();
-               }
 
-               if ( isset( $prop['headitems'] ) ) {
-                       $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
+                       if ( isset( $prop['headitems'] ) ) {
+                               $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
 
-                       $userSkin->setupUserCss( $out );
-                       $css = $this->formatCss( $out->buildCssLinksArray() );
+                               $userSkin = $wgUser->getSkin();
+                               $userSkin->setupUserCss( $out );
+                               $css = $this->formatCss( $out->buildCssLinksArray() );
 
-                       $scripts = array( $out->getHeadScripts( $userSkin ) );
+                               $scripts = array( $out->getHeadScripts( $userSkin ) );
 
-                       $result_array['headitems'] = array_merge( $headItems, $css, $scripts );
-               }
+                               $result_array['headitems'] = array_merge( $headItems, $css, $scripts );
+                       }
 
-               if ( isset( $prop['headhtml'] ) ) {
-                       $result_array['headhtml'] = array();
-                       $result->setContent( $result_array['headhtml'], $out->headElement( $userSkin ) );
+                       if ( isset( $prop['headhtml'] ) ) {
+                               $result_array['headhtml'] = array();
+                               $result->setContent( $result_array['headhtml'], $out->headElement( $userSkin ) );
+                       }
                }
 
                if ( isset( $prop['iwlinks'] ) ) {