Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -199,8 +199,9 @@ |
200 | 200 | 'Replacer' => 'includes/StringUtils.php', |
201 | 201 | 'ResourceLoader' => 'includes/ResourceLoader.php', |
202 | 202 | 'ResourceLoaderContext' => 'includes/ResourceLoaderContext.php', |
| 203 | + 'ResourceLoaderModule' => 'includes/ResourceLoaderModule.php', |
| 204 | + 'ResourceLoaderWikiModule' => 'includes/ResourceLoaderModule.php', |
203 | 205 | 'ResourceLoaderFileModule' => 'includes/ResourceLoaderModule.php', |
204 | | - 'ResourceLoaderModule' => 'includes/ResourceLoaderModule.php', |
205 | 206 | 'ResourceLoaderSiteModule' => 'includes/ResourceLoaderModule.php', |
206 | 207 | 'ResourceLoaderStartUpModule' => 'includes/ResourceLoaderModule.php', |
207 | 208 | 'ReverseChronologicalPager' => 'includes/Pager.php', |
Index: trunk/phase3/includes/ResourceLoaderModule.php |
— | — | @@ -674,58 +674,75 @@ |
675 | 675 | } |
676 | 676 | } |
677 | 677 | |
678 | | -/** |
679 | | - * Custom module for MediaWiki:Common.js and MediaWiki:Skinname.js |
680 | | - */ |
681 | | -class ResourceLoaderSiteModule extends ResourceLoaderModule { |
| 678 | +abstract class ResourceLoaderWikiModule extends ResourceLoaderModule { |
| 679 | + |
682 | 680 | /* Protected Members */ |
683 | | - |
| 681 | + |
684 | 682 | // In-object cache for modified time |
685 | 683 | protected $modifiedTime = null; |
686 | | - |
| 684 | + |
| 685 | + /* Abstract Protected Methods */ |
| 686 | + |
| 687 | + abstract protected function getPages( ResourceLoaderContext $context ); |
| 688 | + |
687 | 689 | /* Methods */ |
688 | | - |
689 | | - public function getScript( ResourceLoaderContext $context ) { |
690 | | - return Skin::newFromKey( $context->getSkin() )->generateUserJs(); |
691 | | - } |
692 | | - |
| 690 | + |
693 | 691 | public function getModifiedTime( ResourceLoaderContext $context ) { |
694 | | - global $wgHandheldStyle; |
695 | | - |
696 | 692 | if ( isset( $this->modifiedTime[$context->getHash()] ) ) { |
697 | 693 | return $this->modifiedTime[$context->getHash()]; |
698 | 694 | } |
699 | | - |
700 | | - // HACK: We duplicate the message names from generateUserJs() |
701 | | - // here and weird things (i.e. mtime moving backwards) can happen |
702 | | - // when a MediaWiki:Something.js page is deleted |
703 | | - $pages = array( |
704 | | - Title::makeTitle( NS_MEDIAWIKI, 'Common.js' ), |
705 | | - Title::makeTitle( NS_MEDIAWIKI, 'Common.css' ), |
706 | | - Title::makeTitle( NS_MEDIAWIKI, ucfirst( $context->getSkin() ) . '.js' ), |
707 | | - Title::makeTitle( NS_MEDIAWIKI, ucfirst( $context->getSkin() ) . '.css' ), |
708 | | - Title::makeTitle( NS_MEDIAWIKI, 'Print.css' ), |
709 | | - ); |
710 | | - if ( $wgHandheldStyle ) { |
711 | | - $pages[] = Title::makeTitle( NS_MEDIAWIKI, 'Handheld.css' ); |
| 695 | + $pages = $this->getPages( $context ); |
| 696 | + foreach ( $pages as $i => $page ) { |
| 697 | + $pages[$i] = Title::makeTitle( NS_MEDIAWIKI, $page ); |
712 | 698 | } |
713 | | - |
714 | 699 | // Do batch existence check |
715 | 700 | // TODO: This would work better if page_touched were loaded by this as well |
716 | 701 | $lb = new LinkBatch( $pages ); |
717 | 702 | $lb->execute(); |
718 | | - |
719 | 703 | $this->modifiedTime = 1; // wfTimestamp() interprets 0 as "now" |
720 | | - |
721 | 704 | foreach ( $pages as $page ) { |
722 | 705 | if ( $page->exists() ) { |
723 | 706 | $this->modifiedTime = max( $this->modifiedTime, wfTimestamp( TS_UNIX, $page->getTouched() ) ); |
724 | 707 | } |
725 | 708 | } |
726 | | - |
727 | 709 | return $this->modifiedTime; |
728 | 710 | } |
| 711 | + public function getMessages() { return array(); } |
| 712 | + public function getLoaderScript() { return ''; } |
| 713 | + public function getDependencies() { return array(); } |
| 714 | +} |
729 | 715 | |
| 716 | +/** |
| 717 | + * Custom module for MediaWiki:Common.js and MediaWiki:Skinname.js |
| 718 | + */ |
| 719 | +class ResourceLoaderSiteModule extends ResourceLoaderWikiModule { |
| 720 | + |
| 721 | + /* Protected Methods */ |
| 722 | + |
| 723 | + protected function getPages( ResourceLoaderContext $context ) { |
| 724 | + global $wgHandheldStyle; |
| 725 | + |
| 726 | + // HACK: We duplicate the message names from generateUserJs() and generateUserCss here and weird things (i.e. |
| 727 | + // mtime moving backwards) can happen when a MediaWiki:Something.js page is deleted |
| 728 | + $pages = array( |
| 729 | + 'Common.js', |
| 730 | + 'Common.css', |
| 731 | + ucfirst( $context->getSkin() ) . '.js', |
| 732 | + ucfirst( $context->getSkin() ) . '.css', |
| 733 | + 'Print.css', |
| 734 | + ); |
| 735 | + if ( $wgHandheldStyle ) { |
| 736 | + $pages[] = 'Handheld.css'; |
| 737 | + } |
| 738 | + return $pages; |
| 739 | + } |
| 740 | + |
| 741 | + /* Methods */ |
| 742 | + |
| 743 | + public function getScript( ResourceLoaderContext $context ) { |
| 744 | + return Skin::newFromKey( $context->getSkin() )->generateUserJs(); |
| 745 | + } |
| 746 | + |
730 | 747 | public function getStyles( ResourceLoaderContext $context ) { |
731 | 748 | global $wgHandheldStyle; |
732 | 749 | $styles = array( |
— | — | @@ -748,12 +765,8 @@ |
749 | 766 | } |
750 | 767 | return $styles; |
751 | 768 | } |
752 | | - public function getMessages() { return array(); } |
753 | | - public function getLoaderScript() { return ''; } |
754 | | - public function getDependencies() { return array(); } |
755 | 769 | } |
756 | 770 | |
757 | | - |
758 | 771 | class ResourceLoaderStartUpModule extends ResourceLoaderModule { |
759 | 772 | /* Protected Members */ |
760 | 773 | |