示例#1
0
 function convertBoolean($booleanstring)
 {
     return str_bool($booleanstring);
 }
示例#2
0
function checkbox($path, $value = null, $options = array())
{
    $result = '';
    $name = _get_complete_bind_path($path);
    $bindStatus =& new BindStatus(_get_bind_path($path));
    $boundValue = $bindStatus->getValue();
    $valueType = $bindStatus->getValueType();
    if (str_equals_icase($valueType, 'boolean')) {
        if (is_string($boundValue)) {
            $boundValue = str_bool($boundValue);
        }
        $booleanValue = $boundValue != null ? $boundValue : false;
        $result .= checkbox_tag($name, 'true', $booleanValue, $options);
    } else {
        assert_not_null($value, "Attribute 'value' is required when binding to non-boolean values");
        $result .= checkbox_tag($name, specialchars($value, true), SelectedValueComparator::isSelected($bindStatus, $value), $options);
    }
    if (!isset($options['disabled']) || $options['disabled'] != 'disabled') {
        $result .= input_hidden_tag('_' . $name, '1');
    }
    return $result;
}
示例#3
0
function str_is_bool($text)
{
    return str_bool($text) !== null;
}
示例#4
0
 function getBooleanParameters(&$request, $parameterName)
 {
     $values = $request->getParameter($parameterName);
     if (!is_array($values)) {
         return array(RequestUtils::getBooleanParameter($request, $parameterName));
     }
     $result = array();
     foreach ((array) $values as $key => $value) {
         if ($value === null || !str_is_bool($value)) {
             show_error('Error', "Parameter '{$parameterName}[{$key}]' with value of '{$value}' is not a valid boolean expression.");
         }
         $result[$key] = str_bool($value);
     }
     return $result;
 }