Localisation updates from http://translatewiki.net.
[mediawiki.git] / maintenance / formatInstallDoc.php
blobfa98813f6206313d423f66e31cf446d5adb7d1e4
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
19 * @ingroup Maintenance
22 require_once( dirname( __FILE__ ) .'/Maintenance.php' );
24 class MaintenanceFormatInstallDoc extends Maintenance {
25 function __construct() {
26 parent::__construct();
27 $this->addArg( 'path', 'The file name to format', false );
28 $this->addOption( 'outfile', 'The output file name', false, true );
29 $this->addOption( 'html', 'Use HTML output format. By default, wikitext is used.' );
32 function execute() {
33 if ( $this->hasArg( 0 ) ) {
34 $fileName = $this->getArg( 0 );
35 $inFile = fopen( $fileName, 'r' );
36 if ( !$inFile ) {
37 $this->error( "Unable to open input file \"$fileName\"" );
38 exit( 1 );
40 } else {
41 $inFile = STDIN;
44 if ( $this->hasOption( 'outfile' ) ) {
45 $fileName = $this->getOption( 'outfile' );
46 $outFile = fopen( $fileName, 'w' );
47 if ( !$outFile ) {
48 $this->error( "Unable to open output file \"$fileName\"" );
49 exit( 1 );
51 } else {
52 $outFile = STDOUT;
55 $inText = stream_get_contents( $inFile );
56 $outText = InstallDocFormatter::format( $inText );
58 if ( $this->hasOption( 'html' ) ) {
59 global $wgParser;
60 $opt = new ParserOptions;
61 $title = Title::newFromText( 'Text file' );
62 $out = $wgParser->parse( $outText, $title, $opt );
63 $outText = "<html><body>\n" . $out->getText() . "\n</body></html>\n";
66 fwrite( $outFile, $outText );
70 $maintClass = 'MaintenanceFormatInstallDoc';
71 require_once( RUN_MAINTENANCE_IF_MAIN );