6 require_once( dirname( __FILE__
) .'/Maintenance.php' );
8 class MaintenanceFormatInstallDoc
extends Maintenance
{
9 function __construct() {
10 parent
::__construct();
11 $this->addArg( 'path', 'The file name to format', false );
12 $this->addOption( 'outfile', 'The output file name', false, true );
13 $this->addOption( 'html', 'Use HTML output format. By default, wikitext is used.' );
17 if ( $this->hasArg( 0 ) ) {
18 $fileName = $this->getArg( 0 );
19 $inFile = fopen( $fileName, 'r' );
21 $this->error( "Unable to open input file \"$fileName\"" );
28 if ( $this->hasOption( 'outfile' ) ) {
29 $fileName = $this->getOption( 'outfile' );
30 $outFile = fopen( $fileName, 'w' );
32 $this->error( "Unable to open output file \"$fileName\"" );
39 $inText = stream_get_contents( $inFile );
40 $outText = InstallDocFormatter
::format( $inText );
42 if ( $this->hasOption( 'html' ) ) {
44 $opt = new ParserOptions
;
45 $title = Title
::newFromText( 'Text file' );
46 $out = $wgParser->parse( $outText, $title, $opt );
47 $outText = "<html><body>\n" . $out->getText() . "\n</body></html>\n";
50 fwrite( $outFile, $outText );
54 $maintClass = 'MaintenanceFormatInstallDoc';
55 require_once( RUN_MAINTENANCE_IF_MAIN
);