Exemplo n.º 1
0
 public function getPositionRepresentation()
 {
     $i0 = com_wiris_common_WInteger::min($this->i, $this->n);
     $s0 = com_wiris_common_WInteger::max(0, $this->i - 20);
     $e0 = com_wiris_common_WInteger::min($this->n, $this->i + 20);
     return "..." . _hx_substr($this->str, $s0, $i0 - $s0) . " >>> . <<<" . _hx_substr($this->str, $i0, $e0);
 }
Exemplo n.º 2
0
 static function escapeArgument($arg)
 {
     $ok = true;
     $_g1 = 0;
     $_g = strlen($arg);
     while ($_g1 < $_g) {
         $i = $_g1++;
         switch (_hx_char_code_at($arg, $i)) {
             case 32:
             case 34:
                 $ok = false;
                 break;
             case 0:
             case 13:
             case 10:
                 $arg = _hx_substr($arg, 0, $i);
                 break;
         }
         unset($i);
     }
     if ($ok) {
         return $arg;
     }
     return "\"" . _hx_explode("\"", $arg)->join("\\\"") . "\"";
 }
Exemplo n.º 3
0
 static function now_in_colour($old_sql, $completed, $start, $end, $char = null)
 {
     $sql = $old_sql;
     $start -= 1;
     $done = _hx_substr($sql, 0, $completed);
     $left = _hx_substr($sql, $completed, $start - $completed);
     $middle = _hx_substr($sql, $start, $end - $start);
     $right = _hx_substr($sql, $end, null);
     if (system_base_Sql_colour::$SYMBOLS->match($left)) {
         $left = system_base_Sql_colour::$SYMBOLS->replace($left, "<span class=\"__symbs__ __bold__\">\$1</span>");
     }
     if (system_base_Sql_colour::$FUNCTIONS->match($left)) {
         $left = system_base_Sql_colour::$FUNCTIONS->replace($left, "<span class=\"__funcs__ __bold__\">\$1(</span>");
     }
     if (system_base_Sql_colour::$RESERVED->match($left)) {
         $left = system_base_Sql_colour::$RESERVED->replace($left, "<span class=\"__sqlv__ __bold__\"> \$1\$2 </span>");
     }
     if (!system_base_Sql_colour::$NUMBERS->match($left)) {
         $left = system_base_Sql_colour::$NUMBERS->replace($left, "<span class=\"__literal__\">\$1</span>");
     }
     if ($char === null) {
         $left = _hx_string_or_null($done) . _hx_string_or_null($left) . "<span class=\"__literal__\">" . _hx_string_or_null($middle) . "</span>";
     } else {
         $left = _hx_string_or_null($done) . _hx_string_or_null($left) . "<span class=\"__fields__\">" . _hx_string_or_null($middle) . "</span>";
     }
     return _hx_anonymous(array("position" => strlen($left), "string" => _hx_string_or_null($left) . _hx_string_or_null($right)));
 }
 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.";
         }
     }
 }
Exemplo n.º 5
0
 static function parseInt($x)
 {
     if (!is_numeric($x)) {
         return null;
     }
     return strtolower(_hx_substr($x, 0, 2)) == "0x" ? intval(substr($x, 2), 16) : intval($x);
 }
Exemplo n.º 6
0
 static function substring($s, $start, $end = null)
 {
     if ($end === null) {
         return _hx_substr($s, $start, null);
     }
     return _hx_substr($s, $start, $end - $start);
 }
Exemplo n.º 7
0
 public function matchedLeft()
 {
     if (count($this->matches) === 0) {
         throw new HException("No string matched");
     }
     return _hx_substr($this->last, 0, $this->matches[0][1]);
 }
Exemplo n.º 8
0
 static function get_RELATIVE()
 {
     if (zcale_core_path_targets_ServerPath::$relativePath === null) {
         zcale_core_path_targets_ServerPath::$relativePath = haxe_web_Request::getURI();
         zcale_core_path_targets_ServerPath::$relativePath = _hx_substr(zcale_core_path_targets_ServerPath::$relativePath, strlen(zcale_core_path_targets_ServerPath::get_FILE_DIR()), null);
     }
     return zcale_core_path_targets_ServerPath::$relativePath;
 }
Exemplo n.º 9
0
 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)));
 }
Exemplo n.º 10
0
 public function matchedRight()
 {
     if (count($this->matches) === 0) {
         throw new HException("No string matched");
     }
     $x = $this->matches[0][1] + strlen($this->matches[0][0]);
     return _hx_substr($this->last, $x, null);
 }
Exemplo n.º 11
0
 public function nextSafeToken()
 {
     if ($this->i < $this->n) {
         $this->c = haxe_Utf8::charCodeAt(_hx_substr($this->str, $this->i, null), 0);
         $this->i += strlen(com_wiris_util_json_StringParser_0($this));
     } else {
         $this->c = -1;
     }
 }
Exemplo n.º 12
0
 public function hpOfString($s)
 {
     $parts = _hx_explode(":", $s);
     if ($parts->length === 2) {
         return _hx_anonymous(array("host" => new sys_net_Host($parts[0]), "port" => Std::parseInt($parts[1])));
     } else {
         return _hx_anonymous(array("host" => new sys_net_Host(_hx_substr($parts[1], 2, null)), "port" => Std::parseInt($parts[2])));
     }
 }
Exemplo n.º 13
0
 public function escape($s)
 {
     $output = $this->pdo->quote($s, null);
     if (strlen($output) > 2) {
         return _hx_substr($output, 1, strlen($output) - 2);
     } else {
         return $output;
     }
 }
Exemplo n.º 14
0
 static function parseInt($x)
 {
     if (!is_numeric($x)) {
         $matches = null;
         preg_match("/^-?\\d+/", $x, $matches);
         return count($matches) === 0 ? null : intval($matches[0]);
     } else {
         return strtolower(_hx_substr($x, 0, 2)) === "0x" ? (int) hexdec(substr($x, 2)) : intval($x);
     }
 }
Exemplo n.º 15
0
 public function getCell($x, $y)
 {
     if ($x === 0) {
         $v = $this->getCellView();
         $txt = $v->toString($this->all->getCell($x, $y));
         if (_hx_char_at($txt, 0) === "@") {
             return _hx_substr($txt, 1, strlen($txt));
         }
     }
     return $this->all->getCell($x, $y);
 }
 static function formatMsg($m)
 {
     $extras = null;
     if (_hx_field($m, "pos") !== null && $m->pos->customParams !== null) {
         $extras = ", " . _hx_string_or_null($m->pos->customParams->join(", "));
     } else {
         $extras = "";
     }
     $type = _hx_substr(Type::enumConstructor($m->type), 1, null);
     return "" . _hx_string_or_null($type) . ": " . _hx_string_or_null($m->pos->className) . "." . _hx_string_or_null($m->pos->methodName) . "(" . _hx_string_rec($m->pos->lineNumber, "") . "): " . Std::string($m->msg) . _hx_string_or_null($extras);
 }
 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;
 }
 static function extractVersion($searchString, $s)
 {
     $index = _hx_index_of($s, $searchString, null);
     if ($index < 0) {
         return null;
     }
     $re = new EReg("(\\d+)\\.(\\d+)[^ ();]*", "");
     if (!$re->match(_hx_substr($s, $index + strlen($searchString) + 1, null))) {
         return null;
     }
     return _hx_anonymous(array("version" => $re->matched(0), "majorVersion" => Std::parseInt($re->matched(1)), "minorVersion" => Std::parseInt($re->matched(2))));
 }
Exemplo n.º 19
0
 static function joinValues($values)
 {
     $str = "";
     $_g = 0;
     while ($_g < $values->length) {
         $v = $values[$_g];
         ++$_g;
         $str .= "," . _hx_string_or_null(zcale_sys_db_SqlTools::evalValue($v));
         unset($v);
     }
     return _hx_substr($str, 1, null);
 }
Exemplo n.º 20
0
 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;
 }
Exemplo n.º 21
0
 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);
 }
Exemplo n.º 22
0
 public function insert_before($needle, $text)
 {
     $start = null;
     if (strlen($this->body) === 0) {
         return false;
     }
     $start = _hx_index_of($this->body, $needle, null);
     if ($start === -1) {
         return false;
     }
     $this->body = _hx_string_or_null(_hx_substr($this->body, 0, $start)) . _hx_string_or_null($text) . _hx_string_or_null(_hx_substr($this->body, $start, null));
     return true;
 }
Exemplo n.º 23
0
 public function getValueForType($type, $name = null)
 {
     $mapping = $this->findMappingForType($type, $name);
     if ($mapping !== null) {
         return $mapping->getValue($this);
     }
     $index = _hx_index_of($type, "<", null);
     if ($index > -1) {
         $mapping = $this->findMappingForType(_hx_substr($type, 0, $index), $name);
     }
     if ($mapping !== null) {
         return $mapping->getValue($this);
     }
     return null;
 }
 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());
         }
     }
 }
Exemplo n.º 25
0
 static function hex($n, $digits = null)
 {
     $s = dechex($n);
     $len = 8;
     if (strlen($s) > StringTools_0($digits, $len, $n, $s)) {
         $s = _hx_substr($s, -$len, null);
     } else {
         if ($digits !== null) {
             if (strlen("0") === 0 || strlen($s) >= $digits) {
                 $s = $s;
             } else {
                 $s = str_pad($s, Math::ceil(($digits - strlen($s)) / strlen("0")) * strlen("0") + strlen($s), "0", STR_PAD_LEFT);
             }
         }
     }
     return strtoupper($s);
 }
Exemplo n.º 26
0
 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);
 }
Exemplo n.º 27
0
 static function escapeArgument($arg)
 {
     $ok = true;
     $_g1 = 0;
     $_g = strlen($arg);
     while ($_g1 < $_g) {
         $i = $_g1++;
         $_g2 = _hx_char_code_at($arg, $i);
         if ($_g2 !== null) {
             switch ($_g2) {
                 case 32:
                 case 9:
                 case 34:
                 case 38:
                 case 124:
                 case 60:
                 case 62:
                 case 35:
                 case 59:
                 case 42:
                 case 63:
                 case 40:
                 case 41:
                 case 123:
                 case 125:
                 case 36:
                     $ok = false;
                     break;
                 case 0:
                 case 13:
                 case 10:
                     $arg = _hx_substr($arg, 0, $i);
                     break;
             }
         }
         unset($i, $_g2);
     }
     if ($ok) {
         return $arg;
     }
     return "\"" . _hx_string_or_null(_hx_explode("\"", _hx_explode("\\", $arg)->join("\\\\"))->join("\\\"")) . "\"";
 }
 static function quoteForDiff($v, $d)
 {
     $nil = "NULL";
     $str = $v->toString($d);
     $score = 0;
     $_g1 = 0;
     $_g = strlen($str);
     while ($_g1 < $_g) {
         $i = $_g1++;
         if (_hx_char_code_at($str, $score) !== 95) {
             break;
         }
         $score++;
         unset($i);
     }
     if (_hx_substr($str, $score, null) === $nil) {
         $str = "_" . _hx_string_or_null($str);
     }
     return $str;
 }
 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";
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 30
0
 public function load_view_object($view, $vars = null)
 {
     $base = isset(system_base_Wet_base::$get_instance) ? system_base_Wet_base::$get_instance : array("system_base_Wet_base", "get_instance");
     $viewpath = _hx_string_or_null(system_base_Wet_base::$views_path) . _hx_string_or_null($view) . ".wtv";
     $view1 = null;
     $pos = 0;
     $left = null;
     $right = null;
     $uservar = null;
     $fieldname = null;
     try {
         $view1 = sys_io_File::getContent($viewpath);
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         throw new HException(new system_base_NoFileError(_hx_string_or_null($viewpath) . " does not exist or cannot be opened for reading"));
     }
     if ($vars !== null) {
         $fields = Reflect::fields($vars);
         $_g = 0;
         while ($_g < $fields->length) {
             $fieldname1 = $fields[$_g];
             ++$_g;
             $uservar = Std::string(Reflect::field($vars, $fieldname1));
             $pos = 0;
             while (($pos = _hx_index_of($view1, "::" . _hx_string_or_null($fieldname1) . "::", $pos)) !== -1) {
                 $left = _hx_substr($view1, 0, $pos);
                 $right = _hx_substr($view1, $pos + strlen($fieldname1) + 4, null);
                 $view1 = _hx_string_or_null($left) . _hx_string_or_null($uservar) . _hx_string_or_null($right);
                 $pos += 1;
             }
             unset($fieldname1);
         }
     }
     $this->cache->append($view1);
 }