public function setMarked($marked)
{
$this->marked = $this->isMultiple() ? array() : null;
if (is_array($marked)) {
foreach ($marked as $v) {
if (is_array($this->value)) {
$inArray = false;
foreach ($this->value as $key => $val) {
if ($key == $v) {
$inArray = true;
} else {
if (is_array($val)) {
foreach ($val as $ky => $va) {
if ($ky == $v) {
$inArray = true;
}
}
}
}
}
if ($inArray) {
$val = null;
if (!isset($this->value[$v])) {
foreach ($this->value as $vl) {
if (is_array($vl) && isset($vl[$v])) {
$val = $v;
}
}
} else {
$val = $v;
}
if (is_array($this->marked)) {
$this->marked[] = $val;
} else {
$this->marked = $val;
}
}
}
}
} else {
if (is_array($this->value)) {
if (array_key_exists($marked, $this->value) !== false) {
if (is_array($this->marked)) {
$this->marked[] = $marked;
} else {
$this->marked = $marked;
}
}
}
}
//print_r($this->marked);
return $this;
}