本文整理匯總了PHP中GFCommon::date_display方法的典型用法代碼示例。如果您正苦於以下問題:PHP GFCommon::date_display方法的具體用法?PHP GFCommon::date_display怎麽用?PHP GFCommon::date_display使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GFCommon
的用法示例。
在下文中一共展示了GFCommon::date_display方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: date_display
/**
* Get the default date format for a field based on the field ID and the time format setting
*
* @since 1.16.4
* @param string $date_format The Gravity Forms date format for the field. Default: "mdy"
* @param int $field_id The ID of the field. Used to figure out full date/day/month/year
*
* @return string PHP date format for the date
*/
public static function date_display($value = '', $date_format = 'mdy', $field_id = 0)
{
// Let Gravity Forms figure out, based on the date format, what day/month/year values are.
$parsed_date = GFCommon::parse_date($value, $date_format);
// Are we displaying an input or the whole field?
$field_input_id = gravityview_get_input_id_from_id($field_id);
$date_field_output = '';
switch ($field_input_id) {
case 1:
$date_field_output = rgar($parsed_date, 'day');
break;
case 2:
$date_field_output = rgar($parsed_date, 'month');
break;
case 3:
$date_field_output = rgar($parsed_date, 'year');
break;
}
/**
* @filter `gravityview_date_format` Whether to override the Gravity Forms date format with a PHP date format
* @see https://codex.wordpress.org/Formatting_Date_and_Time
* @param null|string Date Format (default: $field->dateFormat)
*/
$full_date_format = apply_filters('gravityview_date_format', $date_format);
$full_date = GFCommon::date_display($value, $full_date_format);
// If the field output is empty, use the full date.
// Note: The output might be empty because $parsed_date didn't parse correctly.
return '' === $date_field_output ? $full_date : $date_field_output;
}
示例2: fieldDate
/**
* get HTML for input and label for date field (as date picker)
* @param array $field
* @param string $value
* @param integer $lead_id
* @param integer $form_id
* @return string
*/
protected function fieldDate($field, $value = "", $lead_id = 0, $form_id = 0)
{
$id = $field['id'];
$sub_id = $field['sub_id'];
$field_id = IS_ADMIN || $form_id == 0 ? "gfeway_{$id}_{$sub_id}" : "gfeway_{$form_id}_{$id}_{$sub_id}";
$form_id = IS_ADMIN && empty($form_id) ? rgget('id') : $form_id;
$format = empty($field['dateFormat']) ? 'dmy' : esc_attr($field['dateFormat']);
$size = rgar($field, 'size');
$disabled_text = IS_ADMIN && RG_CURRENT_VIEW != 'entry' ? 'disabled="disabled"' : '';
$class_suffix = RG_CURRENT_VIEW == 'entry' ? '_admin' : '';
$value = GFCommon::date_display($value, $format);
$icon_class = $field['calendarIconType'] == 'none' ? 'datepicker_no_icon' : 'datepicker_with_icon';
$icon_url = empty($field['calendarIconUrl']) ? GFCommon::get_base_url() . '/images/calendar.png' : $field['calendarIconUrl'];
$tabindex = GFCommon::get_tabindex();
$inputClass = array($size . $class_suffix, $format, $icon_class);
$spanClass = array('gfeway_recurring_left', 'gfeway_recurring_date');
if (empty($field['hidden'])) {
$inputClass[] = 'datepicker';
} else {
$spanClass[] = 'gf_hidden';
}
$dataMin = '';
if (!empty($field['dateMin'])) {
$dataMin = sprintf('data-gfeway-minDate="%s"', esc_attr($field['dateMin']));
}
$dataMax = '';
if (!empty($field['dateMax'])) {
$dataMax = sprintf('data-gfeway-maxDate="%s"', esc_attr($field['dateMax']));
}
$value = esc_attr($value);
$spanClass = esc_attr(implode(' ', $spanClass));
$inputClass = esc_attr(implode(' ', $inputClass));
$inputName = sprintf('gfeway_%s[%s]', $id, $sub_id);
$label = esc_html($field['label']);
ob_start();
require GFEWAY_PLUGIN_ROOT . 'views/recurring-field-input-date.php';
$input = ob_get_clean();
return $input;
}
示例3: create_post
//.........這裏部分代碼省略.........
$value = GFCommon::replace_variables_post_image($custom_field['customFieldTemplate'], $post_images, $lead);
//replacing all other variables
$value = GFCommon::replace_variables($value, $form, $lead, false, false, false);
// replace conditional shortcodes
$value = do_shortcode($value);
}
switch (RGFormsModel::get_input_type($custom_field)) {
case 'list':
$value = maybe_unserialize($value);
if (is_array($value)) {
foreach ($value as $item) {
if (is_array($item)) {
$item = implode('|', $item);
}
if (!rgblank($item)) {
add_post_meta($post_id, $meta_name, $item);
}
}
}
break;
case 'multiselect':
case 'checkbox':
$value = explode(',', $value);
if (is_array($value)) {
foreach ($value as $item) {
if (!rgblank($item)) {
// add post meta and replace HTML symbol in $item with real comma
add_post_meta($post_id, $meta_name, str_replace(',', ',', $item));
}
}
}
break;
case 'date':
$value = GFCommon::date_display($value, rgar($custom_field, 'dateFormat'));
if (!rgblank($value)) {
add_post_meta($post_id, $meta_name, $value);
}
break;
default:
if (!rgblank($value)) {
add_post_meta($post_id, $meta_name, $value);
}
break;
}
$meta_index++;
}
}
$has_content_field = sizeof(self::get_fields_by_type($form, array('post_content'))) > 0;
$has_title_field = sizeof(self::get_fields_by_type($form, array('post_title'))) > 0;
$post = false;
//if a post field was configured with a content or title template, process template
if (rgar($form, 'postContentTemplateEnabled') && $has_content_field || rgar($form, 'postTitleTemplateEnabled') && $has_title_field) {
GFCommon::log_debug('GFFormsModel::create_post(): Processing template.');
$post = get_post($post_id);
if (rgar($form, 'postContentTemplateEnabled') && $has_content_field) {
//replacing post image variables
$post_content = GFCommon::replace_variables_post_image($form['postContentTemplate'], $post_images, $lead);
//replacing all other variables
$post_content = GFCommon::replace_variables($post_content, $form, $lead, false, false, false);
//updating post content
$post->post_content = $post_content;
}
if (rgar($form, 'postTitleTemplateEnabled') && $has_title_field) {
//replacing post image variables
$post_title = GFCommon::replace_variables_post_image($form['postTitleTemplate'], $post_images, $lead);
//replacing all other variables
示例4: get_value_merge_tag
public function get_value_merge_tag($value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br)
{
$format_modifier = empty($modifier) ? $this->dateFormat : $modifier;
return GFCommon::date_display($value, $format_modifier);
}
示例5: prepopulate_form
public static function prepopulate_form($form, $config)
{
global $bp;
$mapped_fields = array();
$meta = rgar($config, 'meta');
$user = wp_get_current_user();
foreach (array('username', 'lastname', 'firstname', 'email') as $meta_key) {
$field_id = rgar($meta, $meta_key);
if ($field_id) {
$mapped_fields[(string) $field_id] = $user->get(self::convert_to_wp_meta_key($meta_key));
}
}
$custom_meta = rgars($config, 'meta/user_meta') ? rgars($config, 'meta/user_meta') : array();
foreach ($custom_meta as $meta_item) {
if (rgar($meta_item, 'meta_value')) {
$field_id = rgar($meta_item, 'meta_value');
$mapped_fields[(string) $field_id] = $user->get(rgar($meta_item, 'meta_name'));
}
}
if (function_exists("xprofile_get_field_data")) {
$buddypress_meta = rgars($config, 'meta/buddypress_meta') ? rgars($config, 'meta/buddypress_meta') : array();
foreach ($buddypress_meta as $meta_item) {
if (rgar($meta_item, 'meta_value')) {
$field_id = rgar($meta_item, 'meta_value');
$value = xprofile_get_field_data(rgar($meta_item, 'meta_name'), $user->ID);
$mapped_fields[(string) $field_id] = is_array($value) ? array_map('html_entity_decode', $value) : html_entity_decode($value);
}
}
}
$mapped_fields = apply_filters('gform_user_registration_user_data_pre_populate', $mapped_fields, $form, $config);
// get all fields for cheap check inside field loop
$mapped_field_ids = array_map('intval', array_keys($mapped_fields));
foreach ($form['fields'] as &$field) {
if (!in_array($field['id'], $mapped_field_ids)) {
continue;
}
$value = false;
switch (RGFormsModel::get_input_type($field)) {
case 'fileupload':
$value = rgar($mapped_fields, $field['id']);
$path_info = pathinfo($value);
// check if file has been "deleted" via form UI
$upload_files = json_decode(rgpost('gform_uploaded_files'), ARRAY_A);
$input_name = "input_{$field['id']}";
if (is_array($upload_files) && array_key_exists($input_name, $upload_files) && !$upload_files[$input_name]) {
continue;
}
// if $uploaded_files array is not set for this form at all, init as array
if (!isset(RGFormsModel::$uploaded_files[$form['id']])) {
RGFormsModel::$uploaded_files[$form['id']] = array();
}
// check if this field's key has been set in the $uploaded_files array, if not add this file (otherwise, a new image may have been uploaded so don't overwrite)
if (!isset(RGFormsModel::$uploaded_files[$form['id']]["input_{$field['id']}"])) {
RGFormsModel::$uploaded_files[$form['id']]["input_{$field['id']}"] = $path_info['basename'];
}
break;
case 'checkbox':
$value = rgar($mapped_fields, $field['id']);
$cb_values = array();
if (is_array($value)) {
$cb_values = $value;
} else {
$inputs = $field['inputs'];
foreach ($inputs as &$input) {
$cb_values[] = rgar($mapped_fields, (string) $input['id']);
}
$field['inputs'] = $inputs;
}
$value = implode(',', $cb_values);
break;
case 'list':
$value = maybe_unserialize(rgar($mapped_fields, $field['id']));
$list_values = array();
if (is_array($value)) {
foreach ($value as $vals) {
if (!is_array($vals)) {
$vals = array($vals);
}
$list_values = array_merge($list_values, array_values($vals));
}
$value = $list_values;
}
break;
case 'date':
$value = GFCommon::date_display(rgar($mapped_fields, $field['id']), $field['dateFormat'], false);
break;
default:
// handle complex fields
$inputs = $field instanceof GF_Field ? $field->get_entry_inputs() : rgar($field, 'inputs');
if (is_array($inputs)) {
foreach ($inputs as &$input) {
$filter_name = self::prepopulate_input($input['id'], rgar($mapped_fields, (string) $input['id']));
$field['allowsPrepopulate'] = true;
$input['name'] = $filter_name;
}
$field['inputs'] = $inputs;
} else {
$value = is_array(rgar($mapped_fields, $field['id'])) ? implode(',', rgar($mapped_fields, $field['id'])) : rgar($mapped_fields, $field['id']);
}
}
//.........這裏部分代碼省略.........
示例6: create_post
public static function create_post($form, &$lead)
{
$has_post_field = false;
foreach ($form["fields"] as $field) {
$is_hidden = self::is_field_hidden($form, $field, array(), $lead);
if (!$is_hidden && in_array($field["type"], array("post_category", "post_title", "post_content", "post_excerpt", "post_tags", "post_custom_field", "post_image"))) {
$has_post_field = true;
break;
}
}
//if this form does not have any post fields, don't create a post
if (!$has_post_field) {
return $lead;
}
//processing post fields
$post_data = self::get_post_fields($form, $lead);
//allowing users to change post fields before post gets created
$post_data = apply_filters("gform_post_data_{$form["id"]}", apply_filters("gform_post_data", $post_data, $form, $lead), $form, $lead);
//adding default title if none of the required post fields are in the form (will make sure wp_insert_post() inserts the post)
if (empty($post_data["post_title"]) && empty($post_data["post_content"]) && empty($post_data["post_excerpt"])) {
$post_data["post_title"] = self::get_default_post_title();
}
//inserting post
if (GFCommon::is_bp_active()) {
//disable buddy press action so save_post is not called because the post data is not yet complete at this point
remove_action("save_post", "bp_blogs_record_post");
}
$post_id = wp_insert_post($post_data);
//adding form id and entry id hidden custom fields
add_post_meta($post_id, "_gform-form-id", $form["id"]);
add_post_meta($post_id, "_gform-entry-id", $lead["id"]);
//creating post images
$post_images = array();
foreach ($post_data["images"] as $image) {
$image_meta = array("post_excerpt" => $image["caption"], "post_content" => $image["description"]);
//adding title only if it is not empty. It will default to the file name if it is not in the array
if (!empty($image["title"])) {
$image_meta["post_title"] = $image["title"];
}
if (!empty($image["url"])) {
$media_id = self::media_handle_upload($image["url"], $post_id, $image_meta);
if ($media_id) {
//save media id for post body/title template variable replacement (below)
$post_images[$image["field_id"]] = $media_id;
$lead[$image["field_id"]] .= "|:|{$media_id}";
// set featured image
$field = RGFormsModel::get_field($form, $image["field_id"]);
if (rgar($field, 'postFeaturedImage')) {
set_post_thumbnail($post_id, $media_id);
}
}
}
}
//adding custom fields
foreach ($post_data["post_custom_fields"] as $meta_name => $meta_value) {
if (!is_array($meta_value)) {
$meta_value = array($meta_value);
}
$meta_index = 0;
foreach ($meta_value as $value) {
$custom_field = self::get_custom_field($form, $meta_name, $meta_index);
//replacing template variables if template is enabled
if ($custom_field && rgget("customFieldTemplateEnabled", $custom_field)) {
//replacing post image variables
$value = GFCommon::replace_variables_post_image($custom_field["customFieldTemplate"], $post_images, $lead);
//replacing all other variables
$value = GFCommon::replace_variables($value, $form, $lead, false, false, false);
// replace conditional shortcodes
$value = do_shortcode($value);
}
switch (RGFormsModel::get_input_type($custom_field)) {
case "list":
$value = maybe_unserialize($value);
if (is_array($value)) {
foreach ($value as $item) {
if (is_array($item)) {
$item = implode("|", $item);
}
if (!rgblank($item)) {
add_post_meta($post_id, $meta_name, $item);
}
}
}
break;
case "multiselect":
case "checkbox":
$value = explode(",", $value);
if (is_array($value)) {
foreach ($value as $item) {
if (!rgblank($item)) {
add_post_meta($post_id, $meta_name, $item);
}
}
}
break;
case "date":
$value = GFCommon::date_display($value, rgar($custom_field, "dateFormat"));
if (!rgblank($value)) {
add_post_meta($post_id, $meta_name, $value);
}
//.........這裏部分代碼省略.........
示例7: leads_page
//.........這裏部分代碼省略.........
case "fileupload":
if (rgar($field, "multipleFiles")) {
$uploaded_files_arr = empty($value) ? array() : json_decode($value, true);
$file_count = count($uploaded_files_arr);
if ($file_count > 1) {
$value = empty($uploaded_files_arr) ? "" : sprintf(__("%d files", "gravityforms"), count($uploaded_files_arr));
break;
} elseif ($file_count == 1) {
$value = $uploaded_files_arr[0];
}
}
$file_path = $value;
if (!empty($file_path)) {
//displaying thumbnail (if file is an image) or an icon based on the extension
$thumb = self::get_icon_url($file_path);
$file_path = esc_attr($file_path);
$value = "<a href='{$file_path}' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$thumb}'/></a>";
}
break;
case "source_url":
$value = "<a href='" . esc_attr($lead["source_url"]) . "' target='_blank' alt='" . esc_attr($lead["source_url"]) . "' title='" . esc_attr($lead["source_url"]) . "'>.../" . esc_attr(GFCommon::truncate_url($lead["source_url"])) . "</a>";
break;
case "textarea":
case "post_content":
case "post_excerpt":
$value = esc_html($value);
break;
case "date_created":
case "payment_date":
$value = GFCommon::format_date($value, false);
break;
case "date":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::date_display($value, rgar($field, "dateFormat"));
break;
case "radio":
case "select":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::selection_display($value, $field, $lead["currency"]);
break;
case "number":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::format_number($value, rgar($field, "numberFormat"));
break;
case "total":
case "payment_amount":
$value = GFCommon::to_money($value, $lead["currency"]);
break;
case "created_by":
if (!empty($value)) {
$userdata = get_userdata($value);
if (!empty($userdata)) {
$value = $userdata->user_login;
}
}
break;
case "multiselect":
// add space after comma-delimited values
$value = implode(', ', explode(',', $value));
break;
default:
$value = esc_html($value);
}
$value = apply_filters("gform_entries_field_value", $value, $form_id, $field_id, $lead);
/* ^ maybe move to function */
$query_string = "gf_entries&view=entry&id={$form_id}&lid={$lead["id"]}{$search_qs}{$sort_qs}{$dir_qs}{$filter_qs}&paged=" . ($page_index + 1);
示例8: get_lead_field_display
//.........這裏部分代碼省略.........
$ary = explode("|:|", $value);
$url = count($ary) > 0 ? $ary[0] : "";
$title = count($ary) > 1 ? $ary[1] : "";
$caption = count($ary) > 2 ? $ary[2] : "";
$description = count($ary) > 3 ? $ary[3] : "";
if (!empty($url)) {
$url = str_replace(" ", "%20", $url);
switch ($format) {
case "text":
$value = $url;
$value .= !empty($title) ? "\n\n" . $field["label"] . " (" . __("Title", "gravityforms") . "): " . $title : "";
$value .= !empty($caption) ? "\n\n" . $field["label"] . " (" . __("Caption", "gravityforms") . "): " . $caption : "";
$value .= !empty($description) ? "\n\n" . $field["label"] . " (" . __("Description", "gravityforms") . "): " . $description : "";
break;
default:
$value = "<a href='{$url}' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$url}' width='100' /></a>";
$value .= !empty($title) ? "<div>Title: {$title}</div>" : "";
$value .= !empty($caption) ? "<div>Caption: {$caption}</div>" : "";
$value .= !empty($description) ? "<div>Description: {$description}</div>" : "";
break;
}
}
return $value;
case "fileupload":
$file_path = $value;
if (!empty($file_path)) {
$info = pathinfo($file_path);
$file_path = esc_attr(str_replace(" ", "%20", $file_path));
$value = $format == "text" ? $file_path : "<a href='{$file_path}' target='_blank' title='" . __("Click to view", "gravityforms") . "'>" . $info["basename"] . "</a>";
}
return $value;
break;
case "date":
return GFCommon::date_display($value, rgar($field, "dateFormat"));
break;
case "radio":
case "select":
return GFCommon::selection_display($value, $field, $currency, $use_text);
break;
case "multiselect":
if (empty($value) || $format == "text") {
return $value;
}
$value = explode(",", $value);
$items = '';
foreach ($value as $item) {
$items .= "<li>" . GFCommon::selection_display($item, $field, $currency, $use_text) . "</li>";
}
return "<ul class='bulleted'>{$items}</ul>";
break;
case "calculation":
case "singleproduct":
if (is_array($value)) {
$product_name = trim($value[$field["id"] . ".1"]);
$price = trim($value[$field["id"] . ".2"]);
$quantity = trim($value[$field["id"] . ".3"]);
$product = $product_name . ", " . __("Qty: ", "gravityforms") . $quantity . ", " . __("Price: ", "gravityforms") . $price;
return $product;
} else {
return "";
}
break;
case "number":
return GFCommon::format_number($value, rgar($field, "numberFormat"));
break;
case "singleshipping":
示例9: get_lead_field_display
//.........這裏部分代碼省略.........
$addr_ary = array();
$addr_ary[] = $street_value;
if (!empty($street2_value)) {
$addr_ary[] = $street2_value;
}
$zip_line = trim($zip_value . " " . $city_value);
$zip_line .= !empty($zip_line) && !empty($state_value) ? ", {$state_value}" : $state_value;
$zip_line = trim($zip_line);
if (!empty($zip_line)) {
$addr_ary[] = $zip_line;
}
if (!empty($country_value)) {
$addr_ary[] = $country_value;
}
$address = implode("<br />", $addr_ary);
} else {
$address = $street_value;
$address .= !empty($address) && !empty($street2_value) ? "<br />{$street2_value}" : $street2_value;
$address .= !empty($address) && (!empty($city_value) || !empty($state_value)) ? "<br />{$city_value}" : $city_value;
$address .= !empty($address) && !empty($city_value) && !empty($state_value) ? ", {$state_value}" : $state_value;
$address .= !empty($address) && !empty($zip_value) ? " {$zip_value}" : $zip_value;
$address .= !empty($address) && !empty($country_value) ? "<br />{$country_value}" : $country_value;
}
//adding map link
if (!empty($address)) {
$address_qs = str_replace("<br />", " ", $address);
//replacing <br/> with spaces
$address_qs = urlencode($address_qs);
$address .= "<br/><a href='http://maps.google.com/maps?q={$address_qs}' target='_blank' class='map-it-link'>Map It</a>";
}
return $address;
} else {
return "";
}
break;
case "email":
return GFCommon::is_valid_email($value) ? "<a href='mailto:{$value}'>{$value}</a>" : $value;
break;
case "website":
return GFCommon::is_valid_url($value) ? "<a href='{$value}' target='_blank'>{$value}</a>" : $value;
break;
case "checkbox":
if (is_array($value)) {
foreach ($value as $key => $item) {
if (!empty($item)) {
$items .= "<li>" . GFCommon::selection_display($item, $field, $currency, $use_text) . "</li>";
}
}
return empty($items) ? "" : "<ul class='bulleted'>{$items}</ul>";
} else {
return $value;
}
break;
case "post_image":
list($url, $title, $caption, $description) = explode("|:|", $value);
if (!empty($url)) {
$url = str_replace(" ", "%20", $url);
$value = "<a href='{$url}' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$url}' width='100' /></a>";
$value .= !empty($title) ? "<div>Title: {$title}</div>" : "";
$value .= !empty($caption) ? "<div>Caption: {$caption}</div>" : "";
$value .= !empty($description) ? "<div>Description: {$description}</div>" : "";
}
return $value;
case "fileupload":
$file_path = $value;
if (!empty($file_path)) {
$info = pathinfo($file_path);
$file_path = esc_attr(str_replace(" ", "%20", $file_path));
$value = "<a href='{$file_path}' target='_blank' title='" . __("Click to view", "gravityforms") . "'>" . $info["basename"] . "</a>";
}
return $value;
break;
case "date":
return GFCommon::date_display($value, $field["dateFormat"]);
break;
case "radio":
case "select":
return GFCommon::selection_display($value, $field, $currency, $use_text);
break;
case "singleproduct":
if (is_array($value)) {
$product_name = trim($value[$field["id"] . ".1"]);
$price = trim($value[$field["id"] . ".2"]);
$quantity = trim($value[$field["id"] . ".3"]);
$product = $product_name . ", " . __("Qty: ", "gravityforms") . $quantity . ", " . __("Price: ", "gravityforms") . $price;
return $product;
} else {
return "";
}
break;
case "singleshipping":
case "donation":
case "total":
case "price":
return GFCommon::to_money($value, $currency);
default:
return nl2br($value);
break;
}
}
示例10: extract
<?php
/**
* Display the time field type
*
* @package GravityView
* @subpackage GravityView/templates/fields
*/
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
if (!empty($field_settings) && !empty($field_settings['date_display']) && !empty($value)) {
// If there is a custom PHP date format passed via the date_display setting,
// use PHP's date format
$format = $field_settings['date_display'];
$output = date_i18n($format, strtotime($value));
} else {
// Otherwise, use Gravity Forms, where you can only choose from
// yyyy-mm-dd, mm-dd-yyyy, and dd-mm-yyyy
$format = apply_filters('gravityview_date_format', rgar($field, "dateFormat"));
$output = GFCommon::date_display($value, $format);
}
echo $output;
示例11: leads_page
//.........這裏部分代碼省略.........
//displaying thumbnail (if file is an image) or an icon based on the extension
$thumb = self::get_icon_url($url);
$value = "<a href='" . esc_attr($url) . "' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$thumb}'/></a>";
}
break;
case "post_category":
$ary = explode(":", $value);
$cat_name = count($ary) > 0 ? $ary[0] : "";
$value = $cat_name;
break;
case "fileupload":
$file_path = $value;
if (!empty($file_path)) {
//displaying thumbnail (if file is an image) or an icon based on the extension
$thumb = self::get_icon_url($file_path);
$file_path = esc_attr($file_path);
$value = "<a href='{$file_path}' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$thumb}'/></a>";
}
break;
case "source_url":
$value = "<a href='" . esc_attr($lead["source_url"]) . "' target='_blank' alt='" . esc_attr($lead["source_url"]) . "' title='" . esc_attr($lead["source_url"]) . "'>.../" . esc_attr(GFCommon::truncate_url($lead["source_url"])) . "</a>";
break;
case "textarea":
case "post_content":
case "post_excerpt":
$value = esc_html($value);
break;
case "date_created":
case "payment_date":
$value = GFCommon::format_date($value, false);
break;
case "date":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::date_display($value, $field["dateFormat"]);
break;
case "radio":
case "select":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::selection_display($value, $field, $lead["currency"]);
break;
case "total":
case "payment_amount":
$value = GFCommon::to_money($value, $lead["currency"]);
break;
case "created_by":
if (!empty($value)) {
$userdata = get_userdata($value);
$value = $userdata->user_login;
}
break;
default:
$value = esc_html($value);
}
$value = apply_filters("gform_entries_field_value", $value, $form_id, $field_id, $lead);
$query_string = "gf_entries&view=entry&id={$form_id}&lid={$lead["id"]}{$search_qs}{$sort_qs}{$dir_qs}&paged=" . $page_index + 1;
if ($is_first_column) {
?>
<td class="column-title" >
<a href="admin.php?page=gf_entries&view=entry&id=<?php
echo $form_id;
?>
&lid=<?php
echo $lead["id"] . $search_qs . $sort_qs . $dir_qs;
?>
&paged=<?php
echo $page_index + 1;
示例12: pdf_get_lead_field_display
//.........這裏部分代碼省略.........
case 'text':
$value = $url;
$value .= !empty($title) ? '\\n\\n' . $field['label'] . ' (' . __('Title', 'gravityforms') . '): ' . $title : '';
$value .= !empty($caption) ? '\\n\\n' . $field['label'] . ' (' . __('Caption', 'gravityforms') . '): ' . $caption : '';
$value .= !empty($description) ? '\\n\\n' . $field['label'] . ' (' . __('Description', 'gravityforms') . '): ' . $description : '';
break;
default:
$path = str_replace(site_url() . '/', ABSPATH, $url);
$value = "<a href='{$url}' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$path}' width='100' /></a>";
$value .= !empty($title) ? "<div>Title: {$title}</div>" : "";
$value .= !empty($caption) ? "<div>Caption: {$caption}</div>" : "";
$value .= !empty($description) ? "<div>Description: {$description}</div>" : "";
break;
}
}
return $value;
case 'fileupload':
$output = '';
$output_arr = array();
if (!empty($value)) {
$output .= '<ul>';
$file_paths = rgar($field, 'multipleFiles') ? json_decode($value) : array($value);
foreach ($file_paths as $file_path) {
$info = pathinfo($file_path);
$file_path = esc_attr(str_replace(' ', '%20', $file_path));
$output_arr[] = '<li><a href="' . $file_path . '" target="_blank" title="' . __('Click to view', 'gravityforms') . '">' . $info['basename'] . '</a></li>';
}
$output .= join(PHP_EOL, $output_arr);
$output .= '</ul>';
}
return $output;
break;
case 'date':
return GFCommon::date_display($value, rgar($field, 'dateFormat'));
break;
case 'radio':
case 'select':
return GFCommon::selection_display($value, $field, $currency, true);
break;
case 'multiselect':
if (empty($value) || $format == 'text') {
return $value;
}
if (!is_array($value)) {
$value = explode(',', $value);
}
$items = '';
foreach ($value as $item) {
$items .= '<li>' . GFCommon::selection_display($item, $field, $currency, true) . '</li>';
}
return '<ul class="bulleted">' . $items . '</ul>';
break;
case 'calculation':
case 'singleproduct':
if (is_array($value)) {
$product_name = trim($value[$field['id'] . '.1']);
$price = trim($value[$field['id'] . '.2']);
$quantity = trim($value[$field['id'] . '.3']);
$product = $product_name . ', ' . __('Qty: ', 'gravityforms') . $quantity . ', ' . __('Price: ', 'gravityforms') . $price;
return $product;
} else {
return '';
}
break;
case 'number':
return GFCommon::format_number($value, rgar($field, 'numberFormat'));
示例13: leads_page
//.........這裏部分代碼省略.........
//displaying thumbnail (if file is an image) or an icon based on the extension
$thumb = self::get_icon_url($url);
$value = "<a href='" . esc_attr($url) . "' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$thumb}'/></a>";
}
break;
case "post_category":
$ary = explode(":", $value);
$cat_name = count($ary) > 0 ? $ary[0] : "";
$value = $cat_name;
break;
case "fileupload":
$file_path = $value;
if (!empty($file_path)) {
//displaying thumbnail (if file is an image) or an icon based on the extension
$thumb = self::get_icon_url($file_path);
$file_path = esc_attr($file_path);
$value = "<a href='{$file_path}' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$thumb}'/></a>";
}
break;
case "source_url":
$value = "<a href='" . esc_attr($lead["source_url"]) . "' target='_blank' alt='" . esc_attr($lead["source_url"]) . "' title='" . esc_attr($lead["source_url"]) . "'>.../" . esc_attr(GFCommon::truncate_url($lead["source_url"])) . "</a>";
break;
case "textarea":
case "post_content":
case "post_excerpt":
$value = esc_html($value);
break;
case "date_created":
case "payment_date":
$value = GFCommon::format_date($value, false);
break;
case "date":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::date_display($value, $field["dateFormat"]);
break;
case "radio":
case "select":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::selection_display($value, $field, $lead["currency"]);
break;
case "number":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::format_number($value, rgar($field, "numberFormat"));
break;
case "total":
case "payment_amount":
$value = GFCommon::to_money($value, $lead["currency"]);
break;
case "created_by":
if (!empty($value)) {
$userdata = get_userdata($value);
$value = $userdata->user_login;
}
break;
default:
$value = esc_html($value);
}
$value = apply_filters("gform_entries_field_value", $value, $form_id, $field_id, $lead);
$query_string = "gf_entries&view=entry&id={$form_id}&lid={$lead["id"]}{$search_qs}{$sort_qs}{$dir_qs}&paged=" . ($page_index + 1);
if ($is_first_column) {
?>
<td class="column-title" >
<a href="admin.php?page=gf_entries&view=entry&id=<?php
echo $form_id;
?>
&lid=<?php
示例14: make_directory
//.........這裏部分代碼省略.........
if (in_array('urls', $lightboxsettings) || !empty($lightboxsettings['urls'])) {
$lightboxclass .= ' rel="directory_all directory_urls"';
}
if ($linkwebsite) {
$value = "<a href='" . esc_attr($lead["source_url"]) . "'{$target}{$lightboxclass} title='" . esc_attr($lead["source_url"]) . "'{$nofollow}>.../" . esc_attr(GFCommon::truncate_url($lead["source_url"])) . "</a>";
} else {
$value = esc_attr(GFCommon::truncate_url($lead["source_url"]));
}
break;
case "textarea":
case "post_content":
case "post_excerpt":
if ($fulltext) {
$long_text = $value = "";
if (isset($lead[$field_id]) && strlen($lead[$field_id]) >= GFORMS_MAX_FIELD_LENGTH) {
$long_text = get_gf_field_value_long($lead["id"], $field_id);
}
if (isset($lead[$field_id])) {
$value = !empty($long_text) ? $long_text : $lead[$field_id];
}
if ($wpautop) {
$value = wpautop($value);
}
} else {
$value = esc_html($value);
}
break;
case "date_created":
$value = GFCommon::format_date($value, false, $datecreatedformat);
break;
case "date":
$field = RGFormsModel::get_field($form, $field_id);
if ($dateformat) {
$value = GFCommon::date_display($value, $dateformat);
} else {
$value = GFCommon::date_display($value, $field["dateFormat"]);
}
break;
case "id":
$linkClass = '';
break;
case "list":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::get_lead_field_display($field, $value);
break;
default:
$input_type = 'text';
if (is_email($value) && $linkemail) {
$value = "<a href='mailto:{$value}'{$nofollow}>{$value}</a>";
} elseif (preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $value) && $linkwebsite) {
$href = $value;
if (!empty($lightboxsettings['images'])) {
if (in_array('urls', $lightboxsettings) || !empty($lightboxsettings['urls'])) {
$lightboxclass .= ' rel="directory_all directory_urls"';
}
$linkClass = $lightboxclass;
} else {
$linkClass = isset($linkClass) ? $linkClass : '';
}
if ($truncatelink) {
$value = apply_filters('kws_gf_directory_anchor_text', $value);
}
$value = "<a href='{$href}'{$nofollow}{$target}{$linkClass}>{$value}</a>";
} else {
$value = esc_html($value);
}
示例15: get_lead_field_display
public static function get_lead_field_display($field, $value)
{
switch (RGFormsModel::get_input_type($field)) {
case "name":
if (is_array($value)) {
$prefix = trim($value[$field["id"] . ".2"]);
$first = trim($value[$field["id"] . ".3"]);
$last = trim($value[$field["id"] . ".6"]);
$suffix = trim($value[$field["id"] . ".8"]);
$name = $prefix;
$name .= !empty($name) && !empty($first) ? " {$first}" : $first;
$name .= !empty($name) && !empty($last) ? " {$last}" : $last;
$name .= !empty($name) && !empty($suffix) ? " {$suffix}" : $suffix;
return $name;
} else {
return $value;
}
break;
case "address":
if (is_array($value)) {
$street_value = trim($value[$field["id"] . ".1"]);
$street2_value = trim($value[$field["id"] . ".2"]);
$city_value = trim($value[$field["id"] . ".3"]);
$state_value = trim($value[$field["id"] . ".4"]);
$zip_value = trim($value[$field["id"] . ".5"]);
$country_value = trim($value[$field["id"] . ".6"]);
$address = $street_value;
$address .= !empty($address) && !empty($street2_value) ? " {$street2_value}" : $street2_value;
$address .= !empty($address) && (!empty($city_value) || !empty($state_value)) ? "<br />{$city_value}" : $city_value;
$address .= !empty($address) && !empty($city_value) && !empty($state_value) ? ", {$state_value}" : $state_value;
$address .= !empty($address) && !empty($zip_value) ? " {$zip_value}" : $zip_value;
$address .= !empty($address) && !empty($country_value) ? "<br />{$country_value}" : $country_value;
//adding map link
if (!empty($address)) {
$address_qs = str_replace("<br />", " ", $address);
//replacing <br/> with spaces
$address_qs = urlencode($address_qs);
$address .= "<br/><a href='http://maps.google.com/maps?q={$address_qs}' target='_blank' class='map-it-link'>Map It</a>";
}
return $address;
} else {
return "";
}
break;
case "email":
return GFCommon::is_valid_email($value) ? "<a href='mailto:{$value}'>{$value}</a>" : $value;
break;
case "website":
return GFCommon::is_valid_url($value) ? "<a href='{$value}' target='_blank'>{$value}</a>" : $value;
break;
case "checkbox":
if (is_array($value)) {
foreach ($value as $key => $item) {
if (!empty($item)) {
$items .= "<li>{$item}</li>";
}
}
return empty($items) ? "" : "<ul class='bulleted'>{$items}</ul>";
} else {
return $value;
}
break;
case "post_image":
list($url, $title, $caption, $description) = explode("|:|", $value);
if (!empty($url)) {
$url = str_replace(" ", "%20", $url);
$value = "<a href='{$url}' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$url}' width='100' /></a>";
$value .= !empty($title) ? "<div>Title: {$title}</div>" : "";
$value .= !empty($caption) ? "<div>Caption: {$caption}</div>" : "";
$value .= !empty($description) ? "<div>Description: {$description}</div>" : "";
}
return $value;
case "fileupload":
$file_path = $value;
if (!empty($file_path)) {
$info = pathinfo($file_path);
$file_path = esc_attr(str_replace(" ", "%20", $file_path));
$value = "<a href='{$file_path}' target='_blank' title='" . __("Click to view", "gravityforms") . "'>" . $info["basename"] . "</a>";
}
return $value;
break;
case "date":
return GFCommon::date_display($value, $field["dateFormat"]);
break;
default:
return nl2br($value);
break;
}
}