fieldtype = ['INT' => 10]; $this->defaulttype = 'INT'; } /** * 字段相关属性参数 * * @param array $value 值 * @return string */ public function option($option) { $style = '
'.dr_lang('[整数]表示固定宽度;[整数%]表示百分比').'
'.dr_lang('例如: fa fa-user').'
'.dr_lang('单击按钮时执行的js函数').'
'; return ['', $style]; } /** * 字段入库值 * * @param array $field 字段信息 * @return void */ public function insert_value($field) { // 格式化入库值 $value = \Phpcmf\Service::L('Field')->post[$field['fieldname']]; if ($value) { $value = \Phpcmf\Service::M('member')->uid($value); } \Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = $value; } /** * 字段表单输入 * * @param string $field 字段数组 * @param array $value 值 * @return string */ public function input($field, $value = null) { // 字段禁止修改时就返回显示字符串 if ($this->_not_edit($field, $value)) { return $this->show($field, $value); } // 字段默认值 if (dr_strlen($value)) { if (is_numeric($value)) { // 由uid获取用户名 $user = \Phpcmf\Service::M('member')->username($value); if ($user) { $value = $user; } } } else { $value = \Phpcmf\Service::C()->member ? \Phpcmf\Service::C()->member['username'] : ''; } // 字段存储名称 $name = $field['fieldname']; // 字段显示名称 $text = ($field['setting']['validate']['required'] ? ' * ' : '').dr_lang($field['name']); // 表单宽度设置 $width = \Phpcmf\Service::IS_MOBILE_USER() ? '100%' : ($field['setting']['option']['width'] ? $field['setting']['option']['width'] : 200); // 风格 $style = 'style="width:'.$width.(is_numeric($width) ? 'px' : '').';"'; // 表单附加参数 $attr = $field['setting']['validate']['formattr']; // 字段提示信息 $tips = $field['setting']['validate']['tips'] ? ''.$field['setting']['validate']['tips'].'' : ''; // 当字段必填时,加入html5验证标签 $required = $field['setting']['validate']['required'] ? ' required="required"' : ''; // 按钮颜色 $color = $field['setting']['option']['color'] ? $field['setting']['option']['color'] : 'default'; $ipt = ''; if (IS_ADMIN) { $str = '
'.$ipt.' '.dr_lang('资料').'
'; } else { $str = $ipt; } return $this->input_format($field['fieldname'], $text, $str.$tips); } /** * 字段表单显示 * * @param string $field 字段数组 * @param array $value 值 * @return string */ public function show($field, $value = null) { // 字段默认值 if ($value) { $value = \Phpcmf\Service::M('member')->author($value); } else { $value = \Phpcmf\Service::C()->member ? \Phpcmf\Service::C()->member['username'] : ''; } $str = '
'.htmlspecialchars_decode((string)$value).'
'; return $this->input_format($field['fieldname'], $field['name'], $str); } }