Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 public function execute()
 {
     $text = $this->getFileContents();
     $text = InstallDocFormatter::format($text);
     $this->parent->output->addWikiText($text);
     $this->startForm();
     $this->endForm(false);
 }
 /**
  * @covers InstallDocFormatter::format
  * @dataProvider provideDocFormattingTests
  */
 public function testFormat($expected, $unformattedText, $message = '')
 {
     $this->assertEquals($expected, InstallDocFormatter::format($unformattedText), $message);
 }