Пример #1
0
 /**
  * Класс для элемента формы
  * @param $name
  * @return string
  */
 function cot_formGroupClass($name)
 {
     global $cfg;
     $error = $cfg['msg_separate'] ? cot_implode_messages($name, 'error') : '';
     if ($error) {
         return 'has-error';
     }
     return '';
 }
Пример #2
0
/**
 * Generates a form input file from a resource string
 *
 * @param string $name Input name
 * @param string $value Entered value
 * @param string $filepath Entered filepath if defferent from value
 * @param string $delname  Delete file chechbox name
 * @param mixed $attrs Additional attributes as an associative array or a string
 * @param string $custom_rc Custom resource string name
 * @return string
 */
function cot_filebox($name, $value = '', $filepath = '', $delname = '', $attrs = '', $custom_rc = '')
{
    global $R, $cfg;
    $input_attrs = cot_rc_attr_string($attrs);
    $rc_name = preg_match('#^(\\w+)\\[(.*?)\\]$#', $name, $mt) ? $mt[1] : $name;
    $custom_rc = explode('|', $custom_rc, 2);
    if (empty($value)) {
        $rc = empty($R["input_filebox_{$rc_name}_empty"]) ? empty($custom_rc[1]) ? 'input_filebox_empty' : $custom_rc[1] : "input_filebox_{$rc_name}_empty";
    } else {
        $rc = empty($R["input_filebox_{$rc_name}"]) ? empty($custom_rc[0]) ? 'input_filebox' : $custom_rc[0] : "input_filebox_{$rc_name}";
    }
    $filepath = empty($filepath) ? $value : $filepath;
    $delname = empty($delname) ? 'del' . $name : $delname;
    $error = $cfg['msg_separate'] ? cot_implode_messages($name, 'error') : '';
    return cot_rc($rc, array('name' => $name, 'filepath' => $filepath, 'delname' => $delname, 'value' => $value, 'attrs' => $input_attrs, 'error' => $error));
}