本文整理汇总了PHP中S::isNatualValue方法的典型用法代码示例。如果您正苦于以下问题:PHP S::isNatualValue方法的具体用法?PHP S::isNatualValue怎么用?PHP S::isNatualValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类S
的用法示例。
在下文中一共展示了S::isNatualValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFieldValueHTML
function getFieldValueHTML($type, $fieldvalue, $rules)
{
if ($type == 'radio') {
$newradio = array();
foreach ($rules as $rk => $rv) {
$rv_value = substr($rv, 0, strpos($rv, '='));
$rv_name = substr($rv, strpos($rv, '=') + 1);
$newradio[$rv_value] = $rv_name;
}
$topicvalue .= "{$newradio[$fieldvalue]}";
} elseif ($type == 'checkbox') {
$newcheckbox = array();
foreach ($rules as $ck => $cv) {
$cv_value = substr($cv, 0, strpos($cv, '='));
$cv_name = substr($cv, strpos($cv, '=') + 1);
$newcheckbox[$cv_value] = $cv_name;
}
$topicvalues = '';
foreach (explode(",", $fieldvalue) as $value) {
if (S::isNatualValue($value)) {
$topicvalues .= $topicvalues ? "," . $newcheckbox[$value] : $newcheckbox[$value];
}
}
$topicvalue .= $topicvalues;
} elseif ($type == 'select') {
$newselect = array();
foreach ($rules as $sk => $sv) {
$sv_value = substr($sv, 0, strpos($sv, '='));
$sv_name = substr($sv, strpos($sv, '=') + 1);
$newselect[$sv_value] = $sv_name;
}
$topicvalue .= "{$newselect[$fieldvalue]}";
} elseif ($type == 'url') {
$topicvalue .= "<a href=\"{$fieldvalue}\" target=\"_blank\">{$fieldvalue}</a>";
} elseif ($type == 'calendar') {
$topicvalue .= get_date($fieldvalue, 'Y-n-j');
} else {
$topicvalue .= "{$fieldvalue}";
}
return $topicvalue;
}
示例2: initData
function initData()
{
/*初始化上传信息*/
global $timestamp, $db_topicname, $tid, $limitnums;
$postcate = S::getGP('postcate', 'P');
$query = $this->db->query("SELECT fieldname,name,type,rules,ifmust,ifable FROM pw_pcfield WHERE pcid=" . S::sqlEscape($this->pcid));
while ($rt = $this->db->fetch_array($query)) {
if ($rt['type'] != 'upload' && $rt['ifable'] && $rt['ifmust'] && !S::isNatualValue($postcate[$rt['fieldname']])) {
$db_topicname = $rt['name'];
Showmsg('topic_field_must');
}
if (in_array($rt['fieldname'], array('tel', 'phone', 'limitnum'))) {
$postcate[$rt['fieldname']] && !is_numeric($postcate[$rt['fieldname']]) && Showmsg('telphone_error');
} elseif (in_array($rt['fieldname'], array('price', 'deposit', 'mprice'))) {
$postcate[$rt['fieldname']] && !is_numeric($postcate[$rt['fieldname']]) && Showmsg('numeric_error');
$postcate[$rt['fieldname']] = number_format(floatval($postcate[$rt['fieldname']]), 2, '.', '');
}
if ($postcate[$rt['fieldname']]) {
if ($rt['type'] == 'number') {
!is_numeric($postcate[$rt['fieldname']]) && Showmsg('number_error');
$limitnum = unserialize($rt['rules']);
if ($limitnum['minnum'] && $limitnum['maxnum'] && ($postcate[$rt['fieldname']] < $limitnum['minnum'] || $postcate[$rt['fieldname']] > $limitnum['maxnum'])) {
$db_topicname = $rt['name'];
Showmsg('topic_number_limit');
}
} elseif ($rt['type'] == 'range') {
!is_numeric($postcate[$rt['fieldname']]) && Showmsg('number_error');
} elseif ($rt['type'] == 'email') {
if (!preg_match("/^[-a-zA-Z0-9_\\.]+@([0-9A-Za-z][0-9A-Za-z-]+\\.)+[A-Za-z]{2,5}\$/", $postcate[$rt['fieldname']])) {
Showmsg('illegal_email');
}
} elseif ($rt['type'] == 'checkbox') {
$checkboxs = ',';
foreach ($postcate[$rt['fieldname']] as $value) {
$checkboxs .= $value . ',';
}
$postcate[$rt['fieldname']] = $checkboxs;
} elseif ($rt['type'] == 'calendar') {
//日期值检查
$checkTime = strtotime($postcate[$rt['fieldname']]);
if (!$checkTime || -1 == $checkTime) {
$GLOBALS['db_actname'] = $rt['name'];
Showmsg('calendar_wrong_format');
}
//end
$postcate[$rt['fieldname']] = PwStrtoTime($postcate[$rt['fieldname']]);
}
}
}
$limitnums = $this->db->get_value("SELECT SUM(nums) as num FROM pw_pcmember WHERE tid=" . S::sqlEscape($tid));
if ($postcate['limitnum'] && $limitnums > $postcate['limitnum']) {
Showmsg('pclimitnum_error');
}
$postcate['begintime'] > $postcate['endtime'] && Showmsg('begin_endtime');
$postcate['endtime'] < $timestamp && Showmsg('截止时间必须大于当前时间');
$this->data['postcate'] = serialize($postcate);
}