summaryrefslogtreecommitdiff
path: root/maintenance/formatInstallDoc.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
committerPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
commitca32f08966f1b51fcb19460f0996bb0c4048e6fe (patch)
treeec04cc15b867bc21eedca904cea9af0254531a11 /maintenance/formatInstallDoc.php
parenta22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (diff)
Update to MediaWiki 1.18.0
* also update ArchLinux skin to chagnes in MonoBook * Use only css to hide our menu bar when printing
Diffstat (limited to 'maintenance/formatInstallDoc.php')
-rw-r--r--maintenance/formatInstallDoc.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/maintenance/formatInstallDoc.php b/maintenance/formatInstallDoc.php
new file mode 100644
index 00000000..9acc16a7
--- /dev/null
+++ b/maintenance/formatInstallDoc.php
@@ -0,0 +1,54 @@
+<?php
+
+require_once( dirname( __FILE__ ) .'/Maintenance.php' );
+
+class MaintenanceFormatInstallDoc extends Maintenance {
+ function __construct() {
+ parent::__construct();
+ $this->addArg( 'path', 'The file name to format', false );
+ $this->addOption( 'outfile', 'The output file name', false, true );
+ $this->addOption( 'html', 'Use HTML output format. By default, wikitext is used.' );
+ }
+
+ function execute() {
+ if ( $this->hasArg( 0 ) ) {
+ $fileName = $this->getArg( 0 );
+ $inFile = fopen( $fileName, 'r' );
+ if ( !$inFile ) {
+ $this->error( "Unable to open input file \"$fileName\"" );
+ exit( 1 );
+ }
+ } else {
+ $inFile = STDIN;
+ }
+
+ if ( $this->hasOption( 'outfile' ) ) {
+ $fileName = $this->getOption( 'outfile' );
+ $outFile = fopen( $fileName, 'w' );
+ if ( !$outFile ) {
+ $this->error( "Unable to open output file \"$fileName\"" );
+ exit( 1 );
+ }
+ } else {
+ $outFile = STDOUT;
+ }
+
+ $inText = stream_get_contents( $inFile );
+ $outText = InstallDocFormatter::format( $inText );
+
+ if ( $this->hasOption( 'html' ) ) {
+ global $wgParser;
+ $opt = new ParserOptions;
+ $title = Title::newFromText( 'Text file' );
+ $out = $wgParser->parse( $outText, $title, $opt );
+ $outText = "<html><body>\n" . $out->getText() . "\n</body></html>\n";
+ }
+
+ fwrite( $outFile, $outText );
+ }
+}
+
+$maintClass = 'MaintenanceFormatInstallDoc';
+require_once( RUN_MAINTENANCE_IF_MAIN );
+
+