r72767 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72766‎ | r72767 | r72768 >
Date:23:28, 10 September 2010
Author:tparscal
Status:ok
Tags:
Comment:
Moved some of the logic for generating styles from wiki pages out of ResourceLoaderSiteModule and into ResourceLoaderWikiModule.
Modified paths:
  • /trunk/phase3/includes/ResourceLoaderModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ResourceLoaderModule.php
@@ -21,7 +21,7 @@
2222 */
2323
2424 /**
25 - * Interface for resource loader modules, with name registration and maxage functionality.
 25+ * Abstraction for resource loader modules, with name registration and maxage functionality.
2626 */
2727 abstract class ResourceLoaderModule {
2828 /* Protected Members */
@@ -674,6 +674,9 @@
675675 }
676676 }
677677
 678+/**
 679+ * Abstraction for resource loader modules which pull from wiki pages
 680+ */
678681 abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
679682
680683 /* Protected Members */
@@ -685,6 +688,23 @@
686689
687690 abstract protected function getPages( ResourceLoaderContext $context );
688691
 692+ /* Protected Methods */
 693+
 694+ protected function getStyleCode( array $styles ) {
 695+ foreach ( $styles as $media => $messages ) {
 696+ foreach ( $messages as $i => $message ) {
 697+ $style = wfMsgExt( $message, 'content' );
 698+ if ( !wfEmptyMsg( $message, $style ) ) {
 699+ $styles[$media][$i] = $style;
 700+ }
 701+ }
 702+ }
 703+ foreach ( $styles as $media => $messages ) {
 704+ $styles[$media] = implode( "\n", $messages );
 705+ }
 706+ return $styles;
 707+ }
 708+
689709 /* Methods */
690710
691711 public function getModifiedTime( ResourceLoaderContext $context ) {
@@ -713,7 +733,7 @@
714734 }
715735
716736 /**
717 - * Custom module for MediaWiki:Common.js and MediaWiki:Skinname.js
 737+ * Custom module for site customizations
718738 */
719739 class ResourceLoaderSiteModule extends ResourceLoaderWikiModule {
720740
@@ -752,18 +772,7 @@
753773 if ( $wgHandheldStyle ) {
754774 $sources['handheld'] = array( 'Handheld.css' );
755775 }
756 - foreach ( $styles as $media => $messages ) {
757 - foreach ( $messages as $i => $message ) {
758 - $style = wfMsgExt( $message, 'content' );
759 - if ( !wfEmptyMsg( $message, $style ) ) {
760 - $styles[$media][$i] = $style;
761 - }
762 - }
763 - }
764 - foreach ( $styles as $media => $messages ) {
765 - $styles[$media] = implode( "\n", $messages );
766 - }
767 - return $styles;
 776+ return $this->getStyleCode( $styles );
768777 }
769778 }
770779

Status & tagging log