Index: trunk/phase3/includes/resourceloader/ResourceLoaderSiteModule.php |
— | — | @@ -36,15 +36,14 @@ |
37 | 37 | global $wgHandheldStyle; |
38 | 38 | |
39 | 39 | $pages = array( |
40 | | - 'Common.js' => array( 'ns' => NS_MEDIAWIKI, 'type' => 'script' ), |
41 | | - 'Common.css' => array( 'ns' => NS_MEDIAWIKI, 'type' => 'style' ), |
42 | | - ucfirst( $context->getSkin() ) . '.js' => array( 'ns' => NS_MEDIAWIKI, 'type' => 'script' ), |
43 | | - ucfirst( $context->getSkin() ) . '.css' => array( 'ns' => NS_MEDIAWIKI, 'type' => 'style' ), |
44 | | - 'Print.css' => array( 'ns' => NS_MEDIAWIKI, 'type' => 'style', 'media' => 'print' ), |
| 40 | + 'MediaWiki:Common.js' => array( 'type' => 'script' ), |
| 41 | + 'MediaWiki:Common.css' => array( 'type' => 'style' ), |
| 42 | + 'MediaWiki:' . ucfirst( $context->getSkin() ) . '.js' => array( 'type' => 'script' ), |
| 43 | + 'MediaWiki:' . ucfirst( $context->getSkin() ) . '.css' => array( 'type' => 'style' ), |
| 44 | + 'MediaWiki:Print.css' => array( 'type' => 'style', 'media' => 'print' ), |
45 | 45 | ); |
46 | 46 | if ( $wgHandheldStyle ) { |
47 | | - $pages['Handheld.css'] = array( |
48 | | - 'ns' => NS_MEDIAWIKI, |
| 47 | + $pages['MediaWiki:Handheld.css'] = array( |
49 | 48 | 'type' => 'style', |
50 | 49 | 'media' => 'handheld' ); |
51 | 50 | } |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserModule.php |
— | — | @@ -32,12 +32,12 @@ |
33 | 33 | if ( $context->getUser() ) { |
34 | 34 | $username = $context->getUser(); |
35 | 35 | return array( |
36 | | - "$username/common.js" => array( 'ns' => NS_USER, 'type' => 'script' ), |
37 | | - "$username/" . $context->getSkin() . '.js' => |
38 | | - array( 'ns' => NS_USER, 'type' => 'script' ), |
39 | | - "$username/common.css" => array( 'ns' => NS_USER, 'type' => 'style' ), |
40 | | - "$username/" . $context->getSkin() . '.css' => |
41 | | - array( 'ns' => NS_USER, 'type' => 'style' ), |
| 36 | + "User:$username/common.js" => array( 'type' => 'script' ), |
| 37 | + "User:$username/" . $context->getSkin() . '.js' => |
| 38 | + array( 'type' => 'script' ), |
| 39 | + "User:$username/common.css" => array( 'type' => 'style' ), |
| 40 | + "User:$username/" . $context->getSkin() . '.css' => |
| 41 | + array( 'type' => 'style' ), |
42 | 42 | ); |
43 | 43 | } |
44 | 44 | return array(); |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php |
— | — | @@ -45,12 +45,12 @@ |
46 | 46 | |
47 | 47 | /* Protected Methods */ |
48 | 48 | |
49 | | - protected function getContent( $page, $ns ) { |
50 | | - if ( $ns === NS_MEDIAWIKI ) { |
51 | | - return wfEmptyMsg( $page ) ? '' : wfMsgExt( $page, 'content' ); |
| 49 | + protected function getContent( $title ) { |
| 50 | + if ( $title->getNamespace() === NS_MEDIAWIKI ) { |
| 51 | + $dbkey = $title->getDBkey(); |
| 52 | + return wfEmptyMsg( $dbkey ) ? '' : wfMsgExt( $dbkey, 'content' ); |
52 | 53 | } |
53 | | - $title = Title::newFromText( $page, $ns ); |
54 | | - if ( !$title || !$title->isCssJsSubpage() ) { |
| 54 | + if ( !$title->isCssJsSubpage() ) { |
55 | 55 | return null; |
56 | 56 | } |
57 | 57 | $revision = Revision::newFromTitle( $title ); |
— | — | @@ -64,15 +64,21 @@ |
65 | 65 | |
66 | 66 | public function getScript( ResourceLoaderContext $context ) { |
67 | 67 | $scripts = ''; |
68 | | - foreach ( $this->getPages( $context ) as $page => $options ) { |
| 68 | + foreach ( $this->getPages( $context ) as $titleText => $options ) { |
69 | 69 | if ( $options['type'] !== 'script' ) { |
70 | 70 | continue; |
71 | 71 | } |
72 | | - $script = $this->getContent( $page, $options['ns'] ); |
73 | | - if ( $script ) { |
74 | | - $ns = MWNamespace::getCanonicalName( $options['ns'] ); |
75 | | - $scripts .= "/* $ns:$page */\n$script\n"; |
| 72 | + $title = Title::newFromText( $titleText ); |
| 73 | + if ( !$title ) { |
| 74 | + continue; |
76 | 75 | } |
| 76 | + $script = $this->getContent( $title ); |
| 77 | + if ( strval( $script ) !== '' ) { |
| 78 | + if ( strpos( $titleText, '*/' ) === false ) { |
| 79 | + $scripts .= "/* $titleText */\n"; |
| 80 | + } |
| 81 | + $scripts .= $script . "\n"; |
| 82 | + } |
77 | 83 | } |
78 | 84 | return $scripts; |
79 | 85 | } |
— | — | @@ -80,13 +86,17 @@ |
81 | 87 | public function getStyles( ResourceLoaderContext $context ) { |
82 | 88 | |
83 | 89 | $styles = array(); |
84 | | - foreach ( $this->getPages( $context ) as $page => $options ) { |
| 90 | + foreach ( $this->getPages( $context ) as $titleText => $options ) { |
85 | 91 | if ( $options['type'] !== 'style' ) { |
86 | 92 | continue; |
87 | 93 | } |
| 94 | + $title = Title::newFromText( $titleText ); |
| 95 | + if ( !$title ) { |
| 96 | + continue; |
| 97 | + } |
88 | 98 | $media = isset( $options['media'] ) ? $options['media'] : 'all'; |
89 | | - $style = $this->getContent( $page, $options['ns'] ); |
90 | | - if ( !$style ) { |
| 99 | + $style = $this->getContent( $title ); |
| 100 | + if ( strval( $style ) === '' ) { |
91 | 101 | continue; |
92 | 102 | } |
93 | 103 | if ( $this->getFlip( $context ) ) { |
— | — | @@ -95,8 +105,10 @@ |
96 | 106 | if ( !isset( $styles[$media] ) ) { |
97 | 107 | $styles[$media] = ''; |
98 | 108 | } |
99 | | - $ns = MWNamespace::getCanonicalName( $options['ns'] ); |
100 | | - $styles[$media] .= "/* $ns:$page */\n$style\n"; |
| 109 | + if ( strpos( $titleText, '*/' ) === false ) { |
| 110 | + $styles[$media] .= "/* $titleText */\n"; |
| 111 | + } |
| 112 | + $styles[$media] .= $style . "\n"; |
101 | 113 | } |
102 | 114 | return $styles; |
103 | 115 | } |
— | — | @@ -107,17 +119,16 @@ |
108 | 120 | return $this->modifiedTime[$hash]; |
109 | 121 | } |
110 | 122 | |
111 | | - $titles = array(); |
112 | | - foreach ( $this->getPages( $context ) as $page => $options ) { |
113 | | - $titles[$options['ns']][$page] = true; |
| 123 | + $batch = new LinkBatch; |
| 124 | + foreach ( $this->getPages( $context ) as $titleText => $options ) { |
| 125 | + $batch->addObj( Title::newFromText( $titleText ) ); |
114 | 126 | } |
115 | 127 | |
116 | 128 | $modifiedTime = 1; // wfTimestamp() interprets 0 as "now" |
117 | | - |
118 | | - if ( $titles ) { |
| 129 | + if ( !$batch->isEmpty() ) { |
119 | 130 | $dbr = wfGetDB( DB_SLAVE ); |
120 | 131 | $latest = $dbr->selectField( 'page', 'MAX(page_touched)', |
121 | | - $dbr->makeWhereFrom2d( $titles, 'page_namespace', 'page_title' ), |
| 132 | + $batch->constructSet( 'page', $dbr ), |
122 | 133 | __METHOD__ ); |
123 | 134 | |
124 | 135 | if ( $latest ) { |
— | — | @@ -125,6 +136,7 @@ |
126 | 137 | } |
127 | 138 | } |
128 | 139 | |
129 | | - return $this->modifiedTime[$hash] = $modifiedTime; |
| 140 | + $this->modifiedTime[$hash] = $modifiedTime; |
| 141 | + return $modifiedTime; |
130 | 142 | } |
131 | 143 | } |