fieldtype = ['TEXT' => '']; // TRUE表全部可用字段类型,自定义格式为 array('可用字段类型名称' => '默认长度', ... )
$this->defaulttype = 'TEXT'; // 当用户没有选择字段类型时的缺省值
}
/**
* 字段相关属性参数
*
* @param array $value 值
* @return string
*/
public function option($option) {
$group = '
';
foreach (\Phpcmf\Service::C()->member_cache['group'] as $t) {
$group.= '';
}
$group.= '
';
return [$this->_search_field().'
'];
}
/**
* 字段输出
*/
public function output($value) {
return $value;
}
/**
* 字段入库值
*/
public function insert_value($field) {
$data = \Phpcmf\Service::L('Field')->post[$field['fieldname']];
$value = !$data ? '' : implode(',', $data);
\Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = $value;
}
/**
* 字段表单输入
*
* @param string $cname 字段别名
* @param string $name 字段名称
* @param array $cfg 字段配置
* @param string $value 值
* @return string
*/
public function input($field, $value = '') {
// 字段禁止修改时就返回显示字符串
if ($this->_not_edit($field, $value)) {
return $this->show($field, $value);
}
$is_show = 0;
// 字段存储名称
$name = $field['fieldname'];
// 字段提示信息
$tips = isset($field['setting']['validate']['tips']) && $field['setting']['validate']['tips'] ? ''.$field['setting']['validate']['tips'].'' : '';
// 区域大小
$area = \Phpcmf\Service::IS_MOBILE_USER() ? '["95%", "90%"]' : '["50%", "65%"]';
// 选择数量限制
$limit = intval($field['setting']['option']['limit']);
!$limit && $limit = 99999;
// 字段显示名称
$text = ($field['setting']['validate']['required'] ? ' * ' : '').dr_lang($field['name']);
$value = $value ? trim($value, ',') : '';
$mylist = [];
if ($value && is_string($value)) {
$arr = explode(',', $value);
if ($arr) {
$value = '';
foreach ($arr as $a) {
$a = intval($a);
if ($a) {
$value .= ',' . $a;
}
}
if ($value) {
$value = trim($value, ',');
$db = \Phpcmf\Service::M()->db->query('select * from '.\Phpcmf\Service::M()->dbprefix('member').' where id IN ('.$value.') order by FIELD(id, '.$value.')');
$mylist = $db ? $db->getResultArray() : [];
}
}
}
$file = \Phpcmf\Service::V()->code2php(
file_get_contents(is_file(MYPATH.'View/api_members_field_'.$field['fieldname'].'.html') ? MYPATH.'View/api_members_field_'.$field['fieldname'].'.html' : COREPATH.'View/api_members_field.html')
);
ob_start();
require $file;
$str = ob_get_clean();
$str.= $tips;
$js = \Phpcmf\Service::L('js_packer');
$str.= $js->pack('
', 0);
return $this->input_format($name, $text, $str);
}
/**
* 字段表单显示
*
* @param string $field 字段数组
* @param array $value 值
* @return string
*/
public function show($field, $value = null) {
$value = @trim($value, ',');
$mylist = [];
$is_show = 1;
if ($value && is_string($value)) {
$arr = explode(',', $value);
if ($arr) {
$value = '';
foreach ($arr as $a) {
$a = intval($a);
if ($a) {
$value .= ',' . $a;
}
}
if ($value) {
$value = trim($value, ',');
$db = \Phpcmf\Service::M()->db->query('select * from '.\Phpcmf\Service::M()->dbprefix('member').' where id IN ('.$value.') order by FIELD(id, '.$value.')');
$mylist = $db ? $db->getResultArray() : [];
}
}
}
$file = \Phpcmf\Service::V()->code2php(
file_get_contents(is_file(MYPATH.'View/api_members_field_'.$field['fieldname'].'.html') ? MYPATH.'View/api_members_field_'.$field['fieldname'].'.html' : COREPATH.'View/api_members_field.html')
);
ob_start();
require $file;
$str = ob_get_clean();
return $this->input_format($field['fieldname'], $field['name'], $str);
}
}