/** * Array with all the JS settings of the collection objects. * * @return array * All the JS settings of the collection objects. */ public function getJS() { $clone = clone $this; $settings = array(); foreach ($clone->objects as $type => $objects) { foreach ($objects as $object) { $settings[$type][] = $object->getJS(); } } $settings = array_map_recursive('_floatval_if_numeric', $settings); $settings = removeEmptyElements($settings); return $settings; }
function removeEmptyElements($array) { foreach ($array as $key => $value) { if (empty($value)) { unset($array[$key]); } else { if (is_array($value)) { $array[$key] = removeEmptyElements($value); } } } return $array; }
function readIdentifiers($str) { $returnMe = array(); if (count(isset($str))) { @($ev = evaluateSeparators($str)); if ($ev["SEMICOLON"] == 0 && $ev["COMMA"] == 0 && $ev["ALL"] == 0 && $ev["COLON"] == 0) { if (isset($str) && $str != "") { @($returnMe[] = $str); } } else { if ($ev["SEMICOLON"] == 1 && $ev["COMMA"] == 0 && $ev["ALL"] == 0 && $ev["COLON"] == 0) { if ($pos = strpos($str, ";")) { $dirty = substr($str, 0, $pos); $returnMe[] = $dirty; } } else { if ($ev["SEMICOLON"] == 0 && $ev["COMMA"] > 0 && $ev["COLON"] == 0) { $returnMe = explode(",", $str); } else { if ($ev["SEMICOLON"] == 1 && $ev["COMMA"] == 0 && $ev["COLON"] == 1) { if ($pos = strpos($str, ";")) { $dirty = substr($str, 0, $pos); $a = explode(":", $dirty); $returnMe[] = $a[1]; } } else { if ($ev["SEMICOLON"] > 1 && $ev["COMMA"] == 0 && $ev["ALL"] > 1 && $ev["COLON"] == 0) { $tmp = explode(";", $str); //remove any empty elements $tmp = removeEmptyElements($tmp); //remove things before the : foreach ($tmp as $x) { $a = explode(":", $x); if (count($a) == 2) { $returnMe[] = $a[1]; } else { $returnMe[] = $x; } } } else { if ($ev["SEMICOLON"] > 1 && $ev["COMMA"] == 0 && $ev["ALL"] > 1 && $ev["COLON"] > 1) { $tmp = explode(";", $str); //remove any empty elements $tmp = removeEmptyElements($tmp); //remove things before the : foreach ($tmp as $x) { $a = explode(":", $x); if (count($a) == 2) { $returnMe[] = $a[1]; } else { $returnMe[] = $x; } } } else { if ($ev["SEMICOLON"] > 1 && $ev["COMMA"] > 1 && $ev["BOTH"] > 1 && $ev["COLON"] > 1) { //use multiple explode $delims = array(",", ";"); $tmp = multipleExplode($delims, $str); //remove any empty elements $tmp = removeEmptyElements($tmp); $tmp2 = array(); foreach ($tmp as $x) { $a = explode(":", $x); if (count($a) == 2) { $tmp2[] = $a[1]; } else { $tmp2[] = $x; } } $returnMe = array_merge($returnMe, $tmp2); } } } } } } } } return $returnMe; }