static function parse_file_path($fullpath) { $pos = _hx_last_index_of($fullpath, "/", null); if ($pos === -1) { return _hx_anonymous(array("pathname" => "", "filename" => "")); } return _hx_anonymous(array("pathname" => _hx_substr($fullpath, 0, $pos), "filename" => _hx_substr($fullpath, $pos + 1, null))); }
static function insertScriptsBeforeBodyTag($content, $scripts) { $script = $scripts->join(""); $bodyCloseIndex = _hx_last_index_of($content, "</body>", null); if ($bodyCloseIndex === -1) { $content .= _hx_string_or_null($script); } else { $content = _hx_string_or_null(_hx_substring($content, 0, $bodyCloseIndex)) . _hx_string_or_null($script) . _hx_string_or_null(_hx_substr($content, $bodyCloseIndex, null)); } return $content; }
public function checkFormat($name) { if ($this->extern_preference) { return $this->format_preference; } $ext = ""; if ($name !== null) { $pt = _hx_last_index_of($name, ".", null); if ($pt >= 0) { $ext = strtolower(_hx_substr($name, $pt + 1, null)); switch ($ext) { case "json": $this->format_preference = "json"; break; case "ndjson": $this->format_preference = "ndjson"; break; case "csv": $this->format_preference = "csv"; $this->delim_preference = ","; break; case "tsv": $this->format_preference = "csv"; $this->delim_preference = "\t"; break; case "ssv": $this->format_preference = "csv"; $this->delim_preference = ";"; break; case "sqlite3": $this->format_preference = "sqlite"; break; case "sqlite": $this->format_preference = "sqlite"; break; case "html": case "htm": $this->format_preference = "html"; break; case "www": $this->format_preference = "www"; break; default: $ext = ""; break; } } } $this->nested_output = $this->format_preference === "json" || $this->format_preference === "ndjson"; $this->order_preference = !$this->nested_output; return $ext; }
public function getParent() { $parent = com_wiris_util_sys_Store_0($this); if ($parent === null) { $parent = $this->file; } $i = com_wiris_common_WInteger::max(_hx_last_index_of($parent, "/", null), _hx_last_index_of($parent, "\\", null)); if ($i < 0) { return com_wiris_util_sys_Store::newStore("."); } $parent = _hx_substr($parent, 0, $i); return com_wiris_util_sys_Store::newStore($parent); }
public function getContentType($name) { $ext = _hx_substr($name, _hx_last_index_of($name, ".", null) + 1, null); if ($ext === "png") { return "image/png"; } else { if ($ext === "gif") { return "image/gif"; } else { if ($ext === "jpg" || $ext === "jpeg") { return "image/jpeg"; } else { if ($ext === "html" || $ext === "htm") { return "text/html"; } else { if ($ext === "css") { return "text/css"; } else { if ($ext === "js") { return "application/javascript"; } else { if ($ext === "txt") { return "text/plain"; } else { if ($ext === "ini") { return "text/plain"; } else { return "application/octet-stream"; } } } } } } } } }
function _hx_string_call($s, $method, $params) { if (!is_string($s)) { return call_user_func_array(array($s, $method), $params); } switch ($method) { case 'toUpperCase': return strtoupper($s); case 'toLowerCase': return strtolower($s); case 'charAt': return substr($s, $params[0], 1); case 'charCodeAt': return _hx_char_code_at($s, $params[0]); case 'indexOf': return _hx_index_of($s, $params[0], count($params) > 1 ? $params[1] : null); case 'lastIndexOf': return _hx_last_index_of($s, count($params) > 1 ? $params[1] : null, null); case 'split': return _hx_explode($params[0], $s); case 'substr': return _hx_substr($s, $params[0], count($params) > 1 ? $params[1] : null); case 'toString': return $s; default: throw new HException('Invalid Operation: ' . $method); } }
static function concatPath($s1, $s2) { if (_hx_last_index_of($s1, "/", null) === strlen($s1) - 1) { return $s1 . $s2; } else { return $s1 . "/" . $s2; } }
static function addTrailingSlash($path) { if (strlen($path) === 0) { return "/"; } $c1 = _hx_last_index_of($path, "/", null); $c2 = _hx_last_index_of($path, "\\", null); if ($c1 < $c2) { if ($c2 !== strlen($path) - 1) { return _hx_string_or_null($path) . "\\"; } else { return $path; } } else { if ($c1 !== strlen($path) - 1) { return _hx_string_or_null($path) . "/"; } else { return $path; } } }
static function removeExtension($path, $delimiter = null) { if ($delimiter === null) { $delimiter = "/"; } if (zcale_PathTools::hasExtension($path, $delimiter)) { $path = _hx_substr($path, 0, _hx_last_index_of($path, ".", null)); } return $path; }
public function filterMath($tags, $text, $prop, $safeXML) { $n0 = null; $n1 = null; $m0 = null; $m1 = null; $output = null; $sub = null; $output = new StringBuf(); $n0 = 0; $n1 = _hx_index_of($text, $tags->in_mathopen, $n0); $tag = $this->plugin->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$EDITOR_MATHML_ATTRIBUTE, "data-mathml"); $dataMathml = _hx_index_of($text, $tag, 0); while ($n1 >= 0) { $m0 = $n0; $output->add(_hx_substr($text, $n0, $n1 - $n0)); $n0 = $n1; $n1 = _hx_index_of($text, $tags->in_mathclose, $n0); if ($n1 >= 0) { $n1 = $n1 + strlen($tags->in_mathclose); $sub = _hx_substr($text, $n0, $n1 - $n0); if ($safeXML) { if ($dataMathml !== -1) { $m1 = _hx_index_of($text, "/>", $n1); if ($m1 >= 0 && (_hx_index_of($text, "<img", $n1) === -1 || _hx_index_of($text, "<img", $n1) > $m1)) { $m0 = _hx_last_index_of(_hx_substr($text, $m0, $n0 - $m0), "<img", null); if ($m0 >= 0) { if (_hx_index_of($text, $tag, $m0) > 0 && _hx_index_of($text, $tag, $m0) < $n1) { $n0 = $n1; $output->add($sub); $n1 = _hx_index_of($text, $tags->in_mathopen, $n0); $m0 = $m1; continue; } } } } if ($this->fixUrl === null) { $this->fixUrl = new EReg("<a href=\"[^\"]*\"[^>]*>([^<]*)<\\/a>|<a href=\"[^\"]*\">", ""); } $sub = $this->fixUrl->replace($sub, "\$1"); $sub = $this->html_entity_decode($sub); $sub = str_replace($tags->in_double_quote, $tags->out_double_quote, $sub); $sub = str_replace($tags->in_open, $tags->out_open, $sub); $sub = str_replace($tags->in_close, $tags->out_close, $sub); $sub = str_replace($tags->in_entity, $tags->out_entity, $sub); $sub = str_replace($tags->in_quote, $tags->out_quote, $sub); } $sub = $this->math2Img($sub, $prop); $n0 = $n1; $output->add($sub); $n1 = _hx_index_of($text, $tags->in_mathopen, $n0); } } $output->add(_hx_substr($text, $n0, null)); return $output->b; }
public function fast_body_is_closed() { return _hx_last_index_of($this->body, "</body>", null) !== -1; }
static function setResourcesDir() { $filedir = com_wiris_system_Storage::getCallerFile(); com_wiris_system_Storage::$resourcesDir = _hx_substr($filedir, 0, _hx_last_index_of($filedir, com_wiris_system_Storage::getDirectorySeparator() . "com" . com_wiris_system_Storage::getDirectorySeparator(), null)); }
public function getImageServiceURL($service, $stats) { $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; } } if ($stats) { $path = $this->addStats($path); } return $protocol . "://" . $domain . $port . $path; }
static function get_mime_type($path) { $ext = strtolower(_hx_substr($path, _hx_last_index_of($path, ".", null) + 1, null)); return Reflect::field(system_base_Cache::$mime_type, $ext); }