" id="field_<?php echo $field['field_key']; ?> " <?php do_action('frm_field_input_html', $field); ?> /><br/> <input type="hidden" name="<?php echo $field_name; ?> " value="<?php echo esc_attr(is_array($field['value']) ? reset($field['value']) : $field['value']); ?> " /> <?php echo FrmProFieldsHelper::get_file_icon($field['value']); } } include_once FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-entries/loading.php'; } else { if ($field['type'] == 'data') { ?> <div id="frm_data_field_<?php echo $field['id']; ?> _container"> <?php require FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/data-options.php'; ?> </div> <?php
function display_value($value, $field, $atts = array()) { global $wpdb; $defaults = array('type' => '', 'show_icon' => true, 'show_filename' => true, 'truncate' => false, 'sep' => ', ', 'post_id' => 0, 'form_id' => $field->form_id, 'field' => $field); $atts = wp_parse_args($atts, $defaults); $field->field_options = maybe_unserialize($field->field_options); if (!isset($field->field_options['post_field'])) { $field->field_options['post_field'] = ''; } if (!isset($field->field_options['custom_field'])) { $field->field_options['custom_field'] = ''; } if ($atts['post_id'] and ($field->field_options['post_field'] or $atts['type'] == 'tag')) { $atts['pre_truncate'] = $atts['truncate']; $atts['truncate'] = true; $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); $atts['truncate'] = $atts['pre_truncate']; } if ($value == '') { return $value; } $value = maybe_unserialize($value); if (is_array($value)) { $value = stripslashes_deep($value); } $value = apply_filters('frm_display_value_custom', $value, $field, $atts); $new_value = ''; if (is_array($value)) { foreach ($value as $val) { if (is_array($val)) { //TODO: add options for display (li or ,) $new_value .= implode($atts['sep'], $val); if ($atts['type'] != 'data') { $new_value .= "<br/>"; } } unset($val); } } if (!empty($new_value)) { $value = $new_value; } else { if (is_array($value)) { $value = implode($atts['sep'], $value); } } if ($atts['truncate'] and $atts['type'] != 'image') { $value = FrmAppHelper::truncate($value, 50); } if ($atts['type'] == 'image') { $value = '<img src="' . $value . '" height="50px" alt="" />'; } else { if ($atts['type'] == 'user_id') { $value = FrmProFieldsHelper::get_display_name($value); } else { if ($atts['type'] == 'file') { $old_value = $value; $value = ''; if ($atts['show_icon']) { $value .= FrmProFieldsHelper::get_file_icon($old_value); } if ($atts['show_icon'] and $atts['show_filename']) { $value .= '<br/>'; } if ($atts['show_filename']) { $value .= FrmProFieldsHelper::get_file_name($old_value); } } else { if ($atts['type'] == 'date') { $value = FrmProFieldsHelper::get_date($value); } else { if ($atts['type'] == 'data') { if (!is_numeric($value)) { $value = explode($atts['sep'], $value); if (is_array($value)) { $new_value = ''; foreach ($value as $entry_id) { if (!empty($new_value)) { $new_value .= $atts['sep']; } if (is_numeric($entry_id)) { $new_value .= FrmProFieldsHelper::get_data_value($entry_id, $field, $atts); } else { $new_value .= $entry_id; } } $value = $new_value; } } else { //replace item id with specified field $value = FrmProFieldsHelper::get_data_value($value, $field, $atts); if ($field->field_options['data_type'] == 'data' or $field->field_options['data_type'] == '') { $linked_field = FrmField::getOne($field->field_options['form_select']); if ($linked_field->type == 'file') { $old_value = $value; $value = '<img src="' . $value . '" height="50px" alt="" />'; if ($atts['show_filename']) { $value .= '<br/>' . $old_value; } } } } } } } } } $value = stripslashes_deep($value); return apply_filters('frm_display_value', $value, $field, $atts); }
public static function display_value($value, $field, $atts = array()) { global $wpdb, $frm_field; $defaults = array('type' => '', 'show_icon' => true, 'show_filename' => true, 'truncate' => false, 'sep' => ', ', 'post_id' => 0, 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0); $atts = wp_parse_args($atts, $defaults); $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); if (!isset($field->field_options['post_field'])) { $field->field_options['post_field'] = ''; } if (!isset($field->field_options['custom_field'])) { $field->field_options['custom_field'] = ''; } if ($atts['post_id'] and ($field->field_options['post_field'] or $atts['type'] == 'tag')) { $atts['pre_truncate'] = $atts['truncate']; $atts['truncate'] = true; $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); $atts['truncate'] = $atts['pre_truncate']; } if ($value == '') { return $value; } $value = maybe_unserialize($value); $value = apply_filters('frm_display_value_custom', $value, $field, $atts); $new_value = ''; if (is_array($value)) { foreach ($value as $val) { if (is_array($val)) { //TODO: add options for display (li or ,) $new_value .= implode($atts['sep'], $val); if ($atts['type'] != 'data') { $new_value .= "<br/>"; } } unset($val); } } if (!empty($new_value)) { $value = $new_value; } else { if (is_array($value)) { $value = implode($atts['sep'], $value); } } if ($atts['truncate'] and $atts['type'] != 'image') { $value = FrmAppHelper::truncate($value, 50); } if ($atts['type'] == 'image') { $value = '<img src="' . $value . '" height="50px" alt="" />'; } else { if ($atts['type'] == 'user_id') { $value = FrmProFieldsHelper::get_display_name($value); } else { if ($atts['type'] == 'file') { $old_value = explode(', ', $value); $value = ''; foreach ($old_value as $mid) { $value .= '<div class="frm_file_container">'; if ($atts['show_icon']) { $img = FrmProFieldsHelper::get_file_icon($mid); $value .= $img; if ($atts['show_filename'] and $img and preg_match("/wp-includes\\/images\\/crystal/", $img)) { //prevent two filenames $atts['show_filename'] = $show_filename = false; } unset($img); } if ($atts['show_icon'] and $atts['show_filename']) { $value .= '<br/>'; } if ($atts['show_filename']) { $value .= FrmProFieldsHelper::get_file_name($mid); } if (isset($show_filename)) { //if skipped filename, show it for the next file $atts['show_filename'] = true; unset($show_filename); } $value .= '</div>'; } } else { if ($atts['type'] == 'date') { $value = FrmProFieldsHelper::get_date($value); } else { if ($atts['type'] == 'data') { if (!is_numeric($value)) { $value = explode($atts['sep'], $value); if (is_array($value)) { $new_value = ''; foreach ($value as $entry_id) { if (!empty($new_value)) { $new_value .= $atts['sep']; } if (is_numeric($entry_id)) { $dval = FrmProFieldsHelper::get_data_value($entry_id, $field, $atts); if (is_array($dval)) { $dval = implode($atts['sep'], $dval); } $new_value .= $dval; } else { $new_value .= $entry_id; } } $value = $new_value; } } else { //replace item id with specified field $new_value = FrmProFieldsHelper::get_data_value($value, $field, $atts); if ($field->field_options['data_type'] == 'data' or $field->field_options['data_type'] == '') { $linked_field = $frm_field->getOne($field->field_options['form_select']); if ($linked_field->type == 'file') { $old_value = explode(', ', $new_value); $new_value = ''; foreach ($old_value as $v) { $new_value .= '<img src="' . $v . '" height="50px" alt="" />'; if ($atts['show_filename']) { $new_value .= '<br/>' . $v; } unset($v); } } else { $new_value = $value; } } $value = $new_value; } } } } } } if (!$atts['keepjs']) { $value = wp_kses_post($value); } return apply_filters('frm_display_value', $value, $field, $atts); }
public static function &filter_display_value($value, $field, $atts = array()) { $defaults = array('html' => 0, 'type' => $field->type, 'keepjs' => 0); $atts = array_merge($defaults, $atts); switch ($atts['type']) { case 'user_id': $value = FrmProFieldsHelper::get_display_name($value); break; case 'date': $value = FrmProFieldsHelper::get_date($value); break; case 'file': $old_value = $value; if ($atts['html']) { $value = '<div class="frm_file_container">'; } else { $value = ''; } foreach ((array) $old_value as $mid) { if ($atts['html']) { $img = FrmProFieldsHelper::get_file_icon($mid); $value .= $img; if ($atts['show_filename'] && $img && preg_match('/wp-includes\\/images\\/(crystal|media)/', $img)) { //prevent two filenames $atts['show_filename'] = $show_filename = false; } unset($img); if ($atts['html'] && $atts['show_filename']) { $value .= '<br/>' . FrmProFieldsHelper::get_file_name($mid) . '<br/>'; } if (isset($show_filename)) { //if skipped filename, show it for the next file $atts['show_filename'] = true; unset($show_filename); } } else { if ($mid) { $value .= FrmProFieldsHelper::get_file_name($mid) . $atts['sep']; } } } $value = rtrim($value, $atts['sep']); if ($atts['html']) { $value .= '</div>'; } break; case 'data': if (!is_numeric($value)) { if (!is_array($value)) { $value = explode($atts['sep'], $value); } if (is_array($value)) { $new_value = ''; foreach ($value as $entry_id) { if (!empty($new_value)) { $new_value .= $atts['sep']; } if (is_numeric($entry_id)) { $new_value .= FrmProFieldsHelper::get_data_value($entry_id, $field, $atts); } else { $new_value .= $entry_id; } } $value = $new_value; } } else { //replace item id with specified field $new_value = FrmProFieldsHelper::get_data_value($value, $field, $atts); if (FrmProField::is_list_field($field)) { $linked_field = FrmField::getOne($field->field_options['form_select']); if ($linked_field && $linked_field->type == 'file') { $old_value = explode(', ', $new_value); $new_value = ''; foreach ($old_value as $v) { $new_value .= '<img src="' . esc_url($v) . '" class="frm_image_from_url" alt="" />'; if ($atts['show_filename']) { $new_value .= '<br/>' . $v; } unset($v); } } else { $new_value = $value; } } $value = $new_value; } break; case 'image': $value = FrmProFieldsHelper::get_image_display_value($value, array('html' => true)); break; } if (!$atts['keepjs']) { $value = FrmAppHelper::recursive_function_map($value, 'wp_kses_post'); } return FrmEntriesController::filter_display_value($value, $field, $atts); }