Index: trunk/wiki2xml/php/wiki2xml.php |
— | — | @@ -22,6 +22,7 @@ |
23 | 23 | "br" => "xhtml:br", |
24 | 24 | "div" => "xhtml:div", |
25 | 25 | "span" => "xhtml:span", |
| 26 | + "big" => "xhtml:big", |
26 | 27 | "small" => "xhtml:small", |
27 | 28 | "sub" => "xhtml:sub", |
28 | 29 | "sup" => "xhtml:sup", |
Index: trunk/wiki2xml/php/extension.php |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | function execute( $par = null ) { # Checked for HTML and MySQL insertion attacks
|
52 | 52 | global $wgOut, $wgRequest, $wgUser, $wgTitle, $IP;
|
53 | 53 | $fname = 'Special::Tasks:execute';
|
54 | | - global $xmlg , $html_named_entities_mapping_mine;
|
| 54 | + global $xmlg , $html_named_entities_mapping_mine, $content_provider;
|
55 | 55 | include_once ( "default.php" ) ;
|
56 | 56 | $xmlg['sourcedir'] = $IP.'/extensions/wiki2xml' ;
|
57 | 57 | include_once ( "w2x.php" ) ;
|
Index: trunk/wiki2xml/php/w2x.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | return ((float)$usec + (float)$sec); |
21 | 21 | } |
22 | 22 | |
23 | | -function get_form () { |
| 23 | +function get_form ( $as_extension = false ) { |
24 | 24 | global $xmlg ; |
25 | 25 | $optional = array () ; |
26 | 26 | if ( isset ( $xmlg['docbook']['command_pdf'] ) ) { |
— | — | @@ -34,8 +34,9 @@ |
35 | 35 | } |
36 | 36 | $optional = "<br/>" . implode ( "<br/>" , $optional ) ; |
37 | 37 | |
| 38 | + if ( $as_extension ) $site = "<input type='hidden' name='site' value=''/>" ; |
| 39 | + else $site = "Site : http://<input type='text' name='site' value='".$xmlg["site_base_url"]."'/>/index.php<br/>" ; |
38 | 40 | |
39 | | - |
40 | 41 | return "<form method='post'> |
41 | 42 | <h2>Paste article list or wikitext here</h2> |
42 | 43 | <table border='0' width='100%'><tr> |
— | — | @@ -54,7 +55,7 @@ |
55 | 56 | <INPUT checked type='radio' name='whatsthis' value='articlelist'>a list of articles |
56 | 57 | <br/> |
57 | 58 | |
58 | | -Site : http://<input type='text' name='site' value='".$xmlg["site_base_url"]."'/>/index.php<br/> |
| 59 | +{$site} |
59 | 60 | Title : <input type='text' name='document_title' value='' size=40/><br/> |
60 | 61 | <input type='checkbox' name='add_gfdl' value='1' checked>Include GFDL (for some output formats)</input><br/> |
61 | 62 | <input type='checkbox' name='keep_categories' value='1' checked>Keep categories</input><br/> |
— | — | @@ -85,7 +86,11 @@ |
86 | 87 | if ( isset ( $_POST['doit'] ) ) { # Process |
87 | 88 | $wikitext = stripslashes ( $_POST['text'] ) ; |
88 | 89 | |
89 | | - $content_provider = new ContentProviderHTTP ; |
| 90 | + if( !defined( 'MEDIAWIKI' ) ) { # Stand-alone |
| 91 | + $content_provider = new ContentProviderHTTP ; |
| 92 | + } else { # MediaWiki extension |
| 93 | + $content_provider = new ContentProviderMySQL ; |
| 94 | + } |
90 | 95 | $converter = new MediaWikiConverter ; |
91 | 96 | |
92 | 97 | $xmlg["book_title"] = $_POST['document_title'] || 'document'; |
— | — | @@ -245,7 +250,7 @@ |
246 | 251 | print get_form () ; |
247 | 252 | print "</body></html>" ; |
248 | 253 | } else { # MediaWiki extension |
249 | | - $out = get_form () ; |
| 254 | + $out = get_form ( true ) ; |
250 | 255 | } |
251 | 256 | |
252 | 257 | } |
Index: trunk/wiki2xml/php/content_provider.php |
— | — | @@ -269,4 +269,64 @@ |
270 | 270 | |
271 | 271 | } |
272 | 272 | |
| 273 | +# Access through text file structure |
| 274 | +class ContentProviderMySQL extends ContentProviderHTTP { |
| 275 | + |
| 276 | + function do_get_contents ( $title ) { |
| 277 | + return $this->get_page_text ( $title ) ; |
| 278 | + } |
| 279 | + |
| 280 | + /** |
| 281 | + Called from outside |
| 282 | + */ |
| 283 | + function get_wiki_text ( $title , $do_cache = false ) { |
| 284 | + $title = trim ( $title ) ; |
| 285 | + if ( $title == "" ) return "" ; # Just in case... |
| 286 | + if ( $this->first_title == "" ) { |
| 287 | + $this->first_title = $title ; |
| 288 | + } |
| 289 | + $text = $this->get_page_text ( $title ) ; |
| 290 | + return $text ; |
| 291 | + } |
| 292 | + |
| 293 | + function get_file_location ( $ns , $title ) { |
| 294 | + return get_file_location_global ( $this->basedir , $ns , $title , false ) ; |
| 295 | + } |
| 296 | + |
| 297 | + function get_page_text ( $page , $allow_redirect = true ) { |
| 298 | + /* |
| 299 | + $filename = $this->get_file_location ( 0 , $page ) ; |
| 300 | + $filename = $filename->fullname . $this->file_ending ; |
| 301 | + if ( !file_exists ( $filename ) ) return "" ; |
| 302 | + $text = trim ( file_get_contents ( $filename ) ) ; |
| 303 | + */ |
| 304 | + |
| 305 | + $title = Title::newFromText ( $page ) ; |
| 306 | + $article = new Article ( $title ) ; |
| 307 | + $text = $article->getContent () ; |
| 308 | + |
| 309 | + # REDIRECT? |
| 310 | + if ( $allow_redirect && strtoupper ( substr ( $text , 0 , 9 ) ) == "#REDIRECT" ) { |
| 311 | + $text = substr ( $text , 9 ) ; |
| 312 | + $text = array_shift ( explode ( "\n" , $text , 2 ) ) ; |
| 313 | + $text = str_replace ( "[[" , "" , $text ) ; |
| 314 | + $text = str_replace ( "]]" , "" , $text ) ; |
| 315 | + $text = ucfirst ( trim ( $text ) ) ; |
| 316 | + $text = $this->get_page_text ( $text , false ) ; |
| 317 | + } |
| 318 | + return $text ; |
| 319 | + } |
| 320 | + |
| 321 | + function get_internal_link ( $target , $text ) { |
| 322 | + $file = $this->get_file_location ( 0 , $target ) ; |
| 323 | + if ( !file_exists ( $file->fullname.$this->file_ending ) ) return $text ; |
| 324 | + else return "<a href='browse_texts.php?title=" . urlencode ( $target ) . "'>{$text}</a>" ; |
| 325 | + } |
| 326 | + |
| 327 | + function do_show_images () { |
| 328 | + return false ; |
| 329 | + } |
| 330 | + |
| 331 | +} |
| 332 | + |
273 | 333 | ?> |