Exemplo n.º 1
0
 public static function email_value($value, $meta, $entry)
 {
     if ($entry->id != $meta->item_id) {
         $entry = FrmEntry::getOne($meta->item_id);
     }
     $field = FrmField::getOne($meta->field_id);
     if (!$field) {
         return $value;
     }
     if (FrmField::is_option_true($field, 'post_field')) {
         $value = self::get_post_or_meta_value($entry, $field, array('truncate' => true));
         $value = maybe_unserialize($value);
     }
     switch ($field->type) {
         case 'user_id':
             $value = FrmProFieldsHelper::get_display_name($value);
             break;
         case 'data':
             if (is_array($value)) {
                 $new_value = array();
                 foreach ($value as $val) {
                     $new_value[] = FrmProFieldsHelper::get_data_value($val, $field);
                 }
                 $value = $new_value;
             } else {
                 $value = FrmProFieldsHelper::get_data_value($value, $field);
             }
             break;
         case 'file':
             $value = FrmProFieldsHelper::get_file_name($value);
             break;
         case 'date':
             $value = FrmProFieldsHelper::get_date($value);
     }
     if (is_array($value)) {
         $new_value = '';
         foreach ($value as $val) {
             if (is_array($val)) {
                 // This will affect checkboxes inside of repeating sections
                 $new_value .= implode(', ', $val) . "\n";
             }
         }
         if ($new_value != '') {
             $value = $new_value;
         } else {
             // Only keep non-empty values in array
             $value = array_filter($value);
         }
     }
     return $value;
 }
Exemplo n.º 2
0
 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);
 }
 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 &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);
 }
Exemplo n.º 5
0
}
echo '"' . __('Timestamp', 'formidable') . '","IP","ID","Key"' . "\n";
foreach ($entries as $entry) {
    foreach ($form_cols as $col) {
        $field_value = isset($entry->metas[$col->id]) ? $entry->metas[$col->id] : false;
        if (!$field_value and $entry->post_id) {
            $col->field_options = maybe_unserialize($col->field_options);
            if (isset($col->field_options['post_field']) and $col->field_options['post_field']) {
                $field_value = FrmProEntryMetaHelper::get_post_value($entry->post_id, $col->field_options['post_field'], $col->field_options['custom_field'], array('truncate' => $col->field_options['post_field'] == 'post_category' ? true : false, 'form_id' => $entry->form_id, 'field' => $col, 'type' => $col->type, 'exclude_cat' => isset($col->field_options['exclude_cat']) ? $col->field_options['exclude_cat'] : 0));
            }
        }
        if ($col->type == 'user_id') {
            $field_value = FrmProFieldsHelper::get_display_name($field_value);
        } else {
            if ($col->type == 'file') {
                $field_value = FrmProFieldsHelper::get_file_name($field_value);
            } else {
                if ($col->type == 'date') {
                    $field_value = FrmProFieldsHelper::get_date($field_value, $wp_date_format);
                } else {
                    if ($col->type == 'data' && is_numeric($field_value)) {
                        $field_value = FrmProFieldsHelper::get_data_value($field_value, $col);
                        //replace entry id with specified field
                    } else {
                        $checked_values = maybe_unserialize($field_value);
                        $checked_values = apply_filters('frm_csv_value', $checked_values, array('field' => $col));
                        if (is_array($checked_values)) {
                            if ($col->type == 'data') {
                                $field_value = '';
                                foreach ($checked_values as $checked_value) {
                                    if (!empty($field_value)) {
Exemplo n.º 6
0
 public static function get_export_val($val, $field)
 {
     if ($field->type == 'user_id') {
         $val = FrmProFieldsHelper::get_display_name($val, 'user_login');
     } else {
         if ($field->type == 'file') {
             $val = FrmProFieldsHelper::get_file_name($val, false);
         } else {
             if ($field->type == 'date') {
                 $wp_date_format = apply_filters('frm_csv_date_format', 'Y-m-d');
                 $val = FrmProFieldsHelper::get_date($val, $wp_date_format);
             } else {
                 if ($field->type == 'data') {
                     $new_val = maybe_unserialize($val);
                     if (is_numeric($new_val)) {
                         $val = FrmProFieldsHelper::get_data_value($new_val, $field);
                         //replace entry id with specified field
                     } else {
                         if (is_array($new_val)) {
                             $field_value = array();
                             foreach ($new_val as $v) {
                                 $field_value[] = FrmProFieldsHelper::get_data_value($v, $field);
                                 unset($v);
                             }
                             $val = implode(', ', $field_value);
                         }
                     }
                 }
             }
         }
     }
     return $val;
 }