public function is($field, $value, $id = null)
{
$pod =& $this;
if (null === $id) {
$id = $this->id();
} elseif ($id != $this->id()) {
$pod = pods($this->pod, $id);
}
$this->do_hook('is', $field, $value, $id);
if (!isset($this->fields[$field])) {
return false;
}
// Tableless fields
if (in_array($this->fields[$field]['type'], PodsForm::tableless_field_types())) {
if (!is_array($value)) {
$value = explode(',', $value);
}
$current_value = array();
if ('pick' == $this->fields[$field]['type'] && in_array($this->fields[$field]['pick_object'], PodsForm::simple_tableless_objects())) {
$current_value = $pod->raw($field);
if (!empty($current_value)) {
$current_value = (array) $current_value;
}
foreach ($current_value as $v) {
if (in_array($v, $value)) {
return true;
}
}
} else {
$related_ids = $this->api->lookup_related_items($this->fields[$field]['id'], $this->pod_data['id'], $id, $this->fields[$field], $this->pod_data);
foreach ($value as $k => $v) {
if (!preg_match('/[^0-9]/', $v)) {
$value[$k] = (int) $v;
} else {
}
}
foreach ($related_ids as $v) {
if (in_array($v, $value)) {
return true;
}
}
}
if (!empty($current_value)) {
$current_value = array_filter(array_unique($current_value));
} else {
$current_value = array();
}
if (!empty($value)) {
$value = array_filter(array_unique($value));
} else {
$value = array();
}
sort($current_value);
sort($value);
if ($value === $current_value) {
return true;
}
} elseif (in_array($this->fields[$field]['type'], PodsForm::number_field_types())) {
$current_value = $pod->raw($field);
if ((double) $current_value === (double) $value) {
return true;
}
} elseif (in_array($this->fields[$field]['type'], PodsForm::date_field_types())) {
$current_value = $pod->raw($field);
if (0 < strlen($current_value)) {
if (strtotime($current_value) == strtotime($value)) {
return true;
}
} elseif (empty($value)) {
return true;
}
} elseif (in_array($this->fields[$field]['type'], PodsForm::text_field_types())) {
$current_value = $pod->raw($field);
if ((string) $current_value === (string) $value) {
return true;
}
} else {
$current_value = $pod->raw($field);
if ($current_value === $value) {
return true;
}
}
return false;
}