r13896 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13895‎ | r13896 | r13897 >
Date:14:05, 28 April 2006
Author:magnusmanske
Status:old
Tags:
Comment:
Patch from Tels
Modified paths:
  • /trunk/wiki2xml/php/default.php (modified) (history)
  • /trunk/wiki2xml/php/sample_local.php (modified) (history)
  • /trunk/wiki2xml/php/w2x.php (modified) (history)

Diff [purge]

Index: trunk/wiki2xml/php/sample_local.php
@@ -17,6 +17,9 @@
1818 "dtd" => "file:/c:/docbook/dtd/docbookx.dtd"
1919 ) ;
2020
 21+# On Windows, set
 22+# $xmlg['is_windows'] = true ;
 23+
2124 ### Uncomment the following to use Special:Export and (potentially) automatic authors list; a little slower, though
2225 #$xmlg["use_special_export"] = 1 ;
2326
Index: trunk/wiki2xml/php/w2x.php
@@ -93,7 +93,7 @@
9494 }
9595 $converter = new MediaWikiConverter ;
9696
97 - $xmlg["book_title"] = $_POST['document_title'] || 'document';
 97+ $xmlg["book_title"] = $_POST['document_title'];
9898 $xmlg["site_base_url"] = $_POST['site'] ;
9999 $xmlg["resolvetemplates"] = $_POST['use_templates'] ;
100100 $xmlg['templates'] = explode ( "\n" , $_POST['templates'] ) ;
@@ -109,6 +109,9 @@
110110 } else {
111111 $t = microtime_float() ;
112112 $articles = explode ( "\n" , $wikitext ) ;
 113+ if ($xmlg["book_title"] == '') {
 114+ $xmlg["book_title"] = $articles[0];
 115+ }
113116 foreach ( $articles AS $a ) {
114117 $wiki2xml_authors = array () ;
115118 $a = trim ( $a ) ;
@@ -184,10 +187,20 @@
185188 fwrite ( $handle , $out ) ;
186189 fclose ( $handle ) ;
187190 # Generate temporary ODT file
188 - $out_file = tempnam($dir, "ODT");
 191+ $out_file = tempnam('', "ODT");
189192 $cmd = $xmlg['zip_odt'] ;
190193 $cmd = str_replace ( '$1' , escapeshellarg ( $out_file ) , $cmd ) ;
191 - $cmd = str_replace ( '$2' , escapeshellarg ( $dir . "/" ) , $cmd ) ;
 194+
 195+ if ( $xmlg['is_windows'] ) {
 196+ $cmd = str_replace ( '$2' , escapeshellarg ( $dir . "/" ) , $cmd ) ;
 197+ } else {
 198+ $cmd = str_replace ( '$2' , escapeshellarg ( './' ) , $cmd ) ;
 199+ # linux/unix zip needs to be in the directory, otherwise it will
 200+ # include needless parts into the directory structure
 201+ chdir ($dir);
 202+ # remove the output if it for some reason already exists
 203+ }
 204+
192205 @unlink ( $out_file ) ;
193206 exec ( $cmd ) ;
194207
Index: trunk/wiki2xml/php/default.php
@@ -5,6 +5,7 @@
66 $xmlg["book_title"] = "No title" ;
77 $xmlg['sourcedir'] = "." ;
88 $xmlg["temp_dir"] = "/tmp" ;
 9+$xmlg['is_windows'] = false ;
910
1011 @include ( "local.php" ) ;
1112

Status & tagging log