app('tpl'); } else { load()->web('tpl'); } function tpl_form_field_date($name, $value = '', $withtime = false) { return _tpl_form_field_date($name, $value, $withtime); } function tpl_form_field_clock($name, $value = '') { $s = ''; if(!defined('TPL_INIT_CLOCK_TIME')) { $s .= ' '; define('TPL_INIT_CLOCK_TIME', 1); } $time = date('H:i'); if(!empty($value)) { if(!strexists($value, ':')) { $time = date('H:i', $value); } else { $time = $value; } } $s .= '
'; return $s; } function tpl_form_field_daterange($name, $value = array(), $time = false) { $s = ''; if (empty($time) && !defined('TPL_INIT_DATERANGE_DATE')) { $s = ' '; define('TPL_INIT_DATERANGE_DATE', true); } if (!empty($time) && !defined('TPL_INIT_DATERANGE_TIME')) { $s = ' '; define('TPL_INIT_DATERANGE_TIME', true); } if ($value['starttime'] !== false && $value['start'] !== false) { if($value['start']) { $value['starttime'] = empty($time) ? date('Y-m-d',strtotime($value['start'])) : date('Y-m-d H:i',strtotime($value['start'])); } $value['starttime'] = empty($value['starttime']) ? (empty($time) ? date('Y-m-d') : date('Y-m-d H:i') ): $value['starttime']; } else { $value['starttime'] = '请选择'; } if ($value['endtime'] !== false && $value['end'] !== false) { if($value['end']) { $value['endtime'] = empty($time) ? date('Y-m-d',strtotime($value['end'])) : date('Y-m-d H:i',strtotime($value['end'])); } $value['endtime'] = empty($value['endtime']) ? $value['starttime'] : $value['endtime']; } else { $value['endtime'] = '请选择'; } $s .= ' '; return $s; } function tpl_form_field_calendar($name, $values = array()) { $html = ''; if (!defined('TPL_INIT_CALENDAR')) { $html .= ' '; define('TPL_INIT_CALENDAR', true); } if (empty($values) || !is_array($values)) { $values = array(0,0,0); } $values['year'] = intval($values['year']); $values['month'] = intval($values['month']); $values['day'] = intval($values['day']); if (empty($values['year'])) { $values['year'] = '1980'; } $year = array(date('Y'), '1914'); $html .= '
'; return $html; } function tpl_form_field_district($name, $values = array()) { $html = ''; if (!defined('TPL_INIT_DISTRICT')) { $html .= ' '; define('TPL_INIT_DISTRICT', true); } if (empty($values) || !is_array($values)) { $values = array('province'=>'','city'=>'','district'=>''); } if(empty($values['province'])) { $values['province'] = ''; } if(empty($values['city'])) { $values['city'] = ''; } if(empty($values['district'])) { $values['district'] = ''; } $html .= '
'; return $html; } function tpl_form_field_category_2level($name, $parents, $children, $parentid, $childid){ $html = ' '; if (!defined('TPL_INIT_CATEGORY')) { $html .= ' '; define('TPL_INIT_CATEGORY', true); } $html .= '
'; return $html; } function tpl_form_field_industry($name, $pvalue = '', $cvalue = '', $parentid = 'industry_1', $childid = 'industry_2'){ $html = '
'; return $html; } function tpl_form_field_coordinate($field, $value = array()) { $s = ''; if(!defined('TPL_INIT_COORDINATE')) { $s .= ''; define('TPL_INIT_COORDINATE', true); } $s .= '
'; return $s; } function tpl_fans_form($field, $value = '') { switch ($field) { case 'avatar': $avatar_url = '../attachment/images/global/avatars/'; $html = ''; if (!defined('TPL_INIT_AVATAR')) { $html .= ' '; define('TPL_INIT_AVATAR', true); } if (!defined('TPL_INIT_IMAGE')) { global $_W; if (defined('IN_MOBILE')) { $html .= << // in mobile function showImageDialog(elm) { require(["jquery", "util"], function($, util){ var btn = $(elm); var ipt = btn.parent().prev(); var val = ipt.val(); var img = ipt.parent().next().children(); util.image(elm, function(url){ img.get(0).src = url.url; ipt.val(url.attachment); }); }); } EOF; } else { $html .= << // in web function showImageDialog(elm, opts) { require(["util"], function(util){ var btn = $(elm); var ipt = btn.parent().prev(); var val = ipt.val(); var img = ipt.parent().next().find('img'); util.image(val, function(url){ img.get(0).src = url.url; ipt.val(url.attachment); }, {multiple:false,type:"image",direct:true}, opts); }); } EOF; } define('TPL_INIT_IMAGE', true); } $val = './resource/images/nopic.jpg'; if (!empty($value)) { $val = tomedia($value); } $options = array(); $options['width'] = '200'; $options['height'] = '200'; if (defined('IN_MOBILE')) { $html .= <<
EOF; } else { $html .= '
'; } break; case 'birth': case 'birthyear': case 'birthmonth': case 'birthday': $html = tpl_form_field_calendar('birth', $value); break; case 'reside': case 'resideprovince': case 'residecity': case 'residedist': $html = tpl_form_field_district('reside', $value); break; case 'bio': case 'interest': $html = ''; break; case 'gender': $html = ' '; break; case 'education': case 'constellation': case 'zodiac': case 'bloodtype': if ($field == 'bloodtype') { $options = array('A', 'B', 'AB', 'O', '其它'); } elseif ($field == 'zodiac') { $options = array('鼠', '牛', '虎', '兔', '龙', '蛇', '马', '羊', '猴', '鸡', '狗', '猪'); } elseif ($field == 'constellation') { $options = array('水瓶座', '双鱼座', '白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座'); } elseif ($field == 'education') { $options = array('博士', '硕士', '本科', '专科', '中学', '小学', '其它'); } $html = ''; break; case 'nickname': case 'realname': case 'address': case 'mobile': case 'qq': case 'msn': case 'email': case 'telephone': case 'taobao': case 'alipay': case 'studentid': case 'grade': case 'graduateschool': case 'idcard': case 'zipcode': case 'site': case 'affectivestatus': case 'lookingfor': case 'nationality': case 'height': case 'weight': case 'company': case 'occupation': case 'position': case 'revenue': default: $html = ''; break; } return $html; }