本文整理汇总了PHP中FrmAppHelper::is_empty_value方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmAppHelper::is_empty_value方法的具体用法?PHP FrmAppHelper::is_empty_value怎么用?PHP FrmAppHelper::is_empty_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmAppHelper
的用法示例。
在下文中一共展示了FrmAppHelper::is_empty_value方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_default_value
public static function get_default_value($value, $field, $dynamic_default = true, $allow_array = false)
{
if (is_array(maybe_unserialize($value))) {
if (FrmAppHelper::is_empty_value($value) || count(array_filter($value)) === 0) {
$value = '';
} else {
return $value;
}
}
$prev_val = '';
if ($field && $dynamic_default) {
if (FrmField::is_option_value_in_object($field, 'dyn_default_value')) {
$prev_val = $value;
$value = $field->field_options['dyn_default_value'];
}
}
$matches = self::get_shortcodes_from_string($value);
if (!isset($matches[0])) {
return do_shortcode($value);
}
$args = array('matches' => $matches, 'allow_array' => $allow_array, 'field' => $field, 'prev_val' => $prev_val);
foreach ($matches[1] as $match_key => $shortcode) {
$args['shortcode'] = $shortcode;
$args['match_key'] = $match_key;
self::replace_shortcode_in_string($value, $args);
}
unset($matches);
self::replace_field_id_shortcodes($value, $allow_array);
self::do_shortcode($value, $allow_array);
self::maybe_force_array($value, $field, $allow_array);
return $value;
}
示例2: test_is_empty_value
/**
* @covers FrmAppHelper::is_empty_value
*/
function test_is_empty_value()
{
$empty_value = FrmAppHelper::is_empty_value('');
$this->assertTrue($empty_value);
$empty_value = FrmAppHelper::is_empty_value(array());
$this->assertTrue($empty_value);
$not_empty_value = FrmAppHelper::is_empty_value('test');
$this->assertFalse($not_empty_value);
$not_empty_value = FrmAppHelper::is_empty_value(array('test'));
$this->assertFalse($not_empty_value);
}
示例3: fill_entry_values
public static function fill_entry_values($atts, $f, array &$values)
{
if (FrmField::is_no_save_field($f->type)) {
return;
}
if ($atts['default_email']) {
$values[$f->id] = array('label' => '[' . $f->id . ' show=field_label]', 'val' => '[' . $f->id . ']');
return;
}
//Remove signature from default-message shortcode
if ($f->type == 'signature') {
return;
}
if ($atts['entry'] && !isset($atts['entry']->metas[$f->id])) {
// In case include_blank is set
$atts['entry']->metas[$f->id] = '';
if (FrmAppHelper::pro_is_installed()) {
FrmProEntryMeta::add_post_value_to_entry($f, $atts['entry']);
FrmProEntryMeta::add_repeating_value_to_entry($f, $atts['entry']);
}
}
$val = '';
if ($atts['entry']) {
$prev_val = maybe_unserialize($atts['entry']->metas[$f->id]);
$meta = array('item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type);
//This filter applies to the default-message shortcode and frm-show-entry shortcode only
if (isset($atts['filter']) && $atts['filter'] == false) {
$val = $prev_val;
} else {
$val = apply_filters('frm_email_value', $prev_val, (object) $meta, $atts['entry']);
}
}
// Don't include blank values
if (!$atts['include_blank'] && FrmAppHelper::is_empty_value($val)) {
return;
}
self::textarea_display_value($f->type, $atts['plain_text'], $val);
if (is_array($val) && $atts['format'] == 'text') {
$val = implode(', ', $val);
}
if ($atts['format'] != 'text') {
$values[$f->field_key] = $val;
} else {
$values[$f->id] = array('label' => $f->name, 'val' => $val);
}
}
示例4: add_entry_meta
/**
* @param string $meta_key
*/
public static function add_entry_meta($entry_id, $field_id, $meta_key = null, $meta_value)
{
global $wpdb;
if (FrmAppHelper::is_empty_value($meta_value)) {
// don't save blank fields
return;
}
$new_values = array('meta_value' => is_array($meta_value) ? serialize(array_filter($meta_value, 'FrmAppHelper::is_not_empty_value')) : trim($meta_value), 'item_id' => $entry_id, 'field_id' => $field_id, 'created_at' => current_time('mysql', 1));
$new_values = apply_filters('frm_add_entry_meta', $new_values);
$query_results = $wpdb->insert($wpdb->prefix . 'frm_item_metas', $new_values);
if ($query_results) {
self::clear_cache();
$id = $wpdb->insert_id;
} else {
$id = 0;
}
return $id;
}
示例5: validate
public static function validate($errors, $field, $value, $args)
{
$field->temp_id = $args['id'];
// Keep current value for "Other" fields because it is needed for correct validation
if (!$args['other']) {
FrmEntriesHelper::get_posted_value($field, $value, $args);
}
if ($field->type == 'form' || FrmField::is_repeating_field($field)) {
self::validate_embedded_form($errors, $field, $args['exclude']);
} else {
if ($field->type == 'user_id') {
// make sure we have a user ID
if (!is_numeric($value)) {
$value = FrmAppHelper::get_user_id_param($value);
FrmEntriesHelper::set_posted_value($field, $value, $args);
}
//add user id to post variables to be saved with entry
$_POST['frm_user_id'] = $value;
} else {
if ($field->type == 'time' && is_array($value)) {
$value = $value['H'] . ':' . $value['m'] . (isset($value['A']) ? ' ' . $value['A'] : '');
FrmEntriesHelper::set_posted_value($field, $value, $args);
}
}
}
// don't validate if going backwards
if (FrmProFormsHelper::going_to_prev($field->form_id)) {
return array();
}
// clear any existing errors if draft
if (FrmProFormsHelper::saving_draft() && isset($errors['field' . $field->temp_id])) {
unset($errors['field' . $field->temp_id]);
}
self::validate_file_upload($errors, $field, $args);
// if saving draft, only check file type since it won't be checked later
// and confirmation field since the confirmation field value is not saved
if (FrmProFormsHelper::saving_draft()) {
//Check confirmation field if saving a draft
self::validate_confirmation_field($errors, $field, $value, $args);
return $errors;
}
self::validate_no_input_fields($errors, $field);
if (empty($args['parent_field_id']) && !isset($_POST['item_meta'][$field->id])) {
return $errors;
}
if (($field->type != 'tag' && $value == 0 || $field->type == 'tag' && $value == '') && isset($field->field_options['post_field']) && $field->field_options['post_field'] == 'post_category' && $field->required == '1') {
$frm_settings = FrmAppHelper::get_settings();
$errors['field' . $field->temp_id] = !isset($field->field_options['blank']) || $field->field_options['blank'] == '' || $field->field_options['blank'] == 'Untitled cannot be blank' ? $frm_settings->blank_msg : $field->field_options['blank'];
}
//Don't require fields hidden with shortcode fields="25,26,27"
global $frm_vars;
if (self::is_field_hidden_by_shortcode($field, $errors)) {
unset($errors['field' . $field->temp_id]);
$value = '';
}
//Don't require a conditionally hidden field
self::validate_conditional_field($errors, $field, $value);
//Don't require a field hidden in a conditional page or section heading
self::validate_child_conditional_field($errors, $field, $value);
//make sure the [auto_id] is still unique
self::validate_auto_id($field, $value);
//check uniqueness
self::validate_unique_field($errors, $field, $value);
self::set_post_fields($field, $value, $errors);
if (!FrmProFieldsHelper::is_field_visible_to_user($field)) {
//don't validate admin only fields that can't be seen
unset($errors['field' . $field->temp_id]);
FrmEntriesHelper::set_posted_value($field, $value, $args);
return $errors;
}
self::validate_confirmation_field($errors, $field, $value, $args);
//Don't validate the format if field is blank
if (FrmAppHelper::is_empty_value($value)) {
FrmEntriesHelper::set_posted_value($field, $value, $args);
return $errors;
}
if (!is_array($value)) {
$value = trim($value);
}
$validate_fields = array('number', 'phone', 'date');
if (in_array($field->type, $validate_fields)) {
$function = 'validate_' . $field->type . '_field';
self::$function($errors, $field, $value);
}
FrmEntriesHelper::set_posted_value($field, $value, $args);
return $errors;
}