r66834 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66833‎ | r66834 | r66835 >
Date:16:35, 24 May 2010
Author:reedy
Status:ok
Tags:
Comment:
bug 18608 done in a fashion much closer to how I should've done it originally.

Latching onto bug 22061 output

Following up r62195 and r61125
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -2415,15 +2415,18 @@
24162416 * These will be applied to various media & IE conditionals.
24172417 */
24182418 public function buildCssLinks() {
 2419+ return implode( "\n", $this->buildCssLinksArray() );
 2420+ }
 2421+
 2422+ public function buildCssLinksArray() {
24192423 $links = array();
24202424 foreach( $this->styles as $file => $options ) {
24212425 $link = $this->styleLink( $file, $options );
24222426 if( $link ) {
2423 - $links[] = $link;
 2427+ $links[$file] = $link;
24242428 }
24252429 }
2426 -
2427 - return implode( "\n", $links );
 2430+ return $links;
24282431 }
24292432
24302433 /**
Index: trunk/phase3/includes/api/ApiParse.php
@@ -217,15 +217,26 @@
218218 $titleObj->getPrefixedText();
219219 }
220220
 221+ if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) {
 222+ $out = new OutputPage;
 223+ $out->addParserOutputNoText( $p_result );
 224+ $userSkin = $wgUser->getSkin();
 225+ }
 226+
221227 if ( isset( $prop['headitems'] ) ) {
222 - $result_array['headitems'] = $this->formatHeadItems( $p_result->getHeadItems() );
 228+ $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
 229+
 230+ $userSkin->setupUserCss( $out );
 231+ $css = $this->formatCss( $out->buildCssLinksArray() );
 232+
 233+ $scripts = array( $out->getHeadScripts( $userSkin ) );
 234+
 235+ $result_array['headitems'] = array_merge( $headItems , $css, $scripts );
223236 }
224237
225238 if ( isset( $prop['headhtml'] ) ) {
226 - $out = new OutputPage;
227 - $out->addParserOutputNoText( $p_result );
228239 $result_array['headhtml'] = array();
229 - $result->setContent( $result_array['headhtml'], $out->headElement( $wgUser->getSkin() ) );
 240+ $result->setContent( $result_array['headhtml'], $out->headElement( $userSkin ) );
230241 }
231242
232243 if ( !is_null( $oldid ) ) {
@@ -241,7 +252,7 @@
242253 'images' => 'img',
243254 'externallinks' => 'el',
244255 'sections' => 's',
245 - 'headitems' => 'hi'
 256+ 'headitems' => 'hi',
246257 );
247258 $this->setIndexedTagNames( $result_array, $result_mapping );
248259 $result->addValue( null, $this->getModuleName(), $result_array );
@@ -310,6 +321,17 @@
311322 return $result;
312323 }
313324
 325+ private function formatCss( $css ) {
 326+ $result = array();
 327+ foreach ( $css as $file => $link ) {
 328+ $entry = array();
 329+ $entry['file'] = $file;
 330+ $this->getResult()->setContent( $entry, $link );
 331+ $result[] = $entry;
 332+ }
 333+ return $result;
 334+ }
 335+
314336 private function setIndexedTagNames( &$array, $mapping ) {
315337 foreach ( $mapping as $key => $name ) {
316338 if ( isset( $array[$key] ) ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r66856bug 18608 done in a fashion much closer to how I should've done it originally....reedy23:24, 24 May 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r61125* (bug 22061) API: add prop=headitems to action=parse...reedy13:07, 16 January 2010
r62195* (bug 18608) - API should provide list of CSS styles to apply to rendered o...reedy20:47, 9 February 2010

Status & tagging log