public function start() { if (!$this->isRunning) { $this->isRunning = true; $this->phpStart(); com_wiris_system_Storage::$resourcesDir = null; } }
public function loadINI() { $s = com_wiris_system_Storage::newStorage($this->filename); if (!$s->exists()) { $s = com_wiris_system_Storage::newResourceStorage($this->filename); } try { $file = $s->read(); if ($file !== null) { $this->loadProperties($file); } } catch (Exception $»e) { $_ex_ = $»e instanceof HException ? $»e->e : $»e; $e = $_ex_; } }
public function updateConfiguration(&$configuration) { $configuration = $configuration; $s = com_wiris_system_Storage::newResourceStorage("default-configuration.ini")->read(); $defaultIniFile = com_wiris_util_sys_IniFile::newIniFileFromString($s); $h = $defaultIniFile->getProperties(); $iter = $h->keys(); while ($iter->hasNext()) { $key = null; $key = $iter->next(); if (com_wiris_system_PropertiesTools::getProperty($configuration, $key, null) === null) { $configuration[$key] = $h->get($key); } unset($key); } }
public function addCorsHeaders($response, $origin) { $conf = $this->getConfiguration(); if ($conf->getProperty("wiriscorsenabled", "false") === "true") { $confDir = $conf->getProperty(com_wiris_plugin_api_ConfigurationKeys::$CONFIGURATION_PATH, null); $corsConfFile = $confDir . "/corsservers.ini"; $s = com_wiris_system_Storage::newStorage($corsConfFile); if ($s->exists()) { $dir = $s->read(); $allowedHosts = _hx_explode("\n", $dir); if (com_wiris_system_ArrayEx::contains($allowedHosts, $origin)) { $response->setHeader("Access-Control-Allow-Origin", $origin); } } else { $response->setHeader("Access-Control-Allow-Origin", "*"); } } }
public function updateConfiguration(&$configuration) { $configuration = $configuration; $confDir = com_wiris_system_PropertiesTools::getProperty($configuration, com_wiris_plugin_api_ConfigurationKeys::$CONFIGURATION_PATH, null); if ($confDir !== null) { $confFile = $confDir . "/configuration.ini"; $s = com_wiris_system_Storage::newStorage($confFile); if ($s->exists()) { $defaultIniFile = com_wiris_util_sys_IniFile::newIniFileFromFilename($confFile); $h = $defaultIniFile->getProperties(); $iter = $h->keys(); while ($iter->hasNext()) { $key = null; $key = $iter->next(); $configuration[$key] = $h->get($key); unset($key); } } } }
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 getJavaScriptConfiguration() { $sb = new StringBuf(); $arrayParse = "[]"; $this->appendVarJs($sb, "_wrs_conf_editorEnabled", $this->getProperty("wiriseditorenabled", null), "Specifies if fomula editor is enabled"); $this->appendVarJs($sb, "_wrs_conf_imageMathmlAttribute", "'" . $this->getProperty("wiriseditormathmlattribute", null) . "'", "Specifies the image tag where we should save the formula editor mathml code"); $this->appendVarJs($sb, "_wrs_conf_saveMode", "'" . $this->getProperty("wiriseditorsavemode", null) . "'", "This value can be 'xml', 'safeXml', 'image' or 'base64'"); $this->appendVarJs($sb, "_wrs_conf_editMode", "'" . $this->getProperty("wiriseditoreditmode", null) . "'", "This value can be 'default' or 'image'"); if ($this->getProperty("wiriseditorparselatex", null) === "true") { $arrayParse = $this->appendElement2JavascriptArray($arrayParse, "latex"); } if ($this->getProperty("wiriseditorparsexml", null) === "true") { $arrayParse = $this->appendElement2JavascriptArray($arrayParse, "xml"); } $this->appendVarJs($sb, "_wrs_conf_parseModes", $arrayParse, "This value can contain 'latex' and 'xml)"); $this->appendVarJs($sb, "_wrs_conf_editorAttributes", "'" . $this->getProperty("wiriseditorwindowattributes", null) . "'", "Specifies formula editor window options"); $this->appendVarJs($sb, "_wrs_conf_editorUrl", "'" . $this->plugin->getImageServiceURL("editor", false) . "'", "WIRIS editor"); $this->appendVarJs($sb, "_wrs_conf_modalWindow", $this->getProperty("wiriseditormodalwindow", null), "Editor modal window"); $this->appendVarJs($sb, "_wrs_conf_CASEnabled", $this->getProperty("wiriscasenabled", null), "Specifies if WIRIS cas is enabled"); $this->appendVarJs($sb, "_wrs_conf_CASMathmlAttribute", "'" . $this->getProperty("wiriscasmathmlattribute", null) . "'", "Specifies the image tag where we should save the WIRIS cas mathml code"); $this->appendVarJs($sb, "_wrs_conf_CASAttributes", "'" . $this->getProperty("wiriscaswindowattributes", null) . "'", "Specifies WIRIS cas window options"); $this->appendVarJs($sb, "_wrs_conf_hostPlatform", "'" . $this->getProperty("wirishostplatform", null) . "'", "Specifies host platform"); $this->appendVarJs($sb, "_wrs_conf_versionPlatform", "'" . $this->getProperty("wirisversionplatform", "unknown") . "'", "Specifies host version platform"); $this->appendVarJs($sb, "_wrs_conf_enableAccessibility", $this->getProperty("wirisaccessibilityenabled", null), "Specifies whether accessibility is enabled"); $this->appendVarJs($sb, "_wrs_conf_setSize", $this->getProperty("wiriseditorsetsize", null), "Specifies whether to set the size of the images at edition time"); $this->appendVarJs($sb, "_wrs_conf_editorToolbar", "'" . $this->getProperty(com_wiris_plugin_api_ConfigurationKeys::$EDITOR_TOOLBAR, null) . "'", "Toolbar definition"); $this->appendVarJs($sb, "_wrs_conf_chemEnabled", $this->getProperty("wirischemeditorenabled", null), "Specifies if WIRIS chem editor is enabled"); if ($this->getProperty(com_wiris_plugin_api_ConfigurationKeys::$EDITOR_PARAMS, null) !== null) { $this->appendVarJs($sb, "_wrs_conf_editorParameters", $this->getProperty(com_wiris_plugin_api_ConfigurationKeys::$EDITOR_PARAMS, null), "Editor parameters"); } else { $h = com_wiris_plugin_api_ConfigurationKeys::$imageConfigPropertiesInv; $attributes = new StringBuf(); $confVal = ""; $i = 0; $it = $h->keys(); $value = null; while ($it->hasNext()) { $value = $it->next(); if ($this->getProperty($value, null) !== null) { if ($i !== 0) { $attributes->add(","); } $i++; $confVal = $this->getProperty($value, null); str_replace("-", "_", $confVal); str_replace("-", "_", $confVal); $attributes->add("'"); $attributes->add(com_wiris_plugin_api_ConfigurationKeys::$imageConfigPropertiesInv->get($value)); $attributes->add("' : '"); $attributes->add($confVal); $attributes->add("'"); } } $this->appendVarJs($sb, "_wrs_conf_editorParameters", "{" . $attributes->b . "}", "Editor parameters"); } $this->appendVarJs($sb, "_wrs_conf_wirisPluginPerformance", $this->getProperty("wirispluginperformance", null), "Experimental settings to improve performance"); $sb->add("var _wrs_conf_configuration_loaded = true;\r\n"); $sb->add("if (typeof _wrs_conf_core_loaded != 'undefined') _wrs_conf_plugin_loaded = true;\r\n"); $version = null; try { $version = com_wiris_system_Storage::newResourceStorage("VERSION")->read(); } catch (Exception $»e) { $_ex_ = $»e instanceof HException ? $»e->e : $»e; $ex = $_ex_; $version = "Missing version"; } $sb->add("var _wrs_conf_version = '" . $version . "';\r\n"); return $sb->b; }
static function setDirectorySeparator() { $sep = null; $sep = DIRECTORY_SEPARATOR; com_wiris_system_Storage::$directorySeparator = $sep; }
public function showCasImage($f, $outProp) { $formula = $f; if (StringTools::endsWith($formula, ".png")) { $formula = _hx_substr($formula, 0, strlen($formula) - 4); } $store = $this->plugin->getStorageAndCache(); $data = $store->retreiveData($formula, "png"); if ($data === null) { $data = com_wiris_system_Storage::newResourceStorage("cas.png")->readBinary(); if ($data === null) { throw new HException("Missing resource cas.png"); } } return $data; }
public function editor($language, $prop) { $output = new StringBuf(); if ($language === null || strlen($language) === 0) { $language = "en"; } $language = strtolower($language); str_replace("-", "_", $language); $store = com_wiris_system_Storage::newResourceStorage("lang/" . $language . "/strings.js"); if (!$store->exists()) { $store = com_wiris_system_Storage::newResourceStorage("lang/" . _hx_substr($language, 0, 2) . "/strings.js"); $language = _hx_substr($language, 0, 2); if (!$store->exists()) { $language = "en"; } } $attributes = new StringBuf(); $attributes->add(""); $confVal = ""; $i = 0; $config = $this->plugin->getConfiguration(); $h = com_wiris_plugin_api_ConfigurationKeys::$imageConfigPropertiesInv; $it = $h->keys(); $value = null; while ($it->hasNext()) { $value = $it->next(); if ($config->getProperty($value, null) !== null) { if ($i !== 0) { $attributes->add(","); } $i++; $confVal = $config->getProperty($value, null); str_replace("-", "_", $confVal); str_replace("-", "_", $confVal); $attributes->add("'"); $attributes->add(com_wiris_plugin_api_ConfigurationKeys::$imageConfigPropertiesInv->get($value)); $attributes->add("' : '"); $attributes->add($confVal); $attributes->add("'"); } } $script = new StringBuf(); if ($i > 0) { $script->add("<script type=\"text/javascript\">window.wrs_attributes = {"); $script->add($attributes); $script->add("};</script>"); } $editorUrl = $this->plugin->getImageServiceURL("editor"); $isSegure = com_wiris_system_PropertiesTools::getProperty($prop, "secure", "false") === "true"; if (StringTools::startsWith($editorUrl, "http:") && $isSegure) { $editorUrl = "https:" . _hx_substr($editorUrl, 5, null); } $this->addLine($output, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"); $this->addLine($output, "<html><head>"); $this->addLine($output, "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"/>"); $this->addLine($output, $script->b); $this->addLine($output, "<script type=\"text/javascript\" src=\"" . $editorUrl . "?lang=" . rawurlencode($language) . "\"></script>"); $this->addLine($output, "<script type=\"text/javascript\" src=\"../core/editor.js\"></script>"); $this->addLine($output, "<script type=\"text/javascript\" src=\"../lang/" . rawurlencode($language) . "/strings.js\"></script>"); $this->addLine($output, "<title>WIRIS editor</title>"); $this->addLine($output, "<style type=\"text/css\">/*<!--*/html, body, #container { height: 100%; } body { margin: 0; }"); $this->addLine($output, "#links { text-align: right; margin-right: 20px; } #links_rtl {text-align: left; margin-left: 20px;} #controls { float: left; } #controls_rtl {float: right;}/*-->*/</style>"); $this->addLine($output, "</head><body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">"); $this->addLine($output, "<div id=\"container\"><div id=\"editorContainer\"></div><div id=\"controls\"></div>"); $this->addLine($output, "<div id=\"links\"><a href=\"http://www.wiris.com/editor3/docs/manual/latex-support\" id=\"a_latex\" target=\"_blank\">LaTeX</a> | "); $this->addLine($output, "<a href=\"http://www.wiris.com/editor3/docs/manual\" target=\"_blank\" id=\"a_manual\">Manual</a></div></div></body>"); return $output->b; }
public function getContent($resource) { return com_wiris_system_Storage::newResourceStorage($resource)->read(); }