本文整理汇总了PHP中validation::check_data_set_new方法的典型用法代码示例。如果您正苦于以下问题:PHP validation::check_data_set_new方法的具体用法?PHP validation::check_data_set_new怎么用?PHP validation::check_data_set_new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validation
的用法示例。
在下文中一共展示了validation::check_data_set_new方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
function sanitize_mf_new(&$param)
{
if (empty($this->field_from_parent)) {
foreach ($this->relations as $rel_info) {
if ($rel_info['type'] == 'M-1') {
$this->field_from_parent = $rel_info['link_child'];
}
}
}
$minimum_rows = 0;
foreach ($this->relations as $rel_info) {
if ($rel_info['type'] == 'M-1') {
$minimum_rows = $rel_info['minimum'];
}
}
$lst_error = '';
require_once 'validation_class.php';
require_once 'char_set_class.php';
$validator = new validation();
//Check if some required fields are left blank in the submitted rows.
foreach ($this->fields as $field_name => $field_details) {
$dd_field_name = $field_name;
$field_name = 'cf_' . $this->table_name . '_' . $field_name;
$label = $field_details['label'];
$required = $field_details['required'];
if ($required && $dd_field_name != $this->field_from_parent) {
if (isset($param[$field_name])) {
//$lst_error .= $validator->check_if_null($label, $param[$field_name]);
$arr_error[$field_name] = $validator->check_if_null_new($label, $param[$field_name]);
}
}
}
foreach ($param as $unclean => $unclean_value) {
$prefix_length = strlen('cf_' . $this->table_name . '_');
$unclean_no_prefix = substr($unclean, $prefix_length, strlen($unclean));
if (isset($this->fields[$unclean_no_prefix])) {
$length = $this->fields[$unclean_no_prefix]['length'];
$data_type = $this->fields[$unclean_no_prefix]['data_type'];
$attribute = $this->fields[$unclean_no_prefix]['attribute'];
$control_type = $this->fields[$unclean_no_prefix]['control_type'];
$label = $this->fields[$unclean_no_prefix]['label'];
$char_set_method = $this->fields[$unclean_no_prefix]['char_set_method'];
$char_set_allow_space = $this->fields[$unclean_no_prefix]['char_set_allow_space'];
$extra_chars_allowed = $this->fields[$unclean_no_prefix]['extra_chars_allowed'];
$trim = $this->fields[$unclean_no_prefix]['trim'];
$valid_set = $this->fields[$unclean_no_prefix]['valid_set'];
//Apply trimming if specified.
//Triming should be applied to $unclean_value for purposes of further filtering/checking,
//and then also applied to $param[$unclean] so as to actually affect the POST variable.
//Note: since this is an mf-specialized method, we are dealing with arrays. Count first
$num_items = 0;
if (is_array($param[$unclean])) {
$num_items = count($param[$unclean]);
}
for ($a = 0; $a < $num_items; ++$a) {
if (strtolower($trim) == 'trim') {
$unclean_value[$a] = trim($unclean_value[$a]);
$param[$unclean][$a] = trim($unclean_value[$a]);
} elseif (strtolower($trim) == 'ltrim') {
$unclean_value[$a] = ltrim($unclean_value[$a]);
$param[$unclean][$a] = ltrim($unclean_value[$a]);
} elseif (strtolower($trim) == 'rtrim') {
$unclean_value[$a] = rtrim($unclean_value[$a]);
$param[$unclean][$a] = rtrim($unclean_value[$a]);
}
//Check length
if ($length > 0) {
if (strlen($unclean_value[$a]) > $length) {
$lst_error .= "The field '{$label}' (in line #" . ($a + 1) . ") can only accept {$length} characters.<br>";
}
}
$validator = new validation();
//If there is a set of valid inputs, check if 'unclean' conforms to it.
if (count($valid_set) > 1) {
if ($unclean_value == '') {
//No need to check because no value was submitted.
} else {
$validator->check_data_set_new($unclean_value[$a], $valid_set, TRUE);
if ($validator->validity == FALSE) {
//$lst_error .= $validator->error_message . $label . '<br>';
$arr_error[$unclean] = $validator->error_message;
}
}
} else {
//If a char set method is given, check 'unclean' for invalid characters
if ($char_set_method != '') {
$cg = new char_set();
$cg->allow_space = $char_set_allow_space;
$cg->{$char_set_method}($extra_chars_allowed);
$allowed = $cg->allowed_chars;
$validator->field_name = $label;
$validator->validate_data($unclean_value[$a], $data_type, $allowed);
if ($validator->validity == FALSE) {
$cntInvalidChars = count($validator->invalid_chars);
if ($cntInvalidChars == 1) {
$lst_error .= "Invalid character found in '{$label}' in line #" . ($a + 1) . ": " . cobalt_htmlentities($validator->invalid_chars[0]) . '<br>';
} elseif ($cntInvalidChars > 1) {
$lst_error .= "Invalid characters found in '{$label}' in line #" . ($a + 1) . ": ";
for ($b = 0; $b < $cntInvalidChars; ++$b) {
$lst_error .= cobalt_htmlentities($validator->invalid_chars[$b]) . ' ';
//.........这里部分代码省略.........