3 require_once( dirname( __FILE__
) .'/Maintenance.php' );
5 class MaintenanceFormatInstallDoc
extends Maintenance
{
6 function __construct() {
8 $this->addArg( 'path', 'The file name to format', false );
9 $this->addOption( 'outfile', 'The output file name', false, true );
10 $this->addOption( 'html', 'Use HTML output format. By default, wikitext is used.' );
14 if ( $this->hasArg( 0 ) ) {
15 $fileName = $this->getArg( 0 );
16 $inFile = fopen( $fileName, 'r' );
18 $this->error( "Unable to open input file \"$fileName\"" );
25 if ( $this->hasOption( 'outfile' ) ) {
26 $fileName = $this->getOption( 'outfile' );
27 $outFile = fopen( $fileName, 'w' );
29 $this->error( "Unable to open output file \"$fileName\"" );
36 $inText = stream_get_contents( $inFile );
37 $outText = InstallDocFormatter
::format( $inText );
39 if ( $this->hasOption( 'html' ) ) {
41 $opt = new ParserOptions
;
42 $title = Title
::newFromText( 'Text file' );
43 $out = $wgParser->parse( $outText, $title, $opt );
44 $outText = "<html><body>\n" . $out->getText() . "\n</body></html>\n";
47 fwrite( $outFile, $outText );
51 $maintClass = 'MaintenanceFormatInstallDoc';
52 require_once( RUN_MAINTENANCE_IF_MAIN
);