Пример #1
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;
         }
     }
 }