Esempio n. 1
0
function _format_data_range($name, $value_min, $value_max, $options = array())
{
    $raw = _option($options, 'raw', false);
    $separator = _option($options, 'separator', ' / ');
    $prefix_min = _option($options, 'prefix_min', '');
    $prefix_max = _option($options, 'prefix_max', '');
    $suffix = _option($options, 'suffix', '');
    if ($raw) {
        $text = '';
    } else {
        $text = content_tag('div', __($name), array('class' => 'section_subtitle', 'id' => '_' . $name, 'data-tooltip' => '')) . ' ';
    }
    $is_not_empty_value_min = check_is_numeric_or_text($value_min);
    $is_not_empty_value_max = check_is_numeric_or_text($value_max);
    if ($is_not_empty_value_min && $is_not_empty_value_max && $value_min == $value_max) {
        $text .= $value_min;
        if (!empty($suffix)) {
            $text .= __($suffix);
        }
    } else {
        if ($is_not_empty_value_min) {
            if (!empty($prefix_min)) {
                $text .= __($prefix_min);
            }
            $text .= $value_min;
            if (!empty($suffix)) {
                $text .= __($suffix);
            }
        }
        if ($is_not_empty_value_min && $is_not_empty_value_max) {
            $text .= __($separator);
        }
        if ($is_not_empty_value_max) {
            if (!empty($prefix_max)) {
                $text .= __($prefix_max);
            }
            $text .= $value_max;
            if (!empty($suffix)) {
                $text .= __($suffix);
            }
        }
    }
    return $text;
}
Esempio n. 2
0
function doctrine_value($value)
{
    return check_is_numeric_or_text($value) ? $value : null;
}