public function getMathML($digest, $latex) { if ($digest !== null) { $content = $this->plugin->getStorageAndCache()->decodeDigest($digest); if ($content !== null) { if (StringTools::startsWith($content, "<")) { $breakline = null; $breakline = _hx_index_of($content, "\n", 0); return _hx_substr($content, 0, $breakline); } else { $iniFile = com_wiris_util_sys_IniFile::newIniFileFromString($content); $mathml = $iniFile->getProperties()->get("mml"); if ($mathml !== null) { return $mathml; } else { return "Error: mathml not found."; } } } else { return "Error: formula not found."; } } else { if ($latex !== null) { return $this->latex2mathml($latex); } else { return "Error: no digest or latex has been sent."; } } }
public function flush() { if (!$this->_flushedStatus) { $this->_flushedStatus = true; php_Web::setReturnCode($this->status); } if (!$this->_flushedCookies) { $this->_flushedCookies = true; try { if (null == $this->_cookies) { throw new HException('null iterable'); } $__hx__it = $this->_cookies->iterator(); while ($__hx__it->hasNext()) { unset($cookie); $cookie = $__hx__it->next(); php_Web::setCookie($cookie->name, $cookie->value, $cookie->expires, $cookie->domain, $cookie->path, $cookie->secure, $cookie->httpOnly); } } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e = $_ex_; throw new HException(ufront_web_HttpError::internalServerError("Failed to set cookie on response", $e, _hx_anonymous(array("fileName" => "HttpResponse.hx", "lineNumber" => 34, "className" => "sys.ufront.web.context.HttpResponse", "methodName" => "flush")))); } } if (!$this->_flushedHeaders) { $this->_flushedHeaders = true; if (null == $this->_headers) { throw new HException('null iterable'); } $__hx__it = $this->_headers->keys(); while ($__hx__it->hasNext()) { unset($key); $key = $__hx__it->next(); $val = $this->_headers->get($key); if ($key === "Content-type" && null !== $this->charset && StringTools::startsWith($val, "text/")) { $val .= "; charset=" . _hx_string_or_null($this->charset); } try { header(_hx_string_or_null($key) . ": " . _hx_string_or_null($val)); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e1 = $_ex_; throw new HException(ufront_web_HttpError::internalServerError("Invalid header: \"" . _hx_string_or_null($key) . ": " . _hx_string_or_null($val) . "\", or output already sent", $e1, _hx_anonymous(array("fileName" => "HttpResponse.hx", "lineNumber" => 50, "className" => "sys.ufront.web.context.HttpResponse", "methodName" => "flush")))); } unset($val, $e1); } } if (!$this->_flushedContent) { $this->_flushedContent = true; Sys::hprint($this->_buff->b); } }
public function getImageServiceURL($service) { $protocol = null; $port = null; $url = null; $config = $this->getConfiguration(); $protocol = $config->getProperty(com_wiris_plugin_api_ConfigurationKeys::$SERVICE_PROTOCOL, null); $port = $config->getProperty(com_wiris_plugin_api_ConfigurationKeys::$SERVICE_PORT, null); $url = $config->getProperty(com_wiris_plugin_api_ConfigurationKeys::$INTEGRATION_PATH, null); if ($protocol === null && $url !== null) { if (StringTools::startsWith($url, "https")) { $protocol = "https"; } } if ($protocol === null) { $protocol = "http"; } if ($port !== null) { if ($protocol === "http") { if (!($port === "80")) { $port = ":" . $port; } else { $port = ""; } } if ($protocol === "https") { if (!($port === "443")) { $port = ":" . $port; } else { $port = ""; } } } else { $port = ""; } $domain = $config->getProperty(com_wiris_plugin_api_ConfigurationKeys::$SERVICE_HOST, null); $path = $config->getProperty(com_wiris_plugin_api_ConfigurationKeys::$SERVICE_PATH, null); if ($service !== null) { $end = _hx_last_index_of($path, "/", null); if ($end === -1) { $path = $service; } else { $path = _hx_substr($path, 0, $end) . "/" . $service; } } return $protocol . "://" . $domain . $port . $path; }
public function __construct($directory) { if (!php_Boot::$skip_constructor) { if (StringTools::startsWith($directory, "/")) { $directory = _hx_substr($directory, 1, strlen($directory)); } if (StringTools::endsWith($directory, "/")) { $directory = _hx_substr($directory, 0, strlen($directory) - 1); } $this->directory = $directory; if ($directory !== "") { $this->segments = _hx_explode("/", $directory); } else { $this->segments = new _hx_array(array()); } } }
public function loadPropertiesLine($line, $count) { $line = trim($line); if (strlen($line) === 0) { return; } if (StringTools::startsWith($line, ";") || StringTools::startsWith($line, "#")) { return; } $equals = _hx_index_of($line, "=", null); if ($equals === -1) { throw new HException("Malformed INI file " . $this->filename . " in line " . _hx_string_rec($count, "") . " no equal sign found."); } $key = _hx_substr($line, 0, $equals); $key = trim($key); $value = _hx_substr($line, $equals + 1, null); $value = trim($value); if (StringTools::startsWith($value, "\"") && StringTools::endsWith($value, "\"")) { $value = _hx_substr($value, 1, strlen($value) - 2); } $backslash = 0; while (($backslash = _hx_index_of($value, "\\", $backslash)) !== -1) { if (strlen($value) <= $backslash + 1) { continue; } $letter = _hx_substr($value, $backslash + 1, 1); if ($letter === "n") { $letter = "\n"; } else { if ($letter === "r") { $letter = "\r"; } else { if ($letter === "t") { $letter = "\t"; } } } $value = _hx_substr($value, 0, $backslash) . $letter . _hx_substr($value, $backslash + 2, null); $backslash++; unset($letter); } $this->props->set($key, $value); }
static function isInteger($str) { $str = trim($str); $i = 0; $n = strlen($str); if (StringTools::startsWith($str, "-")) { $i++; } if (StringTools::startsWith($str, "+")) { $i++; } $c = null; while ($i < $n) { $c = _hx_char_code_at($str, $i); if ($c < 48 || $c > 57) { return false; } $i++; } return true; }
public function injectConfig($context) { if ($context->injector->hasMappingForType("String", "sessionName")) { $this->sessionName = $context->injector->getValueForType("String", "sessionName"); } else { $this->sessionName = ufront_web_session_FileSession::$defaultSessionName; } if ($context->injector->hasMappingForType("Int", "sessionExpiry")) { $this->expiry = $context->injector->getValueForType("Int", "sessionExpiry"); } else { $this->expiry = ufront_web_session_FileSession::$defaultExpiry; } if ($context->injector->hasMappingForType("String", "sessionSavePath")) { $this->savePath = $context->injector->getValueForType("String", "sessionSavePath"); } else { $this->savePath = ufront_web_session_FileSession::$defaultSavePath; } $this->savePath = haxe_io_Path::addTrailingSlash($this->savePath); if (!StringTools::startsWith($this->savePath, "/")) { $this->savePath = _hx_string_or_null($context->get_contentDirectory()) . _hx_string_or_null($this->savePath); } }
function ufront_remoting_RemotingHandler_2(&$apiNotFoundMessages, &$args, &$doneTrigger, &$e, &$error, &$httpContext, &$path, &$r, &$remotingResponse, $msg) { return StringTools::startsWith($error, $msg); }
public function get_isPathAbsolute() { return StringTools::startsWith($this->path, "/"); }
public function showImage($digest, $mml, $param) { 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->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->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->computeDigest($mml, com_wiris_system_PropertiesTools::toProperties($renderParams)); } else { $digest = $this->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); $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); } $h->request(true); $b = haxe_io_Bytes::ofString($h->getData()); $store->storeData($digest, "png", $b->b); $bs = $b->b; } return $bs; }
static function htmlUnescape($input) { $output = ""; $start = 0; $position = _hx_index_of($input, "&", $start); while ($position !== -1) { $output .= _hx_substr($input, $start, $position - $start); if (_hx_char_at($input, $position + 1) === "#") { $startPosition = $position + 2; $endPosition = _hx_index_of($input, ";", $startPosition); if ($endPosition !== -1) { $number = _hx_substr($input, $startPosition, $endPosition - $startPosition); if (StringTools::startsWith($number, "x")) { $number = "0" . $number; } $charCode = Std::parseInt($number); $output .= com_wiris_util_xml_WXmlUtils_0($charCode, $endPosition, $input, $number, $output, $position, $start, $startPosition); $start = $endPosition + 1; unset($number, $charCode); } else { $output .= "&"; $start = $position + 1; } unset($startPosition, $endPosition); } else { $output .= "&"; $start = $position + 1; } $position = _hx_index_of($input, "&", $start); } $output .= _hx_substr($input, $start, strlen($input) - $start); $output = str_replace("<", "<", $output); $output = str_replace(">", ">", $output); $output = str_replace(""", "\"", $output); $output = str_replace("'", "'", $output); $output = str_replace("&", "&", $output); return $output; }
public function showImage($digest, $mml, $param) { 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->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->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->computeDigest($mml, com_wiris_system_PropertiesTools::toProperties($renderParams)); } else { $digest = $this->computeDigest($renderParams->get("mml"), com_wiris_system_PropertiesTools::toProperties($renderParams)); } } $store = $this->plugin->getStorageAndCache(); $bs = null; $bs = $store->retreiveData($digest, $this->plugin->getConfiguration()->getProperty("wirisimageformat", "png")); if ($bs === null) { if ($this->plugin->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$EDITOR_PARAMS, null) !== null) { $json = com_wiris_util_json_JSon::decode($this->plugin->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$EDITOR_PARAMS, null)); $decodedHash = $json; $keys = $decodedHash->keys(); $notAllowedParams = _hx_explode(",", com_wiris_plugin_api_ConfigurationKeys::$EDITOR_PARAMETERS_NOTRENDER_LIST); while ($keys->hasNext()) { $key = $keys->next(); if (!com_wiris_system_ArrayEx::contains($notAllowedParams, $key)) { $renderParams->set($key, $decodedHash->get($key)); } unset($key); } } else { $_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); } } $prop = com_wiris_system_PropertiesTools::toProperties($renderParams); $iter = $renderParams->keys(); $mml = $renderParams->get("mml"); $b = $this->render($this->plugin->getConfiguration()->getProperty("wirisimageformat", "png"), $mml, null, $prop, null); $store->storeData($digest, $this->plugin->getConfiguration()->getProperty("wirisimageformat", "png"), $b->b); $bs = $b->b; } return $bs; }
public function __construct($optionsIn = null) { if (!php_Boot::$skip_constructor) { $this->appTemplatingEngines = new HList(); $this->firstRun = true; parent::__construct(); $this->configuration = ufront_app_DefaultUfrontConfiguration::get(); $_g = 0; $_g1 = Reflect::fields($optionsIn); while ($_g < $_g1->length) { $field = $_g1[$_g]; ++$_g; $value = Reflect::field($optionsIn, $field); $this->configuration->{$field} = $value; unset($value, $field); } $this->mvcHandler = new ufront_web_MVCHandler($this->configuration->indexController); $this->remotingHandler = new ufront_remoting_RemotingHandler(); if ($this->configuration->remotingApi !== null) { $_this = $this->remotingHandler; $apiContext = $this->configuration->remotingApi; $_this->apiContexts->push($apiContext); $newAPIs = ufront_api_UFApiContext::getApisInContext($apiContext); if (null == $newAPIs) { throw new HException('null iterable'); } $__hx__it = $newAPIs->iterator(); while ($__hx__it->hasNext()) { unset($api); $api = $__hx__it->next(); $_this->apis->push($api); } } if (null == $this->configuration->controllers) { throw new HException('null iterable'); } $__hx__it = $this->configuration->controllers->iterator(); while ($__hx__it->hasNext()) { unset($controller); $controller = $__hx__it->next(); $this->injector->mapRuntimeTypeOf($controller, null)->_toClass($controller); } $this->addModule($this->requestMiddleware, null, $this->configuration->requestMiddleware, false); $this->addModule($this->requestHandlers, null, new _hx_array(array($this->remotingHandler, $this->mvcHandler)), false); $this->addModule($this->responseMiddleware, null, $this->configuration->responseMiddleware, true); $this->addModule($this->errorHandlers, null, $this->configuration->errorHandlers, false); if (!$this->configuration->disableServerTrace) { $logger = new ufront_log_ServerConsoleLogger(); $this->addModule($this->logHandlers, $logger, null, false); } if (!$this->configuration->disableBrowserTrace) { $logger1 = new ufront_log_BrowserConsoleLogger(); $this->addModule($this->logHandlers, $logger1, null, false); $logger2 = new ufront_log_RemotingLogger(); $this->addModule($this->logHandlers, $logger2, null, false); } if (null !== $this->configuration->logFile) { $logger3 = new ufront_log_FileLogger($this->configuration->logFile); $this->addModule($this->logHandlers, $logger3, null, false); } $path = $this->configuration->basePath; if (StringTools::endsWith($path, "/")) { $path = _hx_substr($path, 0, strlen($path) - 1); } if (StringTools::startsWith($path, "/")) { $path = _hx_substr($path, 1, null); } if (strlen($path) > 0) { parent::addUrlFilter(new ufront_web_url_filter_DirectoryUrlFilter($path)); } if ($this->configuration->urlRewrite !== true) { parent::addUrlFilter(new ufront_web_url_filter_PathInfoUrlFilter(null, null)); } if ($this->configuration->sessionImplementation !== null) { $this->injector->mapType("ufront.web.session.UFHttpSession", null, null)->_toClass($this->configuration->sessionImplementation); $this->injector->mapRuntimeTypeOf($this->configuration->sessionImplementation, null)->_toClass($this->configuration->sessionImplementation); } if ($this->configuration->authImplementation !== null) { $this->injector->mapType("ufront.auth.UFAuthHandler", null, null)->_toClass($this->configuration->authImplementation); $this->injector->mapRuntimeTypeOf($this->configuration->authImplementation, null)->_toClass($this->configuration->authImplementation); } if ($this->configuration->viewEngine !== null) { $this->injector->mapType("String", "viewPath", null)->toValue($this->configuration->viewPath); $this->injector->mapType("ufront.view.UFViewEngine", null, null)->_toSingleton($this->configuration->viewEngine); } if ($this->configuration->contentDirectory !== null) { $this->setContentDirectory($this->configuration->contentDirectory); } if ($this->configuration->defaultLayout !== null) { $this->injector->mapType("String", "defaultLayout", null)->toValue($this->configuration->defaultLayout); } $_g2 = 0; $_g11 = $this->configuration->templatingEngines; while ($_g2 < $_g11->length) { $te = $_g11[$_g2]; ++$_g2; $this->addTemplatingEngine($te); unset($te); } } }
public function isMultipart() { return ufront_web_context_HttpRequest_0($this) && StringTools::startsWith(ufront_core__MultiValueMap_MultiValueMap_Impl_::get($this->get_clientHeaders(), "Content-Type"), "multipart/form-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; }