Esempio 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);
 }
Esempio n. 2
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);
 }
Esempio n. 3
0
 static function nonAsciiToEntities($s)
 {
     $sb = new StringBuf();
     $i = 0;
     $n = strlen($s);
     while ($i < $n) {
         $c = com_wiris_util_xml_WXmlUtils::getUtf8Char($s, $i);
         if ($c > 127) {
             $hex = com_wiris_common_WInteger::toHex($c, 5);
             $j = 0;
             while ($j < strlen($hex)) {
                 if (!(_hx_substr($hex, $j, 1) === "0")) {
                     $hex = _hx_substr($hex, $j, null);
                     break;
                 }
                 ++$j;
             }
             $sb->add("&#x" . $hex . ";");
             $i += strlen(com_wiris_util_xml_WXmlUtils_5($c, $hex, $i, $j, $n, $s, $sb));
             unset($j, $hex);
         } else {
             $sb->b .= chr($c);
             $i++;
         }
         unset($c);
     }
     return $sb->b;
 }
Esempio n. 4
0
 static function getDepth($o)
 {
     if (com_wiris_system_TypeTools::isHash($o)) {
         $h = $o;
         $m = 0;
         if ($h->exists("_left_") || $h->exists("_right_")) {
             if ($h->exists("_left_")) {
                 $m = com_wiris_common_WInteger::max(com_wiris_util_json_JSon::getDepth($h->get("_left_")), $m);
             }
             if ($h->exists("_right_")) {
                 $m = com_wiris_common_WInteger::max(com_wiris_util_json_JSon::getDepth($h->get("_right_")), $m);
             }
             return $m;
         }
         $iter = $h->keys();
         while ($iter->hasNext()) {
             $key = $iter->next();
             $m = com_wiris_common_WInteger::max(com_wiris_util_json_JSon::getDepth($h->get($key)), $m);
             unset($key);
         }
         return $m + 2;
     } else {
         if (com_wiris_system_TypeTools::isArray($o)) {
             $a = $o;
             $i = null;
             $m = 0;
             $_g1 = 0;
             $_g = $a->length;
             while ($_g1 < $_g) {
                 $i1 = $_g1++;
                 $m = com_wiris_common_WInteger::max(com_wiris_util_json_JSon::getDepth($a[$i1]), $m);
                 unset($i1);
             }
             return $m + 1;
         } else {
             return 1;
         }
     }
 }
 static function nonAsciiToEntities($s)
 {
     $sb = new StringBuf();
     $i = 0;
     $n = strlen($s);
     while ($i < $n) {
         $c = com_wiris_util_xml_WXmlUtils::getUtf8Char($s, $i);
         if ($c > 127) {
             $sb->add("&#x" . com_wiris_common_WInteger::toHex($c, 5) . ";");
             $i += strlen(com_wiris_util_xml_WXmlUtils_5($c, $i, $n, $s, $sb));
         } else {
             $sb->b .= chr($c);
             $i++;
         }
         unset($c);
     }
     return $sb->b;
 }