| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
if ( ! class_exists( 'WPSC_Ticket_Field_Formatting' ) ) : |
| 7 |
|
| 8 |
class WPSC_Ticket_Field_Formatting { |
| 9 |
|
| 10 |
public function get_field_val($field){ |
| 11 |
|
| 12 |
global $wpscfunction; |
| 13 |
$ticket_id = isset($_POST['ticket_id']) ? intval($_POST['ticket_id']) : 0; |
| 14 |
$auth_id = $wpscfunction->get_ticket_fields($ticket_id,'ticket_auth_code'); |
| 15 |
$label = $wpscfunction->get_ticket_meta($ticket_id,$field->slug,true); |
| 16 |
$wpsc_tf_type = get_term_meta( $field->term_id, 'wpsc_tf_type',true); |
| 17 |
$custom_fields_localize = get_option('wpsc_custom_fields_localize'); |
| 18 |
$field_label = $custom_fields_localize['custom_fields_'.$field->term_id]; |
| 19 |
//$field_label = get_term_meta( $field->term_id, 'wpsc_tf_label', true); |
| 20 |
|
| 21 |
|
| 22 |
if($wpsc_tf_type==10){ |
| 23 |
$attachments = $wpscfunction->get_ticket_meta($ticket_id,$field->slug); |
| 24 |
?> |
| 25 |
<div class="wpsp_sidebar_labels"> |
| 26 |
<strong><?php _e($field_label,'supportcandy')?>:</strong> |
| 27 |
<table class="wpsc_attachment_tbl"> |
| 28 |
<tbody> |
| 29 |
<?php |
| 30 |
foreach( $attachments as $attachment ): |
| 31 |
$attach = array(); |
| 32 |
$attach_meta = get_term_meta($attachment); |
| 33 |
foreach ($attach_meta as $key => $value) { |
| 34 |
$attach[$key] = $value[0]; |
| 35 |
} |
| 36 |
$upload_dir = wp_upload_dir(); |
| 37 |
$wpsp_file = get_term_meta($attachment,'wpsp_file'); |
| 38 |
|
| 39 |
if ($wpsp_file) { |
| 40 |
$file_url = $upload_dir['baseurl'] . '/wpsp/'. $attach['save_file_name']; |
| 41 |
}else { |
| 42 |
if( isset($attach['is_restructured']) && $attach['is_restructured']){ |
| 43 |
$updated_time = get_term_meta($attachment,'time_uploaded',true); |
| 44 |
$time = strtotime($updated_time); |
| 45 |
$month = date("m",$time); |
| 46 |
$year = date("Y",$time); |
| 47 |
$file_url = $upload_dir['baseurl'] . '/wpsc/'.$year.'/'.$month.'/'. $attach['save_file_name']; |
| 48 |
}else{ |
| 49 |
$file_url = $upload_dir['baseurl'] . '/wpsc/'. $attach['save_file_name']; |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
$download_url = home_url('/').'?wpsc_attachment='.$attachment.'&tid='.$ticket_id.'&tac='.$auth_id; |
| 54 |
?> |
| 55 |
<tr> |
| 56 |
<td> |
| 57 |
<input type="hidden" name="<?php echo esc_attr($field->slug) ?>[]" value="<?php echo esc_attr($attach['filename']) ?>"> |
| 58 |
<span style="padding: 7px;"><a href="<?php echo esc_attr($download_url)?>" target="_blank"><?php echo esc_attr($attach['filename']);?></a></span> |
| 59 |
</td> |
| 60 |
</tr> |
| 61 |
<?php endforeach;?> |
| 62 |
</tbody> |
| 63 |
</table> |
| 64 |
</div> |
| 65 |
<?php |
| 66 |
}elseif($wpsc_tf_type == 7) { |
| 67 |
if (!preg_match("~^(?:f|ht)tps?://~i", $label)) { |
| 68 |
$url = "http://" . $label; |
| 69 |
}else{ |
| 70 |
$url = $label; |
| 71 |
} |
| 72 |
?> |
| 73 |
<div class="wpsp_sidebar_labels"><strong><?php _e($field_label,'supportcandy')?>:</strong> <a href="<?php echo esc_url($url) ?>" target="_blank"><?php _e('Click Here','supportcandy')?></a></div> |
| 74 |
<?php |
| 75 |
}elseif ($wpsc_tf_type == 8 ) { |
| 76 |
?> |
| 77 |
<div class="wpsp_sidebar_labels"><strong><?php _e($field_label,'supportcandy')?>:</strong> <a href="<?php echo 'mailto:'.esc_attr($label)?>" ><?php echo esc_attr($label) ?></a></div> |
| 78 |
<?php |
| 79 |
}elseif ($wpsc_tf_type == 5) { |
| 80 |
?> |
| 81 |
<div class="wpsp_sidebar_labels"><strong><?php _e($field_label,'supportcandy')?>:</strong> <br> <?php echo nl2br(esc_textarea($label)); ?></div> |
| 82 |
<?php |
| 83 |
}elseif ($wpsc_tf_type == 6) { |
| 84 |
$val = $wpscfunction->datetimeToCalenderFormat($label); |
| 85 |
?> |
| 86 |
<div class="wpsp_sidebar_labels"><strong><?php _e($field_label,'supportcandy')?>:</strong> <?php echo esc_attr($val)?></div> |
| 87 |
<?php |
| 88 |
}elseif($wpsc_tf_type == 3){ |
| 89 |
$ticket_meta = $wpscfunction->get_ticket_meta($ticket_id,$field->slug); |
| 90 |
$meta_values = implode(", ", $ticket_meta); |
| 91 |
?> |
| 92 |
<div class="wpsp_sidebar_labels"><strong><?php _e($field_label,'supportcandy')?>:</strong> <?php echo esc_attr($meta_values)?></div> |
| 93 |
<?php |
| 94 |
|
| 95 |
} else if($wpsc_tf_type == 1 || $wpsc_tf_type == 2 || $wpsc_tf_type == 4 || $wpsc_tf_type == 9 ){ |
| 96 |
?> |
| 97 |
<div class="wpsp_sidebar_labels"><strong><?php _e($field_label,'supportcandy')?>:</strong> <?php echo esc_attr($label)?></div> |
| 98 |
<?php |
| 99 |
}else if($wpsc_tf_type == 18 ){ |
| 100 |
?> |
| 101 |
<div class="wpsp_sidebar_labels"><strong><?php _e($field_label,'supportcandy')?>:</strong> <?php echo esc_attr($label)?></div> |
| 102 |
<?php |
| 103 |
}elseif($wpsc_tf_type == 21){ |
| 104 |
$time_format = get_term_meta($field->term_id,'wpsc_time_format',true); |
| 105 |
?> |
| 106 |
<div class="wpsp_sidebar_labels"><strong><?php _e($field_label, 'supportcandy')?>:</strong><?php |
| 107 |
if($time_format == '12'){ |
| 108 |
$label = date("h:i:s a", strtotime($label)); |
| 109 |
} |
| 110 |
echo esc_attr($label); |
| 111 |
?></div> |
| 112 |
<?php |
| 113 |
}else { |
| 114 |
do_action( 'wpsc_widget_ticket_field_item', $field, $ticket_id,$wpsc_tf_type); |
| 115 |
} |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
endif; |
| 120 |
|