本文整理匯總了PHP中GFCommon::prepare_post_category_value方法的典型用法代碼示例。如果您正苦於以下問題:PHP GFCommon::prepare_post_category_value方法的具體用法?PHP GFCommon::prepare_post_category_value怎麽用?PHP GFCommon::prepare_post_category_value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GFCommon
的用法示例。
在下文中一共展示了GFCommon::prepare_post_category_value方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: leads_page
//.........這裏部分代碼省略.........
<?php
$gf_entry_locking->lock_indicator();
?>
</th>
<?php
if (!in_array($filter, array('spam', 'trash'))) {
?>
<td>
<img id="star_image_<?php
echo esc_attr($lead['id']);
?>
" src="<?php
echo GFCommon::get_base_url();
?>
/images/star<?php
echo intval($lead['is_starred']);
?>
.png" onclick="ToggleStar(this, '<?php
echo esc_js($lead['id']);
?>
','<?php
echo esc_js($filter);
?>
');" />
</td>
<?php
}
$is_first_column = true;
$nowrap_class = 'entry_nowrap';
foreach ($field_ids as $field_id) {
$field = RGFormsModel::get_field($form, $field_id);
$value = rgar($lead, $field_id);
if (!empty($field) && $field->type == 'post_category') {
$value = GFCommon::prepare_post_category_value($value, $field, 'entry_list');
}
//filtering lead value
$value = apply_filters('gform_get_field_value', $value, $lead, $field);
$input_type = !empty($columns[$field_id]['inputType']) ? $columns[$field_id]['inputType'] : $columns[$field_id]['type'];
switch ($input_type) {
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 'date_created':
case 'payment_date':
$value = GFCommon::format_date($value, false);
break;
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;
default:
if ($field !== null) {
$value = $field->get_value_entry_list($value, $lead, $field_id, $columns, $form);
} else {
$value = esc_html($value);
}
}
$value = apply_filters('gform_entries_field_value', $value, $form_id, $field_id, $lead);
/* ^ maybe move to function */
示例2: get_value_entry_list
public function get_value_entry_list($value, $entry, $field_id, $columns, $form)
{
//if this is the main checkbox field (not an input), display a comma separated list of all inputs
if (absint($field_id) == $field_id) {
$lead_field_keys = array_keys($entry);
$items = array();
foreach ($lead_field_keys as $input_id) {
if (is_numeric($input_id) && absint($input_id) == $field_id) {
$items[] = GFCommon::selection_display(rgar($entry, $input_id), null, $entry['currency'], false);
}
}
$value = GFCommon::implode_non_blank(', ', $items);
// special case for post category checkbox fields
if ($this->type == 'post_category') {
$value = GFCommon::prepare_post_category_value($value, $this, 'entry_list');
}
} else {
$value = '';
if ($this->is_checkbox_checked($field_id, $columns[$field_id]['label'], $entry)) {
$value = "<i class='fa fa-check gf_valid'></i>";
}
}
return $value;
}
示例3: is_value_match
public static function is_value_match($field_value, $target_value, $operation = 'is', $source_field = null, $rule = null, $form = null)
{
$is_match = false;
if ($source_field && is_subclass_of($source_field, 'GF_Field') && $source_field->type == 'post_category') {
$field_value = GFCommon::prepare_post_category_value($field_value, $source_field, 'conditional_logic');
}
if (!empty($field_value) && !is_array($field_value) && is_subclass_of($source_field, 'GF_Field') && $source_field->type == 'multiselect') {
$field_value = explode(',', $field_value);
}
// convert the comma-delimited string into an array
$form_id = $source_field instanceof GF_Field ? $source_field->formId : 0;
$target_value = GFFormsModel::maybe_trim_input($target_value, $form_id, $source_field);
if (is_array($field_value)) {
$field_value = array_values($field_value);
//returning array values, ignoring keys if array is associative
$match_count = 0;
foreach ($field_value as $val) {
$val = GFFormsModel::maybe_trim_input(GFCommon::get_selection_value($val), rgar($source_field, 'formId'), $source_field);
if (self::matches_operation($val, $target_value, $operation)) {
$match_count++;
}
}
// if operation is Is Not, none of the values in the array can match the target value.
$is_match = $operation == 'isnot' ? $match_count == count($field_value) : $match_count > 0;
} else {
if (self::matches_operation(GFFormsModel::maybe_trim_input(GFCommon::get_selection_value($field_value), $form_id, $source_field), $target_value, $operation)) {
$is_match = true;
}
}
return apply_filters('gform_is_value_match', $is_match, $field_value, $target_value, $operation, $source_field, $rule);
}
示例4: is_value_match
public static function is_value_match($field_value, $target_value, $operation = "is", $source_field = null)
{
if ($source_field && $source_field["type"] == "post_category") {
$field_value = GFCommon::prepare_post_category_value($field_value, $source_field, "conditional_logic");
}
if (!empty($field_value) && !is_array($field_value) && $source_field["type"] == "multiselect") {
//convert the comma-delimited string into an array
$field_value = explode(",", $field_value);
}
if (is_array($field_value)) {
$field_value = array_values($field_value);
//returning array values, ignoring keys if array is associative
$match_count = 0;
foreach ($field_value as $val) {
if (self::matches_operation(GFCommon::get_selection_value($val), $target_value, $operation)) {
$match_count++;
}
}
//If operation is Is Not, none of the values in the array can match the target value.
return $operation == "isnot" ? $match_count == count($field_value) : $match_count > 0;
} else {
if (self::matches_operation(GFCommon::get_selection_value($field_value), $target_value, $operation)) {
return true;
}
}
return false;
}
示例5: leads_page
//.........這裏部分代碼省略.........
<th scope="row" class="check-column">
<input type="checkbox" name="lead[]" value="<?php
echo $lead["id"];
?>
" />
</th>
<?php
if (!in_array($filter, array("spam", "trash"))) {
?>
<td >
<img id="star_image_<?php
echo $lead["id"];
?>
" src="<?php
echo GFCommon::get_base_url();
?>
/images/star<?php
echo intval($lead["is_starred"]);
?>
.png" onclick="ToggleStar(this, <?php
echo $lead["id"] . ",'" . $filter . "'";
?>
);" />
</td>
<?php
}
$is_first_column = true;
$nowrap_class = "entry_nowrap";
foreach ($field_ids as $field_id) {
/* maybe move to function */
$field = RGFormsModel::get_field($form, $field_id);
$value = rgar($lead, $field_id);
if ($field['type'] == 'post_category') {
$value = GFCommon::prepare_post_category_value($value, $field, 'entry_list');
}
//filtering lead value
$value = apply_filters("gform_get_field_value", $value, $lead, $field);
$input_type = !empty($columns[$field_id]["inputType"]) ? $columns[$field_id]["inputType"] : $columns[$field_id]["type"];
switch ($input_type) {
case "checkbox":
$value = "";
//if this is the main checkbox field (not an input), display a comma separated list of all inputs
if (absint($field_id) == $field_id) {
$lead_field_keys = array_keys($lead);
$items = array();
foreach ($lead_field_keys as $input_id) {
if (is_numeric($input_id) && absint($input_id) == $field_id) {
$items[] = GFCommon::selection_display(rgar($lead, $input_id), null, $lead["currency"], false);
}
}
$value = GFCommon::implode_non_blank(", ", $items);
// special case for post category checkbox fields
if ($field['type'] == 'post_category') {
$value = GFCommon::prepare_post_category_value($value, $field, 'entry_list');
}
} else {
$value = "";
//looping through lead detail values trying to find an item identical to the column label. Mark with a tick if found.
$lead_field_keys = array_keys($lead);
foreach ($lead_field_keys as $input_id) {
//mark as a tick if input label (from form meta) is equal to submitted value (from lead)
if (is_numeric($input_id) && absint($input_id) == absint($field_id)) {
if ($lead[$input_id] == $columns[$field_id]["label"]) {
$value = "<img src='" . GFCommon::get_base_url() . "/images/tick.png'/>";
} else {
$field = RGFormsModel::get_field($form, $field_id);
示例6: is_value_match
public static function is_value_match($field_value, $target_value, $operation = "is", $source_field = null, $rule = null)
{
$is_match = false;
if ($source_field && $source_field["type"] == "post_category") {
$field_value = GFCommon::prepare_post_category_value($field_value, $source_field, "conditional_logic");
}
if (!empty($field_value) && !is_array($field_value) && $source_field["type"] == "multiselect") {
$field_value = explode(",", $field_value);
}
// convert the comma-delimited string into an array
$target_value = GFFormsModel::maybe_trim_input($target_value, rgar($source_field, "formId"), $source_field);
if (is_array($field_value)) {
$field_value = array_values($field_value);
//returning array values, ignoring keys if array is associative
$match_count = 0;
foreach ($field_value as $val) {
$val = GFFormsModel::maybe_trim_input(GFCommon::get_selection_value($val), rgar($source_field, "formId"), $source_field);
if (self::matches_operation($val, $target_value, $operation)) {
$match_count++;
}
}
// if operation is Is Not, none of the values in the array can match the target value.
$is_match = $operation == "isnot" ? $match_count == count($field_value) : $match_count > 0;
} else {
if (self::matches_operation(GFFormsModel::maybe_trim_input(GFCommon::get_selection_value($field_value), rgar($source_field, "formId"), $source_field), $target_value, $operation)) {
$is_match = true;
}
}
return apply_filters('gform_is_value_match', $is_match, $field_value, $target_value, $operation, $source_field, $rule);
}
示例7: pdf_get_lead_field_display
public static function pdf_get_lead_field_display($field, $value, $currency = '', $use_text = false, $format = 'html', $media = 'screen')
{
if ($field['type'] == 'post_category') {
$value = GFCommon::prepare_post_category_value($value, $field);
}
switch (RGFormsModel::get_input_type($field)) {
case 'name':
if (is_array($value)) {
$prefix = trim(rgget($field['id'] . '.2', $value));
$first = trim(rgget($field['id'] . '.3', $value));
$middle = trim(rgget($field['id'] . '.4', $value));
$last = trim(rgget($field['id'] . '.6', $value));
$suffix = trim(rgget($field['id'] . '.8', $value));
$name = $prefix;
$name .= !empty($name) && !empty($first) ? " {$first}" : $first;
$name .= !empty($name) && !empty($middle) ? " {$middle}" : $middle;
$name .= !empty($name) && !empty($last) ? " {$last}" : $last;
$name .= !empty($name) && !empty($suffix) ? " {$suffix}" : $suffix;
return $name;
} else {
return $value;
}
break;
case 'creditcard':
if (is_array($value)) {
$card_number = trim(rgget($field['id'] . '.1', $value));
$card_type = trim(rgget($field['id'] . '.4', $value));
$separator = $format == 'html' ? '<br/>' : '\\n';
return empty($card_number) ? '' : $card_type . $separator . $card_number;
} else {
return '';
}
break;
case 'address':
if (is_array($value)) {
$street_value = trim(rgget($field['id'] . '.1', $value));
$street2_value = trim(rgget($field['id'] . '.2', $value));
$city_value = trim(rgget($field['id'] . '.3', $value));
$state_value = trim(rgget($field['id'] . '.4', $value));
$zip_value = trim(rgget($field['id'] . '.5', $value));
$country_value = trim(rgget($field['id'] . '.6', $value));
$line_break = $format == 'html' ? '<br />' : '\\n';
$address_display_format = apply_filters('gform_address_display_format', 'default');
if ($address_display_format == 'zip_before_city') {
/*
Sample:
3333 Some Street
suite 16
2344 City, State
Country
*/
$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) ? $line_break . $street2_value : $street2_value;
$address .= !empty($address) && (!empty($city_value) || !empty($state_value)) ? $line_break . $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) ? $line_break . $country_value : $country_value;
}
return $address;
} else {
return '';
}
break;
case 'email':
return GFCommon::is_valid_email($value) && $format == 'html' ? '<a href="mailto:' . $value . '">' . $value . '</a>' : $value;
break;
case 'website':
return GFCommon::is_valid_url($value) && $format == 'html' ? '<a href="' . $value . '" target="_blank">' . $value . '</a>' : $value;
break;
case 'checkbox':
if (is_array($value)) {
$items = '';
foreach ($value as $key => $item) {
if (!empty($item)) {
switch ($format) {
case 'text':
$items .= GFCommon::selection_display($item, $field, $currency, true) . ', ';
break;
default:
$items .= '<li>' . GFCommon::selection_display($item, $field, $currency, true) . '</li>';
break;
}
}
}
//.........這裏部分代碼省略.........
示例8: column_default
/**
* Displays the entry value.
*
* @param object $entry
* @param string $field_id
*/
function column_default($entry, $column_id)
{
$field_id = (string) str_replace('field_id-', '', $column_id);
$form = $this->get_form();
$form_id = $this->get_form_id();
$field = GFFormsModel::get_field($form, $field_id);
$columns = GFFormsModel::get_grid_columns($form_id, true);
$value = rgar($entry, $field_id);
if (!empty($field) && $field->type == 'post_category') {
$value = GFCommon::prepare_post_category_value($value, $field, 'entry_list');
}
// Filtering lead value
$value = apply_filters('gform_get_field_value', $value, $entry, $field);
switch ($field_id) {
case 'source_url':
$value = "<a href='" . esc_attr($entry['source_url']) . "' target='_blank' alt='" . esc_attr($entry['source_url']) . "' title='" . esc_attr($entry['source_url']) . "'>.../" . esc_attr(GFCommon::truncate_url($entry['source_url'])) . '</a>';
break;
case 'date_created':
case 'payment_date':
$value = GFCommon::format_date($value, false);
break;
case 'payment_amount':
$value = GFCommon::to_money($value, $entry['currency']);
break;
case 'created_by':
if (!empty($value)) {
$userdata = get_userdata($value);
if (!empty($userdata)) {
$value = $userdata->user_login;
}
}
break;
default:
if ($field !== null) {
$value = $field->get_value_entry_list($value, $entry, $field_id, $columns, $form);
} else {
$value = esc_html($value);
}
}
$value = apply_filters('gform_entries_field_value', $value, $form_id, $field_id, $entry);
$primary = $this->get_primary_column_name();
$query_string = $this->get_detail_query_string($entry);
if ($column_id == $primary) {
$edit_url = $this->get_detail_url($entry);
echo '<a title="' . esc_attr__('View this entry', 'gravityforms') . '" href="' . $edit_url . '">' . $value . '</a>';
} else {
/**
* Used to inject markup and replace the value of any non-first column in the entry list grid.
*
* @param string $value The value of the field
* @param int $form_id The ID of the current form
* @param int $field_id The ID of the field
* @param array $entry The Entry object
* @param string $query_string The current page's query string
*/
echo apply_filters('gform_entries_column_filter', $value, $form_id, $field_id, $entry, $query_string);
// Maintains gap between value and content from gform_entries_column which existed when using 1.9 and earlier.
echo ' ';
/**
* Fired within the entries column
*
* Used to insert additional entry details
*
* @param int $form_id The ID of the current form
* @param int $field_id The ID of the field
* @param string $value The value of the field
* @param array $entry The Entry object
* @param string $query_string The current page's query string
*/
do_action('gform_entries_column', $form_id, $field_id, $value, $entry, $query_string);
}
}
示例9: is_value_match
public static function is_value_match($field_value, $target_value, $operation = "is", $source_field = null)
{
if ($source_field && $source_field["type"] == "post_category") {
$field_value = GFCommon::prepare_post_category_value($field_value, $source_field, "conditional_logic");
}
if (!empty($field_value) && !is_array($field_value) && $source_field["type"] == "multiselect") {
//convert the comma-delimited string into an array
$field_value = explode(",", $field_value);
}
if (is_array($field_value)) {
foreach ($field_value as $val) {
if (self::matches_operation(GFCommon::get_selection_value($val), $target_value, $operation)) {
return true;
}
}
} else {
if (self::matches_operation(GFCommon::get_selection_value($field_value), $target_value, $operation)) {
return true;
}
}
return false;
}
示例10: esc_url
}
break;
case "post_title":
if (apply_filters('kws_gf_directory_post_title_link', false, $form, $lead) && !empty($lead['post_id'])) {
$value = '<a href="' . esc_url(get_permalink($lead['post_id'])) . '" title="' . esc_attr($value) . '" ' . $nofollow . $target . '>' . esc_html($value) . '</a>';
} else {
$value = esc_html($value);
}
break;
case "textarea":
case "post_content":
case "post_excerpt":
$value = wpautop($value);
break;
case "post_category":
$value = GFCommon::prepare_post_category_value($lead[$field_id], $field);
break;
case "date_created":
$value = GFCommon::format_date($lead['date_created'], true, apply_filters('kws_gf_date_format', ''));
break;
case "date":
if ($dateformat) {
$value = GFCommon::date_display($value, $dateformat);
} else {
$value = GFCommon::date_display($value, $field["dateFormat"]);
}
break;
case "id":
$linkClass = '';
break;
case "list":
示例11: column_default
/**
* Displays the entry value.
*
* @param object $entry
* @param string $field_id
*/
function column_default($entry, $column_id)
{
$field_id = (string) str_replace('field_id-', '', $column_id);
$form = $this->get_form();
$form_id = $this->get_form_id();
$field = GFFormsModel::get_field($form, $field_id);
$columns = GFFormsModel::get_grid_columns($form_id, true);
$value = rgar($entry, $field_id);
if (!empty($field) && $field->type == 'post_category') {
$value = GFCommon::prepare_post_category_value($value, $field, 'entry_list');
}
// Filtering lead value
$value = apply_filters('gform_get_field_value', $value, $entry, $field);
switch ($field_id) {
case 'source_url':
$value = "<a href='" . esc_attr($entry['source_url']) . "' target='_blank' alt='" . esc_attr($entry['source_url']) . "' title='" . esc_attr($entry['source_url']) . "'>.../" . esc_attr(GFCommon::truncate_url($entry['source_url'])) . '</a>';
break;
case 'date_created':
case 'payment_date':
$value = GFCommon::format_date($value, false);
break;
case 'payment_amount':
$value = GFCommon::to_money($value, $entry['currency']);
break;
case 'created_by':
if (!empty($value)) {
$userdata = get_userdata($value);
if (!empty($userdata)) {
$value = $userdata->user_login;
}
}
break;
default:
if ($field !== null) {
$value = $field->get_value_entry_list($value, $entry, $field_id, $columns, $form);
} else {
$value = esc_html($value);
}
}
$value = apply_filters('gform_entries_field_value', $value, $form_id, $field_id, $entry);
$primary = $this->get_primary_column_name();
if ($column_id == $primary) {
$edit_url = $this->get_detail_url($entry);
$value = '<a title="' . esc_attr__('View this entry', 'gravityforms') . '" href="' . $edit_url . '">' . $value . '</a>';
}
echo $value;
}