Exemple #1
0
 public function getTestPage()
 {
     $random = "" . _hx_string_rec(Math::floor(Math::random() * 9999), "");
     $mml = "<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><msqrt><mn>" . $random . "</mn></msqrt></mrow></math>";
     $testName = null;
     $reportText = null;
     $solutionLink = null;
     $condition = null;
     $output = "";
     $output .= "<html><head>\r\n";
     $output .= "<title>WIRIS plugin test page</title><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" /><style type=\"text/css\">/*<!--*/html {font-family: sans-serif;}h2 {margin-left: 1em;}h3 {margin-left: 2em;}p {margin-left: 3em;}p.concrete {margin-left: 4em;}.ok {font-weight: bold;color: #0c0;}.error {font-weight: bold;color: #f00;}/*-->*/</style><style type=\"text/css\">body{font-family: Arial;}span{font-weight: bold;}span.ok {color: #009900;}span.error {color: #dd0000;}table, th, td, tr {border: solid 1px #000000;border-collapse:collapse;padding: 5px;}th{background-color: #eeeeee;}img{border:none;}</style>\r\n";
     $output .= "<script src=\"../core/WIRISplugins.js?viewer=image\" ></script>\r\n";
     $output .= "</head><body><h1>WIRIS plugin test page</h1>\r\n";
     $output .= "<table><tr><th>Test</th><th>Report</th><th>Status</th></tr>\r\n";
     $testName = "WIRIS plugin version";
     try {
         $s = com_wiris_system_Storage::newResourceStorage("VERSION")->read();
         $reportText = "<b>" . $s . "</b>";
         $solutionLink = "";
         $condition = true;
     } catch (Exception $»e) {
         $_ex_ = $»e instanceof HException ? $»e->e : $»e;
         $ex = $_ex_;
         $reportText = "Missing version";
         $solutionLink = "";
         $condition = false;
     }
     $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
     $testName = "Creating and storing data";
     $solutionLink = "";
     $param = array();
     $outp = array();
     $imageUrl = $this->plugin->newRender()->createImage($mml, $param, $outp);
     $reportText = "<a href=\"" . $imageUrl . "\" />" . $imageUrl . "</a>";
     $condition = true;
     $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
     $testName = "Retrieving data";
     $solutionLink = "";
     $reportText = "<img src=\"" . $imageUrl . "\" />";
     $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
     $testName = "JavaScript MathML filter";
     $solutionLink = "";
     $reportText = $mml;
     $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
     $testName = "Host platform";
     $solutionLink = "";
     $platform = $this->plugin->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$HOST_PLATFORM, "failed");
     $reportText = $platform;
     $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
     $testName = "Filter test";
     $solutionLink = "";
     $condition = true;
     $p = null;
     $p = array();
     $p["savemode"] = "safeXml";
     $s2 = str_replace("<", com_wiris_plugin_impl_TestImpl_0($this, $condition, $ex, $imageUrl, $mml, $outp, $output, $p, $param, $platform, $random, $reportText, $solutionLink, $testName), $mml);
     $s2 = str_replace(">", com_wiris_plugin_impl_TestImpl_1($this, $condition, $ex, $imageUrl, $mml, $outp, $output, $p, $param, $platform, $random, $reportText, $s2, $solutionLink, $testName), $s2);
     $s2 = str_replace("\"", com_wiris_plugin_impl_TestImpl_2($this, $condition, $ex, $imageUrl, $mml, $outp, $output, $p, $param, $platform, $random, $reportText, $s2, $solutionLink, $testName), $s2);
     $reportText = $this->plugin->newTextService()->filter("square root: " . $s2, $p);
     $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
     $testName = "Connecting to www.wiris.net";
     $solutionLink = "";
     $condition = true;
     try {
         $h = new com_wiris_plugin_impl_HttpImpl("http://www.wiris.net", null);
         $h->request(true);
     } catch (Exception $»e) {
         $_ex_ = $»e instanceof HException ? $»e->e : $»e;
         $ex2 = $_ex_;
         $condition = false;
     }
     $reportText = "Checking if WIRIS server is reachable";
     $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
     if (Type::resolveClass("com.wiris.editor.services.PublicServices") !== null) {
         $condition = true;
         $testName = "Testing integrated services";
         $reportText = "WIRIS Services installed";
         $solutionLink = "";
         $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
         $isLicensed = $this->plugin->isEditorLicensed();
         $condition = false;
         $testName = "WIRIS editor license";
         $reportText = "Checking WIRIS editor valid license";
         $output .= $this->createTableRow($testName, $reportText, $solutionLink, $isLicensed);
     } else {
         $reportText = "WIRIS Services not installed";
     }
     $debug = $this->plugin->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$DEBUG, "false") === "true";
     if ($debug) {
         $testName = "Font family";
         $solutionLink = "";
         $condition = true;
         $reportText = $this->plugin->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$FONT_FAMILY, "");
         $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
         $testName = "Configuration file";
         $solutionLink = "";
         $condition = true;
         $reportText = $this->plugin->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$CONFIGURATION_PATH, "") . "\\configuration.ini";
         $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
         $testName = "Cache path";
         $solutionLink = "";
         $condition = true;
         $reportText = $this->plugin->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$CACHE_FOLDER, "");
         $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
         $testName = "Formula path";
         $solutionLink = "";
         $condition = true;
         $reportText = $this->plugin->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$FORMULA_FOLDER, "");
         $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
         $testName = "Integration path";
         $solutionLink = "";
         $condition = true;
         $reportText = $this->plugin->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$INTEGRATION_PATH, "");
         $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
         $testName = "Context path";
         $solutionLink = "";
         $condition = true;
         $reportText = $this->plugin->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$CONTEXT_PATH, "");
         $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
         $testName = "default-configuration.ini load";
         $solutionLink = "";
         $defaultConfiguration = com_wiris_system_Storage::newResourceStorage("default-configuration.ini")->read();
         $condition = $defaultConfiguration !== null && strlen($defaultConfiguration) > 0;
         if ($condition) {
             $reportText = "Length: " . _hx_string_rec(strlen($defaultConfiguration), "");
         } else {
             $reportText = "Not found!";
         }
         $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
         $testName = "cas.png load";
         $solutionLink = "";
         $casPng = com_wiris_system_Storage::newResourceStorage("cas.png")->readBinary();
         $casPngLength = 0;
         if ($casPng !== null) {
             $casPngLength = haxe_io_Bytes::ofData($casPng)->length;
             $condition = $casPngLength > 0;
         } else {
             $condition = false;
         }
         if ($condition) {
             $reportText = "Length: " . _hx_string_rec($casPngLength, "");
         } else {
             $reportText = "Not found!";
         }
         $output .= $this->createTableRow($testName, $reportText, $solutionLink, $condition);
     }
     $output .= "<div id=\"haxe:trace\"></div>";
     return $output;
 }
 public function showImage($digest, $mml, $param, $call)
 {
     if ($digest === null && $mml === null) {
         throw new HException("Missing parameters 'formula' or 'mml'.");
     }
     if ($digest !== null && $mml !== null) {
         throw new HException("Only one parameter 'formula' or 'mml' is valid.");
     }
     $atts = false;
     if ($digest === null && $mml !== null) {
         $digest = $this->render->computeDigest($mml, $param);
     }
     $formula = $this->plugin->getStorageAndCache()->decodeDigest($digest);
     if ($formula === null) {
         throw new HException("Formula associated to digest not found.");
     }
     if (StringTools::startsWith($formula, "<")) {
         throw new HException("Not implemented.");
     }
     $iniFile = com_wiris_util_sys_IniFile::newIniFileFromString($formula);
     $renderParams = $iniFile->getProperties();
     $i = null;
     $ss = $this->render->getEditorParametersList();
     if ($param !== null) {
         $_g1 = 0;
         $_g = $ss->length;
         while ($_g1 < $_g) {
             $i1 = $_g1++;
             $key = $ss[$i1];
             $value = com_wiris_system_PropertiesTools::getProperty($param, $key, null);
             if ($value !== null) {
                 $atts = true;
                 $renderParams->set($key, $value);
             }
             unset($value, $key, $i1);
         }
     }
     if ($atts) {
         if ($mml !== null) {
             $digest = $this->render->computeDigest($mml, com_wiris_system_PropertiesTools::toProperties($renderParams));
         } else {
             $digest = $this->render->computeDigest($renderParams->get("mml"), com_wiris_system_PropertiesTools::toProperties($renderParams));
         }
     }
     $store = $this->plugin->getStorageAndCache();
     $bs = null;
     $bs = $store->retreiveData($digest, "png");
     if ($bs === null) {
         $_g1 = 0;
         $_g = $ss->length;
         while ($_g1 < $_g) {
             $i1 = $_g1++;
             $key = $ss[$i1];
             if (!$renderParams->exists($key)) {
                 $confKey = com_wiris_plugin_api_ConfigurationKeys::$imageConfigProperties->get($key);
                 if ($confKey !== null) {
                     $value = $this->plugin->getConfiguration()->getProperty($confKey, null);
                     if ($value !== null) {
                         $renderParams->set($key, $value);
                     }
                     unset($value);
                 }
                 unset($confKey);
             }
             unset($key, $i1);
         }
         $h = new com_wiris_plugin_impl_HttpImpl($this->plugin->getImageServiceURL(null), null);
         $h->setHeader("Content-Type", "application/x-www-form-urlencoded");
         $this->plugin->addReferer($h);
         $this->plugin->addProxy($h);
         $iter = $renderParams->keys();
         while ($iter->hasNext()) {
             $key = $iter->next();
             $h->setParameter($key, $renderParams->get($key));
             unset($key);
         }
         $this->digest = $digest;
         $this->call = $call;
         com_wiris_plugin_asyncimpl_HttpPostAndContinue::doPost($h, $this, "onData");
     } else {
         $call->returnBytes($bs);
     }
 }