/**
  * Show the page to the user
  *
  * @param string $sub The subpage string argument (if any).
  *  [[Special:HelloWorld/subpage]].
  */
 public function execute($sub)
 {
     $out = $this->getOutput();
     $out->setPageTitle($this->msg('financialmathematics-helloworld'));
     $out->addWikiMsg('financialmathematics-helloworld-intro');
     $_restart_label = wfMessage('fm-restart')->text();
     $_restart = '<form action="" method=GET><input type="submit" value="' . $_restart_label . '"></form>';
     $out->addHTML($_restart);
     $m = new CT1_Concept_All();
     $result = $m->get_controller($_GET);
     if (isset($result['warning'])) {
         $out->addHTML("<span class='fin-math-warning'>" . $result['warning'] . "</span>");
     } else {
         if (isset($result['formulae'])) {
             $out->addHTML($result['formulae']);
         }
         if (isset($result['table'])) {
             $out->addHTML($result['table']);
         }
         if (isset($result['form'])) {
             $out->addHTML($result['form']);
         }
     }
     // creating object of SimpleXMLElement
     $xml_data = new SimpleXMLElement('<?xml version="1.0"?><parameters></parameters>');
     /////////////// NEEDS FIX /////////////////////////////////
     $this->array_to_xml($_GET, $xml_data);
     $result = print_r("Input for fin-math tag is " . htmlentities($xml_data->asXML()), 1);
     $out->addHTML($result);
     $input = print_r("Input from {$_GET} is " . htmlentities(print_r($_GET, 1)), 1);
     $out->addHTML($input);
 }
 public static function fmRender($input, array $args, Parser $parser, PPFrame $frame)
 {
     global $wgResourceModules;
     global $wgOut;
     $wgOut->addModules('ext.FinancialMathematics');
     $parser->getOutput()->addModules('ext.FinancialMathematics');
     $xml = simplexml_load_string($input);
     if (!$xml) {
         $_out = "<span class='fin-math-warning'>" . wfMessage('fm-error-xml')->text() . print_r($input, 1) . "</span>";
     }
     if ($xml) {
         //http://stackoverflow.com/questions/834875/recursive-cast-from-simplexmlobject-to-array
         $x = json_decode(json_encode((array) simplexml_load_string($input)), 1);
         $m = new CT1_Concept_All();
         $result = $m->get_controller($x);
         if (isset($result['warning'])) {
             $_out = "<span class='fin-math-warning'>" . $result['warning'] . "</span>";
         } else {
             if (isset($result['formulae'])) {
                 $_out = $result['formulae'];
             }
         }
     }
     if (!isset($_out)) {
         $_out = "<span class='fin-math-warning'>" . wfMessage('fm-error-no-output')->text() . "</span>";
     }
     //From https://www.mediawiki.org/wiki/QINU_fix
     $localParser = new Parser();
     $output = FinancialMathematicsHooks::renderRawHTML($localParser, $_out);
     return $output;
 }