Index: branches/iwtransclusion/phase3/maintenance/tables.sql |
— | — | @@ -1068,6 +1068,12 @@ |
1069 | 1069 | -- insertion. |
1070 | 1070 | iw_url blob NOT NULL, |
1071 | 1071 | |
| 1072 | + -- The URL of the file api.php |
| 1073 | + iw_api blob NOT NULL, |
| 1074 | + |
| 1075 | + -- The name of the database (for a connection to be established with wfGetLB( 'dbname' )) |
| 1076 | + iw_dbname varchar(32) NOT NULL, |
| 1077 | + |
1072 | 1078 | -- A boolean value indicating whether the wiki is in this project |
1073 | 1079 | -- (used, for example, to detect redirect loops) |
1074 | 1080 | iw_local bool NOT NULL, |
Index: branches/iwtransclusion/phase3/includes/Interwiki.php |
— | — | @@ -17,10 +17,11 @@ |
18 | 18 | |
19 | 19 | protected $mPrefix, $mURL, $mAPI, $mLocal, $mTrans; |
20 | 20 | |
21 | | - public function __construct( $prefix = null, $url = '', $api = '', $local = 0, $trans = 0 ) { |
| 21 | + public function __construct( $prefix = null, $url = '', $api = '', $dbname = '', $local = 0, $trans = 0 ) { |
22 | 22 | $this->mPrefix = $prefix; |
23 | 23 | $this->mURL = $url; |
24 | 24 | $this->mAPI = $api; |
| 25 | + $this->mDBname = $dbname; |
25 | 26 | $this->mLocal = $local; |
26 | 27 | $this->mTrans = $trans; |
27 | 28 | } |
— | — | @@ -169,10 +170,12 @@ |
170 | 171 | * @return Boolean: whether everything was there |
171 | 172 | */ |
172 | 173 | protected static function loadFromArray( $mc ) { |
173 | | - if( isset( $mc['iw_url'] ) && isset( $mc['iw_api'] ) && isset( $mc['iw_local'] ) && isset( $mc['iw_trans'] ) ) { |
| 174 | + if( isset( $mc['iw_url'] ) && isset( $mc['iw_api'] ) && isset( $mc['iw_dbname'] ) |
| 175 | + && isset( $mc['iw_local'] ) && isset( $mc['iw_trans'] ) ) { |
174 | 176 | $iw = new Interwiki(); |
175 | 177 | $iw->mURL = $mc['iw_url']; |
176 | 178 | $iw->mAPI = $mc['iw_api']; |
| 179 | + $iw->mDBname = $mc['iw_dbname']; |
177 | 180 | $iw->mLocal = $mc['iw_local']; |
178 | 181 | $iw->mTrans = $mc['iw_trans']; |
179 | 182 | return $iw; |
— | — | @@ -200,9 +203,16 @@ |
201 | 204 | * @return String: the URL |
202 | 205 | */ |
203 | 206 | public function getAPI( ) { |
204 | | - $url = $this->mAPI; |
| 207 | + return $this->mAPI; |
| 208 | + } |
205 | 209 | |
206 | | - return $url; |
| 210 | + /** |
| 211 | + * Get the DB name for this wiki |
| 212 | + * |
| 213 | + * @return String: the DB name |
| 214 | + */ |
| 215 | + public function getDBname( ) { |
| 216 | + return $this->mDBname; |
207 | 217 | } |
208 | 218 | |
209 | 219 | /** |
Index: branches/iwtransclusion/phase3/includes/parser/Parser.php |
— | — | @@ -3055,7 +3055,7 @@ |
3056 | 3056 | // $text = $this->interwikiTransclude( $title, 'render' ); |
3057 | 3057 | // $isHTML = true; |
3058 | 3058 | //} else { |
3059 | | - $text = $this->interwikiTransclude( $title, 'raw' ); |
| 3059 | + $text = $this->interwikiTransclude( $title ); |
3060 | 3060 | # Preprocess it like a template |
3061 | 3061 | $text = $this->preprocessToDom( $text, self::PTD_FOR_INCLUSION ); |
3062 | 3062 | $isChildObj = true; |
— | — | @@ -3273,15 +3273,17 @@ |
3274 | 3274 | * Transclude an interwiki link. |
3275 | 3275 | * TODO: separate in interwikiTranscludeFromDB & interwikiTranscludeFromAPI according to the iw type |
3276 | 3276 | */ |
3277 | | - function interwikiTransclude( $title, $action ) { |
| 3277 | + function interwikiTransclude( $title ) { |
3278 | 3278 | |
3279 | 3279 | global $wgEnableScaryTranscluding; |
3280 | 3280 | |
3281 | 3281 | if ( !$wgEnableScaryTranscluding ) { |
3282 | 3282 | return wfMsg('scarytranscludedisabled'); |
3283 | 3283 | } |
| 3284 | + |
| 3285 | + $fullTitle = $title->getNsText().':'.$title->getText(); |
3284 | 3286 | |
3285 | | - $url1 = $title->getTransAPI( )."?action=query&prop=revisions&titles=$titles&rvprop=content&format=json"; |
| 3287 | + $url1 = $title->getTransAPI( )."?action=query&prop=revisions&titles=$fullTitle&rvprop=content&format=json"; |
3286 | 3288 | |
3287 | 3289 | if ( strlen( $url1 ) > 255 ) { |
3288 | 3290 | return wfMsg( 'scarytranscludetoolong' ); |
— | — | @@ -3289,8 +3291,7 @@ |
3290 | 3292 | |
3291 | 3293 | $text = $this->fetchTemplateMaybeFromCache( $url1 ); |
3292 | 3294 | |
3293 | | - $titles = $title->getNsText().':'.$title->getText(); |
3294 | | - $url2 = $title->getTransAPI( )."?action=parse&text={{".$titles."}}&prop=templates&format=json"; |
| 3295 | + $url2 = $title->getTransAPI( )."?action=parse&text={{".$fullTitle."}}&prop=templates&format=json"; |
3295 | 3296 | |
3296 | 3297 | $get = Http::get( $url2 ); |
3297 | 3298 | $myArray = FormatJson::decode($get, true); |
— | — | @@ -3313,7 +3314,7 @@ |
3314 | 3315 | |
3315 | 3316 | } |
3316 | 3317 | |
3317 | | - return "<h2>$titles</h2><pre>$text</pre> List of templates: <pre>".$listSubTemplates.'</pre>' . $list2; |
| 3318 | + return "<h2>$fullTitle</h2><pre>$text</pre> List of templates: <pre>".$listSubTemplates.'</pre>' . $list2; |
3318 | 3319 | } |
3319 | 3320 | |
3320 | 3321 | |
Index: branches/iwtransclusion/phase3/includes/Title.php |
— | — | @@ -528,6 +528,19 @@ |
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
| 532 | + * Returns the DB name of the distant wiki |
| 533 | + * which owns the object. |
| 534 | + * |
| 535 | + * @return \type{\string} the DB name |
| 536 | + */ |
| 537 | + public function getTransDBname() { |
| 538 | + if ( $this->mInterwiki == '' ) |
| 539 | + return false; |
| 540 | + |
| 541 | + return Interwiki::fetch( $this->mInterwiki )->getDBname(); |
| 542 | + } |
| 543 | + |
| 544 | + /** |
532 | 545 | * Escape a text fragment, say from a link, for a URL |
533 | 546 | * |
534 | 547 | * @param $fragment string containing a URL or link fragment (after the "#") |