public function simple_value($name, $value = null, $options = null, $pod = null, $id = null, $raw = false)
{
if (in_array(pods_var(self::$type . '_object', $options), self::simple_objects())) {
if (isset($options['options'])) {
$options = array_merge($options, $options['options']);
unset($options['options']);
}
if (!is_array($value) && 0 < strlen($value)) {
$simple = @json_decode($value, true);
if (is_array($simple)) {
$value = $simple;
}
}
$data = pods_var_raw('data', $options, null, null, true);
$object_params = array('name' => $name, 'value' => $value, 'options' => $options, 'pod' => $pod, 'id' => $id, 'context' => 'simple_value');
if (null === $data) {
$data = $this->get_object_data($object_params);
}
$data = (array) $data;
$key = 0;
if (is_array($value)) {
if (!empty($data)) {
$val = array();
foreach ($value as $k => $v) {
if (isset($data[$v])) {
if (false === $raw) {
$k = $v;
$v = $data[$v];
}
$val[$k] = $v;
}
}
$value = $val;
}
} elseif (isset($data[$value]) && false === $raw) {
$key = $value;
$value = $data[$value];
}
$single_multi = pods_var(self::$type . '_format_type', $options, 'single');
if ('multi' == $single_multi) {
$limit = (int) pods_var(self::$type . '_limit', $options, 0);
} else {
$limit = 1;
}
if (is_array($value) && 0 < $limit) {
if (1 == $limit) {
$value = current($value);
} else {
$value = array_slice($value, 0, $limit, true);
}
} elseif (!is_array($value) && null !== $value && 0 < strlen($value)) {
if (1 != $limit || true === $raw && 'multi' == $single_multi) {
$value = array($key => $value);
}
}
}
return $value;
}