Index: trunk/extensions/IncludeWP/IncludeWP.settings.php |
— | — | @@ -20,3 +20,12 @@ |
21 | 21 | die( 'Not an entry point.' ); |
22 | 22 | } |
23 | 23 | |
| 24 | +$egIncWPWikis = array(); |
| 25 | + |
| 26 | +$egIncWPWikis['wikipedia'] = array( |
| 27 | + 'name' => 'Wikipedia', |
| 28 | + 'path' => 'http://en.wikipedia.org/w', |
| 29 | + 'url' => 'http://en.wikipedia.org/wiki', |
| 30 | + 'licencename' => 'CC-BY-SA', |
| 31 | + 'licenceurl' => 'http://creativecommons.org/licenses/by-sa/3.0/' |
| 32 | +); |
Index: trunk/extensions/IncludeWP/IncludeWP.class.php |
— | — | @@ -57,11 +57,17 @@ |
58 | 58 | * @return array |
59 | 59 | */ |
60 | 60 | protected function getParameterInfo( $type ) { |
| 61 | + global $egIncWPWikis; |
| 62 | + |
61 | 63 | $params = array(); |
62 | 64 | |
63 | 65 | $params['page'] = new Parameter( 'page' ); |
64 | 66 | $params['page']->setDescription( wfMsg( 'includewp-include-par-page' ) ); |
65 | 67 | |
| 68 | + $params['wiki'] = new Parameter( 'wiki' ); |
| 69 | + $params['wiki']->setDefault( array_shift( array_keys( $egIncWPWikis ) ) ); |
| 70 | + $params['wiki']->addCriteria( new CriterionInArray( array_keys( $egIncWPWikis ) ) ); |
| 71 | + |
66 | 72 | return $params; |
67 | 73 | } |
68 | 74 | |
— | — | @@ -74,7 +80,7 @@ |
75 | 81 | * @return array |
76 | 82 | */ |
77 | 83 | protected function getDefaultParameters( $type ) { |
78 | | - return array( 'page' ); |
| 84 | + return array( 'page', 'wiki' ); |
79 | 85 | } |
80 | 86 | |
81 | 87 | /** |
— | — | @@ -100,7 +106,7 @@ |
101 | 107 | 'pageid' => $nr, |
102 | 108 | 'class' => 'includewp-loading', |
103 | 109 | 'page' => $parameters['page'], |
104 | | - 'wiki' => 'http://en.wikipedia.org/w' // TODO |
| 110 | + 'wiki' => $parameters['wiki'] |
105 | 111 | ), |
106 | 112 | wfMsgForContent( 'includewp-loading-page' ) |
107 | 113 | ); |
— | — | @@ -142,6 +148,8 @@ |
143 | 149 | |
144 | 150 | $loadedJs = true; |
145 | 151 | |
| 152 | + $this->addJSWikiData(); |
| 153 | + |
146 | 154 | // For backward compatibility with MW < 1.17. |
147 | 155 | if ( is_callable( array( $this->parser->getOutput(), 'addModules' ) ) ) { |
148 | 156 | $this->parser->getOutput()->addModules( 'ext.incwp' ); |
— | — | @@ -164,6 +172,21 @@ |
165 | 173 | } |
166 | 174 | |
167 | 175 | /** |
| 176 | + * Ouput the wiki data needed to display the licence links. |
| 177 | + * |
| 178 | + * @since 0.1 |
| 179 | + */ |
| 180 | + protected function addJSWikiData() { |
| 181 | + global $egIncWPWikis; |
| 182 | + |
| 183 | + $this->parser->getOutput()->addHeadItem( |
| 184 | + Html::inlineScript( |
| 185 | + 'var wgIncWPWikis =' . json_encode( $egIncWPWikis ) . ';' |
| 186 | + ) |
| 187 | + ); |
| 188 | + } |
| 189 | + |
| 190 | + /** |
168 | 191 | * Adds the needed JS messages to the page output. |
169 | 192 | * This is for backward compatibility with pre-RL MediaWiki. |
170 | 193 | * |
Index: trunk/extensions/IncludeWP/ext.incwp.js |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | */ |
40 | 40 | function loadPage( sender ) { |
41 | 41 | $.getJSON( |
42 | | - sender.attr( 'wiki' ) + '/api.php?callback=?', |
| 42 | + window.wgIncWPWikis[sender.attr( 'wiki' )].path + '/api.php?callback=?', |
43 | 43 | { |
44 | 44 | 'action': 'query', |
45 | 45 | 'format': 'json', |
— | — | @@ -162,14 +162,16 @@ |
163 | 163 | * @param integer pageId |
164 | 164 | */ |
165 | 165 | function showCopyright( pageName, pageId ) { |
| 166 | + var wiki = window.wgIncWPWikis[$( '#includewp-loading-' + pageId ).attr( 'wiki' )]; |
| 167 | + |
166 | 168 | var licenceHtml = mediaWiki.msg( // TODO: make non WP-specific |
167 | 169 | 'includewp-licence-notice', |
168 | | - 'Wikipedia', |
169 | | - 'http://en.wikipedia.org/wiki/' + pageName, |
| 170 | + wiki.name, |
| 171 | + wiki.url + '/' + pageName, |
170 | 172 | pageName, |
171 | | - 'http://creativecommons.org/licenses/by-sa/3.0/', |
172 | | - 'CC-BY-SA', |
173 | | - 'http://en.wikipedia.org/wiki/' + pageName + '?action=history' |
| 173 | + wiki.licenceurl, |
| 174 | + wiki.licencename, |
| 175 | + wiki.url + '/' + pageName + '?action=history' |
174 | 176 | ); |
175 | 177 | |
176 | 178 | $( '#includewp-copyright-' + pageId ).html( licenceHtml ); |